aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
AgeCommit message (Collapse)AuthorFilesLines
5 days[lldb] Fix Python stderr redirection in test (#177970)Ebuka Ezike1-2/+8
Python's internal stderr may differ from sys.stderr. When Python writes errors, it uses its internal stderr rather than the overwritten sys.stderr. This may not be the same file/handle Fix the test to explicitly write to the specified stderr.
2026-01-13[lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method ↵Matej Košík1-0/+16
returns the correct value also for "_BitInt(...)" types. (#165857) When trying to get the `SBType` object corresponding to the `_BitInt(...)` type name, we have noticed that the `SBTarget::FindFirstType` metod returns `nil`. This branch proposes: - some test that demonstrate that the problem exists - a possible fix --------- Co-authored-by: Matej Košík <matej.kosik@codasip.com> Co-authored-by: Michael Buch <michaelbuch12@gmail.com>
2026-01-09Revert "[LLDB] Swig python extensions tests for SBTargetExtention" (#175251)Jonas Devlieghere3-148/+0
Reverts llvm/llvm-project#173473
2026-01-09[LLDB] Swig python extensions tests for SBTargetExtention (#173473)Hamza Hassanain3-0/+148
Implements part of #168920
2026-01-09[lldb] fix a problem in the ValueObject::GetExpressionPath method (#171521)Matej Košík3-0/+59
Consider the following program: ``` int main() { int foo[2][3][4]; int (*bar)[3][4] = foo; return 0; } ``` If we: - compile this program - launch an LLDB debugging session - launch the process and let it stop at the `return 0;` statement then the following LLDB command: ``` (lldb) script lldb.frame.FindVariable("bar").GetChildAtIndex(0).get_expr_path() ``` will produce the following output: ``` bar->[0] ``` What we were expecting: - a valid expression in the C programming language - that would allow us (in the scope of the `main` function) access the appropriate object. What we've got is a string that does not represent a valid expression in the C programming language. This pull-request proposes a fix to this problem. --------- Co-authored-by: Matej Košík <matej.kosik@codasip.com>
2026-01-08[lldb] skip the python interactive I/O test on windows (#175055)Ebuka Ezike1-1/+1
There is no indication this ever worked on windows as this is the first test that checks python interactive console from a file. Looking at the error from the CI, It closed the interpreter before running any python commands. Will reconfirm this when I have access to a windows machine. From https://github.com/llvm/llvm-project/pull/174216
2026-01-08[lldb] Fix typed commands not shown on the screen (#174216)Ebuka Ezike1-1/+47
The cause is that in `python3.14`, `fcntl.ioctl` now throws a buffer overflow error when the buffer is too small or too large (see https://github.com/python/cpython/pull/132919). This caused the Python interpreter to fail terminal detection and not properly echo user commands back to the screen. Fix by dropping the custom terminal size check entirely and using the built-in `sys.stdin.isatty()` instead. Fixes #173302
2026-01-07[lldb] Add zlib to version -v output (#174753)David Spickett1-0/+1
I know this is required for at least one feature, because TestSectionAPI.py has failures if zlib isn't enabled. So I think it's useful for users to be able to check. Now that it's in the config, I have also used it to make a test annotation so we don't get the failure in TestSectionAPI.py when zlib is disabled. Which for future reference was: Traceback (most recent call last): File "/home/davspi01/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 452, in wrapper return func(self, *args, **kwargs) File "/home/davspi01/llvm-project/lldb/test/API/python_api/section/TestSectionAPI.py", line 67, in test_compressed_section_data self.assertEqual(section_data, [0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90]) AssertionError: Lists differ: [] != [32, 48, 64, 80, 96, 112, 128, 144] As it failed to decode the compressed section.
2025-12-15[lldb][test] Xfail 3 backtrace related tests on Windows on Arm (#172300)David Spickett1-0/+2
Since we updated our buildbot setup, these have been failing. Ignore them until we have time to find the real problem, which is something to do with failing to backtrace, or missing debug info when we do.
2025-12-04[lldb] Add support for synthetic LineEntry objects without valid address ↵Med Ismail Bennani1-0/+144
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-03Revert "[LLDB] Add SBFrameExtensions Tests (#169236)" (#170555)Vladislav Dzhidzhoev3-570/+0
This reverts commit 5e5937c3d2e493a48837b2bdf179a53e8b80a66a, since the added test fails on the `lldb-x86_64-win` buildbot. https://lab.llvm.org/buildbot/#/builders/211/builds/4246
2025-12-02[LLDB] Add SBFrameExtensions Tests (#169236)Ahmed Nour3-0/+570
Fixes part of https://github.com/llvm/llvm-project/issues/168920
2025-12-02[lldb] Fix GetExpressionPath for vector registers (#169210)Ebuka Ezike3-0/+77
Vector registers have synthetic values for display purposes. This causes SBValue::GetExpressionPath to dispatch to ValueObjectSynthetic instead of ValueObjectRegister, producing incorrect results. Fixes #147144
2025-11-26[lldb] [scripting bridge] 167388 chore: add api to return arch name for ↵n2h91-0/+18
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-14[lldb] Add a test for capturing stdout/stderr from Python commands (#168138)Jonas Devlieghere1-0/+47
2025-11-06[LLDB] Fix debuginfo ELF files overwriting Unified Section List (#166635)Jacob Lalonde7-0/+475
Recently I've been deep diving ELF cores in LLDB, aspiring to move LLDB closer to GDB in capability. One issue I encountered was a system lib losing it's unwind plan when loading the debuginfo. The reason for this was the debuginfo has the eh_frame section stripped and the main executable did not. The root cause of this was this line in [ObjectFileElf](https://github.com/llvm/llvm-project/blob/163933e9e7099f352ff8df1973f9a9c3d7def6c5/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp#L1972) ``` // For eTypeDebugInfo files, the Symbol Vendor will take care of updating the // unified section list. if (GetType() != eTypeDebugInfo) unified_section_list = *m_sections_up; ``` This would always be executed because CalculateType can never return an eTypeDebugInfo ``` ObjectFile::Type ObjectFileELF::CalculateType() { switch (m_header.e_type) { case llvm::ELF::ET_NONE: // 0 - No file type return eTypeUnknown; case llvm::ELF::ET_REL: // 1 - Relocatable file return eTypeObjectFile; case llvm::ELF::ET_EXEC: // 2 - Executable file return eTypeExecutable; case llvm::ELF::ET_DYN: // 3 - Shared object file return eTypeSharedLibrary; case ET_CORE: // 4 - Core file return eTypeCoreFile; default: break; } return eTypeUnknown; } ``` This makes sense as there isn't a explicit sh_type to denote that this file is a debuginfo. After some discussion with @clayborg and @GeorgeHuyubo we settled on joining the exciting unified section list with whatever new sections were being added. Adding each new unique section, or taking the section with the maximum file size. We picked this strategy to pick the section with the most information. In most scenarios, LHS should be SHT_NOBITS and RHS would be SHT_PROGBITS. Here is a diagram documenting the existing vs proposed new way. <img width="1666" height="1093" alt="image" src="https://github.com/user-attachments/assets/73ba9620-c737-439e-9934-ac350d88a3b5" />
2025-11-05[lldb] Introduce SBFrameList for lazy frame iteration (#166651)Med Ismail Bennani3-0/+219
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 Ezike2-0/+6
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-13[lldb][swig] Support SBFileSpec::GetPath (#162964)Wanyi1-1/+1
# Summary `SBFileSpec::GetPath(char *dst_path, size_t dst_len)` contains `char*` type argument. Need to handle this for python. Fortunately there're already similar definitions we can reuse. # Test Plan Start the freshly built lldb and run the following code ``` $ lldb (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> debugger = lldb.SBDebugger.Create() >>> debugger.SetAsync (False) >>> target = debugger.CreateTarget("~/tmp/hello") >>> target.IsValid() True >>> breakpoint = target.BreakpointCreateByName('main', 'hello') >>> breakpoint.GetNumLocations() 1 >>> process = target.LaunchSimple (None, None, os.getcwd()) >>> process.IsValid() True >>> thread = process.GetThreadAtIndex(0) >>> frame = thread.GetFrameAtIndex(0) >>> line = frame.GetLineEntry() # Important line below >>> file = line.GetFileSpec().GetPath(1024) # Important line above >>> print(file) /home/wanyi/tmp/main.cpp ``` ## Before this change ``` $ lldb (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> debugger = lldb.SBDebugger.Create() >>> debugger.SetAsync (False) >>> target = debugger.CreateTarget("~/tmp/hello") >>> target.IsValid() True >>> breakpoint = target.BreakpointCreateByName('main', 'hello') >>> breakpoint.GetNumLocations() 1 >>> process = target.LaunchSimple (None, None, os.getcwd()) >>> process.IsValid() True >>> thread = process.GetThreadAtIndex(0) >>> frame = thread.GetFrameAtIndex(0) >>> line = frame.GetLineEntry() >>> file = line.GetFileSpec().GetPath(1024) Traceback (most recent call last): File "<console>", line 1, in <module> TypeError: SBFileSpec.GetPath() missing 1 required positional argument: 'dst_len' >>> print(file) Traceback (most recent call last): File "<console>", line 1, in <module> NameError: name 'file' is not defined ```
2025-10-13[lldb] Fix TypeSystemClang::GetBasicTypeEnumeration for 128-bit int types ↵Matej Košík1-0/+8
(#162278) When we take the following C program: ``` int main() { return 0; } ``` and create a statically-linked executable from it: ``` clang -static -g -o main main.c ``` Then we can observe the following `lldb` behavior: ``` $ lldb (lldb) target create main Current executable set to '.../main' (x86_64). (lldb) breakpoint set --name main Breakpoint 1: where = main`main + 11 at main.c:2:3, address = 0x000000000022aa7b (lldb) process launch Process 3773637 launched: '/home/me/tmp/built-in/main' (x86_64) Process 3773637 stopped * thread #1, name = 'main', stop reason = breakpoint 1.1 frame #0: 0x000000000022aa7b main`main at main.c:2:3 1 int main() { -> 2 return 0; 3 } (lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("__int128").size 0 (lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("unsigned __int128").size 0 (lldb) quit ``` The value return by the `SBTarget::FindFirstType` method is wrong for the `__int128` and `unsigned __int128` basic types. The proposed changes make the `TypeSystemClang::GetBasicTypeEnumeration` method consistent with `gcc` and `clang` C [language extension](https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html) related to 128-bit integer types as well as with the `BuiltinType::getName` method in the LLVM codebase itself. When the above change is applied, the behavior of the `lldb` changes in the following (desired) way: ``` $ lldb (lldb) target create main Current executable set to '.../main' (x86_64). (lldb) breakpoint set --name main Breakpoint 1: where = main`main + 11 at main.c:2:3, address = 0x000000000022aa7b (lldb) process launch Process 3773637 launched: '/home/me/tmp/built-in/main' (x86_64) Process 3773637 stopped * thread #1, name = 'main', stop reason = breakpoint 1.1 frame #0: 0x000000000022aa7b main`main at main.c:2:3 1 int main() { -> 2 return 0; 3 } (lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("__int128").size 16 (lldb) script lldb.debugger.GetSelectedTarget().FindFirstType("unsigned __int128").size 16 (lldb) quit ``` --------- Co-authored-by: Matej Košík <matej.kosik@codasip.com>
2025-10-10[lldb][Expression] Emit a 'Note' diagnostic that indicates the language used ↵Michael Buch1-11/+39
for expression evaluation (#161688) Depends on: * https://github.com/llvm/llvm-project/pull/162050 Since it's a 'Note' diagnostic it would only show up when expression evaluation actually failed. This helps with expression evaluation failure reports in mixed language environments where it's not quite clear what language the expression ran as. It may also reduce confusion around why the expression evaluator ran an expression in a language it wasn't asked to run (a softer alternative to what I attempted in https://github.com/llvm/llvm-project/pull/156648). Here are some example outputs: ``` # Without target (lldb) expr blah note: Falling back to default language. Ran expression as 'Objective C++'. # Stopped in target (lldb) expr blah note: Ran expression as 'C++14'. (lldb) expr -l objc -- blah note: Expression evaluation in pure Objective-C not supported. Ran expression as 'Objective C++'. (lldb) expr -l c -- blah note: Expression evaluation in pure C not supported. Ran expression as 'ISO C++'. (lldb) expr -l c++14 -- blah note: Ran expression as 'C++14' (lldb) expr -l c++20 -- blah note: Ran expression as 'C++20' (lldb) expr -l objective-c++ -- blah note: Ran expression as 'Objective C++' (lldb) expr -l D -- blah note: Expression evaluation in D not supported. Falling back to default language. Ran expression as 'Objective C++'. ``` I didn't put the diagnostic on the same line as the inline diagnostic for now because of implementation convenience, but if reviewers deem that a blocker I can take a stab at that again. Also, other language plugins (namely Swift), won't immediately benefit from this and will have to emit their own diagnistc. I played around with having a virtual API on `UserExpression` or `ExpressionParser` that will be called consistently, but by the time we're about to parse the expression we are already several frames deep into the plugin. Before (and at the beginning of) the generic `UserExpression::Parse` call we don't have enough information to notify which language we're going to parse in (at least for the C++ plugin). rdar://160297649 rdar://159669244
2025-10-07[lldb] Add support for unique target ids (#160736)Janet Yang1-0/+147
### 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-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-04[lldb] Reland: Add Pythonic API to SBStructuredData extension (#156771)Dave Lee1-26/+79
* Adds `dynamic` property to automatically convert `SBStructuredData` instances to the associated Python type (`str`, `int`, `float`, `bool`, `NoneType`, etc) * Implements `__getitem__` for Pythonic array and dictionary subscripting * Subscripting return the result of the `dynamic` property * Updates `__iter__` to support dictionary instances (supporting `for` loops) * Adds `__str__`, `__int__`, and `__float__` With these changes, these two expressions are equal: ```py data["name"] == data.GetValueForKey("name").GetStringValue(1024) ``` **Note**: Unlike the original commit (#155061), this re-commit removes the `__bool__` implementation, which broke crashlog. Somewhere in the crashlog execution, it depends on `__bool__` meaning only `IsValid()`. Additionally did some cleanup in TestStructuredDataAPI.py.
2025-09-04[lldb] Add issue no to xfail decorators in TestGetBaseName (#155939)Muhammad Omair Javaid1-1/+4
TestGetBaseName.py is currently marked as an expected failure on Windows because SBFunction::GetBaseName() and SBSymbol::GetBaseName() don’t yet handle MSVC-style mangling. This patch updates the @expectedFailureAll decorator to include a reference to https://github.com/llvm/llvm-project/issues/156861
2025-09-03Revert "[lldb] Add Pythonic API to SBStructuredData extension (#155061)" ↵Dave Lee1-98/+26
(#156728) Reverts #155061 (and #156721) which caused Crashlog shell tests to break.
2025-09-03[lldb] Revert custom __str__ in SBStructuredDataExtensions.i (#156721)Dave Lee1-8/+3
`__str__` was implemented in #155061, however its behavior was limited to only a some kinds of `SBStructuredData`. That was a breaking change, and this change removes that implementation of `__str__`, relying on the existing behavior which calls `GetDescription`.
2025-09-02[lldb] Add Pythonic API to SBStructuredData extension (#155061)Dave Lee1-26/+103
* Adds `dynamic` property to automatically convert `SBStructuredData` instances to the associated Python type (`str`, `int`, `float`, `bool`, `NoneType`, etc) * Implements `__getitem__` for Pythonic array and dictionary subscripting * Subscripting return the result of the `dynamic` property * Updates `__iter__` to support dictionary instances (supporting `for` loops) * Adds conversion to `str`, `int`, and `float` * Adds Pythonic `bool` conversion With these changes, these two expressions are equal: ```py data["name"] == data.GetValueForKey("name").GetStringValue(1024) ``` Additionally did some cleanup in TestStructuredDataAPI.py.
2025-09-01[lldb][test] Mark TestGetBaseName.py as expected failure on WindowsMuhammad Omair Javaid1-0/+1
TestGetBaseName.py introduced in PR #155939 is failing on windows LLDB bots. This patch adds @expectedFailureAll(oslist=["windows"]) decorator to mark it as an expected failure on Windows to make buildbots green while the underlying issue is investigated. (see: https://lab.llvm.org/buildbot/#/builders/141/builds/11176).
2025-08-28[lldb] Add SBFunction::GetBaseName() & SBSymbol::GetBaseName() (#155939)Jonas Devlieghere3-0/+55
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-21[lldb/API] Add setters to SBStructuredData (#154445)Med Ismail Bennani1-1/+46
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-19[LLDB] added getName method in SBModule (#150331)barsolo20005-1/+73
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-18Decent to Descent (#154040)LauraElanorJones1-1/+1
[lldb] Rename RecursiveDecentFormatter to RecursiveDescentFormatter (NFC)
2025-08-13[lldb][test] Make TestFindRangesInMemory.py more robust (#152817)Igor Kudrin1-13/+20
`GetHeapRanges()` could return two overlapping ranges because it did not check whether `heap_pointer1` lies within the range returned for `heap_pointer2`. This could result in a test failure in `test_find_ranges_in_memory_two_matches` when `process.FindRangesInMemory()` returned 3 instead of 2. The patch ensures that `GetHeapRanges()` returns either two non-overlapping ranges or one range covering both heap pointers. The issue was probably introduced in #111951
2025-08-11[lldb] Guard SBFrame/SBThread methods against running processes (#152020)Felipe de Azevedo Piovezan1-1/+3
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-07-23[lldb][SBType] GetBasicType to unwrap canonical type (#149112)Michael Buch3-0/+44
`SBType::GetBasicType` fails on typedefs to primitive types. The docs for `GetBasicType` state: ``` Returns the BasicType value that is most appropriate to this type ``` But, e.g., for `uint64_t` this would currently return `eBasicTypeInvalid`. `TypeSystemClang::GetBasicTypeEnumeration` (which is what `SBType::GetBasicType` uses) doesn't see through typedefs. Inside LLDB we almost always call `GetBasicTypeEnumeration` on the canonical type. In the cases we don't I suspect those were just subtle bugs. This patch gets the canonical type inside of `GetBasicTypeEnumeration` instead. rdar://155829208
2025-07-18[LLDB] Fix Memory64 BaseRVA, move all non-stack memory to Mem64. (#146777)Jacob Lalonde1-0/+43
### Context Over a year ago, I landed support for 64b Memory ranges in Minidump (#95312). In this patch we added the Memory64 list stream, which is effectively a Linked List on disk. The layout is a sixteen byte header and then however many Memory descriptors. ### The Bug This is a classic off-by one error, where I added 8 bytes instead of 16 for the header. This caused the first region to start 8 bytes before the correct RVA, thus shifting all memory reads by 8 bytes. We are correctly writing all the regions to disk correctly, with no physical corruption but the RVA is defined wrong, meaning we were incorrectly reading memory ![image](https://github.com/user-attachments/assets/049ef55d-856c-4f3c-9376-aeaa3fe8c0e1) ### Why wasn't this caught? One problem we've had is forcing Minidump to actually use the 64b mode, it would be a massive waste of resources to have a test that actually wrote >4.2gb of IO to validate the 64b regions, and so almost all validation has been manual. As a weakness of manual testing, this issue is psuedo non-deterministic, as what regions end up in 64b or 32b is handled greedily and iterated in the order it's laid out in /proc/pid/maps. We often validated 64b was written correctly by hexdumping the Minidump itself, which was not corrupted (other than the BaseRVA) ![image](https://github.com/user-attachments/assets/b599e3be-2d59-47e2-8a2d-75f182bb0b1d) ### Why is this showing up now? During internal usage, we had a bug report that the Minidump wasn't displaying values. I was unable to repro the issue, but during my investigation I saw the variables were in the 64b regions which resulted in me identifying the bug. ### How do we prevent future regressions? To prevent regressions, and honestly to save my sanity for figuring out where 8 bytes magically came from, I've added a new API to SBSaveCoreOptions. ```SBSaveCoreOptions::GetMemoryRegionsToSave()``` The ability to get the memory regions that we intend to include in the Coredump. I added this so we can compare what we intended to include versus what was actually included. Traditionally we've always had issues comparing regions because Minidump includes `/proc/pid/maps` and it can be difficult to know what memoryregion read failure was a genuine error or just a page that wasn't meant to be included. We are also leveraging this API to choose the memory regions to be generated, as well as for testing what regions should be bytewise 1:1. After much debate with @clayborg, I've moved all non-stack memory to the Memory64 List. This list doesn't incur us any meaningful overhead and Greg originally suggested doing this in the original 64b PR. This also means we're exercising the 64b path every single time we save a Minidump, preventing regressions on this feature from slipping through testing in the future. Snippet produced by [minidump.py](https://github.com/clayborg/scripts) ``` MINIDUMP_MEMORY_LIST: NumberOfMemoryRanges = 0x00000002 MemoryRanges[0] = [0x00007f61085ff9f0 - 0x00007f6108601000) @ 0x0003f655 MemoryRanges[1] = [0x00007ffe47e50910 - 0x00007ffe47e52000) @ 0x00040c65 MINIDUMP_MEMORY64_LIST: NumberOfMemoryRanges = 0x000000000000002e BaseRva = 0x0000000000042669 MemoryRanges[0] = [0x00005584162d8000 - 0x00005584162d9000) MemoryRanges[1] = [0x00005584162d9000 - 0x00005584162db000) MemoryRanges[2] = [0x00005584162db000 - 0x00005584162dd000) MemoryRanges[3] = [0x00005584162dd000 - 0x00005584162ff000) MemoryRanges[4] = [0x00007f6100000000 - 0x00007f6100021000) MemoryRanges[5] = [0x00007f6108800000 - 0x00007f6108828000) MemoryRanges[6] = [0x00007f6108828000 - 0x00007f610899d000) MemoryRanges[7] = [0x00007f610899d000 - 0x00007f61089f9000) MemoryRanges[8] = [0x00007f61089f9000 - 0x00007f6108a08000) MemoryRanges[9] = [0x00007f6108bf5000 - 0x00007f6108bf7000) ``` ### Misc As a part of this fix I had to look at LLDB logs a lot, you'll notice I added `0x` to many of the PRIx64 `LLDB_LOGF`. This is so the user (or I) can directly copy paste the address in the logs instead of adding the hex prefix themselves. Added some SBSaveCore tests for the new GetMemoryAPI, and Docstrings. CC: @DavidSpickett, @da-viper @labath because we've been working together on save-core plugins, review it optional and I didn't tag you but figured you'd want to know
2025-07-17[lldb][test] Adjust TestTypeList.py on Windows with exceptionsDavid Spickett1-1/+6
Since https://github.com/llvm/llvm-project/pull/148691 enabled exceptions when compiling the tests, this test has been failing. Much like was noted there, one of the variables disappeared from the debug info. Giving it a non-zero size and initialising it fixed that.
2025-07-08[LLDB] Add type summaries for MSVC STL strings (#143177)nerix1-1/+0
This PR adds type summaries for `std::{string,wstring,u8string,u16string,u32string}` from the MSVC STL. See https://github.com/llvm/llvm-project/issues/24834 for the MSVC STL issue. The following changes were made: - `dotest.py` now detects if the MSVC STL is available. It does so by looking at the target triple, which is an additional argument passed from Lit. It specifically checks for `windows-msvc` to not match on `windows-gnu` (i.e. MinGW/Cygwin). - (The main part): Added support for summarizing `std::(w)string` from MSVC's STL. Because the type names from the libstdc++ (pre C++ 11) string types are the same as on MSVC's STL, `CXXCompositeSummaryFormat` is used with two entries, one for MSVC's STL and one for libstdc++. With MSVC's STL, `std::u{8,16,32}string` is also handled. These aren't handled for libstdc++, so I put them in `LoadMsvcStlFormatters`.
2025-06-27[lldb] Add class property for the version string (#145974)Jonas Devlieghere1-0/+8
Add a class property for the version string. This allows you to use access the version string through `lldb.SBDebugger.version` instead of having to call `lldb.SBDebugger.GetVersionString()`.
2025-06-23[lldb] Fix SBMemoryRegionInfoListExtensions iter to yield unique refe… ↵Zyn1-2/+23
(#144815)
2025-06-19[lldb] Disable TestTargetWatchAddress on Windows x86_64 (#144779)Dmitry Vasilyev1-0/+10
See #144777 for details.
2025-06-03[lldb] Disable TestTargetWatchAddress.py on Windows x86_64 (#142573)Dmitry Vasilyev1-0/+5
See #142196 and https://github.com/llvm/llvm-zorg/pull/452 for details.
2025-06-02[lldb] Refactor away UB in SBValue::GetLoadAddress (#141799)Pavel Labath1-2/+9
The problem was in calling GetLoadAddress on a value in the error state, where `ValueObject::GetLoadAddress` could end up accessing the uninitialized "address type" by-ref return value from `GetAddressOf`. This probably happened because each function expected the other to initialize it. We can guarantee initialization by turning this into a proper return value. I've added a test, but it only (reliably) crashes if lldb is built with ubsan.
2025-05-27[lldb][NFC] update API tests which skip/expect-fail armJason Molenda5-9/+9
The architectures provided to skipIf / expectedFail are regular expressions (v. _match_decorator_property() in decorators.py so on Darwin systems "arm64" would match the skips for "arm" (32-bit Linux). Update these to "arm$" to prevent this, and also update three tests (TestBuiltinFormats.py, TestCrossDSOTailCalls.py, TestCrossObjectTailCalls.py) that were skipped for arm64 via this behavior, and need to be skipped or they will fail. This was moviated by the new TestDynamicValue.py test which has an expected-fail for arm, but the test was passing on arm64 Darwin resulting in failure for the CIs.
2025-05-27[lldb][test] Skip unamed symbol test on ArmDavid Spickett1-0/+2
Same purpose as https://github.com/llvm/llvm-project/pull/141407, comitting this directly to get the bot green sooner. Co-authored-by: Ely Ronnen <elyronnen@gmail.com>
2025-05-23[lldb] skip unnamed symbol test on windows (#141212)Ely Ronnen1-1/+2
https://lab.llvm.org/buildbot/#/builders/141/builds/8927/steps/6/logs/stdio
2025-05-23[lldb] Change synthetic symbol names to have file address (#138416)Ely Ronnen3-0/+69
* Changes the default synthetic symbol names to contain their file address This is a new PR after the first PR (#137512) was reverted because it didn't update the way unnamed symbols were searched in the symbol table, which relied on the index being in the name. This time also added extra test to make sure the symbol is found as expected
2025-05-20[lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (#140065)Pavel Labath2-0/+37
The motivation here is being (un)able to treat pointer values as an array consistently. This works for pointers to simple/scalar values, but for aggregates, we get a very surprising result: - GetChildAtIndex(x, ??, true) returns the `x` child of the zeroth array member (the one you get by dereferencing the pointer/array) for all `x` which are smaller than the number of children of that value. - for other values of `x`, we get `v[x]`, where `v` is treated like a (C) pointer This patch reimagines this interface so that the value of `true` always treats (pointer and array) values as pointers. For `false`, we always dereference pointers, while in the case of arrays, we only return the values as far as the array bounds will allow. This has the potential to break existing code, but I have a suspicion that code was already broken to begin with, which is why I think this would be better than introducing a new API and keeping the old (and surprising) behavior. If our own test coverage is any indication, breakage should be minimal.
2025-05-13[lldb] Move lldb_enable_attach from test_common to a separate header (#139550)Pavel Labath1-0/+1
test_common is force-included into every compilation, which causes problems when we're compiling assembly code, as we were in #138805. This avoids that as we can include the header only when it's needed.