ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Version 3.1 of GCC, the GNU C compiler, provides macro information if you specify the options `-gdwarf-2' and `-g3'
I haven't tried any of that myself, so I would guess from that documentation that GCC versions earlier than 3.1 lack the feature and GCC versions later than 3.1 probably still support that feature.
Assuming you compiled without those extra switches, GDB obviously can't use information that GCC didn't make available to it.
I haven't tried any of that myself, so I would guess from that documentation that GCC versions earlier than 3.1 lack the feature and GCC versions later than 3.1 probably still support that feature.
Assuming you compiled without those extra switches, GDB obviously can't use information that GCC didn't make available to it.
Hi Johnsfine,
Thanks for the information.
My compilation switches:
gcc -gdwarf-2 -g3 sample.c -o sample
My gcc compiler version: 3.4.6
GDB still does not show the information about the macro while i was debugging.
Did you call the list command first? The page says
Quote:
GDB uses the current listing position to decide which macro definitions are in scope:
I missed that the first time I skimmed through, it seems like surprising behaviour.
Code:
~/tmp/macro$ gdb -q sample
Reading symbols from /home/npostavs/tmp/macro/sample...done.
(gdb) info macro ADD
The symbol `ADD' has no definition as a C/C++ preprocessor macro
at <user-defined>:-1
(gdb) list main
3
4 #define M 42
5 #define ADD(x) (M + x)
6
7 main ()
8 {
9 #define N 28
10 printf ("Hello, world!\n");
11 #undef N
12 printf ("We're so creative.\n");
(gdb) info macro ADD
Defined at /home/npostavs/tmp/macro/sample.c:5
#define ADD(x) (M + x)
(gdb)
Did you call the list command first? The page says
I missed that the first time I skimmed through, it seems like surprising behaviour.
Code:
~/tmp/macro$ gdb -q sample
Reading symbols from /home/npostavs/tmp/macro/sample...done.
(gdb) info macro ADD
The symbol `ADD' has no definition as a C/C++ preprocessor macro
at <user-defined>:-1
(gdb) list main
3
4 #define M 42
5 #define ADD(x) (M + x)
6
7 main ()
8 {
9 #define N 28
10 printf ("Hello, world!\n");
11 #undef N
12 printf ("We're so creative.\n");
(gdb) info macro ADD
Defined at /home/npostavs/tmp/macro/sample.c:5
#define ADD(x) (M + x)
(gdb)
Hi,
Thanks for the information.
I still dont see macro definition under GDB after listing main.
GDB version used: 6.3.0.0-1.153
What command line options you have used to build your sample.c?
What GDB version you are using?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.