aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities
AgeCommit message (Collapse)AuthorFilesLines
2025-12-09[lldb] Remove CommandReturnObject::AppendRawError (#171517)Jonas Devlieghere3-3/+5
Remove `CommandReturnObject::AppendRawError` and replace its two uses with `AppendError`, which correctly prefixes the message with `error:`. The comment for the method is outdated and the prefixing is clearly desired in both situations.
2025-12-09[LLDB] Run MSVC STL optional test with PDB (#171486)nerix1-2/+12
Similar to the other PRs, this runs the `std::optional` test with PDB. Since we don't know that variables use typedefs, we check for the full name when testing PDB.
2025-12-09[LLDB] Run MSVC STL (forward-)list test with PDB (#166953)nerix3-0/+5
Since PDB doesn't have template information, we need to get the element type from somewhere else. I'm using the type of `_Myval` in a list node, which holds the element type.
2025-12-09[LLDB] Run MSVC STL smart pointer tests with PDB (#166946)nerix2-3/+23
Runs the `std::shared/unique_ptr` tests with PDB with two changes: - PDB uses the "full" name, so `std::string` is `std::basic_string<char, std::char_traits<char>, std::allocator<char>>` - The type of the pointer inside the shared/unique_ptr isn't the `element_type` typedef
2025-12-08Fix a typo in "breakpoint add file" and add a test (#171206)jimingham1-0/+19
lldbutil.run_to_line_breakpoint had usages that set column breakpoints, so I thought there was coverage of that on the command-line, but actually all the `run_to` utilities use the SB API's, and there weren't any tests of setting file line & column breakpoint through `run_break_set`. So I missed that I had typed the column option `c` - that's taken by `--command`. This patch fixes that typo and adds a CLI test for file + line + column.
2025-12-05[lldb] Add support for PC-less scripted frames (#170805)Med Ismail Bennani4-48/+334
Scripted frames that materialize Python functions or other non-native code are PC-less by design, meaning they don't have valid program counter values. Previously, these frames would display invalid addresses (`0xffffffffffffffff`) in backtrace output. This patch updates `FormatEntity` to detect and suppress invalid address display for PC-less frames, adds fallback to frame methods when symbol context is unavailable, and modifies `StackFrame::GetSymbolContext` to skip PC-based symbol resolution for invalid addresses. The changes enable PC-less frames to display cleanly with proper function names, file paths, and line numbers, and allow for source display of foreign sources (like Python). Includes comprehensive test coverage demonstrating frames pointing to Python source files. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-04[lldb] Add support for synthetic LineEntry objects without valid address ↵Med Ismail Bennani1-0/+14
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-03[lldb] Refactor LookupInfo object to be per-language (#168797)Augusto Noronha1-2/+7
Some months ago, the LookupInfo constructor logic was refactored to not depend on language specific logic, and use languages plugins instead. In this refactor, when the language type is unknown, a single LookupInfo object will handle multiple languages. This doesn't work well, as multiple languages might want to configure the LookupInfo object in different ways. For example, different languages might want to set the m_lookup_name differently from each other, but the previous implementation would pick the first name a language provided, and effectively ignored every other language. Other fields of the LookupInfo object are also configured in incompatible ways. This approach doesn't seem to be a problem upstream, since only the C++/Objective-C language plugins are available, but it broke downstream on the Swift fork, as adding Swift to the list of default languages when the language type is unknown breaks C++ tests. This patch makes it so instead of building a single LookupInfo object for multiple languages, one LookupInfo object is built per language instead. rdar://159531216
2025-12-03[lldb] add libstdcpp span formatter (#168705)Ebuka Ezike1-7/+19
2025-12-02[lldb/test] Add missing import for decorator (NFC)Med Ismail Bennani2-2/+3
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02[lldb/test] Skip ScriptedFrameProviders tests on arm32 (NFC)Med Ismail Bennani2-2/+2
It looks like the providers don't get loaded on arm32 bots: https://github.com/llvm/llvm-project/issues/170412 Skipping for now since I don't have access to a machine to investigate it. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02[lldb/test] Add missing import for decorator (NFC)Med Ismail Bennani1-0/+1
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02[lldb/test] XFAIL TestFrameProviderCircularDependency.py on WindowsMed Ismail Bennani1-0/+1
This patch disables TestFrameProviderCircularDependency.py on Windows since the scripted frame provider uses SBTarget.FindFunctions which doesn't seem to be working (according to TestTargetAPI.test_find_functions). Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02[lldb/test] Fix scripted frame provider tests on ARM32Med Ismail Bennani1-4/+13
On ARM32, FixCodeAddress unconditionally clears bit 0 (the Thumb bit) from all code addresses, including synthetic frame PCs. This causes test failures where synthetic PCs like 0xFFFF and 0xDEADBEEF become 0xFFFE and 0xDEADBEEE respectively. This adjusts the tests to expect the modified PC values on ARM32. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-12-02Reland "[lldb] Introduce ScriptedFrameProvider for real threads (#161870)" ↵users/pranavk/bazel-fix-159173-1764801865Med Ismail Bennani8-0/+939
(#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-01[lldb] Fix a bug when disabling the statusline. (#169127)Jonas Devlieghere1-2/+4
Currently, disabling the statusline with `settings set show-statusline false` leaves LLDB in a broken state. The same is true when trying to toggle the setting again. The issue was that setting the scroll window to 0 is apparently not identical to setting it to the correct number of rows, even though some documentation online incorrectly claims so. Fixes #166608
2025-11-20[lldb] Fix a test if hardware breakpoints are not supported (#168813)Igor Kudrin1-20/+11
If `HardwareBreakpointTestBase.supports_hw_breakpoints()` returns False, `SimpleHWBreakpointTest.does_not_support_hw_breakpoints()` returns None, so the test runs and fails. However, it should be skipped instead. The test was added in #146602, while `supports_hw_breakpoints()` was changed in #146609, which was landed earlier despite having a bigger number.
2025-11-19[lldb][test] Correctly skip a test on a 32-bit target (#168631)Igor Kudrin1-1/+1
The test was added in #147252. On a 32-bit target, it fails with error: ``` File "...\TestDataFormatterLibcxxInvalidString.py", line 23, in test self.skip() ^^^^^^^^^ AttributeError: 'LibcxxInvalidStringDataFormatterTestCase' object has no attribute 'skip' ```
2025-11-13[lldb] Add libstdcpp initializer_list formatter (#167515)Ebuka Ezike2-3/+14
Make the existing libc++ formatter generic Add initializer_list summary provider. Add test for `libstdcpp`
2025-11-12Revert "[lldb] Introduce ScriptedFrameProvider for real threads" (#167662)Michael Buch4-573/+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[libunwind] Fix execution flow imbalance when using C++ Exceptions (#165066)Med Ismail Bennani3-0/+228
2025-11-11[lldb] Introduce ScriptedFrameProvider for real threads (#161870)Med Ismail Bennani4-0/+573
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-11[lldb][test] Fix ThreadStepUntilAPI.pyDavid Spickett1-0/+1
After #167359 / 95db31e7f69e7008f0c570ed30d54d1e418e10f2. A fix was attempted in #167423 but was not quite enough. From what I could understand, in v1 format you have to specify all the basic blocks. Where before !call_me implied they were all cold (I think, very shaky understanding here). For this test we want to see blocks like call_me/foo/call_me. So adding a line for block 1 fixes the tests. It could produce more blocks at some point but I think as long as foo is within two of them, it'll be fine.
2025-11-10[LLDB] Fix lldb failure caused by 95db31e7f6. (#167423)Rahman Lavaee1-1/+3
2025-11-10[lldb] Fix TestLocationsAfterRebuild test (#167402)GeorgeHuyubo1-4/+21
After commit fce58897ce82 enabled the locate_module callback for main executables, the TestLocationsAfterRebuild.py test started failing on remote platforms. The test was hardcoded to expect breakpoint location "1.3" to exist after three rebuilds, but the new module loading behavior changed how breakpoint locations are managed. This patch fixes the test by: - Removing the @skipIfRemote decorator to re-enable testing on remote platforms - Dynamically querying the actual number of breakpoint locations instead of assuming a specific count - Using loc.GetID() to get actual location IDs rather than assuming sequential IDs (1, 2, 3) - Iterating through all valid locations and verifying each can be disabled/enabled The fix maintains the original test intent (validating that breakpoint location IDs remain valid after rebuilds) while adapting to the new module loading behavior where the number and IDs of locations may vary across platforms. Co-authored-by: George Hu <georgehuyubo@gmail.com>
2025-11-10[lldb] Disable TestLocationsAfterRebuild for remote targets (#167239)Dmitry Vasilyev1-1/+2
#160199 broke buildbots `lldb-remote-linux-ubuntu` and `lldb-remote-linux-win`. This patch must make these buildbots green for now.
2025-11-07[lldb] Correctly detach (rather than kill) when connecting with gdb-remote ↵Jonas Devlieghere1-0/+67
(#166869) We weren't setting `m_should_detach` when going through the `DoConnectRemote` code path. This meant that when you would attaches to a remote process with `gdb-remote <port>` and use Ctrl+D, it would kill the process instead of detach from it. rdar://156111423
2025-11-07[LLDB] Run MSVC STL string(-view) tests with PDB (#166833)nerix4-69/+122
PDB doesn't include the typedefs for types, so all types use their full name. For `std::string` and friends, this means they show up as `std::basic_string<char, std::char_traits<char>, std::allocator<char>>`. This PR updates the `std::{,w,u8,u16,u32}string(_view)` tests to account for this and runs them with PDB.
2025-11-06[LLDB] Run working STL data formatter tests with PDB (#166812)nerix6-0/+12
This enables testing with PDB for all tests that don't require any changes to pass. I ran the `lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic` tests locally and they passed.
2025-10-31[LLDB][NativePDB] Estimate symbol sizes (#165727)nerix1-4/+3
In #165604, a test was skipped on Windows, because the native PDB plugin didn't set sizes on symbols. While the test isn't compiled with debug info, it's linked with `-gdwarf`, causing a PDB to be created on Windows. This PDB will only contain the public symbols (written by the linker) and section information. The symbols themselves don't have a size, however the DIA SDK sets a size for them. It seems like, for these data symbols, the size given from DIA is the distance to the next symbol (or the section end). This PR implements the naive approach for the native plugin. The main difference is in function/code symbols. There, DIA searches for a corresponding `S_GPROC32` which have a "code size" that is sometimes slightly smaller than the difference to the next symbol.
2025-10-30[NFCI][lldb][test] Fix mismatched C/C++ substitutions (#165773)Raul Tambre1-4/+4
Most of the cases were where a C++ file was being compiled with the C substitution. There were a few cases of the opposite though. LLDB seems to be the only real culprit in the LLVM codebase for these mismatches. Rest of the LLVM presumably sticks at least language-specific options in the common substitutions making the mistakes immediately apparent. I found these by using Clang frontend configuration files containing language-specific options for both C and C++ (e.g. `-std=c2y` and `-std=c++26`).
2025-10-30[lldb][test] Fix libc++ API tests on older Clang versionsMichael Buch1-0/+2
Both of these fail on our Clang-19 macOS bots.
2025-10-29[LLDB] Skip TestMultipleSlides.py on Windows (#165604)nerix1-0/+4
After the default PDB plugin changed to the native one (#165363), this test failed, because it uses the size of public symbols and the native plugin sets the size to 0 (as PDB doesn't include this information explicitly). A PDB was built because the final executable in that test was linked with `-gdwarf`.
2025-10-27[lldb] Fix TestVTableValue.py test_overwrite_vtable test (#164910)Daniel Sanders1-0/+6
Some machines have read-only vtables but this test expects to overwrite them. Use -no_data_const to ensure the vtable is writable
2025-10-21[lldb][test] Fix TestEmptyFuncThreadStepOut.py (#161788)Igor Kudrin2-5/+24
The test did not work as intended when the empty function `done()` contained prologue/epilogue code, because a breakpoint was set before the last instruction of the function, which caused the test to pass even with the fix from #126838 having been reverted. The test is intended to check a case when a breakpoint is set on a return instruction, which is the very last instruction of a function. When stepping out from this breakpoint, there is interaction between `ThreadPlanStepOut` and `ThreadPlanStepOverBreakpoint` that could lead to missing the stop location in the outer frame; the detailed explanation can be found in #126838. On `Linux/AArch64`, the source is compiled into: ``` > objdump -d main.o 0000000000000000 <done>: 0: d65f03c0 ret ``` So, when the command `bt set -n done` from the original test sets a breakpoint to the first instruction of `done()`, this instruction luckily also happens to be the last one. On `Linux/x86_64`, it compiles into: ``` > objdump -d main.o 0000000000000000 <done>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 5d pop %rbp 5: c3 ret ``` In this case, setting a breakpoint by function name means setting it several instructions before `ret`, which does not provoke the interaction between `ThreadPlanStepOut` and `ThreadPlanStepOverBreakpoint`.
2025-10-21[lldb] Add bidirectional packetLog to gdbclientutils.py (#162176)Daniel Sanders4-48/+36
While debugging the tests for #155000 I found it helpful to have both sides of the simulated gdb-rsp traffic rather than just the responses so I've extended the packetLog in MockGDBServerResponder to record traffic in both directions. Tests have been updated accordingly
2025-10-20Fix a potential use-after-free in StopInfoBreakpoint. (#163471)jimingham3-0/+83
StopInfoBreakpoint keeps a BreakpointLocationCollection for all the breakpoint locations at the BreakpointSite that was hit. It is also lives through the time a given thread is stopped, so there are plenty of opportunities for one of the owning breakpoints to get deleted. But BreakpointLocations don't keep their owner Breakpoints alive, so if the BreakpointLocationCollection can live past when some code gets a chance to delete an owner breakpoint, and then you ask that location for some breakpoint information, it will access freed memory. This wasn't a problem before PR #158128 because the StopInfoBreakpoint just kept the BreakpointSite that was hit, and when you asked it questions, it relooked up that list. That was not great, however, because if you hit breakpoints 5 & 6, deleted 5 and then asked which breakpoints got hit, you would just get 6. For that and other reasons that PR changed to storing a BreakpointLocationCollection of the breakpoints that were hit. That's better from a UI perspective but caused this potential problem. I fix it by adding a variant of the BreakpointLocationCollection that also holds onto a shared pointer to the Breakpoints that own the locations that were hit, thus keeping them alive till the StopInfoBreakpoint goes away. This fixed the ASAN assertion. I also added a test that works harder to cause trouble by deleting breakpoints during a stop.
2025-10-13[lldb] Remove obsolete comment in TestCortexMExceptionUnwindJason Molenda1-4/+0
2025-10-13[lldb][API test] TestCortexMExceptionUnwind needs ARM llvm targetJason Molenda1-1/+1
Finally figured out the issue with TestCortexMExceptionUnwind.py failing on some CI. When the llvm is configured without the ARM target enabled, the ARM ABI plugins will not be initialized in lldb, and the unwind engine won't backtrace more than one stack frame. This test requires that the ARM target be enabled in the llvm cmake. Update the decorator to specify that; should be the end of these mysterious fails.
2025-10-13[LLDB] Check type before creating `std::atomic` synthetic children (#163176)nerix3-0/+71
From https://github.com/llvm/llvm-project/pull/163077#issuecomment-3396435083: Currently, `std::atomic<T>` will always use the MSVC STL synthetic children and summary. When inspecting types from other STLs, the output would not show any children. This PR adds a check that `std::atomic` contains `_Storage` to be classified as coming from MSVC's STL.
2025-10-10[lldb][NFC] enable unwind logging in TestCortexMExceptionUnwindJason Molenda1-0/+3
Still seeing a failure on a CI bot with this test that I cannot reproduce locally, but luckily this one CI bot is giving me trace output from the tests. Turn on the unwind log when tracing is enabled, migth get a better hint what's up with this test fail.
2025-10-09[lldb] Cortex-M exception unwind API test cleanupJason Molenda3-22/+30
This test, with a corefile created via yaml2macho-core plus an ObjectFileJSON binary with symbol addresses and ranges, was failing on some machines/CI because the wrong ABI was being picked. The bytes of the functions were not included in the yaml or .json binary. The unwind falls back to using the ABI plugin default unwind plans. We have two armv7 ABIs - the Darwin ABI that always uses r7 as the frame pointer, and the AAPCS ABI which uses r11 code. In reality, armv7 code uses r11 in arm mode, r7 in thumb code. But the ABI ArchDefaultUnwindPlan doesn't have any access to the Target's ArchSpec or Process register state, to determine the correct processor state (arm or thumb). And in fact, on Cortex-M targets, the instructions are always thumb, so the arch default unwind plan (hardcoded r11) is always wrong. The corefile doesn't specify a vendor/os, only a cpu. The object file json specifies the armv7m-apple-* triple, which will select the correct ABI plugin, and the test runs. In some cases, it looks like the Process ABI was fetched after opening the corefile, but before the binary.json was loaded and corrected the Target's ArchSpec. And we never re-evaluate the ABI once it is set, in a Process. When we picked the AAPCS armv7 ABI, we would try to use r11 as frame pointer, and the unwind would stop after one stack frame. I'm stepping around this problem by (1) adding the register bytes of the prologues of every test function in the backtrace, and (2) shortening the function ranges (in binary.json) to specify that the functions are all just long enough for the prologue where execution is stopped. The instruction emulation plugin will fail if it can't get all of the bytes from the function instructions, so I hacked the function sizes in the .json to cover the prologue plus one and changed the addresses in the backtrace to fit within those ranges. [ updated this commit to keep the @skipIfRemote on the API test because two remote CI bots are failing for reasons I don't quite see. ]
2025-10-09Add a scripted way to re-present a stop location (#158128)jimingham5-1/+169
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-08[lldb] Fix stepping out if the return address is not allowed to stop at ↵Igor Kudrin3-0/+49
(#161982) When a thread reaches a breakpoint at the return address set by `ThreadPlanStepOut`, `ThreadPlanStepOut::ShouldStop()` calls `ThreadPlanShouldStopHere::InvokeShouldStopHereCallback()`, and if it returns `false`, `ThreadPlanShouldStopHere::QueueStepOutFromHerePlan()` is called to queue a new plan to skip the corresponding range. Once the new plan finishes, `ThreadPlanStepOut::ShouldStop()` should recheck the stop condition; however, there is no code path in the method that sets `done` to `true`. Before #126838, if `done` was `false`, the method checked if a suitable frame had been reached. After the patch, the check is only performed at a breakpoint; thus, the execution continues. This patch causes `ThreadPlanStepOut::ShouldStop()` to recheck the stop condition when `m_step_out_further_plan_sp` completes.
2025-10-08Revert "[lldb] Cortex-M exception unwind API test cleanup" (#162520)Vladislav Dzhidzhoev3-30/+23
This reverts commit 01a8f9b81870ac9bfe26d80fa3313d56cb8cbe13. The reason is "lldb-remote-linux-win" buildbot breakage (https://lab.llvm.org/buildbot/#/builders/197/builds/9625).
2025-10-07[lldb] Cortex-M exception unwind API test cleanupJason Molenda3-23/+30
This test, with a corefile created via yaml2macho-core plus an ObjectFileJSON binary with symbol addresses and ranges, was failing on some machines/CI because the wrong ABI was being picked. The bytes of the functions were not included in the yaml or .json binary. The unwind falls back to using the ABI plugin default unwind plans. We have two armv7 ABIs - the Darwin ABI that always uses r7 as the frame pointer, and the AAPCS ABI which uses r11 code. In reality, armv7 code uses r11 in arm mode, r7 in thumb code. But the ABI ArchDefaultUnwindPlan doesn't have any access to the Target's ArchSpec or Process register state, to determine the correct processor state (arm or thumb). And in fact, on Cortex-M targets, the instructions are always thumb, so the arch default unwind plan (hardcoded r11) is always wrong. The corefile doesn't specify a vendor/os, only a cpu. The object file json specifies the armv7m-apple-* triple, which will select the correct ABI plugin, and the test runs. In some cases, it looks like the Process ABI was fetched after opening the corefile, but before the binary.json was loaded and corrected the Target's ArchSpec. And we never re-evaluate the ABI once it is set, in a Process. When we picked the AAPCS armv7 ABI, we would try to use r11 as frame pointer, and the unwind would stop after one stack frame. I'm stepping around this problem by (1) adding the register bytes of the prologues of every test function in the backtrace, and (2) shortening the function ranges (in binary.json) to specify that the functions are all just long enough for the prologue where execution is stopped. The instruction emulation plugin will fail if it can't get all of the bytes from the function instructions, so I hacked the function sizes in the .json to cover the prologue plus one and changed the addresses in the backtrace to fit within those ranges.
2025-10-02[lldb][test] Un-XFAIL TestDataFormatterStdUnorderedMap.py for older Clang ↵Michael Buch1-5/+0
versions Fixed in https://github.com/llvm/llvm-project/pull/156033
2025-10-01[lldb][RISCV] Fixed TestSymbolFileJSON for RISC-V (#161497)Georgiy Samoylov1-0/+1
This test failed during testing on the RISC-V target because we couldn't strip the main label from the binary. main is dynamically linked when the -fPIC flag is enabled. The RISC-V ABI requires that executables support loading at arbitrary addresses to enable shared libraries and secure loading (ASLR). In PIC mode, function addresses cannot be hardcoded in the code. Instead, code is generated to load addresses from the GOT/PLT tables, which are initialized by the dynamic loader. The reference to main thus ends up in .dynsym and is dynamically bound. We cannot strip main or any other dynamically linked functions because these functions are referenced indirectly via dynamic linking tables (.plt and .got). Removing these symbols would break the dynamic linking mechanism needed to resolve function addresses at runtime, causing the executable to fail to correctly call them.
2025-10-01[LLDB] Add load core time to target metrics (#161581)Jacob Lalonde2-0/+47
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][test] Refactor and expand TestMemoryRegionDirtyPages.py (#156035)David Spickett1-38/+80
This started as me being annoyed that I got loads of this when inspecting memory regions on Mac: Modified memory (dirty) page list provided, 0 entries. So I thought I should test the existing behaviour, which led me to refactor the existing test to run the same checks on all regions. In the process I realised that the output is not wrong. There is a difference between knowing that no pages are dirty and not knowing anything about dirty pages. We print that there are 0 entries so the user knows that difference. The test case now checks "memory region" output as well as API use. There were also some checks only run on certain regions, like page size, which now run for all of them.