summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Reimplemented the code that backed the "settings" in lldb. There were many ↵Greg Clayton2012-08-221-304/+394
| | | | | | | | | | | | | 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". llvm-svn: 162366
* Removed explicit NULL checks for shared pointersSean Callanan2012-08-091-1/+1
| | | | | | | | | and instead made us use implicit casts to bool. This generated a warning in C++11. <rdar://problem/11930775> llvm-svn: 161559
* Added a 'void' format so that the user can manuallySean Callanan2012-08-081-1/+1
| | | | | | | | | suppress all non-error output from the "expression" command. <rdar://problem/11225150> llvm-svn: 161502
* Added an lldb_private & equivalent SB API to send an AsyncInterrupt to the ↵Jim Ingham2012-07-271-119/+172
| | | | | | | | | | | | | | 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> llvm-svn: 160903
* Add "vAttachOrWait" to debugserver, so you can implement "attach to the ↵Jim Ingham2012-07-201-69/+0
| | | | | | process if it exists OR wait for it" without race conditions. Use that in lldb. llvm-svn: 160578
* Ran the static analyzer on the codebase and found a few things.Greg Clayton2012-07-171-2/+1
| | | | llvm-svn: 160338
* <rdar://problem/11672978> Fixing an issue where an ObjC object might come ↵Enrico Granata2012-07-161-0/+16
| | | | | | out without a description because the expression used to obtain it would timeout before running to completion llvm-svn: 160326
* Fixed a bug that caused the Process not to rebroadcastSean Callanan2012-07-111-431/+450
| | | | | | | | | | | | | | the fact that a process exited while running a thread plan. For example, if a user types the expression expr (void)exit(0) then the process terminates but LLDB does not notify listeners like Xcode that this occurred. <rdar://problem/11845155> llvm-svn: 160077
* Work around some problems destroying a process with older debugservers.Jim Ingham2012-07-041-0/+5
| | | | | | rdar://problem/11359989 llvm-svn: 159697
* Add an "extra-startup-commands" process setting so we can send some command ↵Jim Ingham2012-07-021-1/+27
| | | | | | strings to the actual process plugin to interpret as it wishes. llvm-svn: 159511
* Added a setting (target.process.disable-memory-cache)Sean Callanan2012-06-071-56/+89
| | | | | | | | that controls whether memory is cached. This is off by default (i.e., memory is cached) because it greatly improves performance. llvm-svn: 158173
* Make sure that when if we are going to Halt while the process is in the ↵Jim Ingham2012-06-061-4/+32
| | | | | | | | | 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. llvm-svn: 158042
* Fixed a problem where detaching from a processSean Callanan2012-06-021-7/+16
| | | | | | | left a read-write lock dangling, causing crashes in debug builds. llvm-svn: 157875
* We were accessing the ModuleList in the target without locking it for tasks likeJim Ingham2012-05-301-4/+8
| | | | | | | | | | | setting breakpoints. That's dangerous, since while we are setting a breakpoint, the target might hit the dyld load notification, and start removing modules from the list. This change adds a GetMutex accessor to the ModuleList class, and uses it whenever we are accessing the target's ModuleList (as returned by GetImages().) <rdar://problem/11552372> llvm-svn: 157668
* Process::Destroy should Halt before it tries to destroy so we don't have ↵Jim Ingham2012-05-231-0/+26
| | | | | | | | race conditions where we are in the middle of trying to service an event when we go to Destroy. The AttachCompletionHandler should note that it has restarted the target if it indeed does so. llvm-svn: 157327
* <rdar://problem/11355592> Fixing a bug where we would incorrectly try and ↵Enrico Granata2012-05-211-0/+21
| | | | | | determine a dynamic type for a variable of a pointer type that is not a valid generic type for dynamic pointers. llvm-svn: 157190
* Forgot to bump the local string buffer up in size after debugging to make ↵Greg Clayton2012-05-191-1/+1
| | | | | | sure long strings would be correctly read when the buffer is too small for the string. llvm-svn: 157087
* Found a quick way to improve the speed with which we can read object files ↵Greg Clayton2012-05-181-0/+22
| | | | | | 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. llvm-svn: 157083
* <rdar://problem/11386214>Greg Clayton2012-05-181-0/+6
| | | | | | | | | | | <rdar://problem/11455913> "target symbol add" should flush the cached frames "register write" should flush the thread state in case registers modifications change stack llvm-svn: 157042
* Always call RefreshStateAfterStop when we get a stop event. We were ↵Jim Ingham2012-05-161-1/+2
| | | | | | skipping doing it in the case where we had interrupted the target. Presumably at some point in the past RefreshStateAfterStop was done more directly when we handled the interrupt, but it isn't any more so now we need to do it all the time. llvm-svn: 156894
* <rdar://problem/11358639>Greg Clayton2012-05-081-19/+21
| | | | | | | | Switch over to the "*-apple-macosx" for desktop and "*-apple-ios" for iOS triples. Also make the selection process for auto selecting platforms based off of an arch much better. llvm-svn: 156354
* In ProcessGDBRemote::DoConnectRemote(), if the remote system informedJason Molenda2012-05-031-5/+17
| | | | | | | | | | | | | | us of its architecture, use that to set the Target's arch if it doesn't already have one set. In Process::CompleteAttach(), if the Target has a valid arch make sure that the Platform we pick up is compatible with that arch; if not, find a Platform that is compatible. Don't let the the default platform override the Target's arch. <rdar://problem/11185420> llvm-svn: 156116
* Switch to setting the write side of the run lock when we call Resume. Then ↵Jim Ingham2012-04-191-10/+26
| | | | | | make a PrivateResume that doesn't switch the run-lock state, and use that where we are resuming without changing the public resume state. llvm-svn: 155092
* Make sure an error is returned when Process::LoadImage() fails.Greg Clayton2012-04-181-2/+5
| | | | llvm-svn: 154965
* Added a new host function that allows us to run shell command and get the ↵Greg Clayton2012-04-141-22/+44
| | | | | | | | | | | | | | | | 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. llvm-svn: 154730
* The run all threads timeout in RunThreadPlan should respect the user ↵Jim Ingham2012-04-131-17/+40
| | | | | | | | timeout, not be arbitrarily 10 seconds (which was too long anyway...) Also added some logging to RunThreadPlan and made others more regular. llvm-svn: 154708
* Make sure that DoResume doesn't stall if we shut down the async thread while ↵Jim Ingham2012-04-121-9/+35
| | | | | | | | | | | | | DoResume is waiting for packet confirmation. Also added a bit more logging. Also, unlock the writer end of the run lock in Process.cpp on our way out of the private state thread so that the Process can shut down cleanly. <rdar://problem/11228538> llvm-svn: 154601
* Two changes, Jim Ingham2012-04-101-10/+44
| | | | | | | | | | | | | | | 1) Start the PrivateStateThread stopped, and then in StartPrivateStateThread, make the private state thread and then resume it before we say the thread is created. That way we know it is listening for events by the time we get out of StartPrivateStateThread. 2) Backstop running a thread plan when calling Process::RunThreadPlan on the private state thread with a ThreadPlanBase so that running the plan doesn't pass its stop events to whatever plans happen to be above us on the thread plan stack. llvm-svn: 154368
* Trying to solve our disappearing thread issues by making thread list updates ↵Greg Clayton2012-04-101-8/+9
| | | | | | | | | | | | | | | | 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. llvm-svn: 154365
* We sometimes need to be able to call functions (via Process::RunThreadPlan) ↵Jim Ingham2012-04-071-12/+72
| | | | | | | | | | | | 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. llvm-svn: 154230
* Order ivar initializers to how they're declared in the class.Bill Wendling2012-04-061-2/+2
| | | | llvm-svn: 154147
* Added a new Host class: ReadWriteLockGreg Clayton2012-04-051-1/+37
| | | | | | | | | | | | 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. llvm-svn: 154099
* Fix the process of getting the ObjC runtime - if we ask for it too early (in ↵Jim Ingham2012-03-101-10/+9
| | | | | | | | | 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. llvm-svn: 152453
* <rdar://problem/10840355>Greg Clayton2012-03-061-20/+22
| | | | | | 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). llvm-svn: 152102
* <rdar://problem/3535148>Han Ming Ong2012-02-251-2/+2
| | | | | | Added ability to debug root processes on OS X. This uses XPC service that is available on Lion and above only. llvm-svn: 151419
* Fixed a crasher that was happening after making ObjectFile objects have aGreg Clayton2012-02-241-7/+13
| | | | | | | | | weak reference back to the Module. We were crashing when trying to make a memory object file since it was trying to get the object in the Module constructor before the "Module *" had been put into a shared pointer, and the module was trying to initialize a weak pointer back to it. llvm-svn: 151397
* For stepping performance I added the ability to outlaw all memory accessesesGreg Clayton2012-02-221-0/+13
| | | | | | | | | | | 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. llvm-svn: 151128
* The second part in thread hardening the internals of LLDB where we makeGreg Clayton2012-02-181-0/+6
| | | | | | | | | | | | | | | | 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. llvm-svn: 150871
* Add a general mechanism to wait on the debugger for Broadcasters of a given ↵Jim Ingham2012-02-161-3/+11
| | | | | | | | | class/event bit set. Use this to allow the lldb Driver to emit notifications for breakpoint modifications. <rdar://problem/10619974> llvm-svn: 150665
* Only allow expressions to use the JIT if memorySean Callanan2012-02-141-1/+17
| | | | | | can be allocated in the process. llvm-svn: 150523
* Full core file support has been added for mach-o core files.Greg Clayton2012-02-131-11/+31
| | | | | | | | | | | | | | | | 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. llvm-svn: 150426
* First pass at mach-o core file support is in. It currently works for x86_64 Greg Clayton2012-02-091-9/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 150154
* <rdar://problem/10560053>Greg Clayton2012-02-051-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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". llvm-svn: 149804
* SBFrame is now threadsafe using some extra tricks. One issue is that stackGreg Clayton2012-01-301-19/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 149231
* Switching back to using std::tr1::shared_ptr. We originally switched awayGreg Clayton2012-01-291-13/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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). llvm-svn: 149207
* <rdar://problem/10732738>Greg Clayton2012-01-201-1/+11
| | | | | | Release more stuff in Process::Destroy(). llvm-svn: 148597
* Fixed a potential hang while trying to executeSean Callanan2012-01-051-1/+1
| | | | | | a function in the inferior. llvm-svn: 147592
* The "desired result type" code in the expressionSean Callanan2011-12-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | parser has hitherto been an implementation waiting for a use. I have now tied the '-o' option for the expression command -- which indicates that the result is an Objective-C object and needs to be printed -- to the ExpressionParser, which communicates the desired type to Clang. Now, if the result of an expression is determined by an Objective-C method call for which there is no type information, that result is implicitly cast to id if and only if the -o option is passed to the expression command. (Otherwise if there is no explicit cast Clang will issue an error. This behavior is identical to what happened before r146756.) Also added a testcase for -o enabled and disabled. llvm-svn: 147099
* Expose new read memory fucntion through python in SBProcess:Greg Clayton2011-12-151-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 146636
* Process IDs (lldb::pid_t) and thread IDs (lldb::tid_t) are now 64 bit. This Greg Clayton2011-12-011-9/+9
| | | | | | | | will allow us to represent a process/thread ID using a pointer for the OS plug-ins where they might want to represent the process or thread ID using the address of the process or thread structure. llvm-svn: 145644
OpenPOWER on IntegriCloud