From: Francis Deslauriers Date: Sat, 13 Jul 2019 14:39:21 +0000 (-0400) Subject: Tests: flt.lttng-utils.debug-info: update debug-info tests X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=d3765576bcdab2fff6360fffc0b77f1021d1a771 Tests: flt.lttng-utils.debug-info: update debug-info tests * Convert the currently disabled Python bindings based debug-info testcase to a `sink.text.details` based test. * Update debug-info test trace using a recently changed `libhello_so` file. * Move all debug-info test files to `tests/plugins/flt.lttng-utils.debug-info/` * Move `tests/data/debug-info/README.md` content to `CONTRIBUTING.adoc` * Update `tests/data/plugins/flt.lttng-utils.debug-info/README.md` to explain how to generate the debug-info test trace. Signed-off-by: Francis Deslauriers Change-Id: I67b8fa729e462137fb3e584c0f1eaf472256e3c9 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1704 Reviewed-by: Philippe Proulx --- diff --git a/tests/Makefile.am b/tests/Makefile.am index ad8ded96..c2bf42a5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -79,10 +79,11 @@ TESTS_PLUGINS = \ if !ENABLE_BUILT_IN_PLUGINS if ENABLE_PYTHON_BINDINGS TESTS_PLUGINS += plugins/src.ctf.fs/query/test_query +endif if ENABLE_DEBUG_INFO -TESTS_PLUGINS += plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info -endif +TESTS_PLUGINS += \ + plugins/flt.lttng-utils.debug-info/test_succeed endif endif diff --git a/tests/data/ctf-traces/succeed/debug-info/channel0_0 b/tests/data/ctf-traces/succeed/debug-info/channel0_0 new file mode 100644 index 00000000..35b979b2 Binary files /dev/null and b/tests/data/ctf-traces/succeed/debug-info/channel0_0 differ diff --git a/tests/data/ctf-traces/succeed/debug-info/metadata b/tests/data/ctf-traces/succeed/debug-info/metadata new file mode 100644 index 00000000..1d0228d7 --- /dev/null +++ b/tests/data/ctf-traces/succeed/debug-info/metadata @@ -0,0 +1,127 @@ +/* CTF 1.8 */ + +typealias integer { size = 8; align = 8; signed = false; } := uint8_t; +typealias integer { size = 16; align = 8; signed = false; } := uint16_t; +typealias integer { size = 32; align = 8; signed = false; } := uint32_t; +typealias integer { size = 64; align = 8; signed = false; } := uint64_t; +typealias integer { size = 64; align = 8; signed = false; } := unsigned long; +typealias integer { size = 5; align = 1; signed = false; } := uint5_t; +typealias integer { size = 27; align = 1; signed = false; } := uint27_t; + +trace { + major = 1; + minor = 8; + uuid = "d2270f5a-7a70-4521-860b-954f054e046b"; + byte_order = le; + packet.header := struct { + uint32_t magic; + uint8_t uuid[16]; + uint32_t stream_id; + uint64_t stream_instance_id; + }; +}; + +env { + hostname = "raton"; + domain = "ust"; + tracer_name = "lttng-ust"; + tracer_major = 2; + tracer_minor = 11; +}; + +clock { + name = "monotonic"; + uuid = "c56ad62a-6a35-4722-9807-d8e0f118a367"; + description = "Monotonic Clock"; + freq = 1000000000; /* Frequency, in Hz */ + /* clock value offset from Epoch is: offset * (1/freq) */ + offset = 1563264475374722151; +}; + +typealias integer { + size = 27; align = 1; signed = false; + map = clock.monotonic.value; +} := uint27_clock_monotonic_t; + +typealias integer { + size = 32; align = 8; signed = false; + map = clock.monotonic.value; +} := uint32_clock_monotonic_t; + +typealias integer { + size = 64; align = 8; signed = false; + map = clock.monotonic.value; +} := uint64_clock_monotonic_t; + +struct packet_context { + uint64_clock_monotonic_t timestamp_begin; + uint64_clock_monotonic_t timestamp_end; + uint64_t content_size; + uint64_t packet_size; + uint64_t packet_seq_num; + unsigned long events_discarded; + uint32_t cpu_id; +}; + +struct event_header_compact { + enum : uint5_t { compact = 0 ... 30, extended = 31 } id; + variant { + struct { + uint27_clock_monotonic_t timestamp; + } compact; + struct { + uint32_t id; + uint64_clock_monotonic_t timestamp; + } extended; + } v; +} align(8); + +struct event_header_large { + enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id; + variant { + struct { + uint32_clock_monotonic_t timestamp; + } compact; + struct { + uint32_t id; + uint64_clock_monotonic_t timestamp; + } extended; + } v; +} align(8); + +event { + name = "lttng_ust_statedump:bin_info"; + id = 0; + stream_id = 0; + loglevel = 13; + fields := struct { + integer { size = 64; align = 8; signed = 0; encoding = none; base = 16; } _baddr; + integer { size = 64; align = 8; signed = 0; encoding = none; base = 10; } _memsz; + string _path; + integer { size = 8; align = 8; signed = 0; encoding = none; base = 10; } _is_pic; + integer { size = 8; align = 8; signed = 0; encoding = none; base = 10; } _has_build_id; + integer { size = 8; align = 8; signed = 0; encoding = none; base = 10; } _has_debug_link; + }; +}; + +stream { + id = 0; + event.header := struct event_header_large; + packet.context := struct packet_context; + event.context := struct { + integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _vpid; + integer { size = 64; align = 8; signed = 0; encoding = none; base = 16; } _ip; + }; +}; + +event { + name = "my_provider:my_first_tracepoint"; + id = 1; + stream_id = 0; + loglevel = 13; + fields := struct { + string _my_string_field; + integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _my_integer_field; + }; +}; + diff --git a/tests/data/debug-info/Makefile b/tests/data/debug-info/Makefile deleted file mode 100644 index 28208052..00000000 --- a/tests/data/debug-info/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -BUILD_ID_PREFIX=cd -BUILD_ID_SUFFIX=d98cdd87f7fe64c13b6daad553987eafd40cbb -BUILD_ID=$(BUILD_ID_PREFIX)$(BUILD_ID_SUFFIX) - -BUILD_DIR ?= build - -OBJS=$(BUILD_DIR)/dwarf_full/libhello_so \ - $(BUILD_DIR)/elf_only/libhello_so \ - $(BUILD_DIR)/build_id/libhello_so \ - $(BUILD_DIR)/debug_link/libhello_so - -all: $(OBJS) - -%.o: %.c - $(CC) -gdwarf -fdebug-prefix-map=$(CURDIR)=. -fPIC -c -I. -o $@ $< - -# Master copy: ELF with DWARF and build-id -$(BUILD_DIR)/dwarf_full/libhello_so: tp.o libhello.o - mkdir -p $(@D) - $(CC) -shared -gdwarf -llttng-ust -ldl -Wl,-soname,libhello.so -Wl,--build-id=0x$(BUILD_ID) -o $@ $^ - -# ELF only, no debug symbols, no build-d -$(BUILD_DIR)/elf_only/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so - mkdir -p $(@D) - objcopy -g $< $@.tmp - objcopy --remove-section=.note.gnu.build-id $@.tmp - mv $@.tmp $@ - -# ELF with external build-id DWARF -$(BUILD_DIR)/build_id/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so - mkdir -p $(@D)/.build-id/$(BUILD_ID_PREFIX) - objcopy --only-keep-debug $< $(@D)/.build-id/$(BUILD_ID_PREFIX)/$(BUILD_ID_SUFFIX).debug - objcopy -g $< $@ - -# ELF with external debug link DWARF -$(BUILD_DIR)/debug_link/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so - mkdir -p $(@D) - objcopy --remove-section=.note.gnu.build-id $< $@.tmp - objcopy --only-keep-debug $@.tmp $(@D)/libhello_so.debug - objcopy -g $@.tmp - cd $(@D) && objcopy --add-gnu-debuglink=libhello_so.debug $(@F).tmp - mv $@.tmp $@ - -clean: - rm -f *.o - -dist-clean: clean - rm -rf $(BUILD_DIR) - -.PHONY: all clean dist-clean diff --git a/tests/data/debug-info/README.md b/tests/data/debug-info/README.md deleted file mode 100644 index 1912194a..00000000 --- a/tests/data/debug-info/README.md +++ /dev/null @@ -1,81 +0,0 @@ -debug-info-data -============== - -This directory contains pre-generated ELF and DWARF files used to test -the debug info 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: - -* `ARCH/dwarf_full/libhello_so` (ELF and DWARF) -* `ARCH/elf_only/libhello_so` (ELF only) -* `ARCH/build_id/libhello_so` (ELF with separate DWARF via build ID) -* `ARCH/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug` (DWARF for build ID) -* `ARCH/debug_link/libhello_so` (ELF with separate DWARF via debug link) -* `ARCH/debug_link/libhello_so.debug` (DWARF for debug link) - -We use a suffix of "_so" instead of ".so" since some distributions -build systems will consider ".so" files as artifacts from a previous -build that were "left-over" and will remove them prior to the build. - -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 native GNU toolchain on either -Ubuntu 16.04 or 18.04 depending on the architecture. - -To regenerate them, you can use the included Makefile or follow these steps: - -## Generate the object files - - $ gcc -gdwarf -fdebug-prefix-map=$(pwd)=. -fPIC -c -I. tp.c libhello.c - -## Combined ELF and DWARF - - $ build_id_prefix=cd - $ build_id_suffix=d98cdd87f7fe64c13b6daad553987eafd40cbb - $ build_id="$build_id_prefix$build_id_suffix" - $ mkdir dwarf_full - $ 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 - -## ELF only - - $ mkdir elf_only - $ objcopy -g dwarf_full/libhello_so elf_only/libhello_so - $ objcopy --remove-section=.note.gnu.build-id elf_only/libhello_so - -## ELF and DWARF with Build ID - - $ mkdir -p build_id/.build-id/$build_id_prefix - $ objcopy --only-keep-debug dwarf_full/libhello_so build_id/.build-id/$build_id_prefix/$build_id_suffix.debug - $ objcopy -g dwarf_full/libhello_so build_id/libhello_so - -## ELF and DWARF with Debug Link - - $ mkdir debug_link - $ objcopy --remove-section=.note.gnu.build-id dwarf_full/libhello_so debug_link/libhello_so - $ objcopy --only-keep-debug debug_link/libhello_so debug_link/libhello_so.debug - $ objcopy -g debug_link/libhello_so - $ cd debug_link && objcopy --add-gnu-debuglink=libhello_so.debug libhello_so && cd .. - - -Test program ------------- -An executable linked to this library can be compiled from the `main.c` source file. -To compile it, you can do: - - $ ln -s libhello_so libhello.so - $ gcc -I. -o test main.c -L. -lhello_build_id -llttng-ust -ldl -Wl,--rpath=. - -The trace provided in this directory was generated with lttng-ust running this -program and stripped to contain only the bare minimum. When running babeltrace -with the `--debug-info-target-prefix` option pointing to the source tree of -Babeltrace, the `my_provider:my_first_tracepoint` events should contain this -information: - - debug_info = { bin = "libhello_so+0x166b", func = "baz+0x9c", src = "libhello.c:20" } } diff --git a/tests/data/debug-info/i386-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/debug-info/i386-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug deleted file mode 100755 index ba371f5d..00000000 Binary files a/tests/data/debug-info/i386-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug and /dev/null differ diff --git a/tests/data/debug-info/i386-linux-gnu/build_id/libhello_so b/tests/data/debug-info/i386-linux-gnu/build_id/libhello_so deleted file mode 100755 index 218e6685..00000000 Binary files a/tests/data/debug-info/i386-linux-gnu/build_id/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/i386-linux-gnu/debug_link/libhello_so b/tests/data/debug-info/i386-linux-gnu/debug_link/libhello_so deleted file mode 100755 index 4dcfdc50..00000000 Binary files a/tests/data/debug-info/i386-linux-gnu/debug_link/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/i386-linux-gnu/debug_link/libhello_so.debug b/tests/data/debug-info/i386-linux-gnu/debug_link/libhello_so.debug deleted file mode 100755 index 1ede7704..00000000 Binary files a/tests/data/debug-info/i386-linux-gnu/debug_link/libhello_so.debug and /dev/null differ diff --git a/tests/data/debug-info/i386-linux-gnu/dwarf_full/libhello_so b/tests/data/debug-info/i386-linux-gnu/dwarf_full/libhello_so deleted file mode 100755 index 08390c8f..00000000 Binary files a/tests/data/debug-info/i386-linux-gnu/dwarf_full/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/i386-linux-gnu/elf_only/libhello_so b/tests/data/debug-info/i386-linux-gnu/elf_only/libhello_so deleted file mode 100755 index 84c31e25..00000000 Binary files a/tests/data/debug-info/i386-linux-gnu/elf_only/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/libhello.c b/tests/data/debug-info/libhello.c deleted file mode 100644 index 95382b55..00000000 --- a/tests/data/debug-info/libhello.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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/data/debug-info/libhello.h b/tests/data/debug-info/libhello.h deleted file mode 100644 index b3f8893e..00000000 --- a/tests/data/debug-info/libhello.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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/data/debug-info/main.c b/tests/data/debug-info/main.c deleted file mode 100644 index e272bc10..00000000 --- a/tests/data/debug-info/main.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * main.c - * - * Debug Info - Main - * - * Copyright 2017 Julien Desfossez - * - * 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 -#include "libhello.h" -#include "tp.h" - -int main() -{ - foo(); - bar(); - baz(); - return 0; -} diff --git a/tests/data/debug-info/powerpc-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/debug-info/powerpc-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug deleted file mode 100755 index 6fa14992..00000000 Binary files a/tests/data/debug-info/powerpc-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug and /dev/null differ diff --git a/tests/data/debug-info/powerpc-linux-gnu/build_id/libhello_so b/tests/data/debug-info/powerpc-linux-gnu/build_id/libhello_so deleted file mode 100755 index 49c62499..00000000 Binary files a/tests/data/debug-info/powerpc-linux-gnu/build_id/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/powerpc-linux-gnu/debug_link/libhello_so b/tests/data/debug-info/powerpc-linux-gnu/debug_link/libhello_so deleted file mode 100755 index 23efdc8b..00000000 Binary files a/tests/data/debug-info/powerpc-linux-gnu/debug_link/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/powerpc-linux-gnu/debug_link/libhello_so.debug b/tests/data/debug-info/powerpc-linux-gnu/debug_link/libhello_so.debug deleted file mode 100755 index a95eed28..00000000 Binary files a/tests/data/debug-info/powerpc-linux-gnu/debug_link/libhello_so.debug and /dev/null differ diff --git a/tests/data/debug-info/powerpc-linux-gnu/dwarf_full/libhello_so b/tests/data/debug-info/powerpc-linux-gnu/dwarf_full/libhello_so deleted file mode 100755 index ef39d51e..00000000 Binary files a/tests/data/debug-info/powerpc-linux-gnu/dwarf_full/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/powerpc-linux-gnu/elf_only/libhello_so b/tests/data/debug-info/powerpc-linux-gnu/elf_only/libhello_so deleted file mode 100755 index d1e7322b..00000000 Binary files a/tests/data/debug-info/powerpc-linux-gnu/elf_only/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/powerpc64le-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/debug-info/powerpc64le-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug deleted file mode 100755 index b419832f..00000000 Binary files a/tests/data/debug-info/powerpc64le-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug and /dev/null differ diff --git a/tests/data/debug-info/powerpc64le-linux-gnu/build_id/libhello_so b/tests/data/debug-info/powerpc64le-linux-gnu/build_id/libhello_so deleted file mode 100755 index f740eb0c..00000000 Binary files a/tests/data/debug-info/powerpc64le-linux-gnu/build_id/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/powerpc64le-linux-gnu/debug_link/libhello_so b/tests/data/debug-info/powerpc64le-linux-gnu/debug_link/libhello_so deleted file mode 100755 index 01e0c6b4..00000000 Binary files a/tests/data/debug-info/powerpc64le-linux-gnu/debug_link/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/powerpc64le-linux-gnu/debug_link/libhello_so.debug b/tests/data/debug-info/powerpc64le-linux-gnu/debug_link/libhello_so.debug deleted file mode 100755 index 86364a3b..00000000 Binary files a/tests/data/debug-info/powerpc64le-linux-gnu/debug_link/libhello_so.debug and /dev/null differ diff --git a/tests/data/debug-info/powerpc64le-linux-gnu/dwarf_full/libhello_so b/tests/data/debug-info/powerpc64le-linux-gnu/dwarf_full/libhello_so deleted file mode 100755 index 3874f118..00000000 Binary files a/tests/data/debug-info/powerpc64le-linux-gnu/dwarf_full/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/powerpc64le-linux-gnu/elf_only/libhello_so b/tests/data/debug-info/powerpc64le-linux-gnu/elf_only/libhello_so deleted file mode 100755 index 067b4720..00000000 Binary files a/tests/data/debug-info/powerpc64le-linux-gnu/elf_only/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/tp.c b/tests/data/debug-info/tp.c deleted file mode 100644 index e893355f..00000000 --- a/tests/data/debug-info/tp.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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/data/debug-info/tp.h b/tests/data/debug-info/tp.h deleted file mode 100644 index 1a3660e8..00000000 --- a/tests/data/debug-info/tp.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 diff --git a/tests/data/debug-info/trace/metadata b/tests/data/debug-info/trace/metadata deleted file mode 100644 index 1388b296..00000000 --- a/tests/data/debug-info/trace/metadata +++ /dev/null @@ -1,91 +0,0 @@ -/* CTF 1.8 */ - -trace { - major = 1; - minor = 8; - uuid = "c4f5ad74-2d9a-4a17-9633-3e9e49d5f773"; - byte_order = le; - packet.header := struct { - integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } magic; - integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } uuid[16]; - integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } stream_id; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } stream_instance_id; - } align(8); -}; - -env { - hostname = "sinkpad"; - domain = "ust"; - tracer_name = "lttng-ust"; - tracer_major = 2; - tracer_minor = 10; -}; - -clock { - name = monotonic; - uuid = "00000000-0000-0000-0000-000000000000"; - description = "Monotonic Clock"; - freq = 1000000000; - precision = 1; - offset_s = 0; - offset = 1497619475540462738; - absolute = TRUE; -}; - -stream { - id = 0; - event.header := struct { - enum : integer { size = 5; align = 1; signed = false; encoding = none; base = decimal; byte_order = le; } { "compact" = 0 ... 30, "extended" = 31 } id; - variant { - struct { - integer { size = 64; align = 1; signed = false; encoding = none; base = decimal; byte_order = le; map = clock.monotonic.value; } timestamp; - } align(1) compact; - struct { - integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } id; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; map = clock.monotonic.value; } timestamp; - } align(8) extended; - } v; - } align(8); - - packet.context := struct { - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; map = clock.monotonic.value; } timestamp_begin; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; map = clock.monotonic.value; } timestamp_end; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } content_size; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } packet_size; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } packet_seq_num; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } events_discarded; - integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } cpu_id; - } align(8); - - event.context := struct { - integer { size = 32; align = 8; signed = true; encoding = none; base = decimal; byte_order = le; } _vpid; - integer { size = 64; align = 8; signed = false; encoding = none; base = hexadecimal; byte_order = le; } _ip; - } align(8); -}; - -event { - name = "lttng_ust_statedump:bin_info"; - id = 0; - stream_id = 0; - loglevel = 13; - fields := struct { - integer { size = 64; align = 8; signed = false; encoding = none; base = hexadecimal; byte_order = le; } _baddr; - integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } _memsz; - string { encoding = UTF8; } _path; - integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } _is_pic; - integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } _has_build_id; - integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = le; } _has_debug_link; - } align(8); -}; - -event { - name = "my_provider:my_first_tracepoint"; - id = 1; - stream_id = 0; - loglevel = 13; - fields := struct { - string { encoding = UTF8; } _my_string_field; - integer { size = 32; align = 8; signed = true; encoding = none; base = decimal; byte_order = le; } _my_integer_field; - } align(8); -}; - diff --git a/tests/data/debug-info/trace/stream_0_0 b/tests/data/debug-info/trace/stream_0_0 deleted file mode 100644 index 582f445a..00000000 Binary files a/tests/data/debug-info/trace/stream_0_0 and /dev/null differ diff --git a/tests/data/debug-info/x86_64-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/debug-info/x86_64-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug deleted file mode 100755 index 41e2cfb0..00000000 Binary files a/tests/data/debug-info/x86_64-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug and /dev/null differ diff --git a/tests/data/debug-info/x86_64-linux-gnu/build_id/libhello_so b/tests/data/debug-info/x86_64-linux-gnu/build_id/libhello_so deleted file mode 100755 index 0edfd79b..00000000 Binary files a/tests/data/debug-info/x86_64-linux-gnu/build_id/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/x86_64-linux-gnu/debug_link/libhello_so b/tests/data/debug-info/x86_64-linux-gnu/debug_link/libhello_so deleted file mode 100755 index 0c126010..00000000 Binary files a/tests/data/debug-info/x86_64-linux-gnu/debug_link/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/x86_64-linux-gnu/debug_link/libhello_so.debug b/tests/data/debug-info/x86_64-linux-gnu/debug_link/libhello_so.debug deleted file mode 100755 index 082f5136..00000000 Binary files a/tests/data/debug-info/x86_64-linux-gnu/debug_link/libhello_so.debug and /dev/null differ diff --git a/tests/data/debug-info/x86_64-linux-gnu/dwarf_full/libhello_so b/tests/data/debug-info/x86_64-linux-gnu/dwarf_full/libhello_so deleted file mode 100755 index f8d3e411..00000000 Binary files a/tests/data/debug-info/x86_64-linux-gnu/dwarf_full/libhello_so and /dev/null differ diff --git a/tests/data/debug-info/x86_64-linux-gnu/elf_only/libhello_so b/tests/data/debug-info/x86_64-linux-gnu/elf_only/libhello_so deleted file mode 100755 index bffdaab7..00000000 Binary files a/tests/data/debug-info/x86_64-linux-gnu/elf_only/libhello_so and /dev/null differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/Makefile b/tests/data/plugins/flt.lttng-utils.debug-info/Makefile new file mode 100644 index 00000000..28208052 --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/Makefile @@ -0,0 +1,50 @@ +BUILD_ID_PREFIX=cd +BUILD_ID_SUFFIX=d98cdd87f7fe64c13b6daad553987eafd40cbb +BUILD_ID=$(BUILD_ID_PREFIX)$(BUILD_ID_SUFFIX) + +BUILD_DIR ?= build + +OBJS=$(BUILD_DIR)/dwarf_full/libhello_so \ + $(BUILD_DIR)/elf_only/libhello_so \ + $(BUILD_DIR)/build_id/libhello_so \ + $(BUILD_DIR)/debug_link/libhello_so + +all: $(OBJS) + +%.o: %.c + $(CC) -gdwarf -fdebug-prefix-map=$(CURDIR)=. -fPIC -c -I. -o $@ $< + +# Master copy: ELF with DWARF and build-id +$(BUILD_DIR)/dwarf_full/libhello_so: tp.o libhello.o + mkdir -p $(@D) + $(CC) -shared -gdwarf -llttng-ust -ldl -Wl,-soname,libhello.so -Wl,--build-id=0x$(BUILD_ID) -o $@ $^ + +# ELF only, no debug symbols, no build-d +$(BUILD_DIR)/elf_only/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so + mkdir -p $(@D) + objcopy -g $< $@.tmp + objcopy --remove-section=.note.gnu.build-id $@.tmp + mv $@.tmp $@ + +# ELF with external build-id DWARF +$(BUILD_DIR)/build_id/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so + mkdir -p $(@D)/.build-id/$(BUILD_ID_PREFIX) + objcopy --only-keep-debug $< $(@D)/.build-id/$(BUILD_ID_PREFIX)/$(BUILD_ID_SUFFIX).debug + objcopy -g $< $@ + +# ELF with external debug link DWARF +$(BUILD_DIR)/debug_link/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so + mkdir -p $(@D) + objcopy --remove-section=.note.gnu.build-id $< $@.tmp + objcopy --only-keep-debug $@.tmp $(@D)/libhello_so.debug + objcopy -g $@.tmp + cd $(@D) && objcopy --add-gnu-debuglink=libhello_so.debug $(@F).tmp + mv $@.tmp $@ + +clean: + rm -f *.o + +dist-clean: clean + rm -rf $(BUILD_DIR) + +.PHONY: all clean dist-clean diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/README.md b/tests/data/plugins/flt.lttng-utils.debug-info/README.md new file mode 100644 index 00000000..6d20c5cb --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/README.md @@ -0,0 +1,108 @@ +debug-info-data +============== + +This directory contains pre-generated ELF and DWARF files used to test +the debug info 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: + +* `ARCH/dwarf_full/libhello_so` (ELF and DWARF) +* `ARCH/elf_only/libhello_so` (ELF only) +* `ARCH/build_id/libhello_so` (ELF with separate DWARF via build ID) +* `ARCH/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug` (DWARF for build ID) +* `ARCH/debug_link/libhello_so` (ELF with separate DWARF via debug link) +* `ARCH/debug_link/libhello_so.debug` (DWARF for debug link) + +We use a suffix of "_so" instead of ".so" since some distributions +build systems will consider ".so" files as artifacts from a previous +build that were "left-over" and will remove them prior to the build. + +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 native GNU toolchain on either +Ubuntu 16.04 or 18.04 depending on the architecture. + +To regenerate them, you can use the included Makefile or follow these steps: + +## Generate the object files + + $ gcc -gdwarf -fdebug-prefix-map=$(pwd)=. -fPIC -c -I. tp.c libhello.c + +## Combined ELF and DWARF + + $ build_id_prefix=cd + $ build_id_suffix=d98cdd87f7fe64c13b6daad553987eafd40cbb + $ build_id="$build_id_prefix$build_id_suffix" + $ mkdir dwarf_full + $ 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 + +## ELF only + + $ mkdir elf_only + $ objcopy -g dwarf_full/libhello_so elf_only/libhello_so + $ objcopy --remove-section=.note.gnu.build-id elf_only/libhello_so + +## ELF and DWARF with Build ID + + $ mkdir -p build_id/.build-id/$build_id_prefix + $ objcopy --only-keep-debug dwarf_full/libhello_so build_id/.build-id/$build_id_prefix/$build_id_suffix.debug + $ objcopy -g dwarf_full/libhello_so build_id/libhello_so + +## ELF and DWARF with Debug Link + + $ mkdir debug_link + $ objcopy --remove-section=.note.gnu.build-id dwarf_full/libhello_so debug_link/libhello_so + $ objcopy --only-keep-debug debug_link/libhello_so debug_link/libhello_so.debug + $ objcopy -g debug_link/libhello_so + $ cd debug_link && objcopy --add-gnu-debuglink=libhello_so.debug libhello_so && cd .. + + +Test program +------------ +The trace provided in `tests/data/ctf-traces/succeed/debug-info/` was generated +using lttng-ust in a LTTng session configured to contain only the bare minimum +to do the debug-info resolution. You can generate such trace by following these +steps: + +1. Compile the example binary: + $ ln -s x86_64-linux-gnu/dwarf_full/libhello_so libhello.so + $ gcc -I. -o debug_info_app main.c -L. -lhello -llttng-ust -ldl -Wl,--rpath=. + +2. In order to have paths to binary and shared objects that are not relative + to the file system they were built on, we used a simple trick of copying + the following files to the root directory ('/') like this: + + $ sudo cp x86_64-linux-gnu/dwarf_full/libhello_so /libhello_so + $ sudo cp ./debug_info_app / + +3. Create symbolic link to the `/libhello_so` file with the `/libhello.so` name. + $ sudo ln -s /libhello_so /libhello.so + +4. Create the LTTng tracing session using the following commands: + $ cd / + $ sudo lttng create + $ sudo lttng add-context -u -t vpid -t ip + $ sudo lttng enable-event -u my_provider:my_first_tracepoint + $ sudo lttng enable-event -u lttng_ust_statedump:bin_info --filter='path=="/libhello_so"' + $ sudo lttng enable-event -u lttng_ust_statedump:bin_info --filter='path=="[linux-vdso.so.1]"' + $ sudo lttng start + $ sudo /debug_info_app + $ sudo lttng stop + +5. Copy the resulting trace back into the Babeltrace repository. + +When running babeltrace with the `--debug-info-target-prefix` option or +`target-prefix` component paramater set to the directory containing the right +`libhello_so` file. In the example used above, the `libhello_so` file is in the +`x86_64-linux-gnu/dwarf_full/` directory. +In the printed trace, the `my_provider:my_first_tracepoint` events should +contain information similar to this: + + debug_info = { bin = "libhello_so+0x2349", func = "foo+0xd2", src = "libhello.c:35" } diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug new file mode 100755 index 00000000..ba371f5d Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/build_id/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/build_id/libhello_so new file mode 100755 index 00000000..218e6685 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/build_id/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/debug_link/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/debug_link/libhello_so new file mode 100755 index 00000000..4dcfdc50 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/debug_link/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/debug_link/libhello_so.debug b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/debug_link/libhello_so.debug new file mode 100755 index 00000000..1ede7704 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/debug_link/libhello_so.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/dwarf_full/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/dwarf_full/libhello_so new file mode 100755 index 00000000..08390c8f Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/dwarf_full/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/elf_only/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/elf_only/libhello_so new file mode 100755 index 00000000..84c31e25 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/i386-linux-gnu/elf_only/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/libhello.c b/tests/data/plugins/flt.lttng-utils.debug-info/libhello.c new file mode 100644 index 00000000..95382b55 --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/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/data/plugins/flt.lttng-utils.debug-info/libhello.h b/tests/data/plugins/flt.lttng-utils.debug-info/libhello.h new file mode 100644 index 00000000..b3f8893e --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/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/data/plugins/flt.lttng-utils.debug-info/main.c b/tests/data/plugins/flt.lttng-utils.debug-info/main.c new file mode 100644 index 00000000..e272bc10 --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/main.c @@ -0,0 +1,37 @@ +/* + * main.c + * + * Debug Info - Main + * + * Copyright 2017 Julien Desfossez + * + * 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 +#include "libhello.h" +#include "tp.h" + +int main() +{ + foo(); + bar(); + baz(); + return 0; +} diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug new file mode 100755 index 00000000..6fa14992 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/build_id/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/build_id/libhello_so new file mode 100755 index 00000000..49c62499 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/build_id/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/debug_link/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/debug_link/libhello_so new file mode 100755 index 00000000..23efdc8b Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/debug_link/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/debug_link/libhello_so.debug b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/debug_link/libhello_so.debug new file mode 100755 index 00000000..a95eed28 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/debug_link/libhello_so.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/dwarf_full/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/dwarf_full/libhello_so new file mode 100755 index 00000000..ef39d51e Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/dwarf_full/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/elf_only/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/elf_only/libhello_so new file mode 100755 index 00000000..d1e7322b Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc-linux-gnu/elf_only/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug new file mode 100755 index 00000000..b419832f Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/build_id/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/build_id/libhello_so new file mode 100755 index 00000000..f740eb0c Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/build_id/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/debug_link/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/debug_link/libhello_so new file mode 100755 index 00000000..01e0c6b4 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/debug_link/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/debug_link/libhello_so.debug b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/debug_link/libhello_so.debug new file mode 100755 index 00000000..86364a3b Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/debug_link/libhello_so.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/dwarf_full/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/dwarf_full/libhello_so new file mode 100755 index 00000000..3874f118 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/dwarf_full/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/elf_only/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/elf_only/libhello_so new file mode 100755 index 00000000..067b4720 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/powerpc64le-linux-gnu/elf_only/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/tp.c b/tests/data/plugins/flt.lttng-utils.debug-info/tp.c new file mode 100644 index 00000000..e893355f --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/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/data/plugins/flt.lttng-utils.debug-info/tp.h b/tests/data/plugins/flt.lttng-utils.debug-info/tp.h new file mode 100644 index 00000000..1a3660e8 --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/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 diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/trace-debug-info.expect b/tests/data/plugins/flt.lttng-utils.debug-info/trace-debug-info.expect new file mode 100644 index 00000000..047ef8f9 --- /dev/null +++ b/tests/data/plugins/flt.lttng-utils.debug-info/trace-debug-info.expect @@ -0,0 +1,131 @@ +Trace class: + Stream class (ID 0): + Supports packets: Yes + Packets have beginning default clock snapshot: Yes + Packets have end default clock snapshot: Yes + Supports discarded events: Yes + Discarded events have default clock snapshots: Yes + Supports discarded packets: Yes + Discarded packets have default clock snapshots: Yes + Default clock class: + Name: monotonic + Description: Monotonic Clock + Frequency (Hz): 1,000,000,000 + Precision (cycles): 0 + Offset (s): 1,563,264,475 + Offset (cycles): 374,722,151 + Origin is Unix epoch: Yes + UUID: c56ad62a-6a35-4722-9807-d8e0f118a367 + Packet context field class: Structure (1 member): + cpu_id: Unsigned integer (32-bit, Base 10) + Event common context field class: Structure (3 members): + vpid: Signed integer (32-bit, Base 10) + ip: Unsigned integer (64-bit, Base 16) + debug_info: Structure (3 members): + bin: String + func: String + src: String + Event class `lttng_ust_statedump:bin_info` (ID 0): + Log level: Debug (line) + Payload field class: Structure (6 members): + baddr: Unsigned integer (64-bit, Base 16) + memsz: Unsigned integer (64-bit, Base 10) + path: String + is_pic: Unsigned integer (8-bit, Base 10) + has_build_id: Unsigned integer (8-bit, Base 10) + has_debug_link: Unsigned integer (8-bit, Base 10) + Event class `my_provider:my_first_tracepoint` (ID 1): + Log level: Debug (line) + Payload field class: Structure (2 members): + my_string_field: String + my_integer_field: Signed integer (32-bit, Base 10) + +[Unknown] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream beginning: + Trace: + Environment (5 entries): + domain: ust + hostname: raton + tracer_major: 2 + tracer_minor: 11 + tracer_name: lttng-ust + Stream (ID 0, Class ID 0) + +[21,705,969,336,938 cycles, 1,563,286,181,344,059,089 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Packet beginning: + Context: + cpu_id: 0 + +[21,705,976,167,081 cycles, 1,563,286,181,350,889,232 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Event `lttng_ust_statedump:bin_info` (Class ID 0): + Common context: + vpid: 9746 + ip: 0x7f09:b7d2:922b + debug_info: + bin: + func: + src: + Payload: + baddr: 0x7ffc:bd1e:1000 + memsz: 0 + path: [linux-vdso.so.1] + is_pic: 0 + has_build_id: 0 + has_debug_link: 0 + +[21,705,976,183,716 cycles, 1,563,286,181,350,905,867 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Event `lttng_ust_statedump:bin_info` (Class ID 0): + Common context: + vpid: 9746 + ip: 0x7f09:b7d2:922b + debug_info: + bin: + func: + src: + Payload: + baddr: 0x7f09:b7f9:8000 + memsz: 2,114,208 + path: /libhello_so + is_pic: 1 + has_build_id: 1 + has_debug_link: 0 + +[21,705,977,090,044 cycles, 1,563,286,181,351,812,195 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Event `my_provider:my_first_tracepoint` (Class ID 1): + Common context: + vpid: 9746 + ip: 0x7f09:b7f9:a349 + debug_info: + bin: libhello_so+0x2349 + func: foo+0xd2 + src: libhello.c:35 + Payload: + my_string_field: hello, tracer + my_integer_field: 42 + +[21,705,977,161,190 cycles, 1,563,286,181,351,883,341 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Event `my_provider:my_first_tracepoint` (Class ID 1): + Common context: + vpid: 9746 + ip: 0x7f09:b7f9:a448 + debug_info: + bin: libhello_so+0x2448 + func: bar+0xd2 + src: libhello.c:41 + Payload: + my_string_field: recoltes et semailles + my_integer_field: 57 + +[21,706,180,381,092 cycles, 1,563,286,181,555,103,243 ns from origin] +{Trace 0, Stream class ID 0, Stream ID 0} +Packet end + +[Unknown] +{Trace 0, Stream class ID 0, Stream ID 0} +Stream end diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug new file mode 100755 index 00000000..41e2cfb0 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/build_id/.build-id/cd/d98cdd87f7fe64c13b6daad553987eafd40cbb.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/build_id/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/build_id/libhello_so new file mode 100755 index 00000000..0edfd79b Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/build_id/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/debug_link/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/debug_link/libhello_so new file mode 100755 index 00000000..0c126010 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/debug_link/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/debug_link/libhello_so.debug b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/debug_link/libhello_so.debug new file mode 100755 index 00000000..082f5136 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/debug_link/libhello_so.debug differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/dwarf_full/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/dwarf_full/libhello_so new file mode 100755 index 00000000..f8d3e411 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/dwarf_full/libhello_so differ diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/elf_only/libhello_so b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/elf_only/libhello_so new file mode 100755 index 00000000..bffdaab7 Binary files /dev/null and b/tests/data/plugins/flt.lttng-utils.debug-info/x86_64-linux-gnu/elf_only/libhello_so differ diff --git a/tests/plugins/flt.lttng-utils.debug-info/Makefile.am b/tests/plugins/flt.lttng-utils.debug-info/Makefile.am index a076b3e8..44f17db4 100644 --- a/tests/plugins/flt.lttng-utils.debug-info/Makefile.am +++ b/tests/plugins/flt.lttng-utils.debug-info/Makefile.am @@ -11,8 +11,7 @@ dist_check_SCRIPTS = \ test_dwarf_powerpc64le-linux-gnu \ test_dwarf_powerpc-linux-gnu \ test_dwarf_x86_64-linux-gnu \ - test_lttng_utils_debug_info \ - test_lttng_utils_debug_info.py + test_succeed noinst_PROGRAMS = diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu index 484f6380..553778c2 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu @@ -27,9 +27,11 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/i386-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/i386-linux-gnu" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ +"$this_dir_build/test_bin_info" \ --foo-addr=0x1c8d \ --printf-offset=0xda \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu index 9a9ffbd3..eacce862 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu @@ -27,9 +27,11 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/powerpc-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/powerpc-linux-gnu" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ +"$this_dir_build/test_bin_info" \ --foo-addr=0x23bc \ --printf-offset=0x114 \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu index 061a27a4..706e1e79 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu @@ -27,9 +27,11 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/powerpc64le-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/powerpc64le-linux-gnu" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ +"$this_dir_build/test_bin_info" \ --foo-addr=0x2e7c \ --printf-offset=0x190 \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu index b50da5ce..4804f75c 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu @@ -27,9 +27,11 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/x86_64-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/x86_64-linux-gnu" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ +"$this_dir_build/test_bin_info" \ --foo-addr=0x2277 \ --printf-offset=0xf0 \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu index d02227f6..14cb3b1d 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu @@ -27,4 +27,9 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/i386-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/i386-linux-gnu" + +"$this_dir_build/test_dwarf" \ + "$debug_info_data" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu index eb4c3b02..742fbad0 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu @@ -27,4 +27,9 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/powerpc-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/powerpc-linux-gnu" + +"$this_dir_build/test_dwarf" \ + "$debug_info_data" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu index ee4ba4ad..c14ffadc 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu @@ -27,4 +27,9 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/powerpc64le-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/powerpc64le-linux-gnu" + +"$this_dir_build/test_dwarf" \ + "$debug_info_data" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu index ef5416fd..175ce8a4 100755 --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu @@ -27,4 +27,9 @@ fi # shellcheck source=../../utils/utils.sh source "$UTILSSH" -"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/x86_64-linux-gnu" +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +debug_info_data="$BT_TESTS_DATADIR/$this_dir_relative/x86_64-linux-gnu" + +"$this_dir_build/test_dwarf" \ + "$debug_info_data/" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info b/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info deleted file mode 100755 index c1772727..00000000 --- a/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 Philippe Proulx -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then - UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" -else - UTILSSH="$(dirname "$0")/../../utils/utils.sh" -fi - -# shellcheck source=../../utils/utils.sh -source "$UTILSSH" - -export BT_DEBUG_INFO_PATH - -run_python_bt2_test "${BT_TESTS_SRCDIR}/plugins/flt.lttng-utils.debug-info" \ - "test_lttng_utils_debug_info.py" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.py b/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.py deleted file mode 100644 index a79ca479..00000000 --- a/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.py +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright (C) 2019 EfficiOS Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -import unittest -import os.path -import bt2 -import os - - -@unittest.skip('depends on Python bindings, which are broken') -class LttngUtilsDebugInfoTestCase(unittest.TestCase): - def test_debug_info(self): - debug_info_data_path = os.environ['BT_DEBUG_INFO_PATH'] - trace_path = os.path.join(debug_info_data_path, 'trace') - target_prefix = os.path.join(debug_info_data_path, '..', '..') - src = bt2.ComponentSpec('ctf', 'fs', trace_path) - flt = bt2.ComponentSpec( - 'lttng-utils', 'debug-info', {'target-prefix': target_prefix} - ) - it = bt2.TraceCollectionNotificationIterator(src, flt, [bt2.EventNotification]) - notifs = list(it) - debug_info = notifs[2].event['debug_info'] - self.assertEqual(debug_info['bin'], 'libhello_so+0x14d4') - self.assertEqual(debug_info['func'], 'foo+0xa9') - self.assertEqual(debug_info['src'], 'libhello.c:7') - debug_info = notifs[3].event['debug_info'] - self.assertEqual(debug_info['bin'], 'libhello_so+0x15a6') - self.assertEqual(debug_info['func'], 'bar+0xa9') - self.assertEqual(debug_info['src'], 'libhello.c:13') diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_succeed b/tests/plugins/flt.lttng-utils.debug-info/test_succeed new file mode 100755 index 00000000..b57b7a78 --- /dev/null +++ b/tests/plugins/flt.lttng-utils.debug-info/test_succeed @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Copyright (C) 2019 Philippe Proulx +# Copyright (C) 2019 Francis Deslauriers +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; only version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This test validates that a `src.ctf.fs` component successfully reads +# specific CTF traces and creates the expected messages. +# +# Such CTF traces to open either exist (in `tests/ctf-traces/succeed`) +# or are generated by this test using local trace generators. + +SH_TAP=1 + +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi + +# shellcheck source=../../../utils/utils.sh +source "$UTILSSH" + +this_dir_relative="plugins/flt.lttng-utils.debug-info" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" +succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed" +expect_dir="$BT_TESTS_DATADIR/$this_dir_relative" +binary_artefact_dir="$BT_TESTS_DATADIR/$this_dir_relative" + +test_debug_info() { + local name="$1" + local local_args=( + "-c" "flt.lttng-utils.debug-info" + "-p" "target-prefix=\"$binary_artefact_dir/x86_64-linux-gnu/dwarf_full\"" + "-c" "sink.text.details" + "-p" "with-trace-name=no,with-stream-name=no" + ) + + bt_diff_cli "$expect_dir/trace-$name.expect" "/dev/null" \ + "$succeed_trace_dir/$name" "${local_args[@]}" + ok $? "Trace '$name' gives the expected output" +} + +plan_tests 1 + +test_debug_info debug-info diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 27a5f3ee..baef441a 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -129,7 +129,6 @@ export BT_TESTS_SED_BIN # Data files path BT_TESTS_DATADIR="${BT_TESTS_SRCDIR}/data" BT_CTF_TRACES_PATH="${BT_TESTS_DATADIR}/ctf-traces" -BT_DEBUG_INFO_PATH="${BT_TESTS_DATADIR}/debug-info" ### Diff Functions ###