[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)
Petr Hosek via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 21 16:26:19 PDT 2024
petrhosek wrote:
The `lldb-api :: lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py` test has been failing on our builders with the following error:
```
Script:
--
/b/s/w/ir/x/w/lldb_install/python3/bin/python3 /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env ARCHIVER=/b/s/w/ir/x/w/cipd/bin/llvm-ar --env OBJCOPY=/b/s/w/ir/x/w/cipd/bin/llvm-objcopy --env LLVM_LIBS_DIR=/b/s/w/ir/x/w/llvm_build/./lib --env LLVM_INCLUDE_DIR=/b/s/w/ir/x/w/llvm_build/include --env LLVM_TOOLS_DIR=/b/s/w/ir/x/w/llvm_build/./bin --libcxx-include-dir /b/s/w/ir/x/w/llvm_build/include/c++/v1 --libcxx-include-target-dir /b/s/w/ir/x/w/llvm_build/include/x86_64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /b/s/w/ir/x/w/llvm_build/./lib/x86_64-unknown-linux-gnu --arch x86_64 --build-dir /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex --lldb-module-cache-dir /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /b/s/w/ir/x/w/llvm_build/./bin/lldb --compiler /b/s/w/ir/x/w/llvm_build/./bin/clang --dsymutil /b/s/w/ir/x/w/llvm_build/./bin/dsymutil --llvm-tools-dir /b/s/w/ir/x/w/llvm_build/./bin --lldb-obj-root /b/s/w/ir/x/w/llvm_build/tools/lldb --lldb-libs-dir /b/s/w/ir/x/w/llvm_build/./lib --skip-category=pexpect /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/std-function-recognizer -p TestStdFunctionRecognizer.py
--
Exit Code: 1
Command Output (stdout):
--
lldb version 20.0.0git (https://llvm.googlesource.com/a/llvm-project revision 90556efaa2f5703920cce4a9c0ee36365e15e2ab)
clang revision 90556efaa2f5703920cce4a9c0ee36365e15e2ab
llvm revision 90556efaa2f5703920cce4a9c0ee36365e15e2ab
Skipping the following test categories: ['pexpect', 'dsym', 'gmodules', 'debugserver', 'objc']
--
Command Output (stderr):
--
FAIL: LLDB (/b/s/w/ir/x/w/llvm_build/bin/clang-x86_64) :: test_api (TestStdFunctionRecognizer.LibCxxStdFunctionRecognizerTestCase.test_api)
FAIL: LLDB (/b/s/w/ir/x/w/llvm_build/bin/clang-x86_64) :: test_backtrace (TestStdFunctionRecognizer.LibCxxStdFunctionRecognizerTestCase.test_backtrace)
FAIL: LLDB (/b/s/w/ir/x/w/llvm_build/bin/clang-x86_64) :: test_up_down (TestStdFunctionRecognizer.LibCxxStdFunctionRecognizerTestCase.test_up_down)
======================================================================
FAIL: test_api (TestStdFunctionRecognizer.LibCxxStdFunctionRecognizerTestCase.test_api)
Test that std::function implementation details are skipped
----------------------------------------------------------------------
Traceback (most recent call last):
File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py", line 83, in test_api
self.assertGreater(num_hidden, 0)
AssertionError: 0 not greater than 0
Config=x86_64-/b/s/w/ir/x/w/llvm_build/bin/clang
======================================================================
FAIL: test_backtrace (TestStdFunctionRecognizer.LibCxxStdFunctionRecognizerTestCase.test_backtrace)
Test that std::function implementation details are hidden in bt
----------------------------------------------------------------------
Traceback (most recent call last):
File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py", line 27, in test_backtrace
self.expect(
File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2464, in expect
self.fail(log_msg)
AssertionError: Ran command:
"thread backtrace -u"
Got output:
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
* frame #0: 0x00005593a2b1742a a.out`foo(x=1, y=1) at main.cpp:4:10
frame #1: 0x00005593a2b17839 a.out`decltype(std::declval<int (*&)(int, int)>()(std::declval<int>(), std::declval<int>())) std::__2::__invoke[abi:ne200000]<int (*&)(int, int), int, int>(__f=0x00007ffd0bb64e90, __args=0x00007ffd0bb64e04, __args=0x00007ffd0bb64e00) at invoke.h:149:25
frame #2: 0x00005593a2b17805 a.out`int std::__2::__invoke_void_return_wrapper<int, false>::__call[abi:ne200000]<int (*&)(int, int), int, int>(__args=0x00007ffd0bb64e90, __args=0x00007ffd0bb64e04, __args=0x00007ffd0bb64e00) at invoke.h:216:12
frame #3: 0x00005593a2b177d5 a.out`std::__2::__function::__default_alloc_func<int (*)(int, int), int (int, int)>::operator()[abi:ne200000](this=0x00007ffd0bb64e90, __arg=0x00007ffd0bb64e04, __arg=0x00007ffd0bb64e00) at function.h:210:12
frame #4: 0x00005593a2b1777b a.out`int std::__2::__function::__policy_invoker<int (int, int)>::__call_impl[abi:ne200000]<std::__2::__function::__default_alloc_func<int (*)(int, int), int (int, int)>>(__buf=0x00007ffd0bb64e90, __args=1, __args=1) at function.h:610:12
frame #5: 0x00005593a2b178da a.out`std::__2::__function::__policy_func<int (int, int)>::operator()[abi:ne200000](this=0x00007ffd0bb64e90, __args=0x00007ffd0bb64e54, __args=0x00007ffd0bb64e50) const at function.h:716:12
frame #6: 0x00005593a2b17513 a.out`std::__2::function<int (int, int)>::operator()(this=0x00007ffd0bb64e90, __arg=1, __arg=1) const at function.h:989:10
frame #7: 0x00005593a2b1747b a.out`main(argc=1, argv=0x00007ffd0bb64fb8) at main.cpp:9:10
frame #8: 0x00007f152f39ed0a libc.so.6`__libc_start_main + 234
frame #9: 0x00005593a2b1738a a.out`_start + 42
Expecting regex pattern: "frame.*foo" (was found, matched "frame #0: 0x00005593a2b1742a a.out`foo")
Expecting regex pattern: "frame.*std::__1::__function" (was not found)
Config=x86_64-/b/s/w/ir/x/w/llvm_build/bin/clang
======================================================================
FAIL: test_up_down (TestStdFunctionRecognizer.LibCxxStdFunctionRecognizerTestCase.test_up_down)
Test that std::function implementation details are skipped
----------------------------------------------------------------------
Traceback (most recent call last):
File "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py", line 66, in test_up_down
self.assertLess(i, start_idx - end_idx, "skipped frames")
AssertionError: 7 not less than 7 : skipped frames
Config=x86_64-/b/s/w/ir/x/w/llvm_build/bin/clang
----------------------------------------------------------------------
Ran 3 tests in 3.063s
FAILED (failures=3)
--
```
I think the issue is that the test assumes that the internal ABI namespace is `__1` but that's [not guaranteed](https://github.com/llvm/llvm-project/blob/c557d8520413476221a4f3bf2b7b3fed17681691/libcxx/CMakeLists.txt#L197). For example, in our build we enable the unstable ABI so the namespace is `__2`. There are other projects at Google that use custom namespace. The test should be generalized to match `std::__.*::`.
https://github.com/llvm/llvm-project/pull/104523
More information about the lldb-commits
mailing list