summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/unwind/zeroth_frame
AgeCommit message (Collapse)Author
2024-10-18Revert "Renormalize line endings whitespace only after dccebddb3b80"Luke Drummond
This reverts commit 9d98acb196a40fee5229afeb08f95fd36d41c10a.
2024-10-17Renormalize line endings whitespace only after dccebddb3b80Luke Drummond
Line ending policies were changed in the parent, dccebddb3b80. To make it easier to resolve downstream merge conflicts after line-ending policies are adjusted this is a separate whitespace-only commit. If you have merge conflicts as a result, you can simply `git add --renormalize -u && git merge --continue` or `git add --renormalize -u && git rebase --continue` - depending on your workflow.
2024-07-08Fix flake in TestZerothFrame.py (#96685)Kendal Harland
This test is currently flaky on a local Windows amd64 build. The reason is that it relies on the order of `process.threads` but this order is nondeterministic: If we print lldb's inputs and outputs while running, we can see that the breakpoints are always being set correctly, and always being hit: ```sh runCmd: breakpoint set -f "main.c" -l 2 output: Breakpoint 1: where = a.out`func_inner + 1 at main.c:2:9, address = 0x0000000140001001 runCmd: breakpoint set -f "main.c" -l 7 output: Breakpoint 2: where = a.out`main + 17 at main.c:7:5, address = 0x0000000140001021 runCmd: run output: Process 52328 launched: 'C:\workspace\llvm-project\llvm\build\lldb-test-build.noindex\functionalities\unwind\zeroth_frame\TestZerothFrame.test_dwarf\a.out' (x86_64) Process 52328 stopped * thread #1, stop reason = breakpoint 1.1 frame #0: 0x00007ff68f6b1001 a.out`func_inner at main.c:2:9 1 void func_inner() { -> 2 int a = 1; // Set breakpoint 1 here ^ 3 } 4 5 int main() { 6 func_inner(); 7 return 0; // Set breakpoint 2 here ``` However, sometimes the backtrace printed in this test shows that the process is stopped inside NtWaitForWorkViaWorkerFactory from `ntdll.dll`: ```sh Backtrace at the first breakpoint: frame #0: 0x00007ffecc7b3bf4 ntdll.dll`NtWaitForWorkViaWorkerFactory + 20 frame #1: 0x00007ffecc74585e ntdll.dll`RtlClearThreadWorkOnBehalfTicket + 862 frame #2: 0x00007ffecc3e257d kernel32.dll`BaseThreadInitThunk + 29 frame #3: 0x00007ffecc76af28 ntdll.dll`RtlUserThreadStart + 40 ``` When this happens, the test fails with an assertion error that the stopped thread's zeroth frame's current line number does not match the expected line number. This is because the test is looking at the wrong thread: `process.threads[0]`. If we print the list of threads each time the test is run, we notice that threads are sometimes in a different order, within `process.threads`: ```sh Thread 0: thread #4: tid = 0x9c38, 0x00007ffecc7b3bf4 ntdll.dll`NtWaitForWorkViaWorkerFactory + 20 Thread 1: thread #2: tid = 0xa950, 0x00007ffecc7b3bf4 ntdll.dll`NtWaitForWorkViaWorkerFactory + 20 Thread 2: thread #1: tid = 0xab18, 0x00007ff64bc81001 a.out`func_inner at main.c:2:9, stop reason = breakpoint 1.1 Thread 3: thread #3: tid = 0xc514, 0x00007ffecc7b3bf4 ntdll.dll`NtWaitForWorkViaWorkerFactory + 20 Thread 0: thread #3: tid = 0x018c, 0x00007ffecc7b3bf4 ntdll.dll`NtWaitForWorkViaWorkerFactory + 20 Thread 1: thread #1: tid = 0x85c8, 0x00007ff7130c1001 a.out`func_inner at main.c:2:9, stop reason = breakpoint 1.1 Thread 2: thread #2: tid = 0xf344, 0x00007ffecc7b3bf4 ntdll.dll`NtWaitForWorkViaWorkerFactory + 20 Thread 3: thread #4: tid = 0x6a50, 0x00007ffecc7b3bf4 ntdll.dll`NtWaitForWorkViaWorkerFactory + 20 ``` Use `self.thread()` to consistently select the correct thread, instead. Co-authored-by: kendal <kendal@thebrowser.company>
2023-05-25[NFC][Py Reformat] Reformat python files in lldbJonas Devlieghere
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black` (23.1.0). If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run `git checkout --ours <yourfile>` and then reformat it with black. RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential revision: https://reviews.llvm.org/D151460
2022-08-15[LLDB] Remove __future__ imports from testsDavid Spickett
Not needed now that we require python 3. Reviewed By: kastiglione, JDevlieghere Differential Revision: https://reviews.llvm.org/D131761
2022-06-17[lldb][tests] Automatically call compute_mydir (NFC)Dave Lee
Eliminate boilerplate of having each test manually assign to `mydir` by calling `compute_mydir` in lldbtest.py. Differential Revision: https://reviews.llvm.org/D128077
2020-03-16[lldb] Copy m_behaves_like_zeroth_frame on stack frame updateTatyana Krasnukha
Fix to code from https://reviews.llvm.org/D64993. Field StackFrame::m_behaves_like_zeroth_frame was introduced in commit [1], however that commit hasn't added a copying of the field to UpdatePreviousFrameFromCurrentFrame, therefore the value wouldn't change when updating frames to reflect the current situation. The particular scenario, where this matters is following. Assume we have function main that invokes function func1. We set breakpoint at func1 entry and in main after the func1 call, and do not stop at the main entry. Therefore, when debugger stops for the first time, func1 is frame#0, while main is frame#1, thus m_behaves_like_zeroth_frame is set to 0 for main frame. Execution is resumed, and stops now in main, where it is now frame#0. However while updating the frame object, m_behaves_like_zeroth_frame remains false. This field plays an important role when calculating line information for backtrace: for frame#0, PC is the current line, therefore line information is retrieved for PC, however for all other frames this is not the case - calculated PC is a return-PC, i.e. instruction after the function call line, therefore for those frames LLDB needs to step back by one instruction. Initial implementation did this strictly for frames that have index != 0 (and index is updated properly in UpdatePreviousFrameFromCurrentFrame), but m_behaves_like_zeroth_frame added a capability for middle-of-stack frames to behave in a similar manner. But because current code now doesn't check frame idx, m_behaves_like_zeroth_frame must be set to true for frames with 0 index, not only for frame that behave like one. In the described test case, after stopping in main, LLDB would still consider frame#0 as non-zeroth, and would subtract instruction from the PC, and would report previous like as current line. The error doesn't manifest itself in LLDB interpreter though - it can be reproduced through LLDB-MI and when using SB API, but not when we interpreter command "continue" is executed. Honestly, I didn't fully understand why it works in interpreter, I did found that bug "fixes" itself if I enable DEBUG_STACK_FRAMES in StackFrameList.cpp, because that calls StackFrame::Dump and that calls GetSymbolContext(eSymbolContextEverything), which fills the context of frame on the first breakpoint, therefore it doesn't have to be recalculated (improperly) on a second frame. However, on first breakpoint symbol context is calculated for the "call" line, not the next one, therefore it should be recalculated anyway on a second breakpoint, and it is done correctly, even though m_behaves_like_zeroth_frame is still incorrect, as long as GetSymbolContext(eSymbolContextEverything) has been called. [1] 31e6dbe1c6a6 Fix PC adjustment in StackFrame::GetSymbolContext Differential Revision: https://reviews.llvm.org/D75975 Patch by Anton Kolesov <Anton.Kolesov@synopsys.com>