summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectProcess.cpp
Commit message (Collapse)AuthorAgeFilesLines
* This change introduces a "ExpressionExecutionThread" to the ThreadList. Jim Ingham2016-03-121-1/+1
| | | | | | | | | | | | | | | | | | | Turns out that most of the code that runs expressions (e.g. the ObjC runtime grubber) on behalf of the expression parser was using the currently selected thread. But sometimes, e.g. when we are evaluating breakpoint conditions/commands, we don't select the thread we're running on, we instead set the context for the interpreter, and explicitly pass that to other callers. That wasn't getting communicated to these utility expressions, so they would run on some other thread instead, and that could cause a variety of subtle and hard to reproduce problems. I also went through the commands and cleaned up the use of GetSelectedThread. All those uses should have been trying the thread in the m_exe_ctx belonging to the command object first. It would actually have been pretty hard to get misbehavior in these cases, but for correctness sake it is good to make this usage consistent. <rdar://problem/24978569> llvm-svn: 263326
* Fix Clang-tidy modernize-use-nullptr and modernize-use-default warnings in ↵Eugene Zelenko2016-02-231-171/+102
| | | | | | some files in source/Commands; other minor fixes. llvm-svn: 261602
* Fix a glitch in the Driver's batch mode when used with "attach". Jim Ingham2016-01-081-0/+1
| | | | | | | | | | | | | | Batch mode is supposed to stop execution and return control to the user when an exceptional stop occurs (crash, signal or instrumentation). But attach always stops with a SIGSTOP on OSX (maybe on Linux too?) which would short circuit the rest of the commands given. This change allows a command result object to indicate that it expected to leave the process stopped with an exceptional stop reason, and it is okay for batch mode to keep going. <rdar://problem/22243143> llvm-svn: 257120
* Modify "platform connect" to connect to processes as wellTamas Berghammer2015-12-081-61/+29
| | | | | | | | | | | | | | | | | | | | | | | | The standard remote debugging workflow with gdb is to start the application on the remote host under gdbserver (e.g.: gdbserver :5039 a.out) and then connect to it with gdb. The same workflow is supported by debugserver/lldb-gdbserver with a very similar syntax but to access all features of lldb we need to be connected also to an lldb-platform instance running on the target. Before this change this had to be done manually with starting a separate lldb-platform on the target machine and then connecting to it with lldb before connecting to the process. This change modifies the behavior of "platform connect" with automatically connecting to the process instance if it was started by the remote platform. With this command replacing gdbserver in a gdb based worflow is usually as simple as replacing the command to execute gdbserver with executing lldb-platform. Differential revision: http://reviews.llvm.org/D14952 llvm-svn: 255016
* Add a new option to Platform::LoadImage to install the imageTamas Berghammer2015-12-081-8/+88
| | | | | | | | | | | | | | | | | | | | | This change introduce 3 different working mode for Platform::LoadImage depending on the file specs specified. * If only a remote file is specified then the remote file is loaded on the target (same behavior as before) * If only a local file is specified then the local file is installed to the current working directory and then loaded from there. * If both local and remote file is specified then the local file is installed to the specified location and then loaded from there. The same options are exposed on the SB API with a new method LoadImage method while the old signature presers its meaning. On the command line the installation of the shared library can be specified with the "--install" option of "process load". Differential revision: http://reviews.llvm.org/D15152 llvm-svn: 255014
* Fix "process load/unload" on androidTamas Berghammer2015-12-021-3/+4
| | | | | | | | | | | On android the symbols exposed by libdl (dlopen, dlclose, dlerror) prefixed by "__dl_". This change moves the handling of process load/unload to the platform object and override it for android to handle the special prefix. Differential revision: http://reviews.llvm.org/D11465 llvm-svn: 254504
* commands: Use override instead of virtual.Bruce Mitchener2015-10-071-68/+62
| | | | | | | | | | | | | | | | | Summary: This removes all uses of virtual on functions where override could be used, including on destructors. It also adds override where virtual was previously missing. Reviewers: clayborg, labath Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D13503 llvm-svn: 249564
* Fixed line wrapping for the "long help" content in LLDB commands. Content ↵Kate Stone2015-07-141-1/+2
| | | | | | | | | | is now dynamically wrapped for the column width of the current terminal. Lines that begin with whitespace will be indented identically on subsequent lines to maintain formatting. Existing commands supplying this type of help content have been reworked to take advantage of the changes. In addition to formatting changes, content was changes for accuracy and clarity purposes. <rdar://problem/21269977> llvm-svn: 242122
* Refactor Unix signals.Chaoren Lin2015-07-141-22/+22
| | | | | | | | | | | | | | | | | | Summary: - Consolidate Unix signals selection in UnixSignals. - Make Unix signals available from platform. - Add jSignalsInfo packet to retrieve Unix signals from remote platform. - Get a copy of the platform signal for each remote process. - Update SB API for signals. - Update signal utility in test suite. Reviewers: ovyalov, clayborg Subscribers: chaoren, jingham, labath, emaste, tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D11094 llvm-svn: 242101
* Don't #include "lldb-python.h" from anywhere.Zachary Turner2015-05-291-2/+0
| | | | | | | | | | | | | Since interaction with the python interpreter is moving towards being more isolated, we won't be able to include this header from normal files anymore, all includes of it should be localized to the python library which will live under source/bindings/API/Python after a future patch. None of the files that were including this header actually depended on it anyway, so it was just a dead include in every single instance. llvm-svn: 238581
* Improve LLDB prompt handlingPavel Labath2015-05-271-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There is an issue in lldb where the command prompt can appear at the wrong time. The partial fix we have in for this is not working all the time and is introducing unnecessary delays. This change does: - Change Process:SyncIOHandler to use integer start id's for synchronization to avoid it being confused by quick start-stop cycles. I picked this up from a suggested patch by Greg to lldb-dev. - coordinates printing of asynchronous text with the iohandlers. This is also based on a (different) Greg's patch, but I have added stronger synchronization to it to avoid races. Together, these changes solve the prompt problem for me on linux (both with and without libedit). I think they should behave similarly on Mac and FreeBSD and I think they will not make matters worse for windows. Test Plan: Prompt comes out alright. All tests still pass on linux. Reviewers: clayborg, emaste, zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9823 llvm-svn: 238313
* Add support for custom commands to set flags on themselvesEnrico Granata2015-05-271-28/+28
| | | | | | | | | This works for Python commands defined via a class (implement get_flags on your class) and C++ plugin commands (which can call SBCommand::GetFlags()/SetFlags()) Flags allow features such as not letting the command run if there's no target, or if the process is not stopped, ... Commands could always check for these things themselves, but having these accessible via flags makes custom commands more consistent with built-in ones llvm-svn: 238286
* Add real time signals support to LinuxSignalsPavel Labath2015-05-221-3/+3
| | | | | | | | | | | | | | Summary: This enables correct handling of real time signals by lldb. Test Plan: Added a test that verifies handling of SIGRTMIN Reviewers: tberghammer, ovyalov Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9911 llvm-svn: 238009
* Don't call the Process::SyncIOHandler in Target::LaunchIlia K2015-05-071-1/+6
| | | | | | | | | | | | | | Summary: This patch moves synchronization of iohandler to CommandObjectProcessLaunch::DoExecute like it was done in CommandObjectProcessContinue::DoExecute. Reviewers: jingham, clayborg Reviewed By: clayborg Subscribers: lldb-commits, clayborg, jingham Differential Revision: http://reviews.llvm.org/D9373 llvm-svn: 236699
* Change process kill to call Process::Destroy (force_kill = true);Jason Molenda2015-05-011-1/+1
| | | | | | | | follow-up to the change in r235158. Right now if you attach to a process and type "kill", lldb doesn't kill it, it detaches. <rdar://problem/20691198> llvm-svn: 236363
* Add a "force_kill" arg to Process::Destroy(). This is needed afterJason Molenda2015-04-171-2/+2
| | | | | | | | | | | | | | | | | | the changes in r233255/r233258. Normally if lldb attaches to a running process, when we call Process::Destroy, we want to detach from the process. If lldb launched the process itself, ::Destroy should kill it. However, if we attach to a process and the driver calls SBProcess::Kill() (which calls Destroy), we need to kill it even if we didn't launch it originally. The force_kill param allows for the SBProcess::Kill method to force the behavior of Destroy. <rdar://problem/20424439> llvm-svn: 235158
* Further reduce the header footprint of Process.hZachary Turner2015-03-031-0/+1
| | | | | | | No functional change here, only deletes unnecessary headers and moves one function's body from the .h file to the .cpp. llvm-svn: 231145
* Fix Arg0 argument after r229110. The problem was that ↵Ilia K2015-02-131-1/+1
| | | | | | Arg0ValueChangedCallback isn't twitching when Arg0 was updated, therefore target was launched with empty 1st argument or without it at all. In this patch I update Arg0 by hand. llvm-svn: 229125
* Add -exec-arguments commandIlia K2015-02-131-3/+1
| | | | | | | | | | | | | | | | | Summary: This patch adds -exec-arguments command for lldb-mi. -exec-arguments command allows to specify arguments for executable file in MI mode. Also it contains tests for that command. Btw, new added files was formatted by clang-format. Reviewers: abidh, zturner, clayborg Reviewed By: clayborg Subscribers: zturner, emaste, clayborg, jingham, lldb-commits Differential Revision: http://reviews.llvm.org/D6965 llvm-svn: 229110
* Extract attach core logic from SBTarget::Attach* methods into unified ↵Oleksiy Vyalov2015-02-101-59/+8
| | | | | | | | SBTarget::AttachToProcess and make it work with platform for remote attach purposes. http://reviews.llvm.org/D7471 llvm-svn: 228757
* Make "process attach" command to support attaching to remote process in case ↵Oleksiy Vyalov2015-02-031-90/+100
| | | | | | | | if selected platform allows this. http://reviews.llvm.org/D7358 llvm-svn: 227899
* Moved Args::StringToXIntYZ to StringConvert::ToXIntYZVince Harron2015-01-151-5/+6
| | | | | | | | | | The refactor was motivated by some comments that Greg made http://reviews.llvm.org/D6918 and also to break a dependency cascade that caused functions linking in string->int conversion functions to pull in most of lldb llvm-svn: 226199
* Make the platform process connect path less chatty.Stephane Sezer2014-12-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If a stream contains an empty string, no need to append it to the output (otherwise we end up with a blank line). Also, no need to print a status message when the state changes to connected, as this string brings no information -- "Process 0" does not mean anything to the user, and the process being connected has no meaning either. Test Plan: Connect to a remote linux platform mode daemon with `platform select remote-linux` followed by `platform connect ...`, create a target and run it, observe the output. Also, run the full test suite (dosep.py). Before: (lldb) [...] connect, etc. (lldb) r Process 0 connected Process 5635 launched: '/Users/sas/Source/test' (x86_64) Process 5635 stopped After: (lldb) [...] connect, etc. (lldb) r Process 5635 launched: '/Users/sas/Source/test' (x86_64) Process 5635 stopped Reviewers: tfiala, vharron, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D6593 llvm-svn: 224188
* Fixed more fallout from running the test suite remotely on iOS devices.Greg Clayton2014-11-171-1/+1
| | | | | | | | | | | | | | | | Fixed include: - Change Platform::ResolveExecutable(...) to take a ModuleSpec instead of a FileSpec + ArchSpec to help resolve executables correctly when we have just a path + UUID (no arch). - Add the ability to set the listener in SBLaunchInfo and SBAttachInfo in case you don't want to use the debugger as the default listener. - Modified all places that use the SBLaunchInfo/SBAttachInfo and the internal ProcessLaunchInfo/ProcessAttachInfo to not take a listener as a parameter since it is in the launch/attach info now - Load a module's sections by default when removing a module from a target. Since we create JIT modules for expressions and helper functions, we could end up with stale data in the section load list if a module was removed from the target as the section load list would still have entries for the unloaded module. Target now has the following functions to help unload all sections a single or multiple modules: size_t Target::UnloadModuleSections (const ModuleList &module_list); size_t Target::UnloadModuleSections (const lldb::ModuleSP &module_sp); llvm-svn: 222167
* Make the "synchronous" mode actually work without race conditions.Greg Clayton2014-10-211-7/+19
| | | | | | There were many issues with synchronous mode that we discovered when started to try and add a "batch" mode. There was a race condition where the event handling thread might consume events when in sync mode and other times the Process::WaitForProcessToStop() would consume them. This also led to places where the Process IO handler might or might not get popped when it needed to be. llvm-svn: 220254
* Adjust process launch --disable-aslr to take true/false value.Todd Fiala2014-08-191-1/+18
| | | | | | This change modifies the 'process launch' --disable-aslr option to take a boolean argument. If the user directly specifies --disable-aslr {true,false}, that setting will control whether the process is launched with ASLR disabled accordingly. In the event that the setting is not explicitly made on the process launch command line, then the value is retrieved from the target.disable-aslr setting (i.e. settings show target.disable-aslr). llvm-svn: 215996
* Fix iohandler prompt race condition.Todd Fiala2014-08-121-1/+7
| | | | | | | | | | | | | | | | | This issue caused the lldb prompt to not show up in certain cases, very noticeable on Linux systems. See details on this review: http://reviews.llvm.org/D4863 And on this lldb-commits thread: http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140811/012306.html Change by Shawn Best. (Much useful help and testing by the rest of the community, thanks all!) llvm-svn: 215446
* (no commit message)Greg Clayton2014-07-301-1/+8
| | | | llvm-svn: 214319
* Revert "Fix broken tests due to new error output."Zachary Turner2014-07-091-17/+17
| | | | | | | This reverts commit ec7c94f8e6860968d384b578e5564a9c55c80b4a and re-enables OptionValidators. llvm-svn: 212627
* Fix broken tests due to new error output.Todd Fiala2014-07-081-17/+17
| | | | | | | | | | | This reverses out the options validators changes. We'll get these back in once the changes to the output can be resolved. Restores broken tests on FreeBSD, Linux, MacOSX. Changes reverted: r212500, r212317, r212290. llvm-svn: 212543
* Adds the notion of an OptionValidator.Zachary Turner2014-07-031-17/+17
| | | | | | | | | | | | | | | | | | The purpose of the OptionValidator is to determine, based on some arbitrary set of conditions, whether or not a command option is valid for a given debugger state. An example of this might be to selectively disable or enable certain command options that don't apply to a particular platform. This patch contains no functional change, and does not actually make use of an OptionValidator for any purpose yet. A follow-up patch will begin to add the logic and users of OptionValidator. Reviewed by: Greg Clayton, Jim Ingham Differential Revision: http://reviews.llvm.org/D4369 llvm-svn: 212290
* Added an option to turn OFF the "detach on error" behavior that was addedJim Ingham2014-06-251-0/+3
| | | | | | | | to debugserver when launching processes. <rdar://problem/16216199> llvm-svn: 211658
* Added the ability to save core files:Greg Clayton2014-06-131-0/+67
| | | | | | | | | | | (lldb) file /bin/ls (lldb) b malloc (lldb) run (lldb) process save-core /tmp/ls.core Each ObjectFile plug-in now has the option to save core files by registering a new static callback. llvm-svn: 210864
* Make the fail messagesJim Ingham2014-04-031-1/+2
| | | | llvm-svn: 205497
* Stop messages from being emitted out of order when detaching. Greg Clayton2014-03-031-1/+0
| | | | llvm-svn: 202756
* Merging the iohandler branch back into main. Greg Clayton2014-01-271-22/+21
| | | | | | | | | | | | The many many benefits include: 1 - Input/Output/Error streams are now handled as real streams not a push style input 2 - auto completion in python embedded interpreter 3 - multi-line input for "script" and "expression" commands now allow you to edit previous/next lines using up and down arrow keys and this makes multi-line input actually a viable thing to use 4 - it is now possible to use curses to drive LLDB (please try the "gui" command) We will need to deal with and fix any buildbot failures and tests and arise now that input/output and error are correctly hooked up in all cases. llvm-svn: 200263
* Centralized the launching of a process into Target::Launch()Greg Clayton2013-12-131-112/+29
| | | | | | | | | | | | | While investigating test suite failures when running the test suite remotely, I noticed we had 3 copies of code that launched a process: 1 - in "process launch" command 2 - SBTarget::Launch() with args 3 - SBTarget::Launch() with SBLaunchInfo "process launch" was launching through the platform if it was supported (this is needed for remote debugging) and the 2 and 3 were not. Now all code is in one place. llvm-svn: 197247
* Only use a PTY master/slave when launching for local processes.Greg Clayton2013-11-221-3/+3
| | | | llvm-svn: 195483
* Allow Process::WaitForProcessToStop to return immediately if process is ↵Daniel Malea2013-10-091-1/+1
| | | | | | | | | already in the stopped state - By default, the above function will wait for at least one event - Set wait_always=false to make the function return immediately if the process is already stopped llvm-svn: 192301
* Add OptionParser.hVirgile Bello2013-09-051-20/+20
| | | | llvm-svn: 190063
* <rdar://problem/13700260>Greg Clayton2013-05-101-6/+3
| | | | | | 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. llvm-svn: 181651
* Recommitting r180831 with trivial fix - remember to return errors if you ↵Jim Ingham2013-05-021-3/+98
| | | | | | compute. llvm-svn: 180898
* Reverting 180831 as it crashes TestDefaultConstructorForAPIObjects.pyDaniel Malea2013-05-011-98/+3
| | | | llvm-svn: 180868
* Added an option to "process detach" to keep the process stopped, if the ↵Jim Ingham2013-04-301-3/+98
| | | | | | | | | | process plugin (or in the case of ProcessGDBRemote the stub we are talking to) know how to do that. rdar://problem/13680832 llvm-svn: 180831
* “process launch” should “detach” not “kill” if the current ↵Jim Ingham2013-03-291-80/+119
| | | | | | | | | | | | | process was one we attached to. “process attach” should ask the same questions as process launch if there is a current process. “process connect” then “process launch” or “process attach” should actually work. <rdar://problem/13524210> <rdar://problem/13524208> <rdar://problem/13488919> llvm-svn: 178324
* Reworked the way Process::RunThreadPlan and the ThreadPlanCallFunction ↵Jim Ingham2013-02-091-1/+5
| | | | | | | | | | | 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> llvm-svn: 174793
* <rdar://problem/13069948>Greg Clayton2013-01-251-8/+8
| | | | | | | | | | | | 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. llvm-svn: 173463
* Fixed an issue the "process plugin" proxy object was trying to use the ↵Greg Clayton2013-01-091-1/+1
| | | | | | m_exe_ctx when it wasn't ok to do so. llvm-svn: 172014
* Expanded the flags that can be set for a command object in ↵Greg Clayton2013-01-091-82/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lldb_private::CommandObject. This list of available flags are: enum { //---------------------------------------------------------------------- // eFlagRequiresTarget // // Ensures a valid target is contained in m_exe_ctx prior to executing // the command. If a target doesn't exist or is invalid, the command // will fail and CommandObject::GetInvalidTargetDescription() will be // returned as the error. CommandObject subclasses can override the // virtual function for GetInvalidTargetDescription() to provide custom // strings when needed. //---------------------------------------------------------------------- eFlagRequiresTarget = (1u << 0), //---------------------------------------------------------------------- // eFlagRequiresProcess // // Ensures a valid process is contained in m_exe_ctx prior to executing // the command. If a process doesn't exist or is invalid, the command // will fail and CommandObject::GetInvalidProcessDescription() will be // returned as the error. CommandObject subclasses can override the // virtual function for GetInvalidProcessDescription() to provide custom // strings when needed. //---------------------------------------------------------------------- eFlagRequiresProcess = (1u << 1), //---------------------------------------------------------------------- // eFlagRequiresThread // // Ensures a valid thread is contained in m_exe_ctx prior to executing // the command. If a thread doesn't exist or is invalid, the command // will fail and CommandObject::GetInvalidThreadDescription() will be // returned as the error. CommandObject subclasses can override the // virtual function for GetInvalidThreadDescription() to provide custom // strings when needed. //---------------------------------------------------------------------- eFlagRequiresThread = (1u << 2), //---------------------------------------------------------------------- // eFlagRequiresFrame // // Ensures a valid frame is contained in m_exe_ctx prior to executing // the command. If a frame doesn't exist or is invalid, the command // will fail and CommandObject::GetInvalidFrameDescription() will be // returned as the error. CommandObject subclasses can override the // virtual function for GetInvalidFrameDescription() to provide custom // strings when needed. //---------------------------------------------------------------------- eFlagRequiresFrame = (1u << 3), //---------------------------------------------------------------------- // eFlagRequiresRegContext // // Ensures a valid register context (from the selected frame if there // is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx) // is availble from m_exe_ctx prior to executing the command. If a // target doesn't exist or is invalid, the command will fail and // CommandObject::GetInvalidRegContextDescription() will be returned as // the error. CommandObject subclasses can override the virtual function // for GetInvalidRegContextDescription() to provide custom strings when // needed. //---------------------------------------------------------------------- eFlagRequiresRegContext = (1u << 4), //---------------------------------------------------------------------- // eFlagTryTargetAPILock // // Attempts to acquire the target lock if a target is selected in the // command interpreter. If the command object fails to acquire the API // lock, the command will fail with an appropriate error message. //---------------------------------------------------------------------- eFlagTryTargetAPILock = (1u << 5), //---------------------------------------------------------------------- // eFlagProcessMustBeLaunched // // Verifies that there is a launched process in m_exe_ctx, if there // isn't, the command will fail with an appropriate error message. //---------------------------------------------------------------------- eFlagProcessMustBeLaunched = (1u << 6), //---------------------------------------------------------------------- // eFlagProcessMustBePaused // // Verifies that there is a paused process in m_exe_ctx, if there // isn't, the command will fail with an appropriate error message. //---------------------------------------------------------------------- eFlagProcessMustBePaused = (1u << 7) }; Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands. llvm-svn: 171990
* Fix typo in error message (print requested URL instead of command name when ↵Daniel Malea2012-12-181-1/+1
| | | | | | plugin missing) llvm-svn: 170447
OpenPOWER on IntegriCloud