473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

gdb debugger

a
In .C or .h file we have #define some constant.
While using the gdb debugger, how to show the value of these constant?
Thanx
Nov 15 '05 #1
7 1573
"a" <a@mail.com> 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) ks***@mib.org <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.
Nov 15 '05 #2
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.
Nov 15 '05 #3
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.
Nov 15 '05 #4
In article <OUL%e.38606$1i.37904@pd7tw2no>, a <a@mail.com> 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
Nov 15 '05 #5

Keith Thompson wrote:
"a" <a@mail.com> 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."

Nov 15 '05 #6
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.
Nov 15 '05 #7
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>
Nov 15 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: jonathan | last post by:
everyone, I'd like to be able to debug php scripts on the command line, going through the browser. In other words, set up the debugger to listen and then type in a url and have the code stop...
11
by: Ziaran _ | last post by:
I have written a new debugger. I think people will find it useful. Where can I post it for people to download? Thanks, Nir _________________________________________________________________...
4
by: Chuck Ritzke | last post by:
Hi, I've been using VS for a number of projects and the debugger has worked as advertised until now. I have a desktop solution with three projects, two of which are class modules. For some...
25
by: Jeff | last post by:
Use the MS Script Editor included free with MS Office 2002 and above, for debugging Internet Explorer (IE). This subject is of great interest to many JS developers, as there is no obvious, low...
1
by: Rhino | last post by:
Is there any way to install the IBM Distributed Debugger V9.2 on Windows XP without first uninstalling DB2? I installed the IBM Distributed Debugger V9.2 on my Windows XP box in the hopes of...
1
by: Susanne Christe | last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Registeresd JIT debugger is not avaialble: After executing an application I get the Error: ...
1
by: Bill Menees | last post by:
VS.NET 2003 defaults the "Debugger Type" property to "Auto" for Visual C++ projects. Unfortunately, the "Auto" type isn't very smart. "Auto" bases the debugger type on the launched EXE's type,...
9
by: RalphTheExpert | last post by:
I'm getting different behavior if my code is running under the debugger or not. I have modified Winmain to look like this: // Copyright (C) 2002 Microsoft Corporation // All rights reserved....
18
by: R. Bernstein | last post by:
Okay, a bit of an exaggeration. Recently, I've been using Python more seriously, and in using the debugger I think one of the first things I noticed was that there is no "restart" ("R" in...
3
by: Doug | last post by:
I'm having problems w/ the VS2005 debugger with C#. It blows past any breakpoints in even the simplest "Hello World" console application. I can't do any step-by-step debugging. I've provided the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.