aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter
AgeCommit message (Collapse)AuthorFilesLines
35 hoursSwitch the ScriptedBreakpointResolver over to the ScriptedInterface form ↵jimingham1-0/+7
(#150720) This is NFC, I'm modernizing the interface before I add to it in a subsequent commit.
4 days[lldb] Use std::make_shared where possible (NFC) (#150714)Jonas Devlieghere1-2/+1
This is a continuation of 68fd102, which did the same thing but only for StopInfo. Using make_shared is both safer and more efficient: - With make_shared, the object and the control block are allocated together, which is more efficient. - With make_shared, the enable_shared_from_this base class is properly linked to the control block before the constructor finishes, so shared_from_this() will be safe to use (though still not recommended during construction).
13 days[lldb] [cosmetic] Update help message of `(lldb) b` (#149114)royitaqi1-2/+6
`(lldb) b` can be used in two different ways: 1. Running `b` without arguments, it lists all existing breakpoints. 2. Running `b` with arguments, it adds breakpoints. However, the help message doesn't mention the first use case. This patch adds help message to mention it. **Without patch**: ``` (lldb) help b Set a breakpoint using one of several shorthand formats. Expects 'raw' input (see 'help raw-input'.) Syntax: _regexp-break <filename>:<linenum>:<colnum> main.c:12:21 // Break at line 12 and column 21 of main.c ... ``` **With patch**: ``` (lldb) help b Set a breakpoint using one of several shorthand formats, or list the existing breakpoints if no arguments are provided. Expects 'raw' input (see 'help raw-input'.) Syntax: _regexp-break <filename>:<linenum>:<colnum> main.c:12:21 // Break at line 12 and column 21 of main.c ... _regexp-break // List the existing breakpoints ```
2025-07-08[lldb] Pass address expression command args through FixAnyAddress (#147011)Jason Molenda1-2/+1
Commands that take an address expression/address through the OptionArgParser::ToAddress method, which has filtered this user-specified address through one of the Process Fix methods to clear non-addressable bits (MTE, PAC, top byte ignore, etc). We don't know what class of address this is, IMEM or DMEM, but this method is passing the addresses through Process::FixCodeAddress, and on at least one target, FixCodeAddress clears low bits which are invalid for instructions. Correct this to use FixAnyAddress, which doesn't make alignment assumptions. The actual issue found was by people debugging on a 32-bit ARM Cortex-M part, who tried to do a memory read from an odd address, and lldb returned results starting at the next lower even address. rdar://154885727
2025-06-26[lldb] Remove child_process_inherit argument from Pipe (#145516)Pavel Labath1-1/+1
It's not necessary on posix platforms as of #126935 and it's ignored on windows as of #138896. For both platforms, we have a better way of inheriting FDs/HANDLEs.
2025-06-20[lldb] Add Model Context Protocol (MCP) support to LLDB (#143628)Jonas Devlieghere1-0/+2
This PR adds an MCP (Model Context Protocol ) server to LLDB. For motivation and background, please refer to the corresponding RFC: https://discourse.llvm.org/t/rfc-adding-mcp-support-to-lldb/86798 I implemented this as a new kind of plugin. The idea is that we could support multiple protocol servers (e.g. if we want to support DAP from within LLDB). This also introduces a corresponding top-level command (`protocol-server`) with two subcommands to `start` and `stop` the server. ``` (lldb) protocol-server start MCP tcp://localhost:1234 MCP server started with connection listeners: connection://[::1]:1234, connection://[127.0.0.1]:1234 ``` The MCP sever supports one tool (`lldb_command`) which executes a command, but can easily be extended with more commands.
2025-06-10[lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S (#142587)Pavel Labath2-0/+4
Replace (questionable) header globs with an explicit argument supported by llvm_add_library.
2025-06-04[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)Pavel Labath2-6/+4
If we're not touching them, we don't need to do anything special to pass them along -- with one important caveat: due to how cmake arguments work, the implicitly passed arguments need to be specified before arguments that we handle. This isn't particularly nice, but the alternative is enumerating all arguments that can be used by llvm_add_library and the macros it calls (it also relies on implicit passing of some arguments to llvm_process_sources).
2025-06-03[lldb] Fix data race in statusline format handling (#142489)Jonas Devlieghere1-3/+3
This fixes a data race between the main thread and the default event handler thread. The statusline format option value was protected by a mutex, but it was returned as a pointer, allowing one thread to access it while another was modifying it. Avoid the data race by returning format values by value instead of by pointer.
2025-05-29[LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir ↵Akash Agrawal1-1/+0
& few other files (#141478) A few files of lldb dir & few other files had duplicate headers included. This patch removes those redundancies. --------- Co-authored-by: Akash Agrawal <akashag@qti.qualcomm.com>
2025-05-28[lldb] Expose language plugin commands based based on language of current ↵Dave Lee1-1/+50
frame (#136766) Use the current frame's language to lookup commands provided by language plugins. This means commands like `language {objc,cplusplus} <command>` can be used directly, without using the `language <lang>` prefix. For example, when stopped on a C++ frame, `demangle _Z1fv` will run `language cplusplus demangle _Z1fv`. rdar://149882520
2025-05-20Update InterpreterProperties.td (#140746)Anthony Cabrera-Lara1-1/+1
Fix typo in interpreter property description. Fixes #140708
2025-05-17[lldb] Use llvm::replace (NFC) (#140343)Kazu Hirata1-2/+2
2025-05-13[lldb] Use std:::string::find with std::string_view (NFC) (#139679)Kazu Hirata1-1/+1
std::string::find accepts anything that can be converted to std::string_view starting in C++17. Since StringRef can be converted to std::string_view, we do not need to create a temporary instance of std::string here.
2025-05-04[lldb] Remove unused local variables (NFC) (#138457)Kazu Hirata1-3/+0
2025-04-27Complete ToJSON for OptionValues (#137375)Ebuka Ezike11-9/+33
Completes the ToJSON function for `OptionValue` types and make the interface function pure virtual --------- Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-04-24[lldb][lldb-dap] Add ToJSON for OptionValueEnumeration (#137007)Ebuka Ezike1-2/+12
This automatically enables reading enum settings in the SB API
2025-04-22[lldb] Fix use-color settings not persistent (#135626)Ebuka Ezike1-1/+6
Fixes https://github.com/llvm/llvm-project/issues/22981 If `settings set use-color` is changed when lldb is running it does not take effect. This is fixes that. --------- Signed-off-by: Ebuka Ezike <yerimyah1@gmail.com> Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-04-10[lldb] Support programmatically setting the statusline format (NFC) (#135250)Jonas Devlieghere1-0/+9
Support programmatically setting the statusline format. I want to use this API downstream, to change the statusline format for the Swift REPL.
2025-04-04[LLDB][NFC]Fix stack-use-after free bug. (#134296)Vy Nguyen1-1/+3
Details: detailed_command_telemetry (bool) and command_id (int) could already be freed when the dispatcher's dtor runs. So we should just copy them into the lambda since they are cheap.
2025-04-02[LLDB][NFC]Move fields that might be referenced in scope-exit to beginning ↵Vy Nguyen1-2/+7
(#133785) Details: The ScopedDiscpatcher's dtor may reference these fields so we need the fields' dtor to be be invoked *after* the dispatcher's.
2025-04-01Add a new affordance that the Python module in a dSYM (#133290)jimingham1-5/+4
So the dSYM can be told what target it has been loaded into. When lldb is loading modules, while creating a target, it will run "command script import" on any Python modules in Resources/Python in the dSYM. However, this happens WHILE the target is being created, so it is not yet in the target list. That means that these scripts can't act on the target that they a part of when they get loaded. This patch adds a new python API that lldb will call: __lldb_module_added_to_target if it is defined in the module, passing in the Target the module was being added to, so that code in these dSYM's don't have to guess.
2025-03-21[lldb] Show target.debug-file-search-paths setting from python SBDebugger ↵Ebuka Ezike1-0/+9
(#131683) When printing setting variables using the python SBDebugger API if the type is of OptionValueFileSpec it defaults to null as the value even if it has a value. This patch fixes that. --------- Signed-off-by: Ebuka Ezike <yerimyah1@gmail.com> Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-03-20Reapply LLDB-Telemetry TargetInfo branch (pr/127834) (#132043)Vy Nguyen1-1/+1
New changes: add check to avoid accessing invalid obj
2025-03-19Revert "[LLDB][Telemetry]Define TargetInfo for collecting data about a ↵Pavel Labath1-1/+1
target (#127834)" This reverts commit 04e39ce3fddaaec41d9c7babcca55133d7e49969 due to test breakage.
2025-03-18[LLDB][Telemetry]Define TargetInfo for collecting data about a target (#127834)Vy Nguyen1-1/+1
Co-authored-by: Pavel Labath <pavel@labath.sk>
2025-03-17Reapply "[lldb] Implement basic support for reverse-continue (#125242)" ↵Pavel Labath1-1/+2
(again) (#128156) This reverts commit https://github.com/llvm/llvm-project/commit/87b7f63a117c340a6d9ca47959335fd7ef6c7ad2, reapplying https://github.com/llvm/llvm-project/commit/7e66cf74fb4e6a103f923e34700a7b6f20ac2a9b with a small (and probably temporary) change to generate more debug info to help with diagnosing buildbot issues.
2025-03-07[LLDB][Telemetry]Define telemetry::CommandInfo (#129354)Vy Nguyen1-9/+50
and collect telemetry about a command's execution. *NOTE: Please consider this PR a DRAFT ( Waiting on PR/127696 to be submitted. ) --------- Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-02-19[lldb] Synchronize the debuggers output & error streamsJonas Devlieghere2-17/+22
This patch improves the synchronization of the debugger's output and error streams using two new abstractions: `LockableStreamFile` and `LockedStreamFile`. - `LockableStreamFile` is a wrapper around a `StreamFile` and a mutex. Client cannot use the `StreamFile` without calling `Lock`, which returns a `LockedStreamFile`. - `LockedStreamFile` is an RAII object that locks the stream for the duration of its existence. As long as you hold on to the returned object you are permitted to write to the stream. The destruction of the object automatically flush the output stream.
2025-02-19[lldb] Make GetOutputStreamSP and GetErrorStreamSP protected (#127682)Jonas Devlieghere2-4/+4
This makes GetOutputStreamSP and GetErrorStreamSP protected members of Debugger. Users who want to print to the debugger's stream should use GetAsyncOutputStreamSP and GetAsyncErrorStreamSP instead and the few remaining stragglers have been migrated.
2025-02-12[lldb] Remove Debugger::Get{Output,Error}Stream (NFC) (#126821)Jonas Devlieghere1-2/+2
Remove Debugger::GetOutputStream and Debugger::GetErrorStream in preparation for replacing both with a new variant that needs to be locked and hence can't be handed out like we do right now. The patch replaces most uses with GetAsyncOutputStream and GetAsyncErrorStream respectively. There methods return new StreamSP objects that automatically get flushed on destruction. See #126630 for more details.
2025-02-07[lldb][Breakpoint] Allow whitespace in breakpoint address expression (#126053)Michael Buch1-1/+3
Setting a breakpoint on `<symbol> + <offset>` used to work until `2c76e88e9eb284d17cf409851fb01f1d583bb22a`, where this regex was reworked. Now we only accept `<symbol>+ <offset>` or `<symbol>+<offset>`. This patch fixes the regression by adding yet another `[[:space:]]*` component to the regex. One could probably simplify the regex (or even replace the regex by just calling the relevent `consumeXXX` APIs on `llvm::StringRef`). Though I left that for the future. rdar://130780342
2025-02-04[lldb] Support CommandInterpreter print callbacks (#125006)Jonas Devlieghere1-20/+35
Xcode uses a pseudoterminal for the debugger console. - The upside of this apporach is that it means that it can rely on LLDB's IOHandlers for multiline and script input. - The downside of this approach is that the command output is printed to the PTY and you don't get a SBCommandReturnObject. Adrian added support for inline diagnostics (#110901) and we'd like to access those from the IDE. This patch adds support for registering a callback in the command interpreter that gives access to the `(SB)CommandReturnObject` right before it will be printed. The callback implementation can choose whether it likes to handle printing the result or defer to lldb. If the callback indicated it handled the result, the command interpreter will skip printing the result. We considered a few other alternatives to solve this problem: - The most obvious one is using `HandleCommand`, which returns a `SBCommandReturnObject`. The problem with this approach is the multiline input mentioned above. We would need a way to tell the IDE that it should expect multiline input, which isn't known until LLDB starts handling the command. - To address the multiline issue,we considered exposing (some of the) IOHandler machinery through the SB API. To solve this particular issue, that would require reimplementing a ton of logic that already exists today in the CommandInterpeter. Furthermore that seems like overkill compared to the proposed solution. rdar://141254310
2025-02-04[lldb] Store the command in the CommandReturnObject (#125132)Jonas Devlieghere1-4/+6
As suggested in #125006. Depending on which PR lands first, I'll update `TestCommandInterepterPrintCallback.py` to check that the `CommandReturnObject` passed to the callback has the correct command.
2025-01-31[lldb] Use llvm::Error instead of CommandReturnObject for error reporting ↵Jonas Devlieghere3-78/+85
(#125125) Use `llvm::Error` instead of `CommandReturnObject` for error reporting. The command return objects were populated with errors but never displayed. With this patch they're at least logged.
2025-01-31Revert "Reland "[lldb] Implement basic support for reverse-continue" (#125242)"Adrian Prantl1-2/+1
This reverts commit 7e66cf74fb4e6a103f923e34700a7b6f20ac2a9b. Breaking green dragon: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/19569/testReport/junit/lldb-api/functionalities_reverse-execution/TestReverseContinueWatchpoints_py/
2025-01-31Reland "[lldb] Implement basic support for reverse-continue" (#125242)David Spickett1-1/+2
This reverts commit a774de807e56c1147d4630bfec3110c11d41776e. This is the same changes as last time, plus: * We load the binary into the target object so that on Windows, we can resolve the locations of the functions. * We now assert that each required breakpoint has at least 1 location, to prevent an issue like that in the future. * We are less strict about the unsupported error message, because it prints "error: windows" on Windows instead of "error: gdb-remote".
2025-01-30[lldb] Remove another unused CommandReturnObject variable (NFC)Jonas Devlieghere1-1/+0
2025-01-30[lldb] Remove unused CommandReturnObject stack variable (NFC)Jonas Devlieghere1-2/+0
Per the title, the variable is unused.
2025-01-30[lldb] Constify methods in CommandReturnObject (NFC)Jonas Devlieghere1-2/+3
There's no reason these methods cannot be `const`. Currently this prevents us from passing around a const ref. This patch is in preparation for #125006.
2025-01-30[lldb] Fix CommandInterpreter.{h,cpp} formatting (NFC)Jonas Devlieghere1-45/+49
Fix CommandInterpreter.{h,cpp} formatting in preparation for #125006.
2025-01-30Revert "Reland "[lldb] Implement basic support for reverse-continue" ↵David Spickett1-2/+1
(#123906)"" (#125091) Reverts llvm/llvm-project#123945 Has failed on the Windows on Arm buildbot: https://lab.llvm.org/buildbot/#/builders/141/builds/5865 ``` ******************** Unresolved Tests (2): lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py ******************** Failed Tests (1): lldb-api :: functionalities/reverse-execution/TestReverseContinueNotSupported.py ``` Reverting while I reproduce locally.
2025-01-30Reland "[lldb] Implement basic support for reverse-continue" (#123906)" ↵David Spickett1-1/+2
(#123945) This reverts commit 22561cfb443267905d4190f0e2a738e6b412457f and fixes b7b9ccf44988edf49886743ae5c3cf4184db211f (#112079). The problem is that x86_64 and Arm 32-bit have memory regions above the stack that are readable but not writeable. First Arm: ``` (lldb) memory region --all <...> [0x00000000fffcf000-0x00000000ffff0000) rw- [stack] [0x00000000ffff0000-0x00000000ffff1000) r-x [vectors] [0x00000000ffff1000-0xffffffffffffffff) --- ``` Then x86_64: ``` $ cat /proc/self/maps <...> 7ffdcd148000-7ffdcd16a000 rw-p 00000000 00:00 0 [stack] 7ffdcd193000-7ffdcd196000 r--p 00000000 00:00 0 [vvar] 7ffdcd196000-7ffdcd197000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall] ``` Compare this to AArch64 where the test did pass: ``` $ cat /proc/self/maps <...> ffffb87dc000-ffffb87dd000 r--p 00000000 00:00 0 [vvar] ffffb87dd000-ffffb87de000 r-xp 00000000 00:00 0 [vdso] ffffb87de000-ffffb87e0000 r--p 0002a000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ffffb87e0000-ffffb87e2000 rw-p 0002c000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 fffff4216000-fffff4237000 rw-p 00000000 00:00 0 [stack] ``` To solve this, look up the memory region of the stack pointer (using https://lldb.llvm.org/resources/lldbgdbremote.html#qmemoryregioninfo-addr) and constrain the read to within that region. Since we know the stack is all readable and writeable. I have also added skipIfRemote to the tests, since getting them working in that context is too complex to be worth it. Memory write failures now display the range they tried to write, and register write errors will show the name of the register where possible. The patch also includes a workaround for a an issue where the test code could mistake an `x` response that happens to begin with an `O` for an output packet (stdout). This workaround will not be necessary one we start using the [new implementation](https://discourse.llvm.org/t/rfc-fixing-incompatibilties-of-the-x-packet-w-r-t-gdb/84288) of the `x` packet. --------- Co-authored-by: Pavel Labath <pavel@labath.sk>
2025-01-22Revert "[lldb] Implement basic support for reverse-continue" (#123906)Pavel Labath1-2/+1
Reverts llvm/llvm-project#112079 due to failures on the arm bot.
2025-01-22[lldb] Implement basic support for reverse-continue (#112079)Robert O'Callahan1-1/+2
This commit adds support for a `SBProcess::ContinueInDirection()` API. A user-accessible command for this will follow in a later commit. This feature depends on a gdbserver implementation (e.g. `rr`) providing support for the `bc` and `bs` packets. `lldb-server` does not support those packets, and there is no plan to change that. For testing purposes, this commit adds a Python implementation of *very limited* record-and-reverse-execute functionality, implemented as a proxy between lldb and lldb-server in `lldbreverse.py`. This should not (and in practice cannot) be used for anything except testing. The tests here are quite minimal but we test that simple breakpoints and watchpoints work as expected during reverse execution, and that conditional breakpoints and watchpoints work when the condition calls a function that must be executed in the forward direction.
2024-12-20[lldb] Expose structured errors in SBError (#120784)Adrian Prantl1-51/+1
Building on top of previous work that exposed expression diagnostics via SBCommandReturnObject, this patch generalizes the support to expose any SBError as machine-readable structured data. One use-case of this is to allow IDEs to better visualize expression diagnostics. rdar://139997604
2024-12-02[lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (#117504)Dave Lee1-2/+1
`Mode::Always` and `Mode::Default` are handled identically. `Mode::Never` is the same as having a count of 0.
2024-11-14[lldb] Support any flag to _regexp-bt (#116260)Dave Lee1-2/+1
In particular, this allows `bt -u`. Note that this passthrough behavior has precedent in `_regexp-break`, where `b (-.*)` is expanded to `breakpoint set %1`.
2024-11-11[lldb] Use heterogenous lookups with std::map (NFC) (#115684)Kazu Hirata1-15/+12
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string. Note that CommandMap just started accepting heterogeneous lookups (#115634).
2024-11-07[lldb] Add builtin e alias for expression (#115359)Dave Lee1-0/+2
The changes in 461f859a72 (llvm/llvm-project#65974) resulted in a change in behavior not just for completion, but also for selection of inexect commands. Since many use `e` to mean `expression`, this change adds an alias for `e`. Note that the referenced change similarly aliases `h` to `help`.