Symbole makr gdb nie są obecne nawet przy użyciu -g3 lub -ggdb3 lub -gdwarf-4

Mam ten plik C (sample.c):

<code>#include <stdio.h>
#define M 42
#define ADD(x) (M + x)
int main ()
{
  printf("%d\n", M);
  printf("%d\n", ADD(2));
  return 0;
}
</code>

które kompiluję z:

<code>$ gcc -O0 -Wall -g3 sample.c -o sample
</code>

następnie debuguj za pomocą

<code>$ gdb ./sample
GNU gdb (Gentoo 7.3.1 p2) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /tmp/sample...done.
(gdb) macro list
(gdb) macro expand ADD(2)
expands to: ADD(2)
(gdb) print M
No symbol "M" in current context.
(gdb) q
</code>

To kiedyś działało. Potrzebuję tego do działania, ponieważ używam bibliotek, które # definiują nazwy urządzeń peryferyjnych i adresów pamięci.

Wydaje się, że jest to w bezpośredniej sprzeczności z zachowaniem pokazanym naWitryna źródłowa gdb.

Co ja robię źle?

questionAnswers(4)

yourAnswerToTheQuestion