Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > gdb debugger

Reply
Thread Tools

gdb debugger

 
 
a
Guest
Posts: n/a
 
      10-02-2005
In .C or .h file we have #define some constant.
While using the gdb debugger, how to show the value of these constant?
Thanx


 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      10-02-2005
"a" <(E-Mail Removed)> writes:
> In .C or .h file we have #define some constant.
> While using the gdb debugger, how to show the value of these constant?


We don't know; that's not a C question. gdb comes with extensive
documentation. If that doesn't help, you might try the gnu.utils.help
newsgroup.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
 
Emmanuel Delahaye
Guest
Posts: n/a
 
      10-02-2005
a wrote on 02/10/05 :
> In .C or .h file we have #define some constant.
> While using the gdb debugger, how to show the value of these constant?


You don't (macros are just text replacements). If the constant value is
an int, use an enum.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.


 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      10-02-2005
a wrote:
> In .C or .h file we have #define some constant.
> While using the gdb debugger, how to show the value of these constant?
> Thanx


This is a question about a specific tool chain, not the C language
itself. You should therefore ask in a group or mailing list dealing with
your tool chain. You should also read the manuals for the compiler and
debugger.

<OT>
Some compilers have an option to provide this information to the
debugger and some versions of gdb can use the information. However, not
all versions and not all compilers.
</OT>
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
Anonymous 7843
Guest
Posts: n/a
 
      10-03-2005
In article <OUL%e.38606$1i.37904@pd7tw2no>, a <(E-Mail Removed)> wrote:
>
> In .C or .h file we have #define some constant.
> While using the gdb debugger, how to show the value of these constant?
> Thanx


That's off-topic (as others have pointed out) but I would
do something like this:

(gdb) shell grep NAME *.c *.h
 
Reply With Quote
 
John Bode
Guest
Posts: n/a
 
      10-03-2005

Keith Thompson wrote:
> "a" <(E-Mail Removed)> writes:
> > In .C or .h file we have #define some constant.
> > While using the gdb debugger, how to show the value of these constant?

>
> We don't know; that's not a C question. gdb comes with extensive
> documentation. If that doesn't help, you might try the gnu.utils.help
> newsgroup.
>


Actually, I'll argue that it is topical, in that it touches on what
happens to preprocessor macros when code is compiled.

To the OP: remember that preprocessor macros are simply text
substitutions to make your life as the coder a little easier; during
preprocessing, they are expanded into the replacement text, and that
replacement text is what's fed to the compiler.

For example, take the following code fragment:

#define SIZE 10

void foo(void)
{
int arr[SIZE];
...
}

After the preprocessing stage, all occurrences of SIZE are replaced by
the text "10", as below:

void foo(void)
{
int arr[10];
...
}

This is the text that is actually fed to the compiler; the preprocessor
symbol SIZE no longer exists. Therefore, I would not expect it to be
accessible from a debugger.

Now, specific compilers may allow you to preserve that information for
debugging purposes, but that's beyond the scope of the C language.
FWIW, my experience with gdb leads me to say "you can't do that."

 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      10-03-2005
John Bode wrote:

<snip question on making #defines available in gdb>

> This is the text that is actually fed to the compiler; the preprocessor
> symbol SIZE no longer exists. Therefore, I would not expect it to be
> accessible from a debugger.
>
> Now, specific compilers may allow you to preserve that information for
> debugging purposes, but that's beyond the scope of the C language.
> FWIW, my experience with gdb leads me to say "you can't do that."


Which is exactly why the OP should ask the question where it is topical
so that those who know how and on which versions it is or is not
possible. Since with the right combination of versions of gdb, compiler
and switches it *is* possible.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
revival
Guest
Posts: n/a
 
      10-13-2005
a wrote:
> In .C or .h file we have #define some constant.
> While using the gdb debugger, how to show the value of these constant?
> Thanx
>
>

You should be asking in the gcc mailing lists as mentioned.
<OT>
If you see the gdb manual ,using the flags "-gdwarf2 -g3" while
compiling the sources using gcc should make you see #define
constants.Ofcourse you need to use specific gdb commands to see the
macros and macro expansions.
</OT>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GDB debugger problem console kid C++ 1 08-15-2010 03:06 PM
Debugging with gdb: pystack macro for gdb to show python stack trace Timothy Madden Python 1 09-17-2009 11:47 AM
GDB debugger problem mohi C++ 4 04-02-2008 07:31 AM
GDB - no debugging symbols found (GDB Vs GCC?) seba C++ 1 03-22-2007 02:02 PM
Capturing gdb output in pyhton script using gdb -batch -x arguments Surendra Python 0 03-23-2006 02:47 PM



Advertisments