tests: Add Makefile to build debug-info test artifacts
[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
ae1623bb
MJ
11* `ARCH/dwarf_full/libhello_so` (ELF and DWARF)
12* `ARCH/elf_only/libhello_so` (ELF only)
13* `ARCH/build_id/libhello_so` (ELF with separate DWARF via build ID)
14* `ARCH/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug` (DWARF for build ID)
15* `ARCH/debug_link/libhello_so` (ELF with separate DWARF via debug link)
16* `ARCH/debug_link/libhello_so.debug` (DWARF for debug link)
c01dcd34 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
ae1623bb
MJ
29The generated executables were built using a native GNU toolchain on either
30Ubuntu 16.04 or 18.04 depending on the architecture.
c01dcd34 31
ae1623bb 32To regenerate them, you can use the included Makefile or follow these steps:
c01dcd34 33
ae1623bb 34## Generate the object files
c01dcd34 35
ae1623bb
MJ
36 $ gcc -gdwarf -fdebug-prefix-map=$(pwd)=. -fPIC -c -I. tp.c libhello.c
37
38## Combined ELF and DWARF
39
40 $ build_id_prefix=cd
41 $ build_id_suffix=d98cdd87f7fe64c13b6daad553987eafd40cbb
42 $ build_id="$build_id_prefix$build_id_suffix"
43 $ mkdir dwarf_full
44 $ gcc -shared -g -llttng-ust -ldl -Wl,-soname,libhello.so -Wl,--build-id=0x$build_id -o dwarf_full/libhello_so tp.o libhello.o
c01dcd34
AB
45
46## ELF only
47
ae1623bb
MJ
48 $ mkdir elf_only
49 $ objcopy -g dwarf_full/libhello_so elf_only/libhello_so
50 $ objcopy --remove-section=.note.gnu.build-id elf_only/libhello_so
c01dcd34
AB
51
52## ELF and DWARF with Build ID
53
ae1623bb
MJ
54 $ mkdir -p build_id/.build-id/$build_id_prefix
55 $ objcopy --only-keep-debug dwarf_full/libhello_so build_id/.build-id/$build_id_prefix/$build_id_suffix.debug
56 $ objcopy -g dwarf_full/libhello_so build_id/libhello_so
c01dcd34
AB
57
58## ELF and DWARF with Debug Link
59
ae1623bb
MJ
60 $ mkdir debug_link
61 $ objcopy --remove-section=.note.gnu.build-id dwarf_full/libhello_so debug_link/libhello_so
62 $ objcopy --only-keep-debug debug_link/libhello_so debug_link/libhello_so.debug
63 $ objcopy -g debug_link/libhello_so
64 $ cd debug_link && objcopy --add-gnu-debuglink=libhello_so.debug libhello_so && cd ..
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.043449 seconds and 4 git commands to generate.