summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKhem Raj <[email protected]>2023-12-10 12:20:33 -0800
committerMark Wielaard <[email protected]>2023-12-21 01:45:05 +0100
commita2194f6b305bf0d0b9dd49dccd0a5c21994c8eea (patch)
treeb53d3887a8036334f0ee8f355448b82a415fa42e /tests
parent744e3ea84d756006c95a8c07382cfdbef5a3bf58 (diff)
Add helper function for basename
musl does not provide GNU version of basename and lately have removed the definiton from string.h [1] which exposes this problem. It can be made to work by providing a local implementation of basename which implements the GNU basename behavior, this makes it work across C libraries which have POSIX implementation only. [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 * lib/system.h (xbasename): New static inline functions. Poison basename. * libdw/dwarf_getsrc_file.c (dwarf_getsrc_file): Use xbasename. * libdwfl/core-file.c (dwfl_core_file_report): Likewise. * libdwfl/dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Likewise. * libdwfl/dwfl_segment_report_module.c (dwfl_segment_report_module): Likewise. * libdwfl/find-debuginfo.c (find_debuginfo_in_path): Likewise. * libdwfl/link_map.c (report_r_debug): Likewise. * libdwfl/linux-kernel-modules.c (try_kernel_name): Likewise. * src/addr2line.c (print_dwarf_function): Likewise. (print_src): Likewise. * src/ar.c (do_oper_insert): Likewise. And cast away const in entry.key assignment. * src/nm.c (show_symbols): Use xbasename. * src/stack.c (module_callback): Likewise. * src/strip.c (handle_elf): Likewise. * tests/show-die-info.c: Include system.h. (dwarf_tag_string): Use xbasename. * tests/varlocs.c: Likewise. * debuginfod/debuginfod.cxx: Move include system.h to the end. (register_file_name): Rename basename to filename. Signed-off-by: Khem Raj <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/show-die-info.c3
-rw-r--r--tests/varlocs.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/tests/show-die-info.c b/tests/show-die-info.c
index 1a3191cd..bda459a5 100644
--- a/tests/show-die-info.c
+++ b/tests/show-die-info.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include "../libdw/known-dwarf.h"
+#include "../lib/system.h"
static const char *
dwarf_tag_string (unsigned int tag)
@@ -318,7 +319,7 @@ main (int argc, char *argv[])
int fd = open (argv[cnt], O_RDONLY);
Dwarf *dbg;
- printf ("file: %s\n", basename (argv[cnt]));
+ printf ("file: %s\n", xbasename (argv[cnt]));
dbg = dwarf_begin (fd, DWARF_C_READ);
if (dbg == NULL)
diff --git a/tests/varlocs.c b/tests/varlocs.c
index 8e563fd3..1004f969 100644
--- a/tests/varlocs.c
+++ b/tests/varlocs.c
@@ -1120,7 +1120,7 @@ main (int argc, char *argv[])
const char *name = (modname[0] != '\0'
? modname
- : basename (mainfile));
+ : xbasename (mainfile));
printf ("module '%s'\n", name);
print_die (&cudie, "CU", 0);