* How can i show the macro infor
@ 2007-09-21 11:06 江河
2007-09-21 16:23 ` Jim Blandy
0 siblings, 1 reply; 3+ messages in thread
From: 江河 @ 2007-09-21 11:06 UTC (permalink / raw)
To: news.gnu.gdb
I can't show the macro info by these operation.
gcc --version
gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
gdb --version
GNU gdb Red Hat Linux (6.3.0.0-1.96rh)
>cat x.c
#include <stdio.h>
#define NEX 1
int main()
{
printf( "%d\n", N );
return 0;
}
>gcc -gdwarf-2 -g3 x.c -o x
(gdb) l
1 #include <stdio.h>
2 #define NEX 1
3 int main()
4 {
5 printf( "%d\n", NEX );
6 return 0;
7 }
(gdb) info macro NEX
The symbol `NEX' has no definition as a C/C++ preprocessor macro
at x.c:8
included at /usr/include/stdio.h:749
--
桂華秋皎潔
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How can i show the macro infor
2007-09-21 11:06 How can i show the macro infor 江河
@ 2007-09-21 16:23 ` Jim Blandy
2007-09-21 22:21 ` Sheng-Liang Song
0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2007-09-21 16:23 UTC (permalink / raw)
To: 江河; +Cc: news.gnu.gdb
"江河" <empriser@gmail.com> writes:
> I can't show the macro info by these operation.
>
> gcc --version
> gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
>
> gdb --version
> GNU gdb Red Hat Linux (6.3.0.0-1.96rh)
>
>>cat x.c
> #include <stdio.h>
> #define NEX 1
> int main()
> {
> printf( "%d\n", N );
> return 0;
> }
>
>>gcc -gdwarf-2 -g3 x.c -o x
>
> (gdb) l
> 1 #include <stdio.h>
> 2 #define NEX 1
> 3 int main()
> 4 {
> 5 printf( "%d\n", NEX );
> 6 return 0;
> 7 }
> (gdb) info macro NEX
> The symbol `NEX' has no definition as a C/C++ preprocessor macro
> at x.c:8
> included at /usr/include/stdio.h:749
>
> --
> 桂華秋皎潔
That response from GDB to your 'info macro NEX' command looks very
strange. I'd wonder whether your GCC was producing bad macro information.
I wasn't able to reproduce this problem with Fedora Core 6's GCC 4.1.2:
$ cat x.c
#include <stdio.h>
#define NEX 1
int main()
{
printf( "%d\n", NEX );
return 0;
}
$ gcc -gdwarf-2 -g3 x.c -o x
$ ~/gdb/pub/nat/gdb/gdb x
GNU gdb 6.6.50.20070911-cvs
Copyright (C) 2007 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 "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x8048395: file x.c, line 5.
(gdb) run
Starting program: /home/jimb/play/x
Breakpoint 1, main () at x.c:5
5 printf( "%d\n", NEX );
(gdb) info macro NEX
Defined at /home/jimb/play/x.c:2
#define NEX 1
(gdb) print NEX
$1 = 1
(gdb) quit
The program is running. Exit anyway? (y or n) y
$ gcc --version
gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How can i show the macro infor
2007-09-21 16:23 ` Jim Blandy
@ 2007-09-21 22:21 ` Sheng-Liang Song
0 siblings, 0 replies; 3+ messages in thread
From: Sheng-Liang Song @ 2007-09-21 22:21 UTC (permalink / raw)
To: 江河; +Cc: Jim Blandy, news.gnu.gdb
Hi JiangHe,
You may forget to use this gcc compile flags, "-gdwarf-2 -g3", at the compile time.
It works for Jim because he used the gcc compile flags.
gcc -gdwarf-2 -g3 x.c -o x
Reference gdb marco at http://www.delorie.com/gnu/docs/gdb/gdb_70.html
Sheng-Liang Song
Jim Blandy wrote:
> "æ±æ²³" <empriser@gmail.com> writes:
>
>> I can't show the macro info by these operation.
>>
>> gcc --version
>> gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
>>
>> gdb --version
>> GNU gdb Red Hat Linux (6.3.0.0-1.96rh)
>>
>>
>>> cat x.c
>>>
>> #include <stdio.h>
>> #define NEX 1
>> int main()
>> {
>> printf( "%d\n", N );
>> return 0;
>> }
>>
>>
>>> gcc -gdwarf-2 -g3 x.c -o x
>>>
>> (gdb) l
>> 1 #include <stdio.h>
>> 2 #define NEX 1
>> 3 int main()
>> 4 {
>> 5 printf( "%d\n", NEX );
>> 6 return 0;
>> 7 }
>> (gdb) info macro NEX
>> The symbol `NEX' has no definition as a C/C++ preprocessor macro
>> at x.c:8
>> included at /usr/include/stdio.h:749
>>
>> --
>> æ¡è¯ç§çæ½
>>
>
> That response from GDB to your 'info macro NEX' command looks very
> strange. I'd wonder whether your GCC was producing bad macro information.
>
> I wasn't able to reproduce this problem with Fedora Core 6's GCC 4.1.2:
>
>
> $ cat x.c
> #include <stdio.h>
> #define NEX 1
> int main()
> {
> printf( "%d\n", NEX );
> return 0;
> }
> $ gcc -gdwarf-2 -g3 x.c -o x
> $ ~/gdb/pub/nat/gdb/gdb x
> GNU gdb 6.6.50.20070911-cvs
> Copyright (C) 2007 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 "i686-pc-linux-gnu"...
> Using host libthread_db library "/lib/libthread_db.so.1".
> (gdb) b main
> Breakpoint 1 at 0x8048395: file x.c, line 5.
> (gdb) run
> Starting program: /home/jimb/play/x
>
> Breakpoint 1, main () at x.c:5
> 5 printf( "%d\n", NEX );
> (gdb) info macro NEX
> Defined at /home/jimb/play/x.c:2
> #define NEX 1
> (gdb) print NEX
> $1 = 1
> (gdb) quit
> The program is running. Exit anyway? (y or n) y
> $ gcc --version
> gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> $
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-21 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-21 11:06 How can i show the macro infor 江河
2007-09-21 16:23 ` Jim Blandy
2007-09-21 22:21 ` Sheng-Liang Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox