tests: Move to kernel style SPDX license identifiers The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. See https://spdx.org/ids-how for details. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Change-Id: I89cd4b4b7440f71f52426a5508252932bb46e796 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: include foo.h in foo.c Fixes: CC foo.lo /home/smarchi/src/lttng-tools/tests/utils/testapp/userspace-probe-elf-binary/foo.c:19:5: error: no previous declaration for ‘dynamic_symbol’ [-Werror=missing-declarations] int dynamic_symbol(int a) ^~~~~~~~~~~~~~ Change-Id: I58888da2908bcf4c38d59ba9bacf3e96adc575b6 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests: add declaration for test_function in userspace-probe-elf-binary.c Fixes: CC userspace-probe-elf-binary.o /home/smarchi/src/lttng-tools/tests/utils/testapp/userspace-probe-elf-binary/userspace-probe-elf-binary.c:21:34: error: no previous declaration for ‘test_function’ [-Werror=missing-declarations] void __attribute__ ((noinline)) test_function() ^~~~~~~~~~~~~ I did not make test_function static, because from what I understand, it is important that test_function remains an exported symbol, for example for test regression/kernel/test_userspace_probe. Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Change-Id: I52019f69de023b24b46cc701e2e0df919e654a76 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
elf: support dynamic symbol table lookup Background ========== There may be two symbol tables in a shared object or executable. The normal symbol table (.symtab) and the dynamic symbol table (.dynsym). The normal symbol table contains lots of information, such as static linking data, but none of it is used at runtime. This is why some shared libraries are 'stripped', reducing the final size of the file. Stripping an object file removes the entire .symtab section of the elf file, amongst other things. The dynamic symbol table contains symbols that are needed for dynamic linking of the shared object. The symbols in that section form a subset of the symbols contained in the normal symbol section (before stripping). The .dynsym section is left untouched when stripping a file as it is needed at runtime. Current limitation ================== The current elf parsing implementation looks for the normal symbol section (.symtab) to find the target symbol. If the .symtab is not found, the parsing stops and returns that the symbol was not found. As explained in the section above, a shared library might be stripped from its normal symbol table, but still have a dynamic symbol table (.dynsym) containing the information of the target symbol. For example, on distributions where libc is stripped, the malloc symbol can only be found in the .dynsym section Solution ======== Look for the normal symbol section first and, if it's found, use it to find the symbol, as was previously done. If the .symtab is absent, try to use the dynamic symbol section instead. This commit also adds a testcase for this feature. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Implement userspace-probe regression tests This adds regression testcases for the following userspace probe features and should-fail scenarios. Features: * ELF function location tracing works, * ELF C++ mangled function and method location tracing works, * SDT tracepoint location tracing works, * Implicit location type defaults to ELF location, * Binary found $PATH, * Binary found using full path, * Binary with colon in file name, * Disabling of all location types, * Listing of all location types, * Saving and loading of all location types, * SDT probe with one or more callsites, * SDT probe with arguments, * SDT probe in shared object, * SDT probe in dlopen()ed and ldpreload()ed shared object. Should-fail: * Target binary does not exist, * Target binary not ELF file, * ELF symbol not found in target binary, * ELF symbol not a function, * SDT provider name not found, * SDT probe name not found, * SDT probe guarded by a semaphore. We also make sure to disable testcases when the necessary files/tools for them are not found: * Disables C++ testcases if no C++ compiler is found. * Disables SDT testcases if the Systemtap header files are not found. This is tested by trying to compile a simple C program with a SDT probe. If it fails, it will only disable the testcases and not the feature since the SDT userspace probe feature does not use this header for parsing. Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Erica Bugden <ebugden@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>