Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* how to examine data with compiler optimization option set?
@ 2008-09-02 21:27 J R
  2008-09-02 21:36 ` Robert Dewar
  0 siblings, 1 reply; 24+ messages in thread
From: J R @ 2008-09-02 21:27 UTC (permalink / raw)
  To: gdb

Extract of GDB user manual:

"Another possible effect of compiler optimizations is to optimize unused
variables out of existence, or assign variables to registers (as opposed to
memory addresses). Depending on the support for such cases offered by the debug
info format used by the compiler, GDB might not be able to display values for
such local variables.

To solve such problems, either recompile without optimizations, or use a
different debug info format, if the compiler supports several such formats. For
example, GCC, the GNU C/C++ compiler usually supports the `-gstabs' option.
`-gstabs' produces debug info in a format that is superior to formats such as
COFF. You may be able to use DWARF2 (`-gdwarf-2'), which is also an effective
form for debug info. See section `Options for Debugging Your Program or GNU CC'
in Using GNU CC, for more information."

I wanted to keep the optimization option, so I tried to recompile with GCC,
using the -gstabs and -gdwarf-2 options, and even -g3, with this very simple
program:
int main(void){
	int a = 1;
	int b = 2;
	int c = a+b;

	printf("Value c = %d \n", c);
}

But still couldn't display the variables a, b and c!

Is there a particular compiling option configuration to set?

Many thanks in advance.

Regards.


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2008-09-04 20:46 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-02 21:27 how to examine data with compiler optimization option set? J R
2008-09-02 21:36 ` Robert Dewar
2008-09-02 21:45   ` jreiver
2008-09-02 21:50     ` Robert Dewar
2008-09-02 21:57       ` Joel Brobecker
2008-09-03  0:05         ` Michael Snyder
2008-09-03  1:53           ` Robert Dewar
2008-09-03  2:52             ` Daniel Jacobowitz
2008-09-03 14:35               ` Robert Dewar
2008-09-03  3:06           ` Frank Ch. Eigler
2008-09-03  4:37             ` Michael Snyder
2008-09-03 14:36             ` Robert Dewar
2008-09-03 18:34             ` Eli Zaretskii
2008-09-03 21:43               ` Robert Dewar
2008-09-04  8:01                 ` Andreas Schwab
2008-09-04 10:53                   ` Robert Dewar
2008-09-04 14:05                     ` Paul Koning
2008-09-04 14:09                       ` Robert Dewar
2008-09-04 14:15                         ` Paul Koning
2008-09-04 14:17                           ` Robert Dewar
2008-09-04 15:55                   ` Eli Zaretskii
2008-09-04 18:13                     ` Frank Ch. Eigler
2008-09-04 20:46                       ` Ulrich Weigand
2008-09-03  0:04     ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox