diff options
Diffstat (limited to 'tests/get-lines.c')
| -rw-r--r-- | tests/get-lines.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/get-lines.c b/tests/get-lines.c index c361a2c3..188d0162 100644 --- a/tests/get-lines.c +++ b/tests/get-lines.c @@ -24,6 +24,7 @@ #include <libelf.h> #include ELFUTILS_HEADER(dw) #include <stdio.h> +#include <string.h> #include <unistd.h> @@ -100,6 +101,28 @@ main (int argc, char *argv[]) printf ("%" PRIx64 ": %s:%d:", (uint64_t) addr, file ?: "???", line); + /* Getting the file path through the Dwarf_Files should + result in the same path. */ + Dwarf_Files *files; + size_t idx; + if (dwarf_line_file (l, &files, &idx) != 0) + { + printf ("%s: cannot get file from line (%zd): %s\n", + argv[cnt], i, dwarf_errmsg (-1)); + result = 1; + break; + } + const char *path = dwarf_filesrc (files, idx, NULL, NULL); + if ((path == NULL && file != NULL) + || (path != NULL && file == NULL) + || (strcmp (file, path) != 0)) + { + printf ("%s: line %zd srcline (%s) != file srcline (%s)\n", + argv[cnt], i, file ?: "???", path ?: "???"); + result = 1; + break; + } + int column; if (dwarf_linecol (l, &column) != 0) column = 0; |
