summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* If the ThreadList ShouldStop restarts the target, don't resume it again.Jim Ingham2012-09-051-1/+5
| | | | llvm-svn: 163245
* Fix the log channel used in Process.cpp.Greg Clayton2012-09-051-3/+3
| | | | llvm-svn: 163183
* Modified patch from Matt Kopec that fixes a process launch issue on linux ↵Greg Clayton2012-09-041-2/+10
| | | | | | where we wouldn't acquire the process run lock. llvm-svn: 163163
* Initial check-in of "fancy" inlined stepping. Doesn't do anything useful ↵Jim Ingham2012-09-011-1/+7
| | | | | | | | | unless you switch LLDB_FANCY_INLINED_STEPPING to true. With that on, basic inlined stepping works, including step-over of inlined functions. But for some as yet mysterious reason i386 debugging gets an assert and dies immediately. So for now its off. llvm-svn: 163044
* <rdar://problem/11757916>Greg Clayton2012-08-291-0/+1
| | | | | | | | | | | | Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes: - Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". - modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly - Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was. - modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile() Cleaned up header includes a bit as well. llvm-svn: 162860
* Rework how the API mutex is acquired when filling out an ExecutionContext ↵Jim Ingham2012-08-221-0/+2
| | | | | | | | | | | | | | | | | 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> llvm-svn: 162401
* Remove further outdated "settings" code and also implement a few missing things.Greg Clayton2012-08-221-243/+2
| | | | llvm-svn: 162376
* 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
OpenPOWER on IntegriCloud