aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-06-22Fix a bug with "process continue -b" when no breakpoints areJim Ingham1-3/+6
passed. I was passing the empty list of breakponts to the VerifyBreakpointList routine, but that treats empty as "choose the default breakpoint" which we don't want here.
2022-06-22Add a "-b" option to "process continue" to run to a set of breakpoints,Jim Ingham1-3/+166
temporarily ignoring the others. Differential Revision: https://reviews.llvm.org/D126513
2022-05-26Store a by name list of signals with their actions in the TargetJim Ingham1-31/+122
so that they can be used to prime new Process runs. "process handle" was also changed to populate the dummy target if there's no selected target, so that the settings will get copied into new targets. Differential Revision: https://reviews.llvm.org/D126259
2022-03-31[LLDB] Applying clang-tidy modernize-use-equals-default over LLDBShafik Yaghmour1-2/+2
Applied modernize-use-equals-default clang-tidy check over LLDB. This check is already present in the lldb/.clang-tidy config. Differential Revision: https://reviews.llvm.org/D121844
2022-03-14[LLDB] Applying clang-tidy modernize-use-default-member-init over LLDBShafik Yaghmour1-2/+2
Applied modernize-use-default-member-init clang-tidy check over LLDB. It appears in many files we had already switched to in class member init but never updated the constructors to reflect that. This check is already present in the lldb/.clang-tidy config. Differential Revision: https://reviews.llvm.org/D121481
2022-02-14Add a repeat command option for "thread backtrace --count N".Jim Ingham1-3/+3
This way if you have a long stack, you can issue "thread backtrace --count 10" and then subsequent <Return>-s will page you through the stack. This took a little more effort than just adding the repeat command, since the GetRepeatCommand API was returning a "const char *". That meant the command had to keep the repeat string alive, which is inconvenient. The original API returned either a nullptr, or a const char *, so I changed the private API to return an llvm::Optional<std::string>. Most of the patch is propagating that change. Also, there was a little thinko in fetching the repeat command. We don't fetch repeat commands for commands that aren't being added to history, which is in general reasonable. And we don't add repeat commands to the history - also reasonable. But we do want the repeat command to be able to generate the NEXT repeat command. So I adjusted the logic in HandleCommand to work that way. Differential Revision: https://reviews.llvm.org/D119046
2022-01-23[Commands] Remove redundant member initialization (NFC)Kazu Hirata1-27/+18
Identified with readability-redundant-member-init.
2021-11-17Revert "Revert "Make it possible for lldb to launch a remote binary with no ↵Jim Ingham1-10/+30
local file."" This reverts commit dd5505a8f2c75a903ec944b6e46aed2042610673. I picked the wrong class for the test, should have been GDBRemoteTestBase.
2021-11-16Revert "Make it possible for lldb to launch a remote binary with no local file."Jim Ingham1-30/+10
The reworking of the gdb client tests into the PlatformClientTestBase broke the test for this. I did the mutatis mutandis for the move, but the test still fails. Reverting till I have time to figure out why. This reverts commit b715b79d54d5ca2d4e8c91089b8f6a9389d9dc48.
2021-11-16Make it possible for lldb to launch a remote binary with no local file.Jim Ingham1-10/+30
We don't actually need a local copy of the main executable to debug a remote process. So instead of treating "no local module" as an error, see if the LaunchInfo has an executable it wants lldb to use, and if so use it. Then report whatever error the remote server returns. Differential Revision: https://reviews.llvm.org/D113521
2021-10-21[lldb] Remove ConstString from GetPluginNameStatic of some pluginsPavel Labath1-3/+3
This patch deals with ObjectFile, ObjectContainer and OperatingSystem plugins. I'll convert the other types in separate patches. In order to enable piecemeal conversion, I am leaving some ConstStrings in the lowest PluginManager layers. I'll convert those as the last step. Differential Revision: https://reviews.llvm.org/D112061
2021-09-29Make "process attach -c" work correctly, and add a test for it.Jim Ingham1-3/+9
The issue here was that we were not updating the interpreter's execution context when calling HandleCommand to continue the process. Since we had just created the process, it wasn't in the interpreter's execution context so HandleCommand failed at CheckRequirements. The patch fixes that by passing the process execution context directly to HandleCommand. Differential Revision: https://reviews.llvm.org/D110787
2021-09-01[lldb] Add minidump save-core functionality to ELF object filesAndrej Korman1-7/+14
This change adds save-core functionality into the ObjectFileELF that enables saving minidump of a stopped process. This change is mainly targeting Linux running on x86_64 machines. Minidump should contain basic information needed to examine state of threads, local variables and stack traces. Full support for other platforms is not so far implemented. API tests are using LLDB's MinidumpParser. This relands commit aafa05e, reverted in 1f986f6. Failed tests were fixed. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D108233
2021-08-31Revert "[lldb] Add minidump save-core functionality to ELF object files"Andy Yankovsky1-14/+7
This reverts commit aafa05e03d629cc6605718c54575256d9d683659. Broke builder on aarch64 -- https://lab.llvm.org/buildbot/#/builders/96/builds/10926
2021-08-31[lldb] Add minidump save-core functionality to ELF object filesAndrej Korman1-7/+14
This change adds save-core functionality into the ObjectFileELF that enables saving minidump of a stopped process. This change is mainly targeting Linux running on x86_64 machines. Minidump should contain basic information needed to examine state of threads, local variables and stack traces. Full support for other platforms is not so far implemented. API tests are using LLDB's MinidumpParser. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D108233
2021-08-27[trace] [intel pt] Create a "process trace save" commandWalter Erquinigo1-0/+76
added new command "process trace save -d <directory>". -it saves a JSON file as <directory>/trace.json, with the main properties of the trace session. -it saves binary Intel-pt trace as <directory>/thread_id.trace; each file saves each thread. -it saves modules to the directory <directory>/modules . -it only works for live process and it only support Intel-pt right now. Example: ``` b main run process trace start n process trace save -d /tmp/mytrace ``` A file named trace.json and xxx.trace should be generated in /tmp/mytrace. To load the trace that was just saved: ``` trace load /tmp/mytrace thread trace dump instructions ``` You should see the instructions of the trace got printed. To run a test: ``` cd ~/llvm-sand/build/Release/fbcode-x86_64/toolchain ninja lldb-dotest ./bin/lldb-dotest -p TestTraceSave ``` Reviewed By: wallace Differential Revision: https://reviews.llvm.org/D107669
2021-08-11Add the ability to process save-core stack-memory-only corefilesJason Molenda1-5/+8
Add a field to the qMemoryRegionInfo packet where the remote stub can describe the type of memory -- heap, stack. Keep track of memory regions that are stack memory in lldb. Add a new "--style stack" to process save-core to request that only stack memory be included in the corefile. Differential Revision: https://reviews.llvm.org/D107625
2021-08-11[lldb/Commands] Fix heap-use-after-free error in CommandObjectProcessMed Ismail Bennani1-2/+2
This patch should fix the use-after-free error that was brought up by the LLDB ASAN Green Dragon bot. This is caused because the `StringRef` object was acquired too early before being use and by the underlying memory was modified which caused it to point to null memory. Fetching back the string reference close to its usage location should fix the issue. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-07-22[lldb] Fix that `process signal` completion always returns all signalsRaphael Isemann1-1/+1
`CompletionRequest::AddCompletion` adds the given string as completion of the current command token. `CompletionRequest::TryCompleteCurrentArg` only adds it if the current token is a prefix of the given string. We're using `AddCompletion` for the `process signal` handler which means that `process signal SIGIN` doesn't get uniquely completed to `process signal SIGINT` as we unconditionally add all other signals (such as `SIGABRT`) as possible completions. By using `TryCompleteCurrentArg` we actually do the proper filtering which will only add `SIGINT` (as that's the only signal with the prefix 'SIGIN' in the example above). Reviewed By: mib Differential Revision: https://reviews.llvm.org/D105028
2021-07-22Read and write a LC_NOTE "addrable bits" for addressing maskJason Molenda1-0/+14
This patch adds code to process save-core for Mach-O files which embeds an "addrable bits" LC_NOTE when the process is using a code address mask (e.g. AArch64 v8.3 with ptrauth aka arm64e). Add code to ObjectFileMachO to read that LC_NOTE from corefiles, and ProcessMachCore to set the process masks based on it when reading a corefile back in. Also have "process status --verbose" print the current address masks that lldb is using internally to strip ptrauth bits off of addresses. Differential Revision: https://reviews.llvm.org/D106348 rdar://68630113
2021-06-23[lldb] Remove CommandReturnObject's SetError(StringRef)David Spickett1-1/+1
Replacing existing uses with AppendError. SetError is also part of the SBI API. This remains but instead of calling the underlying SetError it will call AppendError. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D104768
2021-06-20Add a corefile style option to process save-core; skinny corefilesJason Molenda1-2/+69
Add a new feature to process save-core on Darwin systems -- for lldb to create a user process corefile with only the dirty (modified memory) pages included. All of the binaries that were used in the corefile are assumed to still exist on the system for the duration of the use of the corefile. A new --style option to process save-core is added, so a full corefile can be requested if portability across systems, or across time, is needed for this corefile. debugserver can now identify the dirty pages in a memory region when queried with qMemoryRegionInfo, and the size of vm pages is given in qHostInfo. Create a new "all image infos" LC_NOTE for Mach-O which allows us to describe all of the binaries that were loaded in the process -- load address, UUID, file path, segment load addresses, and optionally whether code from the binary was executing on any thread. The old "read dyld_all_image_infos and then the in-memory Mach-O load commands to get segment load addresses" no longer works when we only have dirty memory. rdar://69670807 Differential Revision: https://reviews.llvm.org/D88387
2021-06-17[trace][intel-pt] Create basic SB APIWalter Erquinigo1-1/+1
This adds a basic SB API for creating and stopping traces. Note: This doesn't add any APIs for inspecting individual instructions. That'd be a more complicated change and it might be better to enhande the dump functionality to output the data in binary format. I'll leave that for a later diff. This also enhances the existing tests so that they test the same flow using both the command interface and the SB API. I also did some cleanup of legacy code. Differential Revision: https://reviews.llvm.org/D103500
2021-06-17[lldb] Remove redundant calls to set eReturnStatusFailedDavid Spickett1-37/+0
This is part 2, covering the commands source. Some uses remain where it's tricky to see what the logic is or they are not used with AppendError. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D104448
2021-06-09[lldb] Use C++11 default member initializersJonas Devlieghere1-2/+2
This converts a default constructor's member initializers into C++11 default member initializers. This patch was automatically generated with clang-tidy and the modernize-use-default-member-init check. $ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-default-member-init' -fix This is a mass-refactoring patch and this commit will be added to .git-blame-ignore-revs. Differential revision: https://reviews.llvm.org/D103483
2021-03-30[trace][intel-pt] Implement trace start and trace stopWalter Erquinigo1-0/+69
This implements the interactive trace start and stop methods. This diff ended up being much larger than I anticipated because, by doing it, I found that I had implemented in the beginning many things in a non optimal way. In any case, the code is much better now. There's a lot of boilerplate code due to the gdb-remote protocol, but the main changes are: - New tracing packets: jLLDBTraceStop, jLLDBTraceStart, jLLDBTraceGetBinaryData. The gdb-remote packet definitions are quite comprehensive. - Implementation of the "process trace start|stop" and "thread trace start|stop" commands. - Implementaiton of an API in Trace.h to interact with live traces. - Created an IntelPTDecoder for live threads, that use the debugger's stop id as checkpoint for its internal cache. - Added a functionality to stop the process in case "process tracing" is enabled and a new thread can't traced. - Added tests I have some ideas to unify the code paths for post mortem and live threads, but I'll do that in another diff. Differential Revision: https://reviews.llvm.org/D91679
2021-03-23[lldb/Commands] Add command options for ScriptedProcess to ProcessLaunchMed Ismail Bennani1-2/+21
This patch adds a new command options to the CommandObjectProcessLaunch for scripted processes. Among the options, the user need to specify the class name managing the scripted process. The user can also use a key-value dictionary holding arbitrary data that will be passed to the managing class. This patch also adds getters and setters to `SBLaunchInfo` for the class name managing the scripted process and the dictionary. rdar://65508855 Differential Review: https://reviews.llvm.org/D95710 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-01[lldb] Revert ScriptedProcess patchesMed Ismail Bennani1-19/+2
This patch reverts the following commits: - 5a9c34918bb1526b7e8c29aa5e4fb8d8e27e27b4 - 46796762afe76496ec4dd900f64d0cf4cdc30e99 - 2cff3dec1171188ce04ab1a4373cc1885ab97be1 - 182f0d1a34419445bb19d67581d6ac1afc98b7fa - d62a53aaf1d38a55d1affbd3a30d564a4e9d3171 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-03-01[lldb/Commands] Add command options for ScriptedProcess to ProcessLaunchMed Ismail Bennani1-2/+19
This patch adds a new command options to the CommandObjectProcessLaunch for scripted processes. Among the options, the user need to specify the class name managing the scripted process. The user can also use a key-value dictionary holding arbitrary data that will be passed to the managing class. This patch also adds getters and setters to `SBLaunchInfo` for the class name managing the scripted process and the dictionary. rdar://65508855 Differential Review: https://reviews.llvm.org/D95710 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-02-08Reland "[lldb] Make CommandInterpreter's execution context the same as ↵Tatyana Krasnukha1-1/+0
debugger's one"
2021-01-20[lldb/Commands] Refactor ProcessLaunchCommandOptions to use TableGen (NFC)Med Ismail Bennani1-1/+2
This patch refactors the current implementation of `ProcessLaunchCommandOptions` to be generated by TableGen. The patch also renames the class to `CommandOptionsProcessLaunch` to align better with the rest of the codebase style and moves it to separate files. Differential Review: https://reviews.llvm.org/D95059 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-12-17Revert "[lldb] Make CommandInterpreter's execution context the same as ↵Pavel Labath1-0/+1
debugger's one." This reverts commit a01b26fb51c710a3a8ef88cc83b0701461f5b9ab, because it breaks the "finish" command in some way -- the command does not terminate after it steps out, but continues running the target. The exact blast radius is not clear, but it at least affects the usage of the "finish" command in TestGuiBasicDebug.py. The error is *not* gui-related, as the same issue can be reproduced by running the same steps outside of the gui. There is some kind of a race going on, as the test fails only 20% of the time on the buildbot.
2020-12-12[lldb] Make CommandInterpreter's execution context the same as debugger's one.Tatyana Krasnukha1-1/+0
Currently, the interpreter's context is not updated until a command is executed. This has resulted in the behavior of SB-interface functions and some commands depends on previous user actions. The interpreter's context can stay uninitialized, point to a currently selected target, or point to one of previously selected targets. This patch removes any usages of CommandInterpreter::UpdateExecutionContext. CommandInterpreter::HandleCommand* functions still may override context temporarily, but now they always restore it before exiting. CommandInterpreter saves overriden contexts to the stack, that makes nesting commands possible. Added test reproduces one of the issues. Without this fix, the last assertion fails because interpreter's execution context is empty until running "target list", so, the value of the global property was updated instead of process's local instance. Differential Revision: https://reviews.llvm.org/D92164
2020-12-12[lldb] "target create" shouldn't save target if the command failedTatyana Krasnukha1-1/+0
TargetList::CreateTarget automatically adds created target to the list, however, CommandObjectTargetCreate does some additional preparation after creating a target and which can fail. The command should remove created target if it failed. Since the function has many ways to return, scope guard does this work safely. Changes to the TargetList make target adding and selection more transparent. Other changes remove unnecessary SetSelectedTarget after CreateTarget. Differential Revision: https://reviews.llvm.org/D93052
2020-08-24[lldb] common completion for process pids and process namesGongyu Deng1-43/+0
1. Added two common completions: `ProcessIDs` and `ProcessNames`, which are refactored from their original dedicated option completions; 2. Removed the dedicated option completion functions of `process attach` and `platform process attach`, so that they can use arg-type-bound common completions instead; 3. Bound `eArgTypePid` to the pid completion, `eArgTypeProcessName` to the process name completion in `CommandObject.cpp`; 4. Added a related test case. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D80700
2020-08-21[lldb] Tab completion for process load/unloadGongyu Deng1-0/+29
1. Complete `process load` with the common disk file completion, so there is not test provided for it; 2. Complete `process unload` with the tokens of valid loaded images. Thanks for Raphael's help on the test for `process unload`. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D79887
2020-08-05[lldb] Add an option to inherit TCC permissions from parent.Jonas Devlieghere1-0/+3
Add an option that allows the user to decide to not make the inferior is responsible for its own TCC permissions. If you don't make the inferior responsible, it inherits the permissions of its parent. The motivation is the scenario of running the LLDB test suite from an external hard drive. If the inferior is responsible, every test needs to be granted access to the external volume. When the permissions are inherited, approval needs to be granted only once. Differential revision: https://reviews.llvm.org/D85237
2020-07-27[lldb] Modernize away some snprintf callsRaphael Isemann1-10/+10
Reviewers: #lldb, JDevlieghere Reviewed By: #lldb, JDevlieghere Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D84530
2020-07-14[lldb] Make `process connect` blocking in synchronous mode.Jonas Devlieghere1-3/+9
In synchronous mode, the process connect command and its aliases should wait for the stop event before claiming the command is complete. Currently, the stop event is always handled asynchronously by the debugger. The implementation takes the same approach as Process::ResumeSynchronous which hijacks the event and handles it on the current thread. Similarly, after this patch, the stop event is part of the command return object, which is the property used by the test case. Differential revision: https://reviews.llvm.org/D83728
2020-07-01[lldb] Replace StringConvert with llvm::to_integer when parsing integer ↵Raphael Isemann1-6/+6
values in CommandObjects Summary: This replaces the current use of LLDB's own `StringConvert` with LLVM's `to_integer` which has a less error-prone API and doesn't use special 'error values' to designate parsing problems. Where needed I also added missing error handling code that prints a parsing error instead of continuing with the error value returned from `StringConvert` (which either gave a cryptic error message or just took the error value performed an incorrect action with it. For example, `frame recognizer delete -1` just deleted the frame recognizer at index 0). Reviewers: #lldb, labath Reviewed By: labath Subscribers: labath, abidh, JDevlieghere Differential Revision: https://reviews.llvm.org/D82297
2020-06-15[lldb] Remove redundant access specifiers (NFC)Jonas Devlieghere1-1/+0
2020-05-27[lldb] Tab completion for process plugin nameGongyu Deng1-28/+32
Summary: 1. Added tab completion to `process launch -p`, `process attach -P`, `process connect -p`; 2. Bound the plugin name common completion as the default completion for `eArgTypePlugin` arguments. Reviewers: teemperor, JDevlieghere Tags: #lldb Differential Revision: https://reviews.llvm.org/D79929
2020-03-12[lldb/Utility] Replace ProcessInstanceInfoList with std::vector. (NFCI)Jonas Devlieghere1-2/+2
Replace ProcessInstanceInfoList with std::vector<ProcessInstanceInfo> and update the call sites.
2020-03-06tab completion for process signalRaphael Isemann1-0/+14
Summary: Provide a list of Unix signals for the tap completion for command "process signal". Reviewers: teemperor Subscribers: labath, jingham, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D75418
2020-02-24[lldb/Plugins] Move SBTarget::GetExtendedCrashInformation to SBProcessMed Ismail Bennani1-1/+1
This patch moves the SB API method GetExtendedCrashInformation from SBTarget to SBProcess since it only makes sense to call this method on a sane process which might not be the case on a SBTarget object. It also addresses some feedbacks received after landing the first patch for the 'crash-info' feature. Differential Revision: https://reviews.llvm.org/D75049 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-21[lldb/Plugins] Add ability to fetch crash information on crashed processesMed Ismail Bennani1-1/+76
Currently, in macOS, when a process crashes, lldb halts inside the implementation disassembly without yielding any useful information. The only way to get more information is to detach from the process, then wait for ReportCrash to generate a report, find the report, then see what error message was included in it. Instead of waiting for this to happen, lldb could locate the error_string and make it available to the user. This patch addresses this issue by enabling the user to fetch extended crash information for crashed processes using `process status --verbose`. Depending on the platform, this will try to gather different crash information into an structured data dictionnary. This dictionnary is generic and extensible, as it contains an array for each different type of crash information. On Darwin Platforms, lldb will iterate over each of the target's images, extract their `__crash_info` section and generated a StructuredData::Array containing, in each entry, the module spec, its UUID, the crash messages and the abort cause. The array will be inserted into the platform's `m_extended_crash_info` dictionnary and `FetchExtendedCrashInformation` will return its JSON representation like this: ``` { "crash-info annotations": [ { "abort-cause": 0, "image": "/usr/lib/system/libsystem_malloc.dylib", "message": "main(76483,0x1000cedc0) malloc: *** error for object 0x1003040a0: pointer being freed was not allocated", "message2": "", "uuid": "5747D0C9-900D-3306-8D70-1E2EA4B7E821" }, ... ], ... } ``` This crash information can also be fetched using the SB API or lldb-rpc protocol using SBTarget::GetExtendedCrashInformation(). rdar://37736535 Differential Revision: https://reviews.llvm.org/D74657 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-4/+4
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann1-1/+1
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2019-12-16[lldb][NFC] Remove unnecessary includes in source/CommandsRaphael Isemann1-1/+0
Summary: This removes most of unnecessary includes in the `source/Commands` directory. This was generated by IWYU and a script that fixed all the bogus reports from IWYU. Patch is tested on Linux and macOS. Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71489
2019-10-30Run clang-format on lldb/source/Commands (NFC)Adrian Prantl1-5/+5
These files had a lot of whitespace errors in them which was a constant source of merge conflicts downstream.