Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test client that links statically and dynamically to a library
This shows that we somehow don't properly resolve the inlined frame for the call to `foo` and instead only show `bar`. But this seems to affect all tools, including perf and addr2line and happens even in debug builds: ``` cpp-libs 73106 [005] 7235.260003: 120673 cycles: 15c2 std::generate_canonical<double, 53ul, std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul> >+0x192 (inlined) 15c2 std::__detail::_Adaptor<std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul>, double>::operator()+0x192 (inlined) 15c2 std::uniform_real_distribution<double>::operator()<std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul> >+0x192 (inlined) 15c2 std::uniform_real_distribution<double>::operator()<std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul> >+0x192 (inlined) 15c2 StaticLib::bar+0x192 (/home/milian/projects/kdab/hotspot/build-debug/tests/test-clients/cpp-libs/cpp-libs) 1391 main+0x61 (/home/milian/projects/kdab/hotspot/build-debug/tests/test-clients/cpp-libs/cpp-libs) 2d30f __libc_start_call_main+0x7f (/usr/lib/libc.so.6) 2d3c0 __libc_start_main_alias_2+0x80 (inlined) 10c4 _start+0x24 (/home/milian/projects/kdab/hotspot/build-debug/tests/test-clients/cpp-libs/cpp-libs) ``` The first chunk of that is seemingly correct: ``` eu-addr2line -C -f -i -e /home/milian/projects/kdab/hotspot/build-debug/tests/test-clients/cpp-libs/cpp-libs -a 15c2 0x00000000000015c2 double std::generate_canonical<double, 53ul, std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul> >(std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul>&) inlined at /usr/include/c++/11.2.0/bits/random.h:192:38 in StaticLib::bar(unsigned long) const /usr/include/c++/11.2.0/bits/random.tcc:3369:10 std::__detail::_Adaptor<std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul>, double>::operator()() /usr/include/c++/11.2.0/bits/random.h:192:38 double std::uniform_real_distribution<double>::operator()<std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul> >(std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul>&, std::uniform_real_distribution<double>::param_type const&) /usr/include/c++/11.2.0/bits/random.h:1870:19 double std::uniform_real_distribution<double>::operator()<std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul> >(std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul>&) /usr/include/c++/11.2.0/bits/random.h:1861:34 StaticLib::bar(unsigned long) const /home/milian/projects/kdab/hotspot/tests/test-clients/cpp-libs/staticlib.cpp:26:18 ``` But then the call to `StaticLib::foo` is seemingly lost, i.e.: ``` $ objdump -S cpp-libs ... 1388: 48 89 44 24 20 mov %rax,0x20(%rsp) 138d: e8 3e 03 00 00 call 16d0 <StaticLib::foo() const> { return _M_insert(__f); } 1392: 48 8d 3d e7 1c 00 00 lea 0x1ce7(%rip),%rdi # 3080 <std::cout@GLIBCXX_3.4> 1399: e8 82 fc ff ff call 1020 <std::ostream& std::ostream::_M_insert<double>(double)@plt> { return __ostream_insert(__out, &__c, 1); } ``` The address offset 1391 from the background should be pointing to the `call` instruction at `138d` I guess. But there we only get: ``` $ eu-addr2line -C -f -i -e /home/milian/projects/kdab/hotspot/build-debug/tests/test-clients/cpp-libs/cpp-libs -a 1391 0x0000000000001391 main /home/milian/projects/kdab/hotspot/tests/test-clients/cpp-libs/main.cpp:22:32 ``` The output is the same also for offset `138d`. And even GDB gets it wrong in this case: ``` (gdb) b StaticLib::bar (gdb) c ... #0 StaticLib::bar (this=0x7fffffffc728, max=100000800) at /home/milian/projects/kdab/hotspot/tests/test-clients/cpp-libs/staticlib.cpp:25 #1 0x0000555555555392 in main () at /home/milian/projects/kdab/hotspot/tests/test-clients/cpp-libs/main.cpp:22 ```
- Loading branch information