Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - the right -g option to be able to use gdb effectively: (6 Items)
   
the right -g option to be able to use gdb effectively  
What is the right -g level to set (minimum) to be able to get bt and effectively use gdb.

Thanks

Preeti


RE: the right -g option to be able to use gdb effectively  
Default level (2) should work just fine, i.e.  "-g" should be enough.

---
Aleksandar

-----Original Message-----
From: Preeti Sharma [mailto:presharm@cisco.com] 
Sent: November 5, 2007 2:41 PM
To: general-toolchain
Subject: the right -g option to be able to use gdb effectively

What is the right -g level to set (minimum) to be able to get bt and
effectively use gdb.

Thanks

Preeti




_______________________________________________
General
http://community.qnx.com/sf/go/post2463
Re: RE: the right -g option to be able to use gdb effectively  
Is that also true for -O i.e. what is the maximum -O I can use to be able to use gdb effectively....

Thanks ...

Preeti
RE: RE: the right -g option to be able to use gdb effectively  
You should be able to use gdb with any optimization level (with -g option,
of course). 

The difference you will probably see with higher optimization levels is, for
example, not being able to set a breakpoint using function name of a
function that was inlined by the compiler (you should still be able to set a
breakpoint using filename:linenumber format). 

Re: RE: RE: the right -g option to be able to use gdb effectively  
> You should be able to use gdb with any optimization level (with -g option,
> of course). 
> 
> The difference you will probably see with higher optimization levels is, for
> example, not being able to set a breakpoint using function name of a
> function that was inlined by the compiler (you should still be able to set a
> breakpoint using filename:linenumber format). 
> 

Yep, another one is that line information tends to become skewed as the dead code/variables are removed. It is important
 to understand -g  does not change how code is generated but optimization impacts the correctness of the debug 
information generated. I generally find "-O2 -g" to be easily debugged under GDB.

Regards,

Ryan Mansfield
RE: RE: RE: the right -g option to be able to use gdb effectivel y  
> Yep, another one is that line information tends to become skewed as the
> dead code/variables are removed. It is important to understand -g  does
> not change how code is generated but optimization impacts the correctness
> of the debug information generated. I generally find "-O2 -g" to be easily
> debugged under GDB.

And yet another is that the order of execution isn't going to follow your
source as closely either.  This can make stepping through code difficult.


-- 
 Cheers,
    Adam

   QNX Software Systems
   [ amallory@qnx.com ]
   ---------------------------------------------------
   With a PC, I always felt limited by the software available.
   On Unix, I am limited only by my knowledge.
       --Peter J. Schoenster