Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* displaying source after and before the program counter
       [not found] <1071484872.21849.ezmlm@sources.redhat.com>
@ 2003-12-15 10:50 ` Vianney Lecroart
  2003-12-15 14:16   ` Eli Zaretskii
  2003-12-15 15:53   ` Daniel Jacobowitz
  0 siblings, 2 replies; 4+ messages in thread
From: Vianney Lecroart @ 2003-12-15 10:50 UTC (permalink / raw)
  To: gdb

Hello,

I have a C++ program that generates a core dump. I must activate
inlining because it's too slow. It crashes very rarely.

The program stack is:

#2  0x080597da in CBase<TRow>::operator()() const () at
/home/ace/src/gs/mpvi.h:451
#3  0x081e0c1f in CPhrase::update() (this=0x115245d8) at
/home/ace/src/gs/mpvi.h:527

The problem is that CPhrase::update() is a big function in a cpp file. I
would like to know the line where the call to mpvi.h:527 is made. I
can't see it because the function is inlining and it's an accessor, so,
it's called at least 50 times on this function.

The question is: Is it possible to know where in the function ::update()
the crash happened?

Vianney Lecroart
---
lead network programmer / nevrax.com
icq#: 6870415
homepage: http://ace.planet-d.net
www.geekcode.com: GCS/E d- s+++: a- C+++$UL++ P- L+++>+$ E+>- W++ N+ o?
K- w++$ O- M- V- PS- PE? Y PGP t 5? X+ R- tv++ b- DI D+ G e++ h-- r y?



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

* Re: displaying source after and before the program counter
  2003-12-15 10:50 ` displaying source after and before the program counter Vianney Lecroart
@ 2003-12-15 14:16   ` Eli Zaretskii
  2003-12-15 15:47     ` Paul Koning
  2003-12-15 15:53   ` Daniel Jacobowitz
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2003-12-15 14:16 UTC (permalink / raw)
  To: Vianney Lecroart; +Cc: gdb

> From: "Vianney Lecroart" <lecroart@nevrax.com>
> Date: Mon, 15 Dec 2003 11:50:09 +0100
> 
> The problem is that CPhrase::update() is a big function in a cpp file. I
> would like to know the line where the call to mpvi.h:527 is made. I
> can't see it because the function is inlining and it's an accessor, so,
> it's called at least 50 times on this function.
> 
> The question is: Is it possible to know where in the function ::update()
> the crash happened?

Without turning off the inlining, yes?

Well, one way to do that is to look at the machine code in frame #3
(by using the `disassemble' command), then compare that with the
assembly generated by the compiler for the source code in question.
For the latter, invoke GCC exactly as it is invoked to compile the cpp
file which includes mpvi.h, but with the -S switch instead of the -c
switch.  (There are also switches that you can add to cause the
generated assembly to include source lines, which will make it easier
for you to associate the assembly with the source.)

HTH


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

* Re: displaying source after and before the program counter
  2003-12-15 14:16   ` Eli Zaretskii
@ 2003-12-15 15:47     ` Paul Koning
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Koning @ 2003-12-15 15:47 UTC (permalink / raw)
  To: lecroart; +Cc: gdb

>>>>> "Eli" == Eli Zaretskii <eliz@elta.co.il> writes:

 >> From: "Vianney Lecroart" <lecroart@nevrax.com> Date: Mon, 15 Dec
 >> 2003 11:50:09 +0100
 >> 
 >> The problem is that CPhrase::update() is a big function in a cpp
 >> file. I would like to know the line where the call to mpvi.h:527
 >> is made. I can't see it because the function is inlining and it's
 >> an accessor, so, it's called at least 50 times on this function.
 >> 
 >> The question is: Is it possible to know where in the function
 >> ::update() the crash happened?

 Eli> Without turning off the inlining, yes?

 Eli> Well, one way to do that is to look at the machine code in frame
 Eli> #3 (by using the `disassemble' command), then compare that with
 Eli> the assembly generated by the compiler for the source code in
 Eli> question.

Here's another approach:

Invoke the program via gdb.  Set a breakpoint at the address shown in
the call stack.  Start the program.

When the breakpoint hits, step to the next line ("n") until you're
back in the cpp file.  You're now near the inline function call you
need, most likely at the next line.  (Perhaps not quite, depending on
how much the optimizer has moved things around.

    paul


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

* Re: displaying source after and before the program counter
  2003-12-15 10:50 ` displaying source after and before the program counter Vianney Lecroart
  2003-12-15 14:16   ` Eli Zaretskii
@ 2003-12-15 15:53   ` Daniel Jacobowitz
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-12-15 15:53 UTC (permalink / raw)
  To: gdb

On Mon, Dec 15, 2003 at 11:50:09AM +0100, Vianney Lecroart wrote:
> Hello,
> 
> I have a C++ program that generates a core dump. I must activate
> inlining because it's too slow. It crashes very rarely.
> 
> The program stack is:
> 
> #2  0x080597da in CBase<TRow>::operator()() const () at
> /home/ace/src/gs/mpvi.h:451
> #3  0x081e0c1f in CPhrase::update() (this=0x115245d8) at
> /home/ace/src/gs/mpvi.h:527
> 
> The problem is that CPhrase::update() is a big function in a cpp file. I
> would like to know the line where the call to mpvi.h:527 is made. I
> can't see it because the function is inlining and it's an accessor, so,
> it's called at least 50 times on this function.
> 
> The question is: Is it possible to know where in the function ::update()
> the crash happened?

In addition to the other suggestions you've gotten, you can work this
out by hand from the debug information; however, it's a bit of a pain
to do and you have to get familiar with DWARF-2.  GDB has enough
information to do this for you but currently doesn't support it. 
Hopefully that will change sometime next year.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

end of thread, other threads:[~2003-12-15 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1071484872.21849.ezmlm@sources.redhat.com>
2003-12-15 10:50 ` displaying source after and before the program counter Vianney Lecroart
2003-12-15 14:16   ` Eli Zaretskii
2003-12-15 15:47     ` Paul Koning
2003-12-15 15:53   ` Daniel Jacobowitz

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