gdb-Makrosymbole sind auch bei Verwendung von -g3 oder -ggdb3 oder -gdwarf-4 nicht vorhanden

Ich habe diese C-Datei (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>

mit denen ich kompiliere:

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

dann mit debuggen

<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>

Das hat früher funktioniert. Ich brauche dies, um zu arbeiten, weil ich Bibliotheken verwende, die Namen für Hardware-Peripheriegeräte und Speicheradressen definieren.

Dies scheint in direktem Widerspruch zu dem Verhalten zu stehen, das auf derSourceware gdb Seite.

Was mache ich falsch?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage