I've been doing a bunch of analysis of complex code, and to explain how things work I often want to give backtraces to some point of interest containing only function names.
However, when I do just:
bt
it adds a lot of extra information such as addresses and arguments which I have to remove manually:
#0 f2 (i=0) at main.c:1
#1 0x0000555555555155 in f1 (i=1) at main.c:6
#2 0x0000555555555177 in main (argc=1, argv=0x7fffffffc178) at main.c:10
Is there a way to print just the function names and nothing else as in:
f2
f1
main
?
Test program:
main.c
int f2(int i) {
return i + 1;
}
int f1(int i) {
return f2(i) + 1;
}
int main(int argc, char *argv[]) {
return f1(argc);
}
Compile and run:
g++ -ggdb3 -O0 -std=c++11 -Wall -Wextra -pedantic -o main.out main.c
gdb -nh -batch -q -ex 'b f2' -ex r -ex bt main.out
For this use case, I'm mostly interested in a single usage option, but if there are any set configs that get the job done I'm also interested in knowing about them.
Tested in Ubuntu 19.10, GDB 8.3.