Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Step outer function call
@ 2008-01-28 19:55 William K. Foster
  2008-01-28 20:03 ` Marc Khouzam
  2008-01-28 20:10 ` Daniel Jacobowitz
  0 siblings, 2 replies; 9+ messages in thread
From: William K. Foster @ 2008-01-28 19:55 UTC (permalink / raw)
  To: gdb

Hello,

I often find that when stepping through code, I would like to step into 
the outer most function call on a line of code, but the only way I see 
to do this is to step into each inner call and finish them until 
reaching the outer call.  For example:

  foo(bar(), baz());

If on the above line and I step, I first enter bar(), then baz(), and 
finally foo().

The vast majority of the time, I want to enter foo().

Is there a command or script to accomplish this?

If not, is this a reasonable feature request for gdb?

Thanks.

-William


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

* RE: Step outer function call
  2008-01-28 19:55 Step outer function call William K. Foster
@ 2008-01-28 20:03 ` Marc Khouzam
  2008-01-28 20:10 ` Daniel Jacobowitz
  1 sibling, 0 replies; 9+ messages in thread
From: Marc Khouzam @ 2008-01-28 20:03 UTC (permalink / raw)
  To: wkf, gdb

I found a similar question with answer from a couple of months ago:
http://sourceware.org/ml/gdb/2007-11/msg00206.html


-----Original Message-----
From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org]On
Behalf Of William K. Foster
Sent: Monday, January 28, 2008 2:55 PM
To: gdb@sourceware.org
Subject: Step outer function call


Hello,

I often find that when stepping through code, I would like to step into 
the outer most function call on a line of code, but the only way I see 
to do this is to step into each inner call and finish them until 
reaching the outer call.  For example:

  foo(bar(), baz());

If on the above line and I step, I first enter bar(), then baz(), and 
finally foo().

The vast majority of the time, I want to enter foo().

Is there a command or script to accomplish this?

If not, is this a reasonable feature request for gdb?

Thanks.

-William


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

* Re: Step outer function call
  2008-01-28 19:55 Step outer function call William K. Foster
  2008-01-28 20:03 ` Marc Khouzam
@ 2008-01-28 20:10 ` Daniel Jacobowitz
  2008-01-28 20:13   ` William K. Foster
  1 sibling, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2008-01-28 20:10 UTC (permalink / raw)
  To: William K. Foster; +Cc: gdb

On Mon, Jan 28, 2008 at 11:55:24AM -0800, William K. Foster wrote:
> If not, is this a reasonable feature request for gdb?

Folks do seem to want this fairly often.  But current debug formats do
not provide enough information to identify the situation, so (as far
as we've been able to determine) there's no way to implement it.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: Step outer function call
  2008-01-28 20:10 ` Daniel Jacobowitz
@ 2008-01-28 20:13   ` William K. Foster
  2008-01-28 20:20     ` Daniel Jacobowitz
                       ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: William K. Foster @ 2008-01-28 20:13 UTC (permalink / raw)
  To: William K. Foster, gdb

Hi,

I don't know much about the debug formats, but it seems to me that since 
the debugger knows what line number it is on in the source code, it 
should be able to locate the last function call on that line number and 
enter it for this hypothetical command that many people seem to want.

Am I missing something?

Thanks.

-WIlliam


Daniel Jacobowitz wrote:
> On Mon, Jan 28, 2008 at 11:55:24AM -0800, William K. Foster wrote:
>   
>> If not, is this a reasonable feature request for gdb?
>>     
>
> Folks do seem to want this fairly often.  But current debug formats do
> not provide enough information to identify the situation, so (as far
> as we've been able to determine) there's no way to implement it.
>
>   


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

* Re: Step outer function call
  2008-01-28 20:13   ` William K. Foster
@ 2008-01-28 20:20     ` Daniel Jacobowitz
  2008-01-29  4:19       ` Eli Zaretskii
  2008-01-28 22:36     ` Michael Snyder
  2008-01-28 23:00     ` Nick Roberts
  2 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2008-01-28 20:20 UTC (permalink / raw)
  To: William K. Foster; +Cc: gdb

On Mon, Jan 28, 2008 at 12:12:52PM -0800, William K. Foster wrote:
> Hi,
>
> I don't know much about the debug formats, but it seems to me that since  
> the debugger knows what line number it is on in the source code, it  
> should be able to locate the last function call on that line number and  
> enter it for this hypothetical command that many people seem to want.
>
> Am I missing something?

Yes, generally we can't locate the last function call.  The problem
here is "last" - a source line can be broken into many pieces and
contain arbitrary flow control.  We'd have to essentially uncompile
the code to figure it out.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: Step outer function call
  2008-01-28 20:13   ` William K. Foster
  2008-01-28 20:20     ` Daniel Jacobowitz
@ 2008-01-28 22:36     ` Michael Snyder
  2008-01-28 23:00     ` Nick Roberts
  2 siblings, 0 replies; 9+ messages in thread
From: Michael Snyder @ 2008-01-28 22:36 UTC (permalink / raw)
  To: wkf; +Cc: gdb

On Mon, 2008-01-28 at 12:12 -0800, William K. Foster wrote:
> Hi,
> 
> I don't know much about the debug formats, but it seems to me that since 
> the debugger knows what line number it is on in the source code, it 
> should be able to locate the last function call on that line number and 
> enter it for this hypothetical command that many people seem to want.
> 
> Am I missing something?

Yeah.  GDB doesn't do that sort of thing, involving
basically disassembling the instructions and grokking
what they do.

Well it does, in some special and limited circumstances
when it can't be avoided, but not in general.  And those
cases where it does it are very fragile and difficult to
maintain.  In general we'd like to have gdb do that kind
of thing less, not more.




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

* Re: Step outer function call
  2008-01-28 20:13   ` William K. Foster
  2008-01-28 20:20     ` Daniel Jacobowitz
  2008-01-28 22:36     ` Michael Snyder
@ 2008-01-28 23:00     ` Nick Roberts
  2 siblings, 0 replies; 9+ messages in thread
From: Nick Roberts @ 2008-01-28 23:00 UTC (permalink / raw)
  To: wkf; +Cc: gdb

 > >> If not, is this a reasonable feature request for gdb?

This is what I use running gdb in Emacs


In .gdbinit:

define function_step
  tbreak $arg0
  cont
end

------------

In .emacs

(add-hook 'gdb-mode-hook
'(lambda ()
   (gud-def gud-function-step
	    "function_step %e" nil "Step to this function.")
   (define-key-after gud-tool-bar-map [step-outer]
     '(menu-item "Step outer" gud-function-step
       :image (image :type xpm
		     :file "/home/nickrob/emacs/etc/images/jump-to.xpm")))))

------------

You would have to specify your own icon, of course.

Then all you need to do is place the cursor on the function that you want to
stop in and click on the relevant toolbar icon.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


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

* Re: Step outer function call
  2008-01-28 20:20     ` Daniel Jacobowitz
@ 2008-01-29  4:19       ` Eli Zaretskii
  2008-01-29  6:44         ` Michael Snyder
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2008-01-29  4:19 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: wkf, gdb

> Date: Mon, 28 Jan 2008 15:19:39 -0500
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb@sourceware.org
> 
> On Mon, Jan 28, 2008 at 12:12:52PM -0800, William K. Foster wrote:
> > Hi,
> >
> > I don't know much about the debug formats, but it seems to me that since  
> > the debugger knows what line number it is on in the source code, it  
> > should be able to locate the last function call on that line number and  
> > enter it for this hypothetical command that many people seem to want.
> >
> > Am I missing something?
> 
> Yes, generally we can't locate the last function call.

Can we locate all of them?  If so, perhaps we could (optionally)
display a menu of them and ask the user where she wants to step.


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

* Re: Step outer function call
  2008-01-29  4:19       ` Eli Zaretskii
@ 2008-01-29  6:44         ` Michael Snyder
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Snyder @ 2008-01-29  6:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Daniel Jacobowitz, wkf, gdb

On Tue, 2008-01-29 at 06:18 +0200, Eli Zaretskii wrote:
> > Date: Mon, 28 Jan 2008 15:19:39 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: gdb@sourceware.org
> > 
> > On Mon, Jan 28, 2008 at 12:12:52PM -0800, William K. Foster wrote:
> > > Hi,
> > >
> > > I don't know much about the debug formats, but it seems to me that since  
> > > the debugger knows what line number it is on in the source code, it  
> > > should be able to locate the last function call on that line number and  
> > > enter it for this hypothetical command that many people seem to want.
> > >
> > > Am I missing something?
> > 
> > Yes, generally we can't locate the last function call.
> 
> Can we locate all of them?  If so, perhaps we could (optionally)
> display a menu of them and ask the user where she wants to step.

Currently we can't locate any.  Gdb does not know what a
call instruction looks like.  There would have to be an arch
method, since call instructions look different on each target
architecture.



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

end of thread, other threads:[~2008-01-29  6:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-28 19:55 Step outer function call William K. Foster
2008-01-28 20:03 ` Marc Khouzam
2008-01-28 20:10 ` Daniel Jacobowitz
2008-01-28 20:13   ` William K. Foster
2008-01-28 20:20     ` Daniel Jacobowitz
2008-01-29  4:19       ` Eli Zaretskii
2008-01-29  6:44         ` Michael Snyder
2008-01-28 22:36     ` Michael Snyder
2008-01-28 23:00     ` Nick Roberts

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