How do I find the file something was defined in using gdb?

Viewed 2634

When I type list mystruct into gdb, I receive the lines of code used to define mystruct. How can I ask gdb to give me the file it is reading from to print those lines? Getting that file from the gdb python interface would be preferable. The more easily parsable the better.

Thanks!

2 Answers

In case you have compiled with debug information (-g3) option,
you can use:
info macro mystruct
e.g
info macro SOCK_RAW

(gdb) info macro SOCK_RAW

Defined at /usr/include/x86_64-linux-gnu/bits/socket_type.h:33
included at /usr/include/x86_64-linux-gnu/bits/socket.h:38
included at /usr/include/x86_64-linux-gnu/sys/socket.h:38
included at /home/nirl/cpp_tut/filter/filter.cpp:1

``

Related