Rev 1 | Rev 11 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 8 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | // Based on https://gist.github.com/jvranish/4441299 |
1 | // Based on https://gist.github.com/jvranish/4441299 |
2 | 2 | ||
3 |
|
3 | #if defined(__linux__) || defined(__FreeBSD__) // Pierre-Marie Baty -- added compile guard |
4 | 4 | ||
5 | #define _GNU_SOURCE |
5 | #define _GNU_SOURCE |
6 | #include "harness/os.h" |
6 | #include "harness/os.h" |
7 | #include <assert.h> |
7 | #include <assert.h> |
8 | #include <ctype.h> |
8 | #include <ctype.h> |
Line 61... | Line 61... | ||
61 | // Resolve symbol name and source location given the path to the executable and an address |
61 | // Resolve symbol name and source location given the path to the executable and an address |
62 | int addr2line(char const* const program_name, void const* const addr) { |
62 | int addr2line(char const* const program_name, void const* const addr) { |
63 | char addr2line_cmd[512] = { 0 }; |
63 | char addr2line_cmd[512] = { 0 }; |
64 | 64 | ||
65 | /* have addr2line map the address to the related line in the code */ |
65 | /* have addr2line map the address to the related line in the code */ |
66 | sprintf(addr2line_cmd, "addr2line -f -p -e |
66 | sprintf(addr2line_cmd, "addr2line -f -p -e \"%s\" %p", program_name, addr - get_dethrace_offset()); // Pierre-Marie Baty -- support pathnames containing spaces |
67 | 67 | ||
68 | fprintf(stderr, "%d: ", stack_nbr++); |
68 | fprintf(stderr, "%d: ", stack_nbr++); |
69 | return system(addr2line_cmd); |
69 | return system(addr2line_cmd); |
70 | } |
70 | } |
71 | 71 |