From: "yamato at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug libdw/30948] New: src/stack doesn't show source inforamtion if the target is compiled with clang
Date: Sun, 08 Oct 2023 17:22:20 +0000 [thread overview]
Message-ID: <bug-30948-10460@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=30948
Bug ID: 30948
Summary: src/stack doesn't show source inforamtion if the
target is compiled with clang
Product: elfutils
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libdw
Assignee: unassigned at sourceware dot org
Reporter: yamato at redhat dot com
CC: elfutils-devel at sourceware dot org
Target Milestone: ---
dwfl_module_getsrc() doesn't work unexpectedly if the target
executable is compiled with clang though it works well with an
executable compiled with gcc.
For testing I used executables built from the following source code (target.c):
static int
f1(void)
{
while (1);
return 0;
}
static int
f0(void)
{
return f1();
}
int main(void)
{
return f0();
}
I made two executables with two compilers.
$ gcc -O0 -g target.c -o target-gcc
$ clang -O0 -g target.c -o target-clang
I run the two executables in background:
$ ./target-gcc &
[2] 2118229
$ ./target-clang &
[3] 2118253
I run src/stack with -s -p options:
For the executable built with gcc, backtrace reported source lines.
$ ./src/stack -s -p 2118229
PID 2118229 - process
TID 2118229:
#0 0x000000000040110a f1
/home/yamato/var/elfutils/tests/target.c:4:9
#1 0x0000000000401115 f0
/home/yamato/var/elfutils/tests/target.c:11:10
#2 0x0000000000401120 main
/home/yamato/var/elfutils/tests/target.c:16:10
#3 0x00007f7d6c823b8a __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58:16
#4 0x00007f7d6c823c4b __libc_start_main@@GLIBC_2.34
../csu/libc-start.c:360:3
#5 0x0000000000401045 _start
For the executable built with clang, backtrace didn't report source lines.
$ ./src/stack -s -p 2118253
PID 2118253 - process
TID 2118253:
#0 0x0000000000401149 f1
#1 0x0000000000401139 f0
#2 0x0000000000401124 main
#3 0x00007f4a84ab5b8a __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58:16
#4 0x00007f4a84ab5c4b __libc_start_main@@GLIBC_2.34
../csu/libc-start.c:360:3
#5 0x0000000000401045 _start
The bt command of Gdb can report them:
$ ./target-clang &
[1] 2116805
[yamato@dev64]~/var/elfutils/tests% pstack 2116805
#0 0x0000000000401149 in f1 () at target.c:4
#1 0x0000000000401139 in f0 () at target.c:11
#2 0x0000000000401124 in main () at target.c:16
Gdb can report the source lines. So I guess clang injected enough information
to the executable.
The versions of the compilers:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu
--enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-13.2.1-20230728/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-offload-defaulted --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20230728 (Red Hat 13.2.1-1) (GCC)
$ clang -v
clang version 16.0.6 (Fedora 16.0.6-3.fc38)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation:
/usr/bin/../lib/gcc/x86_64-redhat-linux/13
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/13
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
The revision of elfutils: 557aa6a4b7b1d678b7c2c3b9aae1dafcc2160c64 (git
commit).
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2023-10-08 17:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-08 17:22 yamato at redhat dot com [this message]
2023-11-02 13:25 ` [Bug libdw/30948] " mark at klomp dot org
2023-11-06 21:21 ` yamato at redhat dot com
2023-11-07 14:43 ` mark at klomp dot org
2024-02-29 22:54 ` amerey at redhat dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-30948-10460@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).