History log of /external/lldb/include/lldb/Target/Process.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
cf88b95d435873bd312e716da5701cf3882c5da4 29-Jul-2013 Ed Maste <emaste@freebsd.org> Use flag instead of rwlock state to track process running state

LLDB requires that the inferior process be stopped before, and remain
stopped during, certain accesses to process state.

Previously this was achieved with a POSIX rwlock which had a write lock
taken for the duration that the process was running, and released when
the process was stopped. Any access to process state was performed with
a read lock held.

However, POSIX requires that pthread_rwlock_unlock() be called from the
same thread as pthread_rwlock_wrlock(), and lldb needs to stop and start
the process from different threads. Violating this constraint is
technically undefined behaviour, although as it happens Linux and Darwin
result in the unlock proceeding in this case. FreeBSD follows POSIX
more strictly, and the unlock would fail, resulting in a hang later upon
the next attempt to take the lock.

All read lock consumers use ReadTryLock() and handle failure to obtain
the lock (typically by logging an error "process is running"). Thus,
instead of using the lock state itself to track the running state, this
change adds an explicit m_running flag. ReadTryLock tests the flag, and
if the process is not running it returns with the read lock held.

WriteLock and WriteTryLock are renamed to SetRunning and TrySetRunning,
and (if successful) they set m_running with the lock held. This way,
read consumers can determine if the process is running and act
appropriately, and write consumers are still held off from starting the
process if read consumers are active.

Note that with this change there are still some curious access patterns,
such as calling WriteUnlock / SetStopped twice in a row, and there's no
protection from multiple threads trying to simultaneously start the
process. In practice this does not seem to be a problem, and was
exposing other undefined POSIX behaviour prior to this change.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@187377 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
801c11e786cd2c8185206ad4f1eced2b2afa3b77 16-Jul-2013 Ed Maste <emaste@freebsd.org> Remove unused RunLocker and related code

RunLocker was not used anywhere, and was the only instance of the
WriteLocker class. Remove both.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@186361 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
e46dd5bb968f0c269ead5cbf3d05511fd2ebcf92 27-Jun-2013 Sean Callanan <scallanan@apple.com> Remove the process's reservation cache and don't
bother checking if a region is safe to use. In
cases where regions need to be synthesized rather
than properly allocated, the memory reads required
to determine whether the area is used are

- insufficient, because intermediate locations
could be in use, and

- unsafe, because on some platforms reading from
memory can trigger events.

All this only makes a difference on platforms
where memory allocation in the target is impossible.
Behavior on platforms where it is possible should
stay the same.

<rdar://problem/14023970>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@185046 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a1f156aa2695963058615edeabedfcb0f1ca5fab 24-Jun-2013 Han Ming Ong <hanming@apple.com> <rdar://problem/14182286>

Made sure that temporary object created from HarmonizeThreadIdsForProfileData() doesn’t get passed around without creating an object first.

Reviewed by Greg

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184769 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0bb91ef2b0f4d46b72c76076b8f7d99a7abb61f3 24-Jun-2013 Ed Maste <emaste@freebsd.org> Remove comment that is no longer applicable

Since r181446 the m_private_run_lock has been used for all platforms.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184733 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
9e0d89ef07d6318728d2f76fc943cc7710014c7c 22-Jun-2013 Han Ming Ong <hanming@apple.com> <rdar://problem/14004410>

Remove old GetNextThreadIndexID() from lldb

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184600 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
5acdec75cbdb5078de36d0bcf5b0c9bd97f46336 16-May-2013 Sean Callanan <scallanan@apple.com> Added a per-process cache for reserved memory
regions that aren't actually allocated in the
process. This cache is used by the expression
parser if the underlying process doesn't support
memory allocation, to avoid needless repeated
searches for unused address ranges.

Also fixed a silly bug in IRMemoryMap where it
would continue searching even after it found a
valid region.

<rdar://problem/13866629>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@182028 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
ba065cab7acc8ef7fbedc27af5d18c3a694a084a 11-May-2013 Jason Molenda <jmolenda@apple.com> A couple of small fixes to make core file debugging less noisy.
Don't want about being unable to find a needed objective-c runtime
function when we're core file debugging and can't jit anything
anyway. Don't warn when quitting a debug session on a core file,
the program state can be reconstructed by re-running lldb on the
same core file again.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181653 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
addad59552c206466dea98c4a645a471a41252b4 11-May-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13700260>

Avoid a deadlock when using the OperatingSystemPython code and typing "process interrupt". There was a possible lock inversion between the target API lock and the process' thread list lock due to code trying to discard the thread list. This was fixed by adding a boolean to Process::Halt() that indicates if the thread plans should be discarded and doing it in the private state thread when we process the stopped state.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181651 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0e191607adcb0ea8ebd06c278be648a7f5c0097f 10-May-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13854277>
<rdar://problem/13594769>

Main changes in this patch include:
- cleanup plug-in interface and use ConstStrings for plug-in names
- Modfiied the BSD Archive plug-in to be able to pick out the correct .o file when .a files contain multiple .o files with the same name by using the timestamp
- Modified SymbolFileDWARFDebugMap to properly verify the timestamp on .o files it loads to ensure we don't load updated .o files and cause problems when debugging

The plug-in interface changes:

Modified the lldb_private::PluginInterface class that all plug-ins inherit from:

Changed:

virtual const char * GetPluginName() = 0;

To:

virtual ConstString GetPluginName() = 0;

Removed:

virtual const char * GetShortPluginName() = 0;

- Fixed up all plug-in to adhere to the new interface and to return lldb_private::ConstString values for the plug-in names.
- Fixed all plug-ins to return simple names with no prefixes. Some plug-ins had prefixes and most ones didn't, so now they all don't have prefixed names, just simple names like "linux", "gdb-remote", etc.






git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181631 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
c5bcb907e4a898783640c038b84c9f2ac10ee91d 08-May-2013 Daniel Malea <daniel.malea@intel.com> Remove distinction between Apple/Linux for Process run locks:
- Played with the current dual run lock implementation for a few days, noticed
no regressions, so enabling in trunk so we see if any problems are detected
by buildbots.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181446 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
7c79a27b955432dfd3ad9439640f0af2eccf37b8 08-May-2013 Jim Ingham <jingham@apple.com> Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.

Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.

Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--

M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181381 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
4e75e3533bddc7cf7264c6c7f7b4d812d4466e96 07-May-2013 Andrew Kaylor <andrew.kaylor@intel.com> Reinstating r181091 and r181106 with fix for Linux regressions.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181340 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
95bea1dfb166a1816ee36a3453aa3ebeca248844 07-May-2013 Ashok Thirumurthi <ashok.thirumurthi@intel.com> Temporarily reverting r181091 and r181106 due to the vast test breakage on the Linux buildbots
while we develop a better understanding of how to manage the thread lists in a platform-independant fashion.

Reviewed by: Daniel Malea


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181323 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
7bee8abf1678cb4dade06add9036981f7249ba09 04-May-2013 Greg Clayton <gclayton@apple.com> After recent OperatingsSystem plug-in changes, the lldb_private::Process and lldb_private::Thread subclasses were changed and the API was not respected properly.

This checkin aims to fix this. The process now has two thread lists: a real thread list for threads that are created by the lldb_private::Process subclass, and the user visible threads. The user visible threads are the same as the real threas when no OS plug-in in used. But when an OS plug-in is used, the user thread can be a combination of real and "memory" threads. Real threads can be placed inside of memory threads so that a thread appears to be different, but is still controlled by the actual real thread. When the thread list needs updating, the lldb_private::Process class will call the: lldb_private::Process::UpdateThreadList() function with the old real thread list, and the function is expected to fill in the new real thread list with the current state of the process. After this function, the process will check if there is an OS plug-in being used, and if so, it will give the old user thread list, the new real thread list and the OS plug-in will create the new user thread list from both of these lists. If there is no OS plug-in, the real thread list is the user thread list.

These changes keep the lldb_private::Process subclasses clean and no changes are required.




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181091 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
08f60c88b61c42c35abf3233f0cbe19d29fbe814 04-May-2013 Jason Molenda <jmolenda@apple.com> fix a couple of clang static analyzer warnings.
Most important was a new[] + delete mismatch in ScanFormatDescriptor()
and a couple of possible memory leaks in FileSpec::EnumerateDirectory().


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181080 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
ff1bbd78581ab2f1e43fbbc8b6e2dc23a9745967 03-May-2013 Andrew Kaylor <andrew.kaylor@intel.com> Fix logic error in ProcessInfo::SetArg0

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181049 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
761afb822b18c46b2ad84be03f372e90ac1e6143 02-May-2013 Jim Ingham <jingham@apple.com> Recommitting r180831 with trivial fix - remember to return errors if you compute.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@180898 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
411ab47806a478d932926ef7a309ea37edf1f7e7 01-May-2013 Daniel Malea <daniel.malea@intel.com> Reverting 180831 as it crashes TestDefaultConstructorForAPIObjects.py



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@180868 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b4e08abf4972befc8412bc83a0205fbdc547290e 01-May-2013 Jim Ingham <jingham@apple.com> Added an option to "process detach" to keep the process stopped, if the process plugin (or in the
case of ProcessGDBRemote the stub we are talking to) know how to do that.

rdar://problem/13680832


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@180831 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
347d722127cc6a19b077244305c3d350ea4ef80e 19-Apr-2013 Ashok Thirumurthi <ashok.thirumurthi@intel.com> Provided a variant of ReadCStringFromMemory that supports null terminators of any character width.
This prevents unbounded reads (i.e. reads of GetMaximumSizeOfStringSummary() bytes)
from causing test failures (i.e. due to ptrace EIO or EFAULT on Linux).

Note that ReadCStringFromMemory is marked as deprecated because the loop that calls
ReadMemory does not continue until the string has been completely read.
The expected behavior is to read until until max_bytes or a null terminator.

Note: As discussed on lldb-dev, further testing will be performed with ReadStringFromMemory
before further changes are made for users of ReadCStringFromMemory.

Thanks to Enrico, Matt and Andy for their review feedback.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179857 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
102b2c2681c9a830afe25bfea35557421905e42c 19-Apr-2013 Greg Clayton <gclayton@apple.com> After discussing with Chris Lattner, we require C++11, so lets get rid of the macros and just use C++11.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179805 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
81a96aa6242f7b559770f5dc62316253cb8cb0d4 18-Apr-2013 Greg Clayton <gclayton@apple.com> Since we use C++11, we should switch over to using std::unique_ptr when C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++.

Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179779 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
061ca65c4b666f8352ba08700ca4e5fa71ebb4a9 18-Apr-2013 Greg Clayton <gclayton@apple.com> Re-enable m_private_run_lock changes from 179329, but only for Apple hosted builds so it doesn't break the buildbots. We will try and work the issues out in the Apple build before enabling this feature for everyone.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179772 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
6b47bca0e0472439b9c69fb16b9c6a3bcfbe783b 18-Apr-2013 Ashok Thirumurthi <ashok.thirumurthi@intel.com> Revert of r179378 and r179329, which introduce a private thread lock around thread enumeration,
in order to prevent consistent hangs on all 3 LLDB buildbots.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179759 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0e7cff415ada6e6dc45b32b51516bca39eb69e38 12-Apr-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13370286>

Fixed a case there the OperatingSystemPython would try to access and play with SBValue objects when the process' public run lock was taken. Prior to this fix, all attempts to run any SBValue functions would fail if run from the private state thread (like updating the thread list). Now we have two run locks, one for public (all threads except the private state thread) and one for private.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179329 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
e33bb5b0dabf62498715afe3d1cd22cda0af1d24 29-Mar-2013 Jim Ingham <jingham@apple.com> Rationalize how we do Halt-ing before Destroy and Detach.

<rdar://problem/13527167>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@178325 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
d5dc67a10267a7b7e856fb67652e70e6c5ead8be 13-Mar-2013 Jim Ingham <jingham@apple.com> More cleanup, remove an untrue comment.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@176921 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
eb17530206e3f501476a32c5d28c8dc36bac419a 01-Mar-2013 Jim Ingham <jingham@apple.com> Move m_destroy_in_process to Process (from ProcessKDP) since it is generally useful,
and use it to keep from doing the OS Plugin UpdateThreadList while destroying, since
if that does anything that requires the API lock it may deadlock against whoever is
running the Process::Destroy.

<rdar://problem/13308627>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@176375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
4f9103faba72fdfc4b4299d6d459bc820ee597b2 27-Feb-2013 Matt Kopec <Matt.Kopec@intel.com> Add GNU indirect function support in expressions for Linux.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@176206 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
efb4aeba2bd8411ac0aee9934f08959094d50711 15-Feb-2013 Jim Ingham <jingham@apple.com> A little cleanup. {Disable/Enable}Breakpoint actually disables/enables BreakpointSites not breakpoints, it is confusing
to have it not named appropriately. Also in StopInfoMachException, we aren't testing for software or not software, just
whether the thing is a breakpoint we set. So don't use "software"...


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@175241 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
89e248f04ecb87d0df4a4b96158c3fac0a3e43c7 09-Feb-2013 Jim Ingham <jingham@apple.com> Reworked the way Process::RunThreadPlan and the ThreadPlanCallFunction interoperate to fix problems where
hitting auto-continue signals while running a thread plan would cause us to lose control of the debug
session.

<rdar://problem/12993641>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@174793 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
2ddb2b8aed6d43665c6955255f6a077574a08412 01-Feb-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13092722>

Fix in loading mach files from memory when using DynamicLoaderMacOSXDYLD.

Removed the uuid mismatch warning that could be spit out and any time during debugging and removed the test case that was looking for that. Currently the "add-dsym" or "target symbols add" command will report an error when the UUID's don't match.

Be more careful when checking and resolving section + offset addresses to make sure none of the base addresses are invalid.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@174222 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
090f83176695d86197b0e86b67dee4160ec5003d 26-Jan-2013 Jim Ingham <jingham@apple.com> Add "target.process.stop-on-shared-library-events" setting, and make it work.
Add the ability to give breakpoints a "kind" string, and have the StopInfoBreakpoint
print that in the brief description if set. Also print the kind - if set - in the breakpoint
listing.
Give kinds to a bunch of the internal breakpoints.
We were deleting the Mac OS X dynamic loader breakpoint as though the id we had stored away was
a breakpoint site ID, but in fact it was a breakpoint id, so we never actually deleted it. Fixed that.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@173555 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
36da2aa6dc5ad9994b638ed09eb81c44cc05540b 25-Jan-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13069948>

Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary.

So I defined a new "lldb::offset_t" which should be used for all file offsets.

After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed.

Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@173463 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
52ebc0aab1fdecb634801deceeddd71a14c2148c 19-Jan-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13010007>

Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:

class OperatingSystemPlugin:
def create_thread(self, tid, context):
# Return a dictionary for a new thread to create it on demand

This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.

Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*.
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
- PyObject *
- const PythonObject &
- const lldb::ScriptInterpreterObjectSP &

Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@172873 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
64742744396c966e8de770e765130629b0c78335 16-Jan-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13009943>

Added a unique integer identifier to processes. Some systems, like JTAG or other simulators, might always assign the same process ID (pid) to the processes that are being debugged. In order for scripts and the APIs to uniquely identify the processes, there needs to be another ID. Now the SBProcess class has:

uint32_t SBProcess::GetUniqueID();

This integer ID will help to truly uniquely identify a process and help with appropriate caching that can be associated with a SBProcess object.





git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@172628 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b794020ffbd6473c59a6e98be044df50abf7fc30 15-Jan-2013 Jim Ingham <jingham@apple.com> Separated the "expr --unwind-on-error" behavior into two parts, actual errors (i.e. crashes) which continue to be
controlled by the --unwind-on-error flag, and --ignore-breakpoint which separately controls behavior when a called
function hits a breakpoint. For breakpoints, we don't unwind, we either stop, or ignore the breakpoint, which makes
more sense.
Also make both these behaviors globally settable through "settings set".
Also handle the case where a breakpoint command calls code that ends up re-hitting the breakpoint. We were recursing
and crashing. Now we just stop without calling the second command.

<rdar://problem/12986644>
<rdar://problem/9119325>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@172503 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0e3b98e7de6d69613a9729bac9d4b965c0635698 09-Jan-2013 Jim Ingham <jingham@apple.com> Add an SBProcess API to get the current StopID, either considering or ignoring stops caused by expression
evaluation.

<rdar://problem/12968562>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@171914 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
ccd5c4ee85d1592f9ae3da02c85f5647ca02fab2 08-Jan-2013 Han Ming Ong <hanming@apple.com> <rdar://problem/12976225>

Checking in the support for doing index ids reservation when given a thread id.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@171904 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
9c970a371511a0e31ba9360aa841d445792c1ab0 18-Dec-2012 Jim Ingham <jingham@apple.com> Adding events when watchpoints are set or changed.

<rdar://problem/11597849>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@170400 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0bce9a22354df3f00e68ffd912119a0741753b7f 05-Dec-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/12649160>

Added the ability to debug through your process exec'ing itself to the same architecture.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@169340 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
f14269add7f6fb84da7ccfd866f8e9f7e81068be 29-Nov-2012 Han Ming Ong <hanming@apple.com> <rdar://problem/12780259>

Prevent async and sync calls to get profile data from stomping on each other.
At the same time, don't use '$' as end delimiter per chunk of profile data.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168948 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
2827e26d7d85636dd0d934a7e15d9ef5b95fac67 20-Nov-2012 Filipe Cabecinhas <me@filcab.net> Remove unused member variable.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168339 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
559cf6e8b52b940f5f4362b32d628838d6301e2e 17-Nov-2012 Jason Molenda <jmolenda@apple.com> Han Ming's commit in r168228 had a bunch of 4-space tabs
in the source files. Expand to spaces. No content changes,
just whitespace.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168238 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
2529aa356e8cf9c1395da46f66ea2518dfa1982d 17-Nov-2012 Han Ming Ong <hanming@apple.com> Follow up on <rdar://12720514>. Removed commented out code.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168232 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
fb9cee64303d36d6fe5d87e63dd8701d1ddb70a9 17-Nov-2012 Han Ming Ong <hanming@apple.com> <rdar://problem/12720514> Sub-TLF: Provide service to profile the inferior

This allows client to query profiling states on the inferior.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168228 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
2e7f313dc473b036788319690116b324cb44b765 19-Oct-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/12491420>

Added a new setting that allows a python OS plug-in to detect threads and provide registers for memory threads. To enable this you set the setting:

settings set target.process.python-os-plugin-path lldb/examples/python/operating_system.py

Then run your program and see the extra threads.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166244 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0c8446cc220c429fb51f8f9864275c8b1c768533 18-Oct-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/12462048>

LLDB changes argv[0] when debugging a symlink. Now we have the notion of argv0 in the target settings:

target.arg0 (string) =

There is also the program argument that are separate from the first argument that have existed for a while:

target.run-args (arguments) =

When running "target create <exe>", we will place the untouched "<exe>" into target.arg0 to ensure when we run, we run with what the user typed. This has been added to the ProcessLaunchInfo and all other needed places so we always carry around the:
- resolved executable path
- argv0
- program args

Some systems may not support separating argv0 from the resolved executable path and the ProcessLaunchInfo needs to carry all of this information along so that each platform can make that decision.




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166137 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
47beabb1386be44e3f90dbc30a0b22c23b93a4dc 16-Oct-2012 Jim Ingham <jingham@apple.com> Add the ability to set timeout & "run all threads" options both from the "expr" command and from
the SB API's that evaluate expressions.

<rdar://problem/12457211>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166062 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
13193d5ae15f194102c14a5ccdc46e8db5c3d95f 13-Oct-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/12491387>

I added the ability for a process plug-in to implement custom commands. All the lldb_private::Process plug-in has to do is override:

virtual CommandObject *
GetPluginCommandObject();

This object returned should be a multi-word command that vends LLDB commands. There is a sample implementation in ProcessGDBRemote that is hollowed out. It is intended to be used for sending a custom packet, though the body of the command execute function has yet to be implemented!



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@165861 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b0e3c7c4d063da2cc6a2550ad4979d5c342c8306 29-Sep-2012 Jason Molenda <jmolenda@apple.com> Add the RelocateOrLoadKernel and LoadKernel methods to ProcessGDBRemote::DoRemoteConnect().
When attaching to a remote system that does not look like a typical vendor system, and no
executable binary was specified to lldb, check a couple of fixed locations where kernels
running in ASLR mode (slid in memory to a random address) store their load addr when booted
in debug mode, and relocate the symbols or load the kernel wholesale from the host computer
if we can find it.

<rdar://problem/7714201>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@164888 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
fac2e62f08719ba800a440b7ad0d5a55a26dc620 29-Sep-2012 Jason Molenda <jmolenda@apple.com> Add support for debugging KASLR kernels via kdp (the kernel being
loaded at a random offset).

To get the kernel's UUID and load address I need to send a kdp
packet so I had to implement the kernel relocation (and attempt to
find the kernel if none was provided to lldb already) in ProcessKDP
-- but this code really properly belongs in DynamicLoaderDarwinKernel.

I also had to add an optional Stream to ConnectRemote so
ProcessKDP::DoConnectRemote can print feedback about the remote kernel's
UUID, load address, and notify the user if we auto-loaded the kernel via
the UUID.

<rdar://problem/7714201>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@164881 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
bb1af9ce3e25eae9916f85cb9a0c82e291c20bb4 11-Sep-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/11935492>

Fixed an issue where if we call "Process::Destroy()" and the process is running, if we try to stop it and get "exited" back as the stop reason, we will still deliver the exited event.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@163591 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
d0bdddff8bc6dd5f71492452ce2bbd72fdaa147b 22-Aug-2012 Jim Ingham <jingham@apple.com> Rework how the API mutex is acquired when filling out an ExecutionContext from an ExecutionContextRef,
particularly in the SBThread & SBFrame interfaces. Instead of filling the whole context & then getting
the API mutex, we now get only the target, acquire the API mutex from it, then fill out the rest of the
context. This removes a race condition where you get a ThreadSP, then wait on the API mutex while another
command Destroy's the Thread you've just gotten.
Also fixed the ExecutionContextRef::Get*SP calls so they don't return invalid objects.
Also fixed the ExecutionContext::Has*Scope calls so they don't claim to have a scope if the object representing
that scope has been destroyed.
Also fixed a think-o in Thread::IsValid which was causing it to return the opposite of the desired value.

<rdar://problem/11995490>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@162401 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
c6e82e4a323d7a7168b05365c53c9bc2e0d418e3 22-Aug-2012 Greg Clayton <gclayton@apple.com> Remove further outdated "settings" code and also implement a few missing things.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@162376 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
73844aa19a7360b662e2be710fc3c969d6c86606 22-Aug-2012 Greg Clayton <gclayton@apple.com> Reimplemented the code that backed the "settings" in lldb. There were many issues with the previous implementation:
- no setting auto completion
- very manual and error prone way of getting/setting variables
- tons of code duplication
- useless instance names for processes, threads

Now settings can easily be defined like option values. The new settings makes use of the "OptionValue" classes so we can re-use the option value code that we use to set settings in command options. No more instances, just "does the right thing".



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@162366 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
5a60f5e8c81e8263e0d8af85a4f1e6cd1594970a 04-Aug-2012 Enrico Granata <egranata@apple.com> <rdar://problem/12027563> Making sure that some class of stop-hook commands that involve po'ing objects do not cause an endless recursion

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@161271 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
5d90ade8e8e0d776fe8e1b9e88fc1c86d02e8e4e 28-Jul-2012 Jim Ingham <jingham@apple.com> Added an lldb_private & equivalent SB API to send an AsyncInterrupt to the event loop.
Convert from calling Halt in the lldb Driver.cpp's input reader's sigint handler to sending this AsyncInterrupt so it can be handled in the
event loop.
If you are attaching and get an async interrupt, abort the attach attempt.
Also remember to destroy the process if get interrupted while attaching.
Getting this to work also required handing the eBroadcastBitInterrupt in a few more places in Process WaitForEvent & friends.

<rdar://problem/10792425>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160903 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
3a458eb1e413d39546b664813bba9f9ac292357e 20-Jul-2012 Jim Ingham <jingham@apple.com> Add "vAttachOrWait" to debugserver, so you can implement "attach to the process if it exists OR wait for it" without race conditions. Use that in lldb.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160578 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
7de2a3b03f37987c67f142ce328cc2484c831468 14-Jul-2012 Enrico Granata <egranata@apple.com> <rdar://problem/11782789> Changes to the watchpoint implementation on ARM so that we single-step before stopping at the WP. This is necessary because on ARM the WP triggers before the opcode is actually executed, so we would be unable to continue since we would keep hitting the WP. We work around this by disabling the WP, single stepping and then putting the WP back in place.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160199 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
86827fbccc9a4d1f9993d74940f724d63d826e45 02-Jul-2012 Jim Ingham <jingham@apple.com> Add an "extra-startup-commands" process setting so we can send some command strings to the actual process plugin to interpret as it wishes.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@159511 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
f90b5f34b87e0c1354b4d6f3d24830e69a2949a0 08-Jun-2012 Sean Callanan <scallanan@apple.com> Added a setting (target.process.disable-memory-cache)
that controls whether memory is cached. This is off
by default (i.e., memory is cached) because it greatly
improves performance.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@158173 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
4389256aecd2693109969c21fa2f00c4612320b3 06-Jun-2012 Jim Ingham <jingham@apple.com> Make sure that when if we are going to Halt while the process is in the middle of HandlePrivateEvent we
wait till that is done. We need a stronger way to do this, but in practice this works and using some locking
strategy is harder because Halt & HandlePrivateEvent generally happen on different threads.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@158042 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b7b2532bf23c852ea3e43d10f2377338be5b464f 01-Jun-2012 Jim Ingham <jingham@apple.com> When the Platform launches a process for debugging, make sure it goes into a separate process group, otherwise ^C will both cause us to try to Stop it manually, AND send it a SIGINT, which can confuse us.

rdar://problem/11369230

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157791 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
7c09997f9a65bdfd9a0cbd7783d5a5f0a9f83646 24-May-2012 Johnny Chen <johnny.chen@apple.com> rdar://problem/11457634

Supports the use-case scenario of immediately continuing the process once attached.
Add a simple completion test case from "process attach --con" to "process attach --continue ".


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157361 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
7cbdcfb0cefcfd877b507ff2d83e51a1bde3fcc7 23-May-2012 Johnny Chen <johnny.chen@apple.com> Add the capability to display the number of supported hardware watchpoints to the "watchpoint list" command.

Add default Process::GetWatchpointSupportInfo() impl which returns an error of "not supported".
Add "qWatchpointSupportInfo" packet to the gdb communication layer to support this, and modify TestWatchpointCommands.py to test it.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157345 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
293b98f5e24ef736766db37feedfefd3b215a0ce 22-May-2012 Filipe Cabecinhas <me@filcab.net> Remove trailing semicolons.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157240 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
6b1763b5ab8f182029807293d74a66e1e1c6bafd 21-May-2012 Enrico Granata <egranata@apple.com> <rdar://problem/11355592> Fixing a bug where we would incorrectly try and determine a dynamic type for a variable of a pointer type that is not a valid generic type for dynamic pointers.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157190 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
dd29b97f71187509df339596c3397dea0e429754 19-May-2012 Greg Clayton <gclayton@apple.com> Found a quick way to improve the speed with which we can read object files from memory when they are in the shared cache: always read the symbol table strings from memory and let the process' memory cache do the work.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157083 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
cf5927ee246f5e431162f2753ed9e040dd060fe5 18-May-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/11386214>
<rdar://problem/11455913>

"target symbol add" should flush the cached frames
"register write" should flush the thread state in case registers modifications change stack




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157042 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
027aaa74a914823ab4c9cf8f3274d179e97fdb53 19-Apr-2012 Jim Ingham <jingham@apple.com> Switch to setting the write side of the run lock when we call Resume. Then make a PrivateResume that doesn't switch the run-lock state, and use that where we are resuming without changing the public resume state.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@155092 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
97471184b8823c949bc68bbf54ea3edf3845a750 14-Apr-2012 Greg Clayton <gclayton@apple.com> Added a new host function that allows us to run shell command and get the output from them along with the status and signal:

Error
Host::RunShellCommand (const char *command,
const char *working_dir,
int *status_ptr,
int *signo_ptr,
std::string *command_output_ptr,
uint32_t timeout_sec);

This will allow us to use this functionality in the host lldb_private::Platform, and also use it in our lldb-platform binary. It leverages the existing code in Host::LaunchProcess and ProcessLaunchInfo.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154730 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
5ba82b9dfd5b9c6b8849a56bc74a6828d1dd109b 12-Apr-2012 Jim Ingham <jingham@apple.com> Cleanup, keep private types separate from private member variables.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154600 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
ae932359b80098532f3c3766fa9e6527352fbb67 10-Apr-2012 Greg Clayton <gclayton@apple.com> Trying to solve our disappearing thread issues by making thread list updates safer.

The current ProcessGDBRemote function that updates the threads could end up with an empty list if any other thread had the sequence mutex. We now don't clear the thread list when we can't access it, and we also have changed how lldb_private::Process handles the return code from the:

virtual bool
Process::UpdateThreadList (lldb_private::ThreadList &old_thread_list,
lldb_private::ThreadList &new_thread_list) = 0;

A bool is now returned to indicate if the list was actually updated or not and the lldb_private::Process class will only update the stop ID of the validity of the thread list if "true" is returned.

The ProcessGDBRemote also got an extra assertion that will hopefully assert when running debug builds so we can find the source of this issue.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154365 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
1831e78a6253392fca1c99e555e7adaa3f372647 07-Apr-2012 Jim Ingham <jingham@apple.com> We sometimes need to be able to call functions (via Process::RunThreadPlan) from code run on the private state thread. To do that we have to
spin up a temporary "private state thread" that will respond to events from the lower level process plugins. This check-in should work to do
that, but it is still buggy. However, if you don't call functions on the private state thread, these changes make no difference.

This patch also moves the code in the AppleObjCRuntime step-through-trampoline handler that might call functions (in the case where the debug
server doesn't support the memory allocate/deallocate packet) out to a safe place to do that call.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154230 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a894fe78bc15344a0025c1154e414c554ab31dd9 05-Apr-2012 Greg Clayton <gclayton@apple.com> Added a new Host class: ReadWriteLock

This abstracts read/write locks on the current host system. It is currently backed by pthread_rwlock_t objects so it should work on all unix systems.

We also need a way to control multi-threaded access to the process through the public API when it is running. For example it isn't a good idea to try and get stack frames while the process is running. To implement this, the lldb_private::Process class now contains a ReadWriteLock member variable named m_run_lock which is used to control the public process state. The public process state represents the state of the process as the client knows it. The private is used to control the actual current process state. So the public state of the process can be stopped, yet the private state can be running when evaluating an expression for example.

Adding the read/write lock where readers are clients that want the process to stay stopped, and writers are clients that run the process, allows us to accurately control multi-threaded access to the process.

Switched the SBThread and SBFrame over to us shared pointers to the ExecutionContextRef class instead of making their own class to track this. This fixed an issue with assigning on SBFrame to another and will also centralize the code that tracks weak references to execution context objects into one location.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154099 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
598df88bd6fc33c6fb330bc859bdc277795501f3 14-Mar-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/10434005>

Prepare LLDB to be built with C++11 by hiding all accesses to std::tr1 behind
macros that allows us to easily compile for either C++.




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@152698 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
e31176627725f4236c9ca049edc027756709780b 10-Mar-2012 Jim Ingham <jingham@apple.com> Fix the process of getting the ObjC runtime - if we ask for it too early (in the process of handling the
load notification for the first load) then we will set it the runtime to NULL and won't re-search for it.
Added a way for the dynamic loader to force a re-search, since it knows the world has changed.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@152453 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
95ec1688db0efe51509ad9356052f5004d8856e0 06-Mar-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/10840355>

Fixed STDERR to not be opened as readable. Also cleaned up some of the code that implemented the file actions as some of the code was using the wrong variables, they now use the right ones (in for stdin, out for stdout, err for stderr).



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@152102 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
c86723f0a71f5d929f4543c544d9255da52ea49d 02-Mar-2012 Han Ming Ong <hanming@apple.com> <rdar://problem/10967188>

When using launch_info for launching with a target already set, we should just prepend the target's path as the first argument.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151867 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
d1040dd360c07305a30d33b5d4501cb9dfb03114 25-Feb-2012 Han Ming Ong <hanming@apple.com> <rdar://problem/3535148>

Added ability to debug root processes on OS X. This uses XPC service that is available on Lion and above only.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151419 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0a8dcacde404c520f1131c641041dceb9f68b6fa 24-Feb-2012 Greg Clayton <gclayton@apple.com> Added the new way we will eventually do all attaches and launches. First clients
will fill out either a SBLaunchInfo or SBAttachInfo class, then call:

SBProcess SBTarget::Launch (SBLaunchInfo &, SBError &);
SBProcess SBTarget::Attach (SBAttachInfo &, SBError &);

The attach is working right now and allows the ability to set many filters such
as the parent process ID, the user/group ID, the effective user/group ID, and much
more.

The launch is not yet working, but I will get this working soon. By changing our
launch and attach calls to take an object, it allows us to add more capabilities to
launching and attaching without having to have launch and attach functions that
take more and more arguments.

Once this is all working we will deprecated the older launch and attach fucntions
and eventually remove them.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151344 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
761133029ba2d5bb0c21c3a871dede340b2775fc 22-Feb-2012 Greg Clayton <gclayton@apple.com> For stepping performance I added the ability to outlaw all memory accesseses
to the __PAGEZERO segment on darwin. The dynamic loader now correctly doesn't
slide __PAGEZERO and it also registers it as an invalid region of memory. This
allows us to not make any memory requests from the local or remote debug session
for any addresses in this region. Stepping performance can improve when uninitialized
local variables that point to locations in __PAGEZERO are attempted to be read
from memory as we won't even make the memory read or write request.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151128 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
289afcb5e26c2527a0d2e71f84e780b86bbcf90a 18-Feb-2012 Greg Clayton <gclayton@apple.com> The second part in thread hardening the internals of LLDB where we make
the lldb_private::StackFrame objects hold onto a weak pointer to the thread
object. The lldb_private::StackFrame objects the the most volatile objects
we have as when we are doing single stepping, frames can often get lost or
thrown away, only to be re-created as another object that still refers to the
same frame. We have another bug tracking that. But we need to be able to
have frames no longer be able to get the thread when they are not part of
a thread anymore, and this is the first step (this fix makes that possible
but doesn't implement it yet).

Also changed lldb_private::ExecutionContextScope to return shared pointers to
all objects in the execution context to further thread harden the internals.




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@150871 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
5a15e6927b5b3234fb3e688717297ba6b5dd6ad7 16-Feb-2012 Jim Ingham <jingham@apple.com> Add a general mechanism to wait on the debugger for Broadcasters of a given class/event bit set.
Use this to allow the lldb Driver to emit notifications for breakpoint modifications.
<rdar://problem/10619974>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@150665 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
9ce953807eb814a93b449dc243de4f7bf32c3115 14-Feb-2012 Greg Clayton <gclayton@apple.com> Full core file support has been added for mach-o core files.

Tracking modules down when you have a UUID and a path has been improved.

DynamicLoaderDarwinKernel no longer parses mach-o load commands and it
now uses the memory based modules now that we can load modules from memory.

Added a target setting named "target.exec-search-paths" which can be used
to supply a list of directories to use when trying to look for executables.
This allows one or more directories to be used when searching for modules
that may not exist in the SDK/PDK. The target automatically adds the directory
for the main executable to this list so this should help us in tracking down
shared libraries and other binaries.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@150426 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
46c9a355af9b39db78c006b2a5cbf97d3c58d947 09-Feb-2012 Greg Clayton <gclayton@apple.com> First pass at mach-o core file support is in. It currently works for x86_64
user space programs. The core file support is implemented by making a process
plug-in that will dress up the threads and stack frames by using the core file
memory.

Added many default implementations for the lldb_private::Process functions so
that plug-ins like the ProcessMachCore don't need to override many many
functions only to have to return an error.

Added new virtual functions to the ObjectFile class for extracting the frozen
thread states that might be stored in object files. The default implementations
return no thread information, but any platforms that support core files that
contain frozen thread states (like mach-o) can make a module using the core
file and then extract the information. The object files can enumerate the
threads and also provide the register state for each thread. Since each object
file knows how the thread registers are stored, they are responsible for
creating a suitable register context that can be used by the core file threads.

Changed the process CreateInstace callbacks to return a shared pointer and
to also take an "const FileSpec *core_file" parameter to allow for core file
support. This will also allow for lldb_private::Process subclasses to be made
that could load crash logs. This should be possible on darwin where the crash
logs contain all of the stack frames for all of the threads, yet the crash
logs only contain the registers for the crashed thrad. It should also allow
some variables to be viewed for the thread that crashed.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@150154 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b5a8f1498e1ddaeed5187a878d57ea0b74af9c26 05-Feb-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/10560053>

Fixed "target modules list" (aliased to "image list") to output more information
by default. Modified the "target modules list" to have a few new options:

"--header" or "-h" => show the image header address
"--offset" or "-o" => show the image header address offset from the address in the file (the slide applied to the shared library)

Removed the "--symfile-basename" or "-S" option, and repurposed it to
"--symfile-unique" "-S" which will show the symbol file if it differs from
the executable file.

ObjectFile's can now be loaded from memory for cases where we don't have the
files cached locally in an SDK or net mounted root. ObjectFileMachO can now
read mach files from memory.

Moved the section data reading code into the ObjectFile so that the object
file can get the section data from Process memory if the file is only in
memory.

lldb_private::Module can now load its object file in a target with a rigid
slide (very common operation for most dynamic linkers) by using:

bool
Module::SetLoadAddress (Target &target, lldb::addr_t offset, bool &changed)

lldb::SBModule() now has a new constructor in the public interface:

SBModule::SBModule (lldb::SBProcess &process, lldb::addr_t header_addr);

This will find an appropriate ObjectFile plug-in to load an image from memory
where the object file header is at "header_addr".




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@149804 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
334d33a19fd28cf41cba74cc61cf149e7101a603 30-Jan-2012 Greg Clayton <gclayton@apple.com> SBFrame is now threadsafe using some extra tricks. One issue is that stack
frames might go away (the object itself, not the actual logical frame) when
we are single stepping due to the way we currently sometimes end up flushing
frames when stepping in/out/over. They later will come back to life
represented by another object yet they have the same StackID. Now when you get
a lldb::SBFrame object, it will track the frame it is initialized with until
the thread goes away or the StackID no longer exists in the stack for the
thread it was created on. It uses a weak_ptr to both the frame and thread and
also stores the StackID. These three items allow us to determine when the
stack frame object has gone away (the weak_ptr will be NULL) and allows us to
find the correct frame again. In our test suite we had such cases where we
were just getting lucky when something like this happened:

1 - stop at breakpoint
2 - get first frame in thread where we stopped
3 - run an expression that causes the program to JIT and run code
4 - run more expressions on the frame from step 2 which was very very luckily
still around inside a shared pointer, yet, not part of the current
thread (a new stack frame object had appeared with the same stack ID and
depth).

We now avoid all such issues and properly keep up to date, or we start
returning errors when the frame doesn't exist and always responds with
invalid answers.

Also fixed the UserSettingsController (not going to rewrite this just yet)
so that it doesn't crash on shutdown. Using weak_ptr's came in real handy to
track when the master controller has already gone away and this allowed me to
pull out the previous NotifyOwnerIsShuttingDown() patch as it is no longer
needed.




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@149231 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
13d24fb1817faa7ccc4cfd799113ba1a2b8968eb 29-Jan-2012 Greg Clayton <gclayton@apple.com> Switching back to using std::tr1::shared_ptr. We originally switched away
due to RTTI worries since llvm and clang don't use RTTI, but I was able to
switch back with no issues as far as I can tell. Once the RTTI issue wasn't
an issue, we were looking for a way to properly track weak pointers to objects
to solve some of the threading issues we have been running into which naturally
led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared
pointer from just a pointer, which is also easily solved using the
std::tr1::enable_shared_from_this class.

The main reason for this move back is so we can start properly having weak
references to objects. Currently a lldb_private::Thread class has a refrence
to its parent lldb_private::Process. This doesn't work well when we now hand
out a SBThread object that contains a shared pointer to a lldb_private::Thread
as this SBThread can be held onto by external clients and if they end up
using one of these objects we can easily crash.

So the next task is to start adopting std::tr1::weak_ptr where ever it makes
sense which we can do with lldb_private::Debugger, lldb_private::Target,
lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and
many more objects now that they are no longer using intrusive ref counted
pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive
pointers).



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@149207 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
4a2e33769873d68d5703da5742c0e248f46e3a72 15-Dec-2011 Greg Clayton <gclayton@apple.com> Expose new read memory fucntion through python in SBProcess:

size_t
SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);

uint64_t
SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);

lldb::addr_t
SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &error);

These ReadCStringFromMemory() has some SWIG type magic that makes it return the
python string directly and the "buf" is not needed:

error = SBError()
max_cstr_len = 256
cstr = lldb.process.ReadCStringFromMemory (0x1000, max_cstr_len, error)
if error.Success():
....

The other two functions behave as expteced. This will make it easier to get integer values
from the inferior process that are correctly byte swapped. Also for pointers, the correct
pointer byte size will be used.

Also cleaned up a few printf style warnings for the 32 bit lldb build on darwin.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@146636 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
1f9c39c3c146f3c057575f53707e97019f402c46 13-Dec-2011 Jason Molenda <jmolenda@apple.com> When unwinding from the first frame, try to ask the remote debugserver
if this is a mapped/executable region of memory. If it isn't, we've jumped
through a bad pointer and we know how to unwind the stack correctly based
on the ABI.

Previously I had 0x0 special cased but if you jumped to 0x2 on x86_64 one
frame would be skipped because the unwinder would try using the x86_64
ArchDefaultUnwindPlan which relied on the rbp.

Fixes <rdar://problem/10508291>



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@146477 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a9385537809ef342c843c5ab972e513742652047 18-Nov-2011 Greg Clayton <gclayton@apple.com> 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.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144976 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
464c6161464694412b7472129e789248f1cf21b9 17-Nov-2011 Greg Clayton <gclayton@apple.com> Use a pseudoterminal for local processes if no STDIO redirection or other
file actions have been specified.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144922 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
ffa43a6bc42bfcccae46eec9cf7bf73f17c328e9 17-Nov-2011 Greg Clayton <gclayton@apple.com> Fixed the issue that was causing our monitor process threads to crash, it
turned out to be unitialized data in the ProcessLaunchInfo default constructor.
Turning on MallocScribble in the environment helped track this down.

When we launch and attach using the host layer, we now inform the process that
it shouldn't detach when by calling an accessor.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144882 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
1c4642c6ab741d85c98d4288cf922c9a2ef77007 16-Nov-2011 Greg Clayton <gclayton@apple.com> Made the darwin host layer properly reap any child processes that it spawns.
After recent changes we weren't reaping child processes resulting in many
zombie processes.

This was fixed by adding more settings to the ProcessLaunchOptions class
that allow clients to specify a callback function and baton to be notified
when their process dies. If one is not supplied a default callback will be
used that "does the right thing".

Cleaned up a race condition in the ProcessGDBRemote class that would attempt
to monitor when debugserver died.

Added an extra boolean to the process monitor callbacks that indicate if a
process exited or not. If your process exited with a zero exit status and no
signal, both items could be zero.

Modified the process monitor functions to not require a callback function
in order to reap the child process.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144780 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
527154d8e532f27f25af226c9e1dac607c48b5d1 15-Nov-2011 Greg Clayton <gclayton@apple.com> Added a new class to Process.h: ProcessAttachInfo. This class contains enough
info for us to attach by pid, or by name and will also allow us to eventually
do a lot more powerful attaches. If you look at the options for the "platform
process list" command, there are many options which we should be able to
specify. This will allow us to do things like "attach to a process named 'tcsh'
that has a parent process ID of 123", or "attach to a process named 'x' which
has an effective user ID of 345".

I finished up the --shell implementation so that it can be used without the
--tty option in "process launch". The "--shell" option now can take an
optional argument which is the path to the shell to use (or a partial name
like "sh" which we will find using the current PATH environment variable).

Modified the Process::Attach to use the new ProcessAttachInfo as the sole
argument and centralized a lot of code that was in the "process attach"
Execute function so that everyone can take advantage of the powerful new
attach functionality.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144615 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
bd06ff435614ff4e884c40f3ea13e24f0cef96f7 13-Nov-2011 Greg Clayton <gclayton@apple.com> <rdar://problem/10103980>

A long time ago we started to centralized the STDOUT in lldb_private::Process
but we missed a few things still in ProcessGDBRemote.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144491 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
2d9adb73af7520bec430e0585ca40467828e6ed1 12-Nov-2011 Greg Clayton <gclayton@apple.com> Added the ability to run a process in a shell on MacOSX currently when using
the --tty option. So you can now get shell expansion and file redirection:

(lldb) process launch --tty --shell -- *.jpg < in.txt > out.txt

Again, the "--tty" is mandatory for now until we hook this up to other
functions. The shell is also currently hard coded to "/bin/bash" and not the
"SHELL" variable. "/bin/tcsh" was causing problems which I need to dig into.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144443 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0296fe73a7cb1482226b1303a795ede00e12d677 08-Nov-2011 Jim Ingham <jingham@apple.com> Do a better job of detecting when a breakpoint command has set the target running again (except you have to ignore
cases where the breakpoint runs expressions, those don't count as really "running again").


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144064 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
abb3302051246273eb92cca203c9a1b9d9736e05 08-Nov-2011 Greg Clayton <gclayton@apple.com> 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.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144061 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
07c51d09d4b61891cdc37f44bb332dc286b4de2f 04-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> Include limits.h for PATH_MAX.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143694 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
36bc5ea5a48c19421d44f559e2165c105657b809 03-Nov-2011 Greg Clayton <gclayton@apple.com> Modified all Process::Launch() calls to use a ProcessLaunchInfo structure
on internal only (public API hasn't changed) to simplify the paramter list
to the launch calls down into just one argument. Also all of the argument,
envronment and stdio things are now handled in a much more centralized fashion.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143656 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
444e35b5fdf15a25a427285650f06f1390e62c75 19-Oct-2011 Greg Clayton <gclayton@apple.com> Moved lldb::user_id_t values to be 64 bit. This was going to be needed for
process IDs, and thread IDs, but was mainly needed for for the UserID's for
Types so that DWARF with debug map can work flawlessly. With DWARF in .o files
the type ID was the DIE offset in the DWARF for the .o file which is not
unique across all .o files, so now the SymbolFileDWARFDebugMap class will
make the .o file index part (the high 32 bits) of the unique type identifier
so it can uniquely identify the types.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@142534 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
ecd4feb5111432d2878e95461220c720cb2d24c8 14-Oct-2011 Johnny Chen <johnny.chen@apple.com> SBValue::Watch() and SBValue::WatchPointee() are now the official API for creating
a watchpoint for either the variable encapsulated by SBValue (Watch) or the pointee
encapsulated by SBValue (WatchPointee).

Removed SBFrame::WatchValue() and SBFrame::WatchLocation() API as a result of that.

Modified the watchpoint related test suite to reflect the change.

Plus replacing WatchpointLocation with Watchpoint throughout the code base.

There are still cleanups to be dome. This patch passes the whole test suite.
Check it in so that we aggressively catch regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@141925 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
567e7f3ba16eb48cb9fd6a2f26f2f7269eb6983c 22-Sep-2011 Greg Clayton <gclayton@apple.com> Converted the lldb_private::Process over to use the intrusive
shared pointers.

Changed the ExecutionContext over to use shared pointers for
the target, process, thread and frame since these objects can
easily go away at any time and any object that was holding onto
an ExecutionContext was running the risk of using a bad object.

Now that the shared pointers for target, process, thread and
frame are just a single pointer (they all use the instrusive
shared pointers) the execution context is much safer and still
the same size.

Made the shared pointers in the the ExecutionContext class protected
and made accessors for all of the various ways to get at the pointers,
references, and shared pointers.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140298 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
6cf6c474742a23e7cb6b4f618bf1de711db90a85 21-Sep-2011 Sean Callanan <scallanan@apple.com> Fixed a problem where expressions would attempt to
allocate memory in a process that did not support
expression execution. Also improved detection of
whether or not a process can execute expressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140202 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
dbcf98c194742f911c963854084c66aa49a5e513 15-Sep-2011 Jim Ingham <jingham@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@139852 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
37f962e785be99dc4f0c5e9d02416992ff03bbd0 22-Aug-2011 Greg Clayton <gclayton@apple.com> Added a new plug-in type: lldb_private::OperatingSystem. The operating system
plug-ins are add on plug-ins for the lldb_private::Process class that can add
thread contexts that are read from memory. It is common in kernels to have
a lot of threads that are not currently executing on any cores (JTAG debugging
also follows this sort of thing) and are context switched out whose state is
stored in memory data structures. Clients can now subclass the OperatingSystem
plug-ins and then make sure their Create functions correcltly only enable
themselves when the right binary/target triple are being debugged. The
operating system plug-ins get a chance to attach themselves to processes just
after launching or attaching and are given a lldb_private::Process object
pointer which can be inspected to see if the main executable, target triple,
or any shared libraries match a case where the OS plug-in should be used.
Currently the OS plug-ins can create new threads, define the register contexts
for these threads (which can all be different if desired), and populate and
manage the thread info (stop reason, registers in the register context) as
the debug session goes on.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@138228 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
21f37ad875d4f50d1b4b3d307e120f6d27103730 09-Aug-2011 Jim Ingham <jingham@apple.com> Move the handling of breakpoint conditions from the Private event loop to the StopInfoBreakpoint::DoActions, which happens as the
event is removed. Also use the return value of asynchronous breakpoint callbacks, they get checked before, and override the
breakpoint conditions.

Added ProcessModInfo class, to unify "stop_id generation" and "memory modification generation", and use where needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@137102 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
2bc9eb3ba78efc64a273729b480bafc3bbaa433a 19-Jul-2011 Johnny Chen <johnny.chen@apple.com> Patch by Matt Johnson to silence G++ warnings!
Used hand merge to apply the diffs. I did not apply the diffs for FormatManager.h and
the diffs for memberwise initialization for ValueObject.cpp because they changed since.
I will ask my colleague to apply them later.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@135508 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
8d2ea2888a4acb7f140f9af64ddd2b16b2dee870 17-Jul-2011 Greg Clayton <gclayton@apple.com> Added a boolean to the pure virtual lldb_private::Process::CanDebug(...)
method so process plug-ins that are requested by name can answer yes when
asked if they can debug a target that might not have any file in the target.

Modified the ConnectionFileDescriptor to have both a read and a write file
descriptor. This allows us to support UDP, and eventually will allow us to
support pipes. The ConnectionFileDescriptor class also has a file descriptor
type for each of the read and write file decriptors so we can use the correct
read/recv/recvfrom call when reading, or write/send/sendto for writing.

Finished up an initial implementation of UDP where you can use the "udp://"
URL to specify a host and port to connect to:

(lldb) process connect --plugin kdp-remote udp://host:41139

This will cause a ConnectionFileDescriptor to be created that can send UDP
packets to "host:41139", and it will also bind to a localhost port that can
be given out to receive the connectionless UDP reply.

Added the ability to get to the IPv4/IPv6 socket port number from a
ConnectionFileDescriptor instance if either file descriptor is a socket.

The ProcessKDP can now successfully connect to a remote kernel and detach
using the above "processs connect" command!!! So far we have the following
packets working:
KDP_CONNECT
KDP_DISCONNECT
KDP_HOSTINFO
KDP_VERSION
KDP_REATTACH

Now that the packets are working, adding new packets will go very quickly.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@135363 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
c0fa53324d62a48257c092a3347d6e7236aa3152 23-May-2011 Greg Clayton <gclayton@apple.com> Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:

lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);

bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);

size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);

size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);

in lldb_private::Process the following functions were renamed:

From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);

To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);

Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.

Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):

uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;

The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.

Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:

lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;

lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;

All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.

Fixed up a lot of places that were calling :

addr_t
Address::GetLoadAddress(Target*);

to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131878 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
6cf4d2b31bf208cd6e48d4e37af671ab9b451446 22-May-2011 Jim Ingham <jingham@apple.com> Change the m_update_state to an int, and only trigger the "on removal"
action the second time the event is removed (the first is the internal ->
external transition, the second when it is pulled off the public event
queue, and further times when it is put back because we are faking a
stop reason to hide the expression evaluation stops.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131869 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b9e8f6e7a374d9313f89193e90ae41ef91712e5b 18-May-2011 Greg Clayton <gclayton@apple.com> Added a way to resolve an load address from a target:

bool
Address::SetLoadAddress (lldb::addr_t load_addr, Target *target);

Added an == and != operator to RegisterValue.

Modified the ThreadPlanTracer to use RegisterValue objects to store the
register values when single stepping. Also modified the output to be a bit
less wide.

Fixed the ABIMacOSX_arm to not overwrite stuff on the stack. Also made the
trivial function call be able to set the ARM/Thumbness of the target
correctly, and also sets the return value ARM/Thumbness.

Fixed the encoding on the arm s0-s31 and d16 - d31 registers when the default
register set from a standard GDB server register sets.







git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131517 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
613b8739a4d489b7f1c571288d5786768c024205 17-May-2011 Greg Clayton <gclayton@apple.com> Added an allocated memory cache to avoid having to allocate memory over and
over when running JITed expressions. The allocated memory cache will cache
allocate memory a page at a time for each permission combination and divvy up
the memory and hand it out in 16 byte increments.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131453 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
75906e4ec98af3717e415727a8d663a4e246bb4f 11-May-2011 Greg Clayton <gclayton@apple.com> Moved all code from ArchDefaultUnwindPlan and ArchVolatileRegs into their
respective ABI plugins as they were plug-ins that supplied ABI specfic info.

Also hookep up the UnwindAssemblyInstEmulation so that it can generate the
unwind plans for ARM.

Changed the way ABI plug-ins are handed out when you get an instance from
the plug-in manager. They used to return pointers that would be mananged
individually by each client that requested them, but now they are handed out
as shared pointers since there is no state in the ABI objects, they can be
shared.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131193 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
abe0fed36d83e1c37af9dae90c2d25db742b4515 18-Apr-2011 Greg Clayton <gclayton@apple.com> Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).

Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.

We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:

(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52

Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129695 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
143fcc3a15425659b381502ed4e1e50a3e726f36 13-Apr-2011 Greg Clayton <gclayton@apple.com> Added two new classes for command options:

lldb_private::OptionGroup
lldb_private::OptionGroupOptions

OptionGroup lets you define a class that encapsulates settings that you want
to reuse in multiple commands. It contains only the option definitions and the
ability to set the option values, but it doesn't directly interface with the
lldb_private::Options class that is the front end to all of the CommandObject
option parsing. For that the OptionGroupOptions class can be used. It aggregates
one or more OptionGroup objects and directs the option setting to the
appropriate OptionGroup class. For an example of this, take a look at the
CommandObjectFile and how it uses its "m_option_group" object shown below
to be able to set values in both the FileOptionGroup and PlatformOptionGroup
classes. The members used in CommandObjectFile are:

OptionGroupOptions m_option_group;
FileOptionGroup m_file_options;
PlatformOptionGroup m_platform_options;

Then in the constructor for CommandObjectFile you can combine the option
settings. The code below shows a simplified version of the constructor:

CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) :
CommandObject (...),
m_option_group (interpreter),
m_file_options (),
m_platform_options(true)
{
m_option_group.Append (&m_file_options);
m_option_group.Append (&m_platform_options);
m_option_group.Finalize();
}

We append the m_file_options and then the m_platform_options and then tell
the option group the finalize the results. This allows the m_option_group to
become the organizer of our prefs and after option parsing we end up with
valid preference settings in both the m_file_options and m_platform_options
objects. This also allows any other commands to use the FileOptionGroup and
PlatformOptionGroup classes to implement options for their commands.

Renamed:
virtual void Options::ResetOptionValues();
to:
virtual void Options::OptionParsingStarting();

And implemented a new callback named:

virtual Error Options::OptionParsingFinished();

This allows Options subclasses to verify that the options all go together
after all of the options have been specified and gives the chance for the
command object to return an error. It also gives a chance to take all of the
option values and produce or initialize objects after all options have
completed parsing.

Modfied:

virtual Error
SetOptionValue (int option_idx, const char *option_arg) = 0;

to be:

virtual Error
SetOptionValue (uint32_t option_idx, const char *option_arg) = 0;

(option_idx is now unsigned).




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129415 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b72d0f098e45936fa72e26b1a026c603e17e2d6c 12-Apr-2011 Greg Clayton <gclayton@apple.com> Moved the execution context that was in the Debugger into
the CommandInterpreter where it was always being used.

Make sure that Modules can track their object file offsets correctly to
allow opening of sub object files (like the "__commpage" on darwin).

Modified the Platforms to be able to launch processes. The first part of this
move is the platform soon will become the entity that launches your program
and when it does, it uses a new ProcessLaunchInfo class which encapsulates
all process launching settings. This simplifies the internal APIs needed for
launching. I want to slowly phase out process launching from the process
classes, so for now we can still launch just as we used to, but eventually
the platform is the object that should do the launching.

Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able
to launch processes with all of the new eLaunchFlag settings. Modified any
code that was manually launching processes to use the Host::LaunchProcess
functions.

Fixed an issue where lldb_private::Args had implicitly defined copy
constructors that could do the wrong thing. This has now been fixed by adding
an appropriate copy constructor and assignment operator.

Make sure we don't add empty ModuleSP entries to a module list.

Fixed the commpage module creation on MacOSX, but we still need to train
the MacOSX dynamic loader to not get rid of it when it doesn't have an entry
in the all image infos.

Abstracted many more calls from in ProcessGDBRemote down into the
GDBRemoteCommunicationClient subclass to make the classes cleaner and more
efficient.

Fixed the default iOS ARM register context to be correct and also added support
for targets that don't support the qThreadStopInfo packet by selecting the
current thread (only if needed) and then sending a stop reply packet.

Debugserver can now start up with a --unix-socket (-u for short) and can
then bind to port zero and send the port it bound to to a listening process
on the other end. This allows the GDB remote platform to spawn new GDB server
instances (debugserver) to allow platform debugging.







git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129351 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
ff39f746ebaa3710c44ba49bd9b0a6cf05f60a3f 01-Apr-2011 Greg Clayton <gclayton@apple.com> Added the ability to get a broadcaster event name for a given broadcaster
event.

Modified the ProcessInfo structure to contain all process arguments. Using the
new function calls on MacOSX allows us to see the full process name, not just
the first 16 characters.

Added a new platform command: "platform process info <pid> [<pid> <pid> ...]"
that can be used to get detailed information for a process including all
arguments, user and group info and more.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128694 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
24bc5d9bfad2a1c562c27e7cf37e1c56d85c45e7 30-Mar-2011 Greg Clayton <gclayton@apple.com> Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:

int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff

// Platform subclass specific code...
int result = ...
return result;
}

Added new functions to the platform:

virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);

The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.

Added the parent process ID to the ProcessInfo class.

Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.

This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:

machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver


This of course also works remotely with the lldb-platform:

machine1.foo.com % lldb-platform --listen 1234

machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari

The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.

Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:

% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out

Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.

Modified the disassembly to show the current PC value. Example output:

(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret

This can be handy when dealing with the new --line options that was recently
added:

(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf

Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.

Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:

const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;





git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128563 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b344843f75ef893762c93fd0a22d2d45712ce74d 24-Mar-2011 Greg Clayton <gclayton@apple.com> Fixed the LLDB build so that we can have private types, private enums and
public types and public enums. This was done to keep the SWIG stuff from
parsing all sorts of enums and types that weren't needed, and allows us to
abstract our API better.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128239 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a733c04608cc94592a15d27583529588e19db552 21-Mar-2011 Greg Clayton <gclayton@apple.com> Added real user/group id, effective user/group id, and parent
process ID to the ProcessInfo.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128023 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b1888f24fa181489840b9acf193e224d125d0776 19-Mar-2011 Greg Clayton <gclayton@apple.com> Added more platform support. There are now some new commands:

platform status -- gets status information for the selected platform
platform create <platform-name> -- creates a new instance of a remote platform
platform list -- list all available platforms
platform select -- select a platform instance as the current platform (not working yet)

When using "platform create" it will create a remote platform and make it the
selected platform. For instances for iPhone OS debugging on Mac OS X one can
do:

(lldb) platform create remote-ios --sdk-version=4.0
Remote platform: iOS platform
SDK version: 4.0
SDK path: "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0"
Not connected to a remote device.
(lldb) file ~/Documents/a.out
Current executable set to '~/Documents/a.out' (armv6).
(lldb) image list
[ 0] /Volumes/work/gclayton/Documents/devb/attach/a.out
[ 1] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/dyld
[ 2] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libSystem.B.dylib


Note that this is all happening prior to running _or_ connecting to a remote
platform. Once connected to a remote platform the OS version might change which
means we will need to update our dependecies. Also once we run, we will need
to match up the actualy binaries with the actualy UUID's to files in the
SDK, or download and cache them locally.

This is just the start of the remote platforms, but this modification is the
first iteration in getting the platforms really doing something.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@127934 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
2a456816c5d7c575f2e141acd48bb5f8085d9910 10-Mar-2011 Caroline Tice <ctice@apple.com> The UserSettings controllers must be initialized & terminated in the
correct order. Previously this was tacitly implemented but not
enforced, so it was possible to accidentally do things in the wrong
order and cause problems. This fixes that problem.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@127430 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
e4b9c1fb338ee1ada72e6a3c198afb342d68c5c1 08-Mar-2011 Greg Clayton <gclayton@apple.com> LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide
an interface to a local or remote debugging platform. By default each host OS
that supports LLDB should be registering a "default" platform that will be
used unless a new platform is selected. Platforms are responsible for things
such as:
- getting process information by name or by processs ID
- finding platform files. This is useful for remote debugging where there is
an SDK with files that might already or need to be cached for debug access.
- getting a list of platform supported architectures in the exact order they
should be selected. This helps the native x86 platform on MacOSX select the
correct x86_64/i386 slice from universal binaries.
- Connect to remote platforms for remote debugging
- Resolving an executable including finding an executable inside platform
specific bundles (macosx uses .app bundles that contain files) and also
selecting the appropriate slice of universal files for a given platform.

So by default there is always a local platform, but remote platforms can be
connected to. I will soon be adding a new "platform" command that will support
the following commands:
(lldb) platform connect --name machine1 macosx connect://host:port
Connected to "machine1" platform.
(lldb) platform disconnect macosx

This allows LLDB to be well setup to do remote debugging and also once
connected process listing and finding for things like:
(lldb) process attach --name x<TAB>

The currently selected platform plug-in can now auto complete any available
processes that start with "x". The responsibilities for the platform plug-in
will soon grow and expand.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@127286 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
c7129c3ca353eb7f0bc8c2aa0d99b54de21b9de6 02-Mar-2011 Jim Ingham <jingham@apple.com> Add some function docs.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126868 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a2f7423310044cf76d8d52aa9153b7fd8b226b49 24-Feb-2011 Greg Clayton <gclayton@apple.com> Fixed CommandReturnObject::SetImmediateErrorFile() to set the correct stream.

Modifed lldb_private::Process to be able to handle connecting to a remote
target that isn't running a process. This leaves lldb_private::Process in the
eStateConnected state from which we can then do an attach or launch.

Modified ProcessGDBRemote to be able to set stdin, stdout, stderr, working
dir, disable ASLR and a few other settings down by using new GDB remote
packets. This allows us to keep all of our current launch flags and settings
intact and still be able to communicate them over to the remote GDB server.
Previously these were being sent as arguments to the debugserver binary that
we were spawning. Also modified ProcessGDBRemote to handle losing connection
to the remote GDB server and always exit immediately. We do this by watching
the lldb_private::Communication event bit for the read thread exiting in the
ProcessGDBRemote async thread.

Added support for many of the new 'Q' packets for setting stdin, stdout,
stderr, working dir and disable ASLR to the GDBRemoteCommunication class for
easy accesss.

Modified debugserver for all of the new 'Q' packets and also made it so that
debugserver always exists if it loses connection with the remote debugger.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126444 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
d284b663aa7d08b4f767de5ffa6289f33fcbcce7 18-Feb-2011 Greg Clayton <gclayton@apple.com> Added new target instance settings for execution settings:

Targets can now specify some additional parameters for when we debug
executables that can help with plug-in selection:

target.execution-level = auto | user | kernel
target.execution-mode = auto | dynamic | static
target.execution-os-type = auto | none | halted | live

On some systems, the binaries that are created are the same wether you use
them to debug a kernel, or a user space program. Many times inspecting an
object file can reveal what an executable should be. For these cases we can
now be a little more complete by specifying wether to detect all of these
things automatically (inspect the main executable file and select a plug-in
accordingly), or manually to force the selection of certain plug-ins.

To do this we now allow the specficifation of wether one is debugging a user
space program (target.execution-level = user) or a kernel program
(target.execution-level = kernel).

We can also specify if we want to debug a program where shared libraries
are dynamically loaded using a DynamicLoader plug-in
(target.execution-mode = dynamic), or wether we will treat all symbol files
as already linked at the correct address (target.execution-mode = static).

We can also specify if the inferior we are debugging is being debugged on
a bare board (target.execution-os-type = none), or debugging an OS where
we have a JTAG or other direct connection to the inferior stops the entire
OS (target.execution-os-type = halted), or if we are debugging a program on
something that has live debug services (target.execution-os-type = live).

For the "target.execution-os-type = halted" mode, we will need to create
ProcessHelper plug-ins that allow us to extract the process/thread and other
OS information by reading/writing memory.

This should allow LLDB to be used for a wide variety of debugging tasks and
handle them all correctly.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125815 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
75c703dd8b492bad25a987b96853626641ae7246 16-Feb-2011 Greg Clayton <gclayton@apple.com> The DynamicLoader plug-in instance now lives up in lldb_private::Process where
it should live and the lldb_private::Process takes care of managing the
auto pointer to the dynamic loader instance.

Also, now that the ArchSpec contains the target triple, we are able to
correctly set the Target architecture in DidLaunch/DidAttach in the subclasses,
and then the lldb_private::Process will find the dynamic loader plug-in
by letting the dynamic loader plug-ins inspect the arch/triple in the target.

So now the ProcessGDBRemote plug-in is another step closer to be purely
process/platform agnostic.

I updated the ProcessMacOSX and the ProcessLinux plug-ins accordingly.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125650 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
395fc33dc4b06c048ed35047ec461bc092ef2df3 15-Feb-2011 Greg Clayton <gclayton@apple.com> Made lldb_private::ArchSpec contain much more than just an architecture. It
now, in addition to cpu type/subtype and architecture flavor, contains:
- byte order (big endian, little endian)
- address size in bytes
- llvm::Triple for true target triple support and for more powerful plug-in
selection.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125602 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
f9f40c20b210eea72ab042c63178ca000f005ed9 08-Feb-2011 Jim Ingham <jingham@apple.com> Rework the RunThreadPlan event handling to use Event Hijacking not stopping the event thread. Also clarify the logic of the function.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125083 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
e71e258286a1713dbb2d366d8b81ff2f28e0216f 04-Feb-2011 Greg Clayton <gclayton@apple.com> Added support for attaching to a remote debug server with the new command:
(lldb) process connect <remote-url>

Currently when you specify a file with the file command it helps us to find
a process plug-in that is suitable for debugging. If you specify a file you
can rely upon this to find the correct debugger plug-in:

% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) process connect connect://localhost:2345
...

If you don't specify a file, you will need to specify the plug-in name that
you wish to use:

% lldb
(lldb) process connect --plugin process.gdb-remote connect://localhost:2345

Other connection URL examples:

(lldb) process connect connect://localhost:2345
(lldb) process connect tcp://127.0.0.1
(lldb) process connect file:///dev/ttyS1

We are currently treating the "connect://host:port" as a way to do raw socket
connections. If there is a URL for this already, please let me know and we
will adopt it.

So now you can connect to a remote debug server with the ProcessGDBRemote
plug-in. After connection, it will ask for the pid info using the "qC" packet
and if it responds with a valid process ID, it will be equivalent to attaching.
If it response with an error or invalid process ID, the LLDB process will be
in a new state: eStateConnected. This allows us to then download a program or
specify the program to run (using the 'A' packet), or specify a process to
attach to (using the "vAttach" packets), or query info about the processes
that might be available.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124846 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
7e2f91cb958c8670774cb2190db7b858618b5b9b 29-Jan-2011 Greg Clayton <gclayton@apple.com> Finished up the async attach support. This allows us to request to attach
by name or by pid (with or without waiting for a process to launch) and
catch the response asynchronously.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124530 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
68bffc51b218dc3a124820cb4d983204bf20be4a 29-Jan-2011 Jim Ingham <jingham@apple.com> The m_next_action is simpler if it is an auto_pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124525 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
c2dc7c88cebe05cce059970cc907768256b28a42 29-Jan-2011 Jim Ingham <jingham@apple.com> Added a completion action class to the Process events so that we can make things like Attach and later Launch start their job, and then return to the event loop while waiting for the work to be done.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124520 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
de915beb5febe597505ba33fdc2c39eea2abdbd4 23-Jan-2011 Greg Clayton <gclayton@apple.com> Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.

Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.

Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.

After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.

Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124060 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
72e1c782ba1e4226da37af4722af608de9f39408 23-Jan-2011 Greg Clayton <gclayton@apple.com> Fixed an issue in "SBError SBProcess::Destroy ()" where it wasn't properly
checking the validity of the shared pointer prior to using it.

Fixed the GDB remote plug-in to once again watch for a reply from the "k"
packet, and fixed the logic to make sure the thread requesting the kill
and the async thread play nice (and very quickly) by synchronizing the
packet sending and reply. I also tweaked some of the shut down packet
("k" kill, "D" detach, and the halt packet) to make sure they do the right
thing.

Fixed "StateType Process::WaitForProcessStopPrivate (...)" to correctly pass
the timeout along to WaitForStateChangedEventsPrivate() and made the function
behave correctly with respect to timing out.

Added separate STDIN, STDOUT, and STDERR support to debugserver. Also added
the start of being able to set the working directory for the inferior process.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124049 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
55e01d8635032ee10cc06e0114213a76a8677be0 22-Jan-2011 Jim Ingham <jingham@apple.com> Added an interface for noticing new thread creation. At this point, I only turn it on when
we are requesting a single thread to run. May seem like a silly thing to do, but the kernel
on MacOS X will inject new threads into a program willy-nilly, and I would like to keep them
from running if I can.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124018 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
fd119995f2693eb6e9e2ea3e685f9d872f5cd4f1 07-Jan-2011 Greg Clayton <gclayton@apple.com> Added memory caching to lldb_private::Process. All lldb_private::Process
subclasses will automatically be able to take advantage of caching. The
cache line size is set to 512 by default.

This greatly speeds up stack backtraces on MacOSX when using the
ProcessGDBRemote process plug-in since only about 6300 packets per second
can be sent.

Initial speedups show:

Prior to caching: 10,000 stack frames took 5.2 seconds
After caching: 10,000 stack frames in 240 ms!

About a 20x speedup!



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@122996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
6d29aebd9e7f8fa947dcc9c344aec2393922973d 16-Dec-2010 Greg Clayton <gclayton@apple.com> Added header doc for the recently added Process::ReadUnsignedInteger (addr_t addr, size_t int_byte_size, Error &error) function.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@121999 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
f72fdeee129bbd7195f3db888b561ede689886aa 16-Dec-2010 Greg Clayton <gclayton@apple.com> Added the ability to read unsigned integers from the Process:

uint64_t Process::ReadUnsignedInteger (addr_t addr, size_t int_byte_size, Error &error);


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@121996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
427f290ff96f3ab9f2cf3a1af7001d2c560424c7 14-Dec-2010 Greg Clayton <gclayton@apple.com> Modified LLDB expressions to not have to JIT and run code just to see variable
values or persistent expression variables. Now if an expression consists of
a value that is a child of a variable, or of a persistent variable only, we
will create a value object for it and make a ValueObjectConstResult from it to
freeze the value (for program variables only, not persistent variables) and
avoid running JITed code. For everything else we still parse up and JIT code
and run it in the inferior.

There was also a lot of clean up in the expression code. I made the
ClangExpressionVariables be stored in collections of shared pointers instead
of in collections of objects. This will help stop a lot of copy constructors on
these large objects and also cleans up the code considerably. The persistent
clang expression variables were moved over to the Target to ensure they persist
across process executions.

Added the ability for lldb_private::Target objects to evaluate expressions.
We want to evaluate expressions at the target level in case we aren't running
yet, or we have just completed running. We still want to be able to access the
persistent expression variables between runs, and also evaluate constant
expressions.

Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects
can now dump their contents with the UUID, arch and full paths being logged with
appropriate prefix values.

Thread hardened the Communication class a bit by making the connection auto_ptr
member into a shared pointer member and then making a local copy of the shared
pointer in each method that uses it to make sure another thread can't nuke the
connection object while it is being used by another thread.

Added a new file to the lldb/test/load_unload test that causes the test a.out file
to link to the libd.dylib file all the time. This will allow us to test using
the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@121745 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
638351aee118e89c658ca295cb4e9d1db7849bef 04-Dec-2010 Greg Clayton <gclayton@apple.com> Added the ability for a process to inherit the current host environment. This
was done as an settings variable in the process for now. We will eventually
move all environment stuff over to the target, but we will leave it with the
process for now. The default setting is for a process to inherit the host
environment. This can be disabled by setting the "inherit-env" setting to
false in the process.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@120862 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
bd666017403e102e0ca435d6da585ff979f83598 03-Dec-2010 Caroline Tice <ctice@apple.com> Add '-no-stdio' option to 'process launch' command, which causes the
inferior to be launched without setting up terminal stdin/stdout for it
(leaving the lldb command line accessible while the program is executing).
Also add a user settings variable, 'target.process.disable-stdio' to allow
the user to set this globally rather than having to use the command option
each time the process is launched.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@120825 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
360f53f3c216ee4fb433da0a367168785328a856 30-Nov-2010 Jim Ingham <jingham@apple.com> Moved the code in ClangUserExpression that set up & ran the thread plan with timeouts, and restarting with all threads into a utility function in Process. This required a bunch of renaming.

Added a ThreadPlanCallUserExpression that differs from ThreadPlanCallFunction in that it holds onto a shared pointer to its ClangUserExpression so that can't go away before the thread plan is done using it.

Fixed the stop message when you hit a breakpoint while running a user expression so it is more obvious what has happened.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@120386 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
990de7bb41d3afec6b789155408ff322187d8682 19-Nov-2010 Greg Clayton <gclayton@apple.com> Cleaned up code that wasn't using the Initialize and Terminate paradigm by
changing it to use it. There was an extra parameter added to the static
accessor global user settings controllers that wasn't needed. A bool was being
used as a parameter to the accessor just so it could be used to clean up
the global user settings controller which is now fixed by splitting up the
initialization into the "static void Class::Initialize()", access into the
"static UserSettingsControllerSP & Class::GetSettingsController()", and
cleanup into "static void Class::Terminate()".

Also added initialize and terminate calls to the logging code to avoid issues
when LLDB is shutting down. There were cases after the logging was switched
over to use shared pointers where we could crash if the global destructor
chain was being run and it causes the log to be destroyed and any any logging
occurred.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@119757 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
20d338fad87eba91de65aa9bec76e01c04472848 18-Nov-2010 Greg Clayton <gclayton@apple.com> Fixed Process::Halt() as it was broken for "process halt" after recent changes
to the DoHalt down in ProcessGDBRemote. I also moved the functionality that
was in ProcessGDBRemote::DoHalt up into Process::Halt so not every class has
to implement a tricky halt/resume on the internal state thread. The
functionality is the same as it was before with two changes:
- when we eat the event we now just reuse the event we consume when the private
state thread is paused and set the interrupted bool on the event if needed
- we also properly update the Process::m_public_state with the state of the
event we consume.

Prior to this, if you issued a "process halt" it would eat the event, not
update the process state, and then produce a new event with the interrupted
bit set and send it. Anyone listening to the event would get the stopped event
with a process that whose state was set to "running".

Fixed debugserver to not have to be spawned with the architecture of the
inferior process. This worked fine for launching processes, but when attaching
to processes by name or pid without a file in lldb, it would fail.

Now debugserver can support multiple architectures for a native debug session
on the current host. This currently means i386 and x86_64 are supported in
the same binary and a x86_64 debugserver can attach to a i386 executable.
This change involved a lot of changes to make sure we dynamically detect the
correct registers for the inferior process.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@119680 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
3ae449a5c3b4f51afc0da22cfeaef00c303c0acc 17-Nov-2010 Jim Ingham <jingham@apple.com> Added an "Interrupted" bit to the ProcessEventData. Halt now generates an event
with the Interrupted bit set. Process::HandlePrivateEvent ignores Interrupted events.
DoHalt is changed to ensure that the stop even is processed, and an event with
the Interrupted event is posted. Finally ClangFunction is rationalized to use this
facility so the that Halt is handled more deterministically.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@119453 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
861efb3f6e225e45c45511d6da894633b36025a1 16-Nov-2010 Caroline Tice <ctice@apple.com> Make processes use InputReaders for their input. Move the process
ReadThread stuff into the main Process class (out of the Process Plugins).
This has the (intended) side effect of disabling the command line tool
from reading input/commands while the process is running (the input is
directed to the running process rather than to the command interpreter).



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@119329 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0baa394cd55c6dfb7a6259d215d0dea2b708067b 04-Nov-2010 Greg Clayton <gclayton@apple.com> Added support for loading and unloading shared libraries. This was done by
adding support into lldb_private::Process:

virtual uint32_t
lldb_private::Process::LoadImage (const FileSpec &image_spec,
Error &error);

virtual Error
lldb_private::Process::UnloadImage (uint32_t image_token);

There is a default implementation that should work for both linux and MacOSX.
This ability has also been exported through the SBProcess API:

uint32_t
lldb::SBProcess::LoadImage (lldb::SBFileSpec &image_spec,
lldb::SBError &error);

lldb::SBError
lldb::SBProcess::UnloadImage (uint32_t image_token);

Modified the DynamicLoader plug-in interface to require it to be able to
tell us if it is currently possible to load/unload a shared library:

virtual lldb_private::Error
DynamicLoader::CanLoadImage () = 0;

This way the dynamic loader plug-ins are allows to veto whether we can
currently load a shared library since the dynamic loader might know if it is
currenlty loading/unloading shared libraries. It might also know about the
current host system and know where to check to make sure runtime or malloc
locks are currently being held.

Modified the expression parser to have ClangUserExpression::Evaluate() be
the one that causes the dynamic checkers to be loaded instead of other code
that shouldn't have to worry about it.






git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@118227 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
d168690e51f9020b926d3d0d57dc9a2cfb2095a8 15-Oct-2010 Jim Ingham <jingham@apple.com> Added support for breakpoint conditions. I also had to separate the "run the expression" part of ClangFunction::Execute from the "Gather the expression result" so that in the case of the Breakpoint condition I can move the condition evaluation into the normal thread plan processing.

Also added support for remembering the "last set breakpoint" so that "break modify" will act on the last set breakpoint.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116542 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
63e24d7aeae8a7feb2aae0581e597b922749d4a1 12-Oct-2010 Jim Ingham <jingham@apple.com> Add a way to temporarily divert events from a broadcaster to a private listener.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116271 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a830adbcd63d1995a01e6e18da79893c1426ca43 04-Oct-2010 Greg Clayton <gclayton@apple.com> There are now to new "settings set" variables that live in each debugger
instance:

settings set frame-format <string>
settings set thread-format <string>

This allows users to control the information that is seen when dumping
threads and frames. The default values are set such that they do what they
used to do prior to changing over the the user defined formats.

This allows users with terminals that can display color to make different
items different colors using the escape control codes. A few alias examples
that will colorize your thread and frame prompts are:

settings set frame-format 'frame #${frame.index}: \033[0;33m${frame.pc}\033[0m{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{ \033[0;35mat \033[1;35m${line.file.basename}:${line.number}}\033[0m\n'

settings set thread-format 'thread #${thread.index}: \033[1;33mtid\033[0;33m = ${thread.id}\033[0m{, \033[0;33m${frame.pc}\033[0m}{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{, \033[1;35mstop reason\033[0;35m = ${thread.stop-reason}\033[0m}{, \033[1;36mname = \033[0;36m${thread.name}\033[0m}{, \033[1;32mqueue = \033[0;32m${thread.queue}}\033[0m\n'

A quick web search for "colorize terminal output" should allow you to see what
you can do to make your output look like you want it.

The "settings set" commands above can of course be added to your ~/.lldbinit
file for permanent use.

Changed the pure virtual
void ExecutionContextScope::Calculate (ExecutionContext&);
To:
void ExecutionContextScope::CalculateExecutionContext (ExecutionContext&);

I did this because this is a class that anything in the execution context
heirarchy inherits from and "target->Calculate (exe_ctx)" didn't always tell
you what it was really trying to do unless you look at the parameter.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115485 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
b66cd074ec097b5b0a6f2ce292f5072aa1217ca6 28-Sep-2010 Jim Ingham <jingham@apple.com> Replace the vestigial Value::GetOpaqueCLangQualType with the more correct Value::GetValueOpaqueClangQualType.

But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114935 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
1ebef44c126bd3a615b3ad844c46a82a82efa0e7 27-Sep-2010 Caroline Tice <ctice@apple.com> Create more useful instance names for target, process and thread instances.

Change default 'set' behavior so that all instance settings for the specified variable will be
updated, unless the "-n" ("--no_override") command options is specified.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114808 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
642036f22366d47ea8e6f8498bedb92b88f7f79f 23-Sep-2010 Jim Ingham <jingham@apple.com> Committing the skeleton of Language runtime plugin classes.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114620 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
bcb5b454767121980d937d2610ba762fdb575c45 20-Sep-2010 Caroline Tice <ctice@apple.com> Make GetInstanceSettingsValue methods take an Error * rather than an Error &,
and have them return a bool to indicate success or not.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114361 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
5bc8c97d62b2e399bd90fb7e00c903d7887412ab 20-Sep-2010 Caroline Tice <ctice@apple.com> Add UserSettings to Target class, making Target settings
the parent of Process settings; add 'default-arch' as a
class-wide setting for Target. Replace lldb::GetDefaultArchitecture
with Target::GetDefaultArchitecture & Target::SetDefaultArchitecture.

Add 'use-external-editor' as user setting to Debugger class & update
code appropriately.

Add Error parameter to methods that get user settings, for easier
reporting of bad requests.

Fix various other minor related bugs.

Fix test cases to work with new changes.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114352 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
d0a5a23d734da7a2170802ccd096f53b8a527811 19-Sep-2010 Greg Clayton <gclayton@apple.com> Added code that will allow completely customizable prompts for use in
replacing the "(lldb)" prompt, the "frame #1..." displays when doing
stack backtracing and the "thread #1....". This will allow you to see
exactly the information that you want to see where you want to see it.
This currently isn't hookup up to the prompts yet, but it will be soon.

So what is the format of the prompts? Prompts can contain variables that
have access to the current program state. Variables are text that appears
in between a prefix of "${" and ends with a "}". Some of the interesting
variables include:

// The frame index (0, 1, 2, 3...)
${frame.index}

// common frame registers with generic names
${frame.pc}
${frame.sp}
${frame.fp}
${frame.ra}
${frame.flags}

// Access to any frame registers by name where REGNAME is any register name:
${frame.reg.REGNAME}

// The current compile unit file where the frame is located
${file.basename}
${file.fullpath}

// Function information
${function.name}
${function.pc-offset}

// Process info
${process.file.basename}
${process.file.fullpath}
${process.id}
${process.name}

// Thread info
${thread.id}
${thread.index}
${thread.name}
${thread.queue}
${thread.stop-reason}

// Target information
${target.arch}

// The current module for the current frame (the shared library or executable
// that contains the current frame PC value):
${module.file.basename}
${module.file.fullpath}

// Access to the line entry for where the current frame is when your thread
// is stopped:
${line.file.basename}
${line.file.fullpath}
${line.number}
${line.start-addr}
${line.end-addr}

Many times the information that you might have in your prompt might not be
available and you won't want it to print out if it isn't valid. To take care
of this you can enclose everything that must resolve into a scope. A scope
is starts with '{' and ends with '}'. For example in order to only display
the current file and line number when the information is available the format
would be:

"{ at {$line.file.basename}:${line.number}}"

Broken down this is:

start the scope: "{"

format whose content will only be displayed if all information is available:
"at {$line.file.basename}:${line.number}"

end the scope: "}"

We currently can represent the infomration we see when stopped at a frame:

frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19

with the following format:

"frame #${frame.index}: ${frame.pc} {${module.file.basename}`}{${function.name}{${function.pc-offset}}{ at ${line.file.basename}:${line.number}}\n"

This breaks down to always print:

"frame #${frame.index}: ${frame.pc} "

only print the module followed by a tick if we have a valid module:

"{${module.file.basename}`}"

print the function name with optional offset:
"{${function.name}{${function.pc-offset}}"

print the line info if it is available:

"{ at ${line.file.basename}:${line.number}}"

then finish off with a newline:

"\n"

Notice you can also put newlines ("\n") and tabs and everything else you
are used to putting in a format string when desensitized with the \ character.

Cleaned up some of the user settings controller subclasses. All of them
do not have any global settings variables and were all implementing stubs
for the get/set global settings variable. Now there is a default version
in UserSettingsController that will do nothing.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114306 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
fe424a92fc6fd92f810d243912461fe028a2b63c 18-Sep-2010 Greg Clayton <gclayton@apple.com> General command line help cleanup:
- All single character options will now be printed together
- Changed all options that contains underscores to contain '-' instead
- Made the help come out a little flatter by showing the long and short
option on the same line.
- Modified the short character for "--ignore-count" options to "-i"



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114265 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
238c0a1e7b733cee539258faa656159c63f9e893 18-Sep-2010 Greg Clayton <gclayton@apple.com> Fixed the way set/show variables were being accessed to being natively
accessed by the objects that own the settings. The previous approach wasn't
very usable and made for a lot of unnecessary code just to access variables
that were already owned by the objects.

While I fixed those things, I saw that CommandObject objects should really
have a reference to their command interpreter so they can access the terminal
with if they want to output usaage. Fixed up all CommandObjects to take
an interpreter and cleaned up the API to not need the interpreter to be
passed in.

Fixed the disassemble command to output the usage if no options are passed
down and arguments are passed (all disassebmle variants take options, there
are no "args only").



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114252 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
0021c97fbd17e38113d2e76b93c94ee05213ee45 16-Sep-2010 Johnny Chen <johnny.chen@apple.com> Undo 114084 and 114087 to unbreak the build for the time being.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114095 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a2784ee3c8451936d50abf94dcb29527d1a2a85a 16-Sep-2010 Benjamin Kramer <benny.kra@googlemail.com> Turns out CreateInstanceName is duplicated in two other places. Make them static too, sigh.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114087 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
eea264007bc5fb42c8f3239726a9d28ae42e1b7b 15-Sep-2010 Greg Clayton <gclayton@apple.com> Moved the section load list up into the target so we can use the target
to symbolicate things without the need for a valid process subclass.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113895 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
f2c330df115cfdaedbf9d359b00f3ebb3cab9887 09-Sep-2010 Caroline Tice <ctice@apple.com> Move the ProcessPlugins enum definition from lldb-enumerations.h to
Process.h; modify the process.plugins settings variable to use the
correct plugin names.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113510 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
004afcb95736e97d071b1dd9b5254800e11e581c 08-Sep-2010 Caroline Tice <ctice@apple.com> Make sure creating a pending instance doesn't also trigger creating a live instance; also make sure creating a
pending instance uses the specified instance name rather than creating a new one; add brackets to instance names
when searching for and removing pending instances.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113370 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
c3c24084efb0e1c4734c136532c1e43e9427c912 08-Sep-2010 Jim Ingham <jingham@apple.com> The functions that return the static ConstString names of the settings should be static
as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113328 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
6e4c5ce0f697eb9899a54854a2a9004e961b0de2 04-Sep-2010 Caroline Tice <ctice@apple.com> This is a very large commit that completely re-does the way lldb
handles user settable internal variables (the equivalent of set/show
variables in gdb). In addition to the basic infrastructure (most of
which is defined in UserSettingsController.{h,cpp}, there are examples
of two classes that have been set up to contain user settable
variables (the Debugger and Process classes). The 'settings' command
has been modified to be a command-subcommand structure, and the 'set',
'show' and 'append' commands have been moved into this sub-commabnd
structure. The old StateVariable class has been completely replaced
by this, and the state variable dictionary has been removed from the
Command Interpreter. Places that formerly accessed the state variable
mechanism have been modified to access the variables in this new
structure instead (checking the term-width; getting/checking the
prompt; etc.)

Variables are attached to classes; there are two basic "flavors" of
variables that can be set: "global" variables (static/class-wide), and
"instance" variables (one per instance of the class). The whole thing
has been set up so that any global or instance variable can be set at
any time (e.g. on start up, in your .lldbinit file), whether or not
any instances actually exist (there's a whole pending and default
values mechanism to help deal with that).




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113041 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
f18d91c9bbd01152b29d84ab55ad2f0bbc9baf6c 01-Sep-2010 Sean Callanan <scallanan@apple.com> Added support for dynamic sanity checking in
expressions. Values used by the expression are
checked by validation functions which cause the
program to crash if the values are unsafe.

Major changes:

- Added IRDynamicChecks.[ch], which contains the
core code related to this feature

- Modified CommandObjectExpression to install the
validator functions into the target process.

- Added an accessor to Process that gets/sets the
helper functions


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@112690 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
452bf613496c7290c6b7a1a1eb28efbce63fd3b9 31-Aug-2010 Greg Clayton <gclayton@apple.com> Added the ability to disable ASLR (Address Space Layout Randomization). ASLR
is disabled by default, and can be enabled using:

(lldb) set disable-aslr 0



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@112616 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
a48fe1637ec6a381e500633c087f76662e364c20 11-Aug-2010 Sean Callanan <scallanan@apple.com> Added support for persistent variables to the
expression parser. It is now possible to type:

(lldb) expr int $i = 5; $i + 1
(int) 6
(lldb) expr $i + 2
(int) 7

The skeleton for automatic result variables is
also implemented. The changes affect:

- the process, which now contains a
ClangPersistentVariables object that holds
persistent variables associated with it
- the expression parser, which now uses
the persistent variables during variable
lookup
- TaggedASTType, where I loaded some commonly
used tags into a header so that they are
interchangeable between different clients of
the class


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@110777 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
7508e732818c32e1cfeaaf7d1d507fe3834ce9d2 10-Aug-2010 Jim Ingham <jingham@apple.com> Change Target & Process so they can really be initialized with an invalid architecture.
Arrange that this then gets properly set on attach, or when a "file" is set.
Add a completer for "process attach -n".

Caveats: there isn't currently a way to handle multiple processes with the same name. That
will have to wait on a way to pass annotations along with the completion strings.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@110624 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
3fd1f36c937575dbf57bae04c7ebaef78d8ecc1d 17-Jul-2010 Stephen Wilson <wilsons@start.ca> Have Process::CreateBreakpointSite return a break_id_t instead of a user_id_t.
Also, update BreakpointLocation::ResolveBreakpointSite to check for invalid
breakpoint ID's using the proper magic constant.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@108598 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
54e7afa84d945f9137f9372ecde432f9e1a702fc 09-Jul-2010 Greg Clayton <gclayton@apple.com> Merged Eli Friedman's linux build changes where he added Makefile files that
enabled LLVM make style building and made this compile LLDB on Mac OS X. We
can now iterate on this to make the build work on both linux and macosx.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@108009 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
e28824e0b988221c7eedf8e3d212527d2bdac6a7 09-Jun-2010 Eli Friedman <eli.friedman@gmail.com> And a few more warning/error fixes.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@105698 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h
24943d2ee8bfaa7cf5893e4709143924157a5c1e 08-Jun-2010 Chris Lattner <sabre@nondot.org> Initial checkin of lldb code from internal Apple repo.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@105619 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/include/lldb/Target/Process.h