0

Assume I have C code that includes this include file:

struct foo {
    int bar;
};

#define FOO ((struct foo*)(0x123))

The program is compiled with -ggdb3.

When FOO is used at runtime anywhere, I can use it also in the debugging console. But when it isn't (but the include is included), the macro #define FOO works, but the unused definition of struct foo is unknown to gdb:

(gdb) p FOO
No struct type named foo.
(gdb) p FOOx
No symbol "FOOx" in current context.

How can I make gdb include also unused structures in its debugging information?

  • 1
    Have you tried [-fno-eliminate-unused-debug-types](https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-fno-eliminate-unused-debug-types)? – ssbssa Nov 30 '22 at 19:16
  • Does this answer your question? [Can we define a new data type in a GDB session](https://stackoverflow.com/questions/7272558/can-we-define-a-new-data-type-in-a-gdb-session) – Mark Plotnick Dec 01 '22 at 08:42

0 Answers0