From 6073533d9b743fcdc94afb87d8b96a8beb2df61a Mon Sep 17 00:00:00 2001 From: Antoine Busque Date: Fri, 22 Apr 2016 11:34:21 -0400 Subject: [PATCH 1/1] Add source and information to regenerate debuginfo-data MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Antoine Busque Signed-off-by: Jérémie Galarneau --- tests/debuginfo-data/README.md | 60 ++++++++++++++++++++++++++++++ tests/debuginfo-data/libhello.c | 50 +++++++++++++++++++++++++ tests/debuginfo-data/libhello.h | 36 ++++++++++++++++++ tests/debuginfo-data/tp.c | 30 +++++++++++++++ tests/debuginfo-data/tp.h | 66 +++++++++++++++++++++++++++++++++ 5 files changed, 242 insertions(+) create mode 100644 tests/debuginfo-data/README.md create mode 100644 tests/debuginfo-data/libhello.c create mode 100644 tests/debuginfo-data/libhello.h create mode 100644 tests/debuginfo-data/tp.c create mode 100644 tests/debuginfo-data/tp.h diff --git a/tests/debuginfo-data/README.md b/tests/debuginfo-data/README.md new file mode 100644 index 00000000..02d6bd34 --- /dev/null +++ b/tests/debuginfo-data/README.md @@ -0,0 +1,60 @@ +debuginfo-data +============== + +This directory contains pre-generated ELF and DWARF files used to test +the debuginfo analysis feature, including lookup of DWARF debugging +information via build ID and debug link methods, as well as the source +files used to generate them. + +The generated files are: + +* `libhello.so` (ELF and DWARF) +* `libhello_elf.so` (ELF only) +* `libhello_build_id.so` (ELF with separate DWARF via build ID) +* `libhello_debug_link.so` (ELF with separate DWARF via debug link) +* `libhello_debug_link.so.debug` (DWARF for debug link) +* `.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug` (DWARF for build ID) + +All files are generated from the four (4) following source files: + +* libhello.c +* libhello.h +* tp.c +* tp.h + +The generated executables were built using a GNU toolchain on an +x86_64 machine. + +To regenerate them, you can use follow these steps: + +## ELF and DWARF + + $ gcc -g -fPIC -c -I. tp.c libhello.c + $ gcc -shared -g -llttng-ust -ldl -Wl,-soname,libhello.so -o libhello.so tp.o libhello.o + +## ELF only + + $ gcc -fPIC -c -I. tp.c libhello.c + $ gcc -shared -llttng-ust -ldl -Wl,-soname,libhello_elf.so -o libhello_elf.so tp.o libhello.o + +## ELF and DWARF with Build ID + + $ gcc -g -fPIC -c -I. tp.c libhello.c + $ 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 + $ mkdir -p .build-id/cd/ + $ objcopy --only-keep-debug libhello_build_id.so .build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug + $ strip -g libhello_build_id.so + +The build ID might not be the same once the executable is regenerated +on your system, so adjust the values in the directory and file names +accordingly. Refer to the GDB documentation for more information: +https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html + +## ELF and DWARF with Debug Link + + $ gcc -g -fPIC -c -I. tp.c libhello.c + $ gcc -shared -g -llttng-ust -ldl -Wl,-soname,libhello_debug_link.so -o libhello_debug_link.so tp.o libhello.o + + $ objcopy --only-keep-debug libhello_debug_link.so libhello_debug_link.so.debug + $ strip -g libhello_debug_link.so + $ objcopy --add-gnu-debuglink=libhello_debug_link.so.debug libhello_debug_link.so diff --git a/tests/debuginfo-data/libhello.c b/tests/debuginfo-data/libhello.c new file mode 100644 index 00000000..95382b55 --- /dev/null +++ b/tests/debuginfo-data/libhello.c @@ -0,0 +1,50 @@ +/* + * libhello.c + * + * Debug Info - Tests + * + * Copyright 2016 Antoine Busque + * + * Author: Antoine Busque + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#define TRACEPOINT_DEFINE +#include "tp.h" + +void foo() +{ + tracepoint(my_provider, my_first_tracepoint, 42, "hello, tracer"); + printf("foo\n"); +} + +void bar() +{ + tracepoint(my_provider, my_first_tracepoint, 57, + "recoltes et semailles"); + printf("bar\n"); +} + +void baz() +{ + tracepoint(my_provider, my_other_tracepoint, 1729); + printf("baz\n"); +} diff --git a/tests/debuginfo-data/libhello.h b/tests/debuginfo-data/libhello.h new file mode 100644 index 00000000..b3f8893e --- /dev/null +++ b/tests/debuginfo-data/libhello.h @@ -0,0 +1,36 @@ +/* + * libhello.h + * + * Debug Info - Tests + * + * Copyright 2016 Antoine Busque + * + * Author: Antoine Busque + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _LIBHELLO_H +#define _LIBHELLO_H + +void foo(); +void bar(); +void baz(); + +#endif /* _LIBHELLO_H */ diff --git a/tests/debuginfo-data/tp.c b/tests/debuginfo-data/tp.c new file mode 100644 index 00000000..e893355f --- /dev/null +++ b/tests/debuginfo-data/tp.c @@ -0,0 +1,30 @@ +/* + * tp.c + * + * Debug Info - Tests + * + * Copyright 2016 Antoine Busque + * + * Author: Antoine Busque + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#define TRACEPOINT_CREATE_PROBES + +#include "tp.h" diff --git a/tests/debuginfo-data/tp.h b/tests/debuginfo-data/tp.h new file mode 100644 index 00000000..1a3660e8 --- /dev/null +++ b/tests/debuginfo-data/tp.h @@ -0,0 +1,66 @@ +/* + * tp.h + * + * Debug Info - Tests + * + * Copyright 2016 Antoine Busque + * + * Author: Antoine Busque + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER my_provider + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./tp.h" + +#if !defined(_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TP_H + +#include + +TRACEPOINT_EVENT( + my_provider, + my_first_tracepoint, + TP_ARGS( + int, my_integer_arg, + char*, my_string_arg + ), + TP_FIELDS( + ctf_string(my_string_field, my_string_arg) + ctf_integer(int, my_integer_field, my_integer_arg) + ) +) + +TRACEPOINT_EVENT( + my_provider, + my_other_tracepoint, + TP_ARGS( + int, my_int + ), + TP_FIELDS( + ctf_integer(int, some_field, my_int) + ) +) + +#endif /* _TP_H */ + +#include -- 2.34.1