diff options
| author | Mark Wielaard <[email protected]> | 2017-07-21 21:23:07 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2017-07-26 23:22:38 +0200 |
| commit | c24b900cc9cf225e98372253cb02c77342634b6e (patch) | |
| tree | bbc3b4085b66b6e0bf2e52de978d0b8351819588 /tests | |
| parent | 55a471f5fe44945414af243613d4590c4e7cd8d1 (diff) | |
libdw: Add dwarf_line_file.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 4 | ||||
| -rw-r--r-- | tests/get-lines.c | 23 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 0700e7ca..519f25a3 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2017-07-21 Mark Wielaard <[email protected]> + + * get-lines.c (main): Add dwarf_line_file test. + 2017-07-19 Gustavo Romero <[email protected]> * run-addrcfi.sh: Update generic SPRs names to HTM SPRs names 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; |
