Sample Header Ad - 728x90

How to find which Debian package might include a given source file?

1 vote
1 answer
86 views
I would like to debug my application in gdb, however with full sources of some system libraries I might need. For instance, at a certain point in my debug process in gdb, I arrive at a situation like:
...
(gdb) si
0x00047e28 in std::thread::detach() ()
(gdb) c
Continuing.
...
Thread 1 "myProject" received signal SIGABRT, Aborted.
raise (sig=) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
I am not sure why for std::thread::detach() I do not get a source file suggestion (I have looked it up manually online and found it is in [libstdc++-v3/src/c++11/thread.cc](https://github.com/gcc-mirror/gcc/blob/releases/gcc-6.3.0/libstdc%2B%2B-v3/src/c%2B%2B11/thread.cc)) , but for raise() I do get source file and line ../sysdeps/unix/sysv/linux/raise.c:51. Anyways, for either of these, thread.cc or raise.c, how can I find which *source* package on a given Debian includes them? So I could eventually get them with apt source [package] and provide the path to those files to gdb as described in https://stackoverflow.com/questions/48278881/gdb-complaining-about-missing-raise-c/48287761#48287761 so I could step through source lines (and especially see what underlying function receive as arguments from my code) ... I have tried apt-file, but it seems that it does not work with source packages:
$ apt-file search raise.c
gnulib: /usr/share/gnulib/lib/raise.c
gnulib: /usr/share/gnulib/tests/test-raise.c
` Cool, but none of those look like ../sysdeps/unix/sysv/linux/raise.c?!
$ apt-file search thread.cc
c++-annotations: /usr/share/doc/c++-annotations/examples/yo/threading/examples/functorthread.cc
libglibmm-2.4-doc: /usr/share/doc/libglibmm-2.4-doc/examples/thread/thread.cc
omniorb-doc: /usr/share/doc/omniorb-doc/examples/poa/threading/mainthread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/asan/asan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/lsan/lsan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/msan/msan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/lib/tsan/tests/rtl/tsan_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/test/tsan/race_with_finished_thread.cc
rust-src: /usr/src/rustc-1.24.1/src/libcompiler_builtins/compiler-rt/test/tsan/signal_thread.cc
Ok, apt-file again found something, but all of them seem to be false positives, nothing matches the expected libstdc++-v3/src/c++11/thread.cc. So, is there any way to look up source files like this on Debian? Specifically, I'm on Raspbian Stretch on Raspberry Pi 3B+.
Asked by sdbbs (578 rep)
Mar 19, 2025, 08:25 PM
Last activity: Mar 20, 2025, 12:34 PM