Commit Graph

246 Commits

Author SHA1 Message Date
Greg Clayton 46fb558df1 Added optional calls to lldb_private::Process for getting memory region info
from a process and hooked it up to the new packet that was recently added
to our GDB remote executable named debugserver. Now Process has the following
new calls:

virtual Error
Process::GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info);

virtual uint32_t
GetLoadAddressPermissions (lldb::addr_t load_addr);

Only the first one needs to be implemented by subclasses that can add this
support.

Cleaned up the way the new packet was implemented in debugserver to be more
useful as an API inside debugserver. Also found an error where finding a region
for an address actually will pick up the next region that follows the address
in the query so we also need ot make sure that the address we requested the
region for falls into the region that gets returned.

llvm-svn: 144976
2011-11-18 07:03:08 +00:00
Greg Clayton f9d851b2ca Bumped Xcode project versions for lldb-89 and debugserver-153.
llvm-svn: 144911
2011-11-17 17:22:31 +00:00
Greg Clayton 2d8d63a927 Bumped Xcode project version for lldb-88 and debugserver-152.
llvm-svn: 144616
2011-11-15 03:56:34 +00:00
Greg Clayton ed3ae7005d Cleanup some warnings.
llvm-svn: 144200
2011-11-09 19:04:58 +00:00
Jason Molenda 3dc8583c96 Remove the QAddressIsExecutable packet I added last night.
Add a more general purpose qMemoryRegionInfo packet which can
describe various attributes about a memory region.  Currently it
will return the start address, size, and permissions (read, write,
executable) for the memory region.  It may be possible to add
additional attributes in the future such as whether the region is
designated as stack memory or jitted code a la vmmap.

I still haven't implemented the lldb side of the code to use this
packet yet so there may be unexpected behavior - but the basic implementation looks
about right.  I'll hook it up to lldb soon and fix any problems that crop up.

llvm-svn: 144175
2011-11-09 08:03:56 +00:00
Jason Molenda 1f3966bebd Add "QAddressIsExecutable" packet to debugserver. Used to test
whether a given address is in an executable region of memory or
not.  I haven't written the lldb side that will use this packet it
hasn't been tested yet but it's a simple enough bit of code.

I want to have this feature available for the unwinder code.  When
we're stopped at an address with no valid symbol context, there are
a number of questions I'd like to ask --

  is the current pc value in an executable region (e.g. did they
  jump to unallocated/unexecutable memory?  we know how to unwind
  from here if so.)

  Is the stack pointer or the frame pointer the correct register
  to use to find the caller's saved pc value?

Once we're past the first frame we can trust things like eh_frame
and ABI unwind schemes but the first frame is challenging and having
a way to check potential addresses to see if they're executable or
not would help narrow down the possibilities a lot.

llvm-svn: 144074
2011-11-08 04:28:12 +00:00
Greg Clayton 1d8859668f Moved many of the "settings" that used to be in "target.process.*" to just
be in the target. All of the environment, args, stdin/out/err files, etc have
all been moved. Also re-enabled the ability to launch a process in a separate
terminal on MacOSX.

llvm-svn: 144061
2011-11-08 02:43:13 +00:00
Greg Clayton 44148b367f Bumped Xcode project version for lldb-86 and debugserver-151
llvm-svn: 144032
2011-11-07 22:50:17 +00:00
Greg Clayton c64b5c7c47 Xcode project changes to install "lldb" into "/usr/bin" and have LLDB.framework
in "/System/Library/PrivateFrameworks", and also have "lldb" in the Xcode.app
and the LLDB.framework in Xcode.app as well.

llvm-svn: 144030
2011-11-07 22:45:39 +00:00
Greg Clayton dce502ede0 Fixed the Xcode project building of LLVM to be a bit more user friendly:
- If you download and build the sources in the Xcode project, x86_64 builds
  by default using the "llvm.zip" checkpointed LLVM.
- If you delete the "lldb/llvm.zip" and the "lldb/llvm" folder, and build the
  Xcode project will download the right LLVM sources and build them from 
  scratch
- If you have a "lldb/llvm" folder already that contains a "lldb/llvm/lib"
  directory, we will use the sources you have placed in the LLDB directory.
  
Python can now be disabled for platforms that don't support it. 

Changed the way the libllvmclang.a files get used. They now all get built into
arch specific directories and never get merged into universal binaries as this
was causing issues where you would have to go and delete the file if you wanted
to build an extra architecture slice.

llvm-svn: 143678
2011-11-04 03:34:56 +00:00
Jim Ingham cf0bca9e85 Print out the task suspend count as well.
llvm-svn: 143659
2011-11-03 21:43:55 +00:00
Greg Clayton e59da1688e Bumping Xcode project versions for lldb-85 and debugserver-150.
llvm-svn: 143587
2011-11-02 23:11:17 +00:00
Greg Clayton 93d217889e Bumped Xcode project version to lldb-84 and debugserver-149.
llvm-svn: 143408
2011-11-01 01:10:56 +00:00
Greg Clayton 9d3d6886e6 Fixed some warnings after enabling some stricter warnings in the Xcode project
settings.

Also fixed an issue where we weren't creating anonymous namepaces correctly:
<rdar://problem/10371295>

llvm-svn: 143403
2011-10-31 23:51:19 +00:00
Daniel Dunbar a08823fd10 warnings: Fix a bunch of -Wreorder problems.
llvm-svn: 143381
2011-10-31 22:50:49 +00:00
Greg Clayton c05203ba81 Updated the project to use the "DEVELOPER_DIR" build setting that specifies
the path to the /Developer directory, and also bumped the Xcode project version
for lldb-83 and debugserver-148.

llvm-svn: 143269
2011-10-29 01:19:08 +00:00
Greg Clayton 490fbbe270 Enabled the "printf" attribute on all debugserver logging functions and fixed
the ensuing mayhem.

llvm-svn: 143244
2011-10-28 22:59:14 +00:00
Greg Clayton e3c3d724c9 Bumping Xcode project version in mainline to match the latest build that was
submitted.

llvm-svn: 143199
2011-10-28 16:41:16 +00:00
Greg Clayton 708c1ab6f5 Python does some bad things to the signal masks in the current process and
then we spawn child processes (debugserver, etc) and those bad settings get 
inherited. We stop this from happening by correctly mucking with the posix
spawn attributes.

llvm-svn: 143176
2011-10-28 01:24:12 +00:00
Benjamin Kramer d34a329c68 Remove unused include of deprecated header.
llvm-svn: 142753
2011-10-23 16:31:38 +00:00
Greg Clayton 607ddc571e Bumped versions for lldb-81 and debugserver-146.
llvm-svn: 142718
2011-10-22 03:38:38 +00:00
Greg Clayton d74713b18c Bumped Xcode project version for lldb-80 and debugserver-145.
llvm-svn: 140922
2011-10-01 02:01:36 +00:00
Johnny Chen a9b68f4dd6 Modify the delegation chain from MachThreadList -> MachThread -> DNBArchProtocol so that when
the watchpoint state is changed, not only does the change propagate to all the thread instances,
it also updates a global debug state, if chosen by the DNBArchProtocol derivative.

Once implemented, the DNBArchProtocol derivative, also makes sure that when new thread comes along,
it tries to inherit from the global debug state, if it is valid.

Modify TestWatchpointMultipleThreads.py to test this functionality.

llvm-svn: 140811
2011-09-29 21:48:52 +00:00
Johnny Chen 825ea37835 Fix a bug in the current MacOSX MachThreadList::EnableHardwareWatchpoint() impl so that
it enables the hardware watchpoint for all existing threads.  Add a test file for that.
Also fix MachThreadList::DisableHardwareWatchpoint().

llvm-svn: 140757
2011-09-29 01:20:42 +00:00
Johnny Chen 870f4f4213 The r139982 patch has a bug by using the constant "x86_AVX_STATE64".
Patch by Filipe.

llvm-svn: 140037
2011-09-19 18:54:01 +00:00
Greg Clayton 747bcb03d2 Convert lldb::ModuleSP to use an instrusive ref counted pointer.
We had some cases where getting the shared pointer for a module from
the global module list was causing a performance issue when debugging
with DWARF in .o files. Now that the module uses intrusive ref counts,
we can easily convert any pointer to a shared pointer.

llvm-svn: 139983
2011-09-17 06:21:20 +00:00
Greg Clayton 5631ebce5e Added more logging, and renamed FPR to FPU in a the register set/flavor enum.
llvm-svn: 139982
2011-09-17 05:59:37 +00:00
Greg Clayton 5299cc58cb Correctly handle the when we the 'G' packet fails. There were
cases where we were returning no error even though this packet
was failing.

llvm-svn: 139981
2011-09-17 05:47:55 +00:00
Johnny Chen 236888d026 Foe x86_64/i386, piggyback the hardware index of the fired watchpoint in the exception
data sent back to the debugger.  On the debugger side, use the opportunity during the
StopInfoMachException::CreateStopReasonWithMachException() method to set the hardware index
for the very watchpoint location.

llvm-svn: 139975
2011-09-17 01:05:03 +00:00
Jim Ingham 12e9a2012f Track whether a process was Launched or Attached to. If Attached, the detach when the debugger is destroyed, rather than killing the process. Also added a Debugger::Clear, which gets called in Debugger::Destroy to deal with all the targets in the Debugger. Also made the Driver's main loop call Destroy on the debugger, rather than just Destroying the currently selected Target's process.
llvm-svn: 139852
2011-09-15 21:30:02 +00:00
Johnny Chen 76abb3b559 Add comment regarding method call to DNBArchProtocol::NotifyException().
llvm-svn: 139800
2011-09-15 17:17:51 +00:00
Johnny Chen 88c1b77f74 Modify MachThread::NotifyException() to allow the arch specific protocol to process
the passed in (MachException::Data &)exc first before possible reassignment of the
member m_stop_exception with exc.  This allows lldb to stop at the watchpoint of
a simple test program.

llvm-svn: 139767
2011-09-15 01:12:15 +00:00
Johnny Chen 3ba42283f4 Update I386 DNB impl to fix the same errors as DNBArchImplX86_64: ('==' instead of '=') and (by value instead of by reference).
llvm-svn: 139667
2011-09-13 23:43:18 +00:00
Johnny Chen 3c53258964 Watchpoint WIP:
o WatchpointLocationList:
  Add a GetListMutex() method.
o WatchpointLocation:
  Fix Dump() method where there was an extra % in the format string.
o Target.cpp:
  Add implementation to CreateWatchpointLocation() to create and enable a watchpoint.

o DNBArchImplX86_64.cpp:
  Fix bugs in SetWatchpoint()/ClearWatchpoint() where '==' was used, instead of '=',
  to assign/reset the data break address to a debug register.

  Also fix bugs where a by reference debug_state should have been used, not by value.

llvm-svn: 139666
2011-09-13 23:29:31 +00:00
Jim Ingham e64f0dc7bf Adding "-n", "-p" and "-w" flags to the lldb command-line tool to
allow attaching from the command line.

llvm-svn: 139665
2011-09-13 23:25:31 +00:00
Jim Ingham e37d605e7d SBSourceManager now gets the real source manager either from the Debugger or Target. Also, move the SourceManager file cache into the debugger
so it can be shared amongst the targets.

llvm-svn: 139564
2011-09-13 00:29:56 +00:00
Johnny Chen 67b20bbbee Reset the debug status register, only if necessary, before we resume,
which saves unnecessary traffic to the kernel.

llvm-svn: 139410
2011-09-09 21:11:25 +00:00
Enrico Granata 13f1d56170 Basic infrastructure code to exploit malloc stack logging as available on Mac OS X to track the allocation history of pointers on the target process
llvm-svn: 139337
2011-09-09 00:04:24 +00:00
Johnny Chen f8f68a132a Added comments about exception code.
llvm-svn: 139294
2011-09-08 17:07:22 +00:00
Johnny Chen af3d4af4eb Add logic to the DNBArchImplX86_64/DNBArchImplI386::NotifyException() callback method
in order to distinguish the real single step exception from a watchpoint exception
which uses the same exc_type of EXC_BREAKPOINT and exc_code of EXC_I386_SGL.

This is done by checking the debug status register to find out whether the watchpoint
data break event has fired, and, if yes, stuff the data break address into the exception's
exc_sub_code field on the debugserver side for lldb to consume on the other end.

llvm-svn: 139274
2011-09-08 01:16:50 +00:00
Johnny Chen ec6a2d3160 Add logic to MachThreadList::GetThreadID() for the use case of setting a watchpoint
(MachThreadList::EnableHardwareWatchpoint()) where the watchpoint is not associated
with a thread and the current thread, if set, is returned, otherwise we return the
first thread.

Plus minor change to RNBRemote::HandlePacket_z() to use the existing macros to check
the validity of break_id/watch_id.

llvm-svn: 139246
2011-09-07 19:03:50 +00:00
Johnny Chen 9d814e0dd2 Minor change: compare the return val of DNBWatchpointSet() against INVALID_NUB_WATCH_ID
to determine its validity.

llvm-svn: 139209
2011-09-07 00:09:23 +00:00
Johnny Chen 86f97a417d DNBBreakpoint::SetEnabled() should take a bool, not a uint32_t, as its input argument.
Plus for watchpoint related functions, add new macros INVALID_NUB_WATCH_ID and
NUB_WATCH_ID_IS_VALID and use them, instead.

llvm-svn: 139163
2011-09-06 19:52:49 +00:00
Johnny Chen 1bd08dd878 Watchpoint work in progress:
Add a virtual method GetHardwareWatchpointHit() to the DNBArchProtocol base class
which consults the architecture to return the watchpoint hit; otherwise return an
invalid index.

Add impl. of the method to X86_64 and I386 subclasses, plus reset the debug status
register before we resume execution of the inferior thread.

llvm-svn: 139034
2011-09-02 21:13:07 +00:00
Johnny Chen 8d31e5eac5 Renaming: from IsVacantWatchpoint() to IsWatchpointVacant().
llvm-svn: 138907
2011-08-31 21:44:56 +00:00
Johnny Chen a18460635a Renamed the helper method to ClearWatchpointHits() for clarity of its purpose.
llvm-svn: 138899
2011-08-31 21:19:39 +00:00
Johnny Chen e0d4208a8b Add a couple of helper methods to check/clear the debug status register
which contains the watchpoint hit information.

llvm-svn: 138881
2011-08-31 19:05:55 +00:00
Johnny Chen 205395e7e0 Fix the shift amount applied to size_and_rw_bits() for debug control register,
which did not take into account the hardware index.

llvm-svn: 138867
2011-08-31 17:51:43 +00:00
Johnny Chen edce1f3f7d Update comments.
llvm-svn: 138863
2011-08-31 17:29:29 +00:00
Johnny Chen 0399ec26c0 Watchpoint work in progress: add helper methods to DNB arch impl for I386 to implment Enable/DisableHardwareWatchpoint.
llvm-svn: 138847
2011-08-31 00:50:10 +00:00