Addr2line
lastmod 2020-04-06created 2017-04-292 edits
addr2line uses debug information to obtain file names and line numbers.
How to use
The program must be compiled in advance to include debug information. In GCC, use the -g option.
#include <stdio.h>
void func(void)
{
printf("func call\n");
}
int main(void)
{
printf(" func addr %p\n", func);
}
Compile as follows.
Run it.
Let's look at the simplest example.
Given the input file and an address, it prints the exact line being executed.
It can also print the function name.
addr2line also uses the BFD library to obtain debug information. addr2line can obtain the file name and line number from an address.