Test debug-info
[babeltrace.git] / tests / debug-info-data / README.md
CommitLineData
2748fb3b 1debug-info-data
c01dcd34
AB
2==============
3
4This directory contains pre-generated ELF and DWARF files used to test
2748fb3b 5the debug info analysis feature, including lookup of DWARF debugging
c01dcd34
AB
6information via build ID and debug link methods, as well as the source
7files used to generate them.
8
9The generated files are:
10
24d3147c
MJ
11* `libhello_so` (ELF and DWARF)
12* `libhello_elf_so` (ELF only)
13* `libhello_build_id_so` (ELF with separate DWARF via build ID)
14* `libhello_debug_link_so` (ELF with separate DWARF via debug link)
15* `libhello_debug_link_so.debug` (DWARF for debug link)
c01dcd34
AB
16* `.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug` (DWARF for build ID)
17
24d3147c
MJ
18We use a suffix of "_so" instead of ".so" since some distributions
19build systems will consider ".so" files as artifacts from a previous
20build that were "left-over" and will remove them prior to the build.
21
c01dcd34
AB
22All files are generated from the four (4) following source files:
23
24* libhello.c
25* libhello.h
26* tp.c
27* tp.h
28
29The generated executables were built using a GNU toolchain on an
30x86_64 machine.
31
32To regenerate them, you can use follow these steps:
33
34## ELF and DWARF
35
36 $ gcc -g -fPIC -c -I. tp.c libhello.c
24d3147c 37 $ gcc -shared -g -llttng-ust -ldl -Wl,-soname,libhello.so -o libhello_so tp.o libhello.o
c01dcd34
AB
38
39## ELF only
40
41 $ gcc -fPIC -c -I. tp.c libhello.c
24d3147c 42 $ gcc -shared -llttng-ust -ldl -Wl,-soname,libhello_elf.so -o libhello_elf_so tp.o libhello.o
c01dcd34
AB
43
44## ELF and DWARF with Build ID
45
46 $ gcc -g -fPIC -c -I. tp.c libhello.c
24d3147c 47 $ gcc -shared -g -llttng-ust -ldl -Wl,-soname,libhello_build_id.so -Wl,--build-id=sha1 -o libhello_build_id_so tp.o libhello.o
c01dcd34 48 $ mkdir -p .build-id/cd/
24d3147c
MJ
49 $ objcopy --only-keep-debug libhello_build_id_so .build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug
50 $ strip -g libhello_build_id_so
c01dcd34
AB
51
52The build ID might not be the same once the executable is regenerated
53on your system, so adjust the values in the directory and file names
54accordingly. Refer to the GDB documentation for more information:
55https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
56
57## ELF and DWARF with Debug Link
58
59 $ gcc -g -fPIC -c -I. tp.c libhello.c
24d3147c 60 $ gcc -shared -g -llttng-ust -ldl -Wl,-soname,libhello_debug_link.so -o libhello_debug_link_so tp.o libhello.o
c01dcd34 61
24d3147c
MJ
62 $ objcopy --only-keep-debug libhello_debug_link_so libhello_debug_link_so.debug
63 $ strip -g libhello_debug_link_so
64 $ objcopy --add-gnu-debuglink=libhello_debug_link_so.debug libhello_debug_link_so
2ca134ef
JD
65
66
67Test program
68------------
69An executable linked to this library can be compiled from the `main.c` source file.
70To compile it, you can do:
71
72 $ ln -s libhello_so libhello.so
73 $ gcc -I. -o test main.c -L. -lhello_build_id -llttng-ust -ldl -Wl,--rpath=.
74
75The trace provided in this directory was generated with lttng-ust running this
76program and stripped to contain only the bare minimum. When running babeltrace
77with the `--debug-info-target-prefix` option pointing to the source tree of
78Babeltrace, the `my_provider:my_first_tracepoint` events should contain this
79information:
80
81 debug_info = { bin = "libhello_so+0x166b", func = "baz+0x9c", src = "libhello.c:20" } }
This page took 0.035239 seconds and 4 git commands to generate.