aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API
AgeCommit message (Collapse)AuthorFilesLines
4 days[lldb] Fix SBBreakpointName::SetEnabled to propagate changes to breakpoints ↵Ebuka Ezike1-0/+1
(#178734) When setting the enabled state of a breakpoint name via the API, the change was not being propagated to breakpoints using that name. This was inconsistent with the CLI behaviour where `breakpoint name configure --enable/--disable` correctly updates all associated breakpoints.
4 days[lldb] [disassembler] chore: add GetVariableAnnotations to SBInstruction api ↵n2h91-1/+22
(#177676) ## Description Contribution to this topic [Rich Disassembler for LLDB](https://discourse.llvm.org/t/rich-disassembler-for-lldb/76952), this part. ``` The rich disassembler output should be exposed as structured data and made available through LLDB’s scripting API so more tooling could be built on top of this ``` ---- This pr replaces #174847 As was suggested in [this comment](https://github.com/llvm/llvm-project/pull/174847#issuecomment-3757015552), implement access to variable annotations from `SBInstruction` class itself. Notes: - :white_check_mark: did run black formatter on the python file; ## Testing Run test with ```sh ./build/bin/lldb-dotest -v -p TestVariableAnnotationsDisassembler.py lldb/test/API/functionalities/disassembler-variables ``` all tests (9 existing + 1 newly added) are passing <details> <summary>screenshot 2026-01-23</summary> build from the latest commit 08f00730b5768a8e3f7039d810084fabaaa24470 <img width="1506" height="562" alt="image" src="https://github.com/user-attachments/assets/69516353-3432-47df-ae45-c40b51ec14c4" /> </details> <details> <summary>screenshot 2026-01-29</summary> build from the latest commit f48a1a2c10f96a457ca6844be2ccc9406d3d57a0 <img width="1232" height="740" alt="image" src="https://github.com/user-attachments/assets/9d104ce6-36c3-430b-98fe-f028f83a6b6d" /> </details> --------- Signed-off-by: Nikita B <n2h9z4@gmail.com>
4 days[lldb] Move ValueImpl and ValueLocker to ValueObject, NFC. (#178573)Aman LaChapelle1-166/+0
This patch moves ValueImpl and ValueLocker to ValueObject.{h,cpp}. This follows the example set in TypeImpl/SBType, where we have something that SBType uses internally that needs to be exposed in the layer below. In this case, SBValue uses ValueImpl, which wraps ValueObject. The wrapper helps avoid bugs, so we want to keep it, but the script interpreter needs to use it and said interpreter is conceptually *below* the SB layer...which means we can't use methods on SBValue. This patch is purely the code motion part of that, future patches will actually make use of this moved code.
12 days[lldb][cmake] Fix standalone Xcode build header staging (#177033)Augusto Noronha1-2/+5
The LLDB standalone build using Xcode fails because the staging directory custom command output is attached to multiple liblldb-stage-header-* targets, but none of these targets depend on each other. Xcode's new build system doesn't allow this. This creates a new target `liblldb-header-staging-dir` that depends on the staging directory creation, and makes all header staging targets depend on it instead of directly depending on the directory in their custom commands. This ensures all targets share a common dependency, satisfying Xcode's build system requirements.
2026-01-12[lldb] Change SBSymbol::GetID() to return LLDB_INVALID_SYMBOL_ID for invalid ↵Ebuka Ezike1-1/+1
symbols (#175545) Return UINT32_MAX instead of 0 when SBSymbol has no underlying symbol, since 0 is a valid symbol ID. This makes it possible to distinguish between a valid symbol with ID 0 and an invalid/uninitialised symbol. From https://github.com/llvm/llvm-project/pull/172687#discussion_r2628319927
2026-01-10[lldb-dap] Add clipboard context support (#170644)Sergei Druzhkov1-3/+35
This patch introduces support for `clipboard` context from [DAP](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Capabilities). This feature is very useful when you want to copy all nested values from a structure or a container instead of a summary (e.g. `size = 3` for vector). I added new short mode for description generation to reduce output verbosity, which is particularly useful for primitive types.
2026-01-07[lldb] Add missing locks in SBThread methods (#174791)Felipe de Azevedo Piovezan1-0/+49
Some of these methods are not acquiring the run lock prior to executing.
2026-01-06[lldb][NFC] use parenthesis constructor (#174556)Ebuka Ezike1-1/+1
Follow the LLVM coding standard
2025-12-25[lldb/cmake] create staging directory for headers (#173427)Jan Palus1-1/+6
copy_command can either become `cmake -E copy`, which handles target directory creation automatically, or `unifdef >` which fails without explicitly created directory and consequently so does version-header-fix.py later on.
2025-12-23[lldb][NFC] Remove temp allocation SBCommandReturnObject::PutCString (#173365)Ebuka Ezike1-2/+2
Use llvm::StringRef instead of std::string to eliminate an unnecessary heap allocation when len > 0. There should not be any functional difference.
2025-12-19[lldb][API] Make SB-API functions const if possible. (#172687)Ebuka Ezike6-9/+9
Only applied to functions that were added after 22.x tag.
2025-12-12[LLDB][NFC] Remove redundant target/process checks in SBFrame (#153258)Felipe de Azevedo Piovezan1-256/+269
This is a follow up to https://github.com/llvm/llvm-project/pull/152020, continuing the removal of now-redundant `if(process && target)` checks. Since this causes a diff in every line of the affected functions, this commit also uses the opportunity to create some helper functions and reduce nesting of the affected methods by rewriting all pre-condition checks as early returns, while remaining strictly NFC. This has exposed some odd behaviors: 1. `SBFrame::GetVariables` has a variable `num_produced` which is clearly meant to be incremented on every iteration of the loop but it is only incremented once, after the loop. So its value is always 0 or 1. The variable now lives in `FetchVariablesUnlessInterrupted`. 2. `SBFrame::GetVariables` has an interruption mechanism for local variables, but not for "recognized arguments". It's unclear if this is by design or not, but it is now evident that there is a discrepancy there. 3. In `SBFrame::EvaluateExpression` we only log some error paths, but not all of them. To stick to the strictly NFC nature of this patch, it does not address any of these issues.
2025-12-10[lldb] Document the behaviour of IsValid for SBError (#170862)David Spickett1-1/+1
This reverts commit d20d84fec5945fcc16aa6f63879e1458d4af9ea6. Fixes #169788, but in a different way. In which I changed an SBError use so that when the function succeeded, IsValid on the SBError would be true. This seemed to make sense but SBError acts differently to other SB classes in this respect. For something like SBMemoryRegionInfo, if IsValid() is false, you can't do anything with it. However for SBError, IsValid() true only means there's some underlying error object in there. If the SBError represents a success, there's no need to put anything in there. You can see this intent from a lot of its methods, many have handling for IsValid() false. This is not a bug but a misunderstanding of what IsValid means. Yes it does function the way I expected for most classes, but it does not for SBError and though that's not intuitive, it is consistent with how we describe IsValid in the documentation. So instead of changing that method's use of SBError I'm documenting this initially counterintuitive behaviour in the SBError header and on the website (https://lldb.llvm.org/resources/sbapi.html).
2025-12-08[lldb] Dump build configuration with `version -v` (#170772)Jonas Devlieghere1-51/+1
Add a verbose option to the version command and include the "build configuration" in the command output. This allows users to quickly identify if their version of LLDB was built with support for xml/curl/python/lua etc. This data is already available through the SB API using SBDebugger::GetBuildConfiguration, but this makes it more discoverable. ``` (lldb) version -v lldb version 22.0.0git (git@github.com:llvm/llvm-project.git revision 21a2aac5e5456f9181384406f3b3fcad621a7076) clang revision 21a2aac5e5456f9181384406f3b3fcad621a7076 llvm revision 21a2aac5e5456f9181384406f3b3fcad621a7076 editline_wchar: yes lzma: yes curses: yes editline: yes fbsdvmcore: yes xml: yes lua: yes python: yes targets: [AArch64, AMDGPU, ARM, AVR, BPF, Hexagon, Lanai, LoongArch, Mips, MSP430, NVPTX, PowerPC, RISCV, Sparc, SPIRV, SystemZ, VE, WebAssembly, X86, XCore] curl: yes ``` Resolves #170727
2025-12-04[lldb] Add support for synthetic LineEntry objects without valid address ↵Med Ismail Bennani1-0/+2
ranges (#158811) Scripted frames that materialize Python functions are PC-less by design, meaning they don't have valid address ranges. Previously, LineEntry::IsValid() required both a valid address range and a line number, preventing scripted frames from creating valid line entries for these synthetic stack frames. Relaxing this requirement is necessary since `SBSymbolContext::SetLineEntry` will first check if the LineEntry is valid and discard it otherwise. This change introduces an `synthetic` flag that gets set when LineEntry objects are created or modified through the SBAPI (specifically via SetLine). When this flag is set, IsValid() no longer requires a valid address range, only a valid line number. This is risk-free because the flag is only set for LineEntry objects created through the SBAPI, which are primarily used by scripted processes and frames. Regular debug information-derived line entries continue to require valid address ranges. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02Reland "[lldb] Introduce ScriptedFrameProvider for real threads (#161870)" ↵Med Ismail Bennani1-0/+82
(#170236) This patch re-lands #161870 with fixes to the previous test failures. rdar://161834688 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02[lldb] Make sure SBError is valid when ↵David Spickett1-1/+1
SBDebugger::InitializeWithErrorHandling succeeds (#170156) Fixes #169788 When this function fails to initialise the debugger, it sets the SBError using the returned error from the initialise function. This results in Success being false and isVaid being true. This is expected behaviour. When it does not fail to initialise, it was returning the default constructed SBError which has Success() == true but IsValid == false. IsValid should be true, to show that the success can be trusted. To fix this, construct the SBError using a default constructed Status, which results in Success and IsValid being true.
2025-11-26[lldb] [scripting bridge] 167388 chore: add api to return arch name for ↵n2h91-0/+13
target (#168273) This pr fixes #167388 . ## Description This pr adds new method `GetArchName` to `SBTarget` so that no need to parse triple to get arch name in client code. ## Testing ### All from `TestTargetAPI.py` run test with ``` ./build/bin/lldb-dotest -v -p TestTargetAPI.py ``` <details> <summary>existing tests (without newly added)</summary> <img width="1425" height="804" alt="image" src="https://github.com/user-attachments/assets/617e4c69-5c6b-44c4-9aeb-b751a47e253c" /> </details> <details> <summary>existing tests (with newly added)</summary> <img width="1422" height="778" alt="image" src="https://github.com/user-attachments/assets/746990a1-df88-4348-a090-224963d3c640" /> </details> ### Only `test_get_arch_name` run test with ``` ./build/bin/lldb-dotest -v -p TestTargetAPI.py -f test_get_arch_name_dwarf -f test_get_arch_name_dwo -f test_get_arch_name_dsym lldb/test/API/python_api/target ``` <details> <summary>only newly added</summary> <img width="1422" height="778" alt="image" src="https://github.com/user-attachments/assets/fcaafa5d-2622-4171-acee-e104ecee0652" /> </details> --------- Signed-off-by: Nikita B <n2h9z4@gmail.com> Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-11-26[lldb-dap] Add multi-session support with shared debugger instances (#163653)Janet Yang1-0/+14
## Summary: This change introduces a `DAPSessionManager` to enable multiple DAP sessions to share debugger instances when needed, for things like child process debugging and some scripting hooks that create dynamically new targets. Changes include: - Add `DAPSessionManager` singleton to track and coordinate all active DAP sessions - Support attaching to an existing target via its globally unique target ID (targetId parameter) - Share debugger instances across sessions when new targets are created dynamically - Refactor event thread management to allow sharing event threads between sessions and move event thread and event thread handlers to `EventHelpers` - Add `eBroadcastBitNewTargetCreated` event to notify when new targets are created - Extract session names from target creation events - Defer debugger initialization from 'initialize' request to 'launch'/'attach' requests. The only time the debugger is used currently in between its creation in `InitializeRequestHandler` and the `Launch` or `Attach` requests is during the `TelemetryDispatcher` destruction call at the end of the `DAP::HandleObject` call, so this is safe. This enables scenarios when new targets are created dynamically so that the debug adapter can automatically start a new debug session for the spawned target while sharing the debugger instance. ## Tests: The refactoring maintains backward compatibility. All existing DAP test cases pass. Also added a few basic unit tests for DAPSessionManager ``` >> ninja DAPTests >> ./tools/lldb/unittests/DAP/DAPTests >>./bin/llvm-lit -v ../llvm-project/lldb/test/API/tools/lldb-dap/ ```
2025-11-17[lldb] Ensure FILE* access mode is correctly specified when creating a ↵John Harrison6-13/+39
NativeFile. (#167764) If we open a `NativeFile` with a `FILE*`, the OpenOptions default to `eOpenOptionReadOnly`. This is an issue in python scripts if you try to write to one of the files like `print("Hi", file=lldb.debugger.GetOutputFileHandle())`. To address this, we need to specify the access mode whenever we create a `NativeFile` from a `FILE*`. I also added an assert on the `NativeFile` that validates the file is opened with the correct access mode and updated `NativeFile::Read` and `NativeFile::Write` to check the access mode. Before these changes: ``` $ lldb -b -O 'script lldb.debugger.GetOutputFileHandle().write("abc")' (lldb) script lldb.debugger.GetOutputFileHandle().write("abc") Traceback (most recent call last): File "<input>", line 1, in <module> io.UnsupportedOperation: not writable ``` After: ``` $ lldb -b -O 'script lldb.debugger.GetOutputFileHandle().write("abc")' (lldb) script lldb.debugger.GetOutputFileHandle().write("abc") abc3 ``` Fixes #122387
2025-11-12Revert "[lldb] Introduce ScriptedFrameProvider for real threads" (#167662)Michael Buch1-82/+0
The new test fails on x86 and arm64 public macOS bots: ``` 09:27:59 ====================================================================== 09:27:59 FAIL: test_append_frames (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that we can add frames after real stack. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 122, in test_append_frames 09:27:59 self.assertEqual(new_frame_count, original_frame_count + 1) 09:27:59 AssertionError: 5 != 6 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_applies_to_thread (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that applies_to_thread filters which threads get the provider. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 218, in test_applies_to_thread 09:27:59 self.assertEqual( 09:27:59 AssertionError: 5 != 1 : Thread with ID 1 should have 1 synthetic frame 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_prepend_frames (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that we can add frames before real stack. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 84, in test_prepend_frames 09:27:59 self.assertEqual(new_frame_count, original_frame_count + 2) 09:27:59 AssertionError: 5 != 7 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_remove_frame_provider_by_id (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that RemoveScriptedFrameProvider removes a specific provider by ID. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 272, in test_remove_frame_provider_by_id 09:27:59 self.assertEqual(thread.GetNumFrames(), 3, "Should have 3 synthetic frames") 09:27:59 AssertionError: 5 != 3 : Should have 3 synthetic frames 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_replace_all_frames (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that we can replace the entire stack. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 41, in test_replace_all_frames 09:27:59 self.assertEqual(thread.GetNumFrames(), 3, "Should have 3 synthetic frames") 09:27:59 AssertionError: 5 != 3 : Should have 3 synthetic frames 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_scripted_frame_objects (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that provider can return ScriptedFrame objects. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 159, in test_scripted_frame_objects 09:27:59 self.assertEqual(frame0.GetFunctionName(), "custom_scripted_frame_0") 09:27:59 AssertionError: 'thread_func(int)' != 'custom_scripted_frame_0' 09:27:59 - thread_func(int) 09:27:59 + custom_scripted_frame_0 09:27:59 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ---------------------------------------------------------------------- 09:27:59 Ran 6 tests in 14.242s 09:27:59 09:27:59 FAILED (failures=6) ``` Reverts llvm/llvm-project#161870
2025-11-11[lldb] Introduce ScriptedFrameProvider for real threads (#161870)Med Ismail Bennani1-0/+82
This patch extends ScriptedFrame to work with real (non-scripted) threads, enabling frame providers to synthesize frames for native processes. Previously, ScriptedFrame only worked within ScriptedProcess/ScriptedThread contexts. This patch decouples ScriptedFrame from ScriptedThread, allowing users to augment or replace stack frames in real debugging sessions for use cases like custom calling conventions, reconstructing corrupted frames from core files, or adding diagnostic frames. Key changes: - ScriptedFrame::Create() now accepts ThreadSP instead of requiring ScriptedThread, extracting architecture from the target triple rather than ScriptedProcess.arch - Added SBTarget::RegisterScriptedFrameProvider() and ClearScriptedFrameProvider() APIs, with Target storing a SyntheticFrameProviderDescriptor template for new threads - Added "target frame-provider register/clear" commands for CLI access - Thread class gains LoadScriptedFrameProvider(), ClearScriptedFrameProvider(), and GetFrameProvider() methods for per-thread frame provider management - New SyntheticStackFrameList overrides FetchFramesUpTo() to lazily provide frames from either the frame provider or the real stack This enables practical use of the SyntheticFrameProvider infrastructure in real debugging workflows. rdar://161834688 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma> Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-11-06[lldb] Enable locate module callback for all module loading (#160199)GeorgeHuyubo2-2/+15
Main executables were bypassing the locate module callback that shared libraries use, preventing custom symbol file location logic from working consistently. This PR fix this by * Adding target context to ModuleSpec * Leveraging that context to use target search path and platform's locate module callback in ModuleList::GetSharedModule This ensures both main executables and shared libraries get the same callback treatment for symbol file resolution. --------- Co-authored-by: George Hu <hyubo@meta.com> Co-authored-by: George Hu <georgehuyubo@gmail.com>
2025-11-05[lldb] Introduce SBFrameList for lazy frame iteration (#166651)Med Ismail Bennani3-0/+119
This patch introduces `SBFrameList`, a new SBAPI class that allows iterating over stack frames lazily without calling `SBThread::GetFrameAtIndex` in a loop. The new `SBThread::GetFrames()` method returns an `SBFrameList` that supports Python iteration (`for frame in frame_list:`), indexing (`frame_list[0]`, `frame_list[-1]`), and length queries (`len()`). The implementation uses `StackFrameListSP` as the opaque pointer, sharing the thread's underlying frame list to ensure frames are materialized on-demand. This is particularly useful for ScriptedFrameProviders, where user scripts will be to iterate, filter, and replace frames lazily without materializing the entire stack upfront. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-10-30[lldb] Add alternative SBThread::GetStopDescription (#165379)Ebuka Ezike1-6/+29
the function signature for `GetStopDescription` is `lldb::SBThread::GetStopDescription(char *dst_or_null, size_t len)`. To get a description you need to call the function first time to get the buffer size. a second time to get the description. This is little worse from the python size as the signature is `lldb.SBThread.GetStopDescription(int: len) -> list[str]` the user has to pass the max size as possible with no way of checking if it is enough. This patch adds a new api `lldb.SBThread.GetStopDescription(desc: lldb.SBStream()) -> bool` `bool lldb::SBThread::GetStopDescription(lldb::SBStream &description)` which handles this case. Adds new Test case for lua.
2025-10-21[lldb-dap] Send a 'process' event on restart. (#163833)John Harrison1-0/+5
When we restart a process, send an updated 'process' event describing the newly launched process. I also updated the `isLocalProcess` value based on if we're on the 'host' platform or not.
2025-10-20[lldb] Add try_lock to SBMutex (#164109)Jonas Devlieghere1-0/+9
Add `try_lock` to confirm to Lockable, which is necessary to use it with `std::scoped_lock`.
2025-10-09Add a scripted way to re-present a stop location (#158128)jimingham1-0/+9
This patch adds the notion of "Facade" locations which can be reported from a ScriptedResolver instead of the actual underlying breakpoint location for the breakpoint. Also add a "was_hit" method to the scripted resolver that allows the breakpoint to say which of these "Facade" locations was hit, and "get_location_description" to provide a description for the facade locations. I apologize in advance for the size of the patch. Almost all of what's here was necessary to (a) make the feature testable and (b) not break any of the current behavior. The motivation for this feature is given in the "Providing Facade Locations" section that I added to the python-reference.rst so I won't repeat it here. rdar://152112327
2025-10-08Make SBBreakpoint/SBBreakpointLocation.SetCondition(nullptr) work again. ↵jimingham2-4/+18
(#162370) The addition of the StopCondition in the lldb_private layer meant that clearing a breakpoint condition with: sb_break.SetCondition(nullptr); now crashes. Also, GetCondition for an empty condition used to return a nullptr, but now it returns "". This patch fixes that crash and makes the SB GetCondition always return nullptr for an empty condition.
2025-10-07[lldb] Add support for unique target ids (#160736)Janet Yang2-0/+19
### Summary Add support for unique target ids per Target instance. This is needed for upcoming changes to allow debugger instances to be shared across separate DAP instances for child process debugging. We want the IDE to be able to attach to existing targets in an already runny lldb-dap session, and having a unique ID per target would make that easier. Each Target instance will have its own unique id, and uses a function-local counter in `TargetList::CreateTargetInternal` to assign incremental unique ids. ### Tests Added several unit tests to test basic functionality, uniqueness of targets, and target deletion doesn't affect the uniqueness. ``` bin/lldb-dotest -p TestDebuggerAPI ```
2025-10-02[LLDB][NFC] Fix variable casing issue (#161691)Jacob Lalonde1-1/+1
Fixes some casing mistakes I added in #161581
2025-10-01[LLDB] Add load core time to target metrics (#161581)Jacob Lalonde1-0/+1
This patch adds a load core time, right now we don't have much insight into the performance of load core, especially for large coredumps. To start collecting information on this I've added some minor instrumentation code to measure the two call sites of `LoadCore`. I've also added a test to validate the new metric is output in statistics dump
2025-09-25[lldb] Avoid copying header just to overwrite it (#160555)Justin Cady1-0/+2
The build script copies lldb-defines.h into the staging area but it gets overwritten by version-header-fix.py. This flow assumes that the lldb-defines.h from the source was writable originally (thus the copy maintains that permission). This is problematic for systems that integrate LLVM source as read only. This change skips the initial copy of lldb-defines.h, which prevents lldb build failures when the source is not writable.
2025-09-12[lldb] Track CFA pointer metadata in StackID (#157498)Felipe de Azevedo Piovezan1-1/+1
[lldb] Track CFA pointer metadata in StackID In this commit: 9c8e71644227 [lldb] Make StackID call Fix{Code,Data} pointers (#152796) We made StackID keep track of the CFA without any pointer metadata in it. This is necessary when comparing two StackIDs to determine which one is "younger". However, the CFA inside StackIDs is also used in other contexts through the method StackID::GetCallFrameAddress. One notable case is DWARFExpression: the computation of `DW_OP_call_frame_address` is done using StackID. This feeds into many other places, e.g. expression evaluation may require the address of a variable that is computed from the CFA; to access the variable without faulting, we may need to preserve the pointer metadata. As such, StackID must be able to provide both versions of the CFA. In the spirit of allowing consumers of pointers to decide what to do with pointer metadata, this patch changes StackID to store both versions of the cfa pointer. Two getter methods are provided, and all call sites except DWARFExpression preserve their existing behavior (stripped pointer). Other alternatives were considered: * Just store the raw pointer. This would require changing the comparisong operator `<` to also receive a Process, as the comparison requires stripped pointers. It wasn't clear if all call-sites had a non-null process, whereas we know we have a process when creating a StackID. * Store a weak pointer to the process inside the class, and then strip metadata as needed. This would require a `weak_ptr::lock` in many operations of LLDB, and it felt wasteful. It also prevents stripping of the pointer if the process has gone away. This patch also changes RegisterContextUnwind::ReadFrameAddress, which is the method computing the CFA fed into StackID, to also preserve the signature pointers.
2025-09-09NFC: SBThread should not be the one to compute StopReasonData. (#157577)jimingham1-103/+4
This is something the StopInfo class manages, so it should be allowed to compute this rather than having SBThread do so. This code just moves the computation to methods in StopInfo. It is mostly NFC. The one change that I actually had to adjust the tests for was a couple of tests that were asking for the UnixSignal stop info data by asking for the data at index 1. GetStopInfoDataCount returns 1 and we don't do 1 based indexing so the test code was clearly wrong. But I don't think it makes sense to perpetuate handing out the value regardless of what index you pass us.
2025-09-04[lldb] Correct style of error messages (#156774)Jonas Devlieghere1-1/+1
The LLVM Style Guide says the following about error and warning messages [1]: > [T]o match error message styles commonly produced by other tools, > start the first sentence with a lowercase letter, and finish the last > sentence without a period, if it would end in one otherwise. I often provide this feedback during code review, but we still have a bunch of places where we have inconsistent error message, which bothers me as a user. This PR identifies a handful of those places and updates the messages to be consistent. [1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages
2025-09-03[lldb] Mark scripted frames as synthetic instead of artificial (#153117)Med Ismail Bennani1-0/+16
This patch changes the way frames created from scripted affordances like Scripted Threads are displayed. Currently, they're marked artificial which is used usually for compiler generated frames. This patch changes that behaviour by introducing a new synthetic StackFrame kind and moves 'artificial' to be a distinct StackFrame attribut. On top of making these frames less confusing, this allows us to know when a frame was created from a scripted affordance. rdar://155949703 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-08-29[lldb] Adjust ProtocolServer connection defaults. (#155714)John Harrison1-9/+1
This adjusts the ProtocolServer command to default to create a new connection listening on `localhost:0` and adds a new `ServerMetadata` details to `~/.lldb/mcp/lldb-<pid>.json` to record information about the current MCP server. This can be consumed by the lldb-mcp binary to establish a connection from an LLM client. --------- Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-08-28[lldb] Add SBFunction::GetBaseName() & SBSymbol::GetBaseName() (#155939)Jonas Devlieghere2-0/+18
When you are trying for instance to set a breakpoint on a function by name, but the SBFunction or SBSymbol are returning demangled names with argument lists, that match can be tedious to do. Internally, the base name of a symbol is something we handle all the time, so it's reasonable that there should be a way to get that info from the API as well. rdar://159318791
2025-08-23Re-land LLDB dap module symbol tables (#155021)Ely Ronnen2-0/+40
Re-land the symbol table feature in lldb-dap after it was [reverted](https://github.com/llvm/llvm-project/commit/2b8e80694263fb404d1d0b816f33df731e617625) because of a crash in the `aarch64` tests, which was caused by dereferencing `SBSymbol::GetName` which might return `nullptr` for an invalid symbol. This patch reapplies the original commits and adds the missing null check. Also adding `skipIfWindows` for the module symbols tests, since LLDB doesn't recognize the symbols from a.out there.
2025-08-22Revert "[lldb-dap] Add module symbol table viewer to VS Code extension ↵Muhammad Omair Javaid2-40/+0
#140626 (#153836)" This reverts commit 8b64cd8be29da9ea74db5a1a21f7cd6e75f9e9d8. This breaks lldb-aarch64-* bots causing a crash in lldb-dap while running test TestDAP_moduleSymbols.py https://lab.llvm.org/buildbot/#/builders/59/builds/22959 https://lab.llvm.org/buildbot/#/builders/141/builds/10975
2025-08-21[lldb/API] Add setters to SBStructuredData (#154445)Med Ismail Bennani1-0/+44
This patch adds setters to the SBStruturedData class to be able to initialize said object from the client side directly. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-08-21[lldb-dap] Add module symbol table viewer to VS Code extension #140626 (#153836)Ely Ronnen2-0/+40
- VS Code extension: - Add module symbol table viewer using [Tabulator](https://tabulator.info/) for sorting and formatting rows. - Add context menu action to the modules tree. - lldb-dap - Add `DAPGetModuleSymbolsRequest` to get symbols from a module. Fixes #140626 [Screencast From 2025-08-15 19-12-33.webm](https://github.com/user-attachments/assets/75e2f229-ac82-487c-812e-3ea33a575b70)
2025-08-19[LLDB] added getName method in SBModule (#150331)barsolo20001-0/+8
added getName method in SBModule.h and .cpp in order to get the name of the module from m_object_name. --------- Co-authored-by: Bar Soloveychik <barsolo@fb.com>
2025-08-11[lldb][NFC] Address follow up comments in ExecutionContext (#153110)Felipe de Azevedo Piovezan1-1/+1
The PR https://github.com/llvm/llvm-project/pull/152020 got merged by accident. This commit addresses some follow up review comments.
2025-08-11[lldb] Guard SBFrame/SBThread methods against running processes (#152020)Felipe de Azevedo Piovezan2-756/+721
Prior to this patch, SBFrame/SBThread methods exhibit racy behavior if called while the process is running, because they do not lock the `Process::RetRunLock` mutex. If they did, they would fail, correctly identifying that the process is not running. Some methods _attempt_ to protect against this with the pattern: ``` ExecutionContext exe_ctx(m_opaque_sp.get(), lock); // this is a different lock Process *process = exe_ctx.GetProcessPtr(); if (process) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) .... do work ... ``` However, this is also racy: the constructor of `ExecutionContext` will access the frame list, which is something that can only be done once the process is stopped. With this patch: 1. The constructor of `ExecutionContext` now expects a `ProcessRunLock` as an argument. It attempts to lock the run lock, and only fills in information about frames and threads if the lock can be acquired. Callers of the constructor are expected to check the lock. 2. All uses of ExecutionContext are adjusted to conform to the above. 3. The SBThread.cpp-defined helper function ResumeNewPlan now expects a locked ProcessRunLock as _proof_ that the execution is stopped. It will unlock the mutex prior to resuming the process. This commit exposes many opportunities for early-returns, but these would increase the diff of this patch and distract from the important changes, so we opt not to do it here.
2025-08-08[lldb-dap] persistent assembly breakpoints (#148061)Ely Ronnen1-25/+21
Resolves #141955 - Adds data to breakpoints `Source` object, in order for assembly breakpoints, which rely on a temporary `sourceReference` value, to be able to resolve in future sessions like normal path+line breakpoints - Adds optional `instructions_offset` parameter to `BreakpointResolver`
2025-08-04[lldb][NFC] Move SBThread::ResumeNewPlan out of the header (#151988)Felipe de Azevedo Piovezan1-17/+7
This *private* method is only defined as a member class of SBThread so that it may be declared a `friend` of SBError and access a private constructor of SBError that takes a `Status`, which is an `lldb_private` object. In other words, the method does not use anything about the class is belongs to, so it has no business being a member method. A subsequent patch will need to add a new argument to this class, a `Process::StopLocker`, which is also another `lldb_private` object. This is another strong suggestion that this method does not belong on the header file of a public API, even if at the private visibility level. We can't forward declare nested types like `Process:StopLocker`, so this problem is not easily solvable. This commit moves the method out of the header and into an anon namespace of the cpp file. It is also made to return a Status instead, and the private `SBError` constructor is accessed by the SBThread methods that call it.
2025-07-29[lldb][cmake] Create dependencies for LLDB header targets (#150995)Chelsea Cassanova1-0/+2
The LLDB standalone build using Xcode currently fails due to the headers being attached to multiple targets, but none of these targets depending on each other. This commit resolves this by creating those dependencies.
2025-07-25[lldb] Use std::make_shared where possible (NFC) (#150714)Jonas Devlieghere5-42/+41
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).