This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Return from manually called function in gdb


It is amazing that no one noticed this before.
Please try the following patch and let me know if it works for you:

*** gdb/stack.c.orig	Sat Aug  5 11:37:49 2000
--- gdb/stack.c	Mon Sep 11 11:36:11 2000
***************
*** 1886,1891 ****
--- 1886,1897 ----
  
    POP_FRAME;
  
+   /* If we are at the end of a call dummy now, pop the dummy frame too.  */
+ 
+   if (CALL_DUMMY_HAS_COMPLETED (read_pc(), read_sp (),
+ 				FRAME_FP (get_current_frame ())))
+     POP_FRAME;
+ 
    /* Compute the return value (if any) and store in the place
       for return values.  */
  

> Hi,
> 
> This problem occurs on native (in my case i686-pc-linux(-gnu)) on both
> the 2000-05-19 release, as well as the latest CVS sources. What happens
> is that when I set a breakpoint at a function, call it from gdb, and
> force a return, gdb is thoroughly confused upon return. Allow me to
> illustrate what happens (using the funcargs test case from gdb.base):
> 
> 
> (gdb) b add
> Breakpoint 2 at 0x8048443: file
> ../../../src/gdb/testsuite/gdb.base/callfuncs.c, line 58.
> (gdb) call add(4,5)
> 
> Breakpoint 2, add (a=4, b=5)
>     at ../../../src/gdb/testsuite/gdb.base/callfuncs.c:58
> 58        return (a + b);
> The program being debugged stopped while in a function called from GDB.
> When the function (add) is done executing, GDB will silently
> stop (instead of continuing to evaluate the expression containing
> the function call).
> (gdb) return
> Make add return now? (y or n) y
> #0  <function called from gdb>
> (gdb) bt
> #0  <function called from gdb>
> #1  main () at ../../../src/gdb/testsuite/gdb.base/callfuncs.c:185
> #2  0x4004ca42 in __libc_start_main () from /lib/libc.so.6
> (gdb) n
> warning: Cannot insert breakpoint 0:
> Cannot access memory at address 0x4
> 
> 
> I'm merely using native gdb as a reference for my gdb port (which is for
> cross-debugging), and I'm not very familiar with the i386 registers.
> What happens with my gdb port is that the dummy pc used to recognize
> that we are in a call dummy is written to the pc when continuing from
> the breakpoint. Regular function calls from within gdb, when there is no
> breakpoint in the called function, works fine.
> 
> I'm probably asking for trouble by forcing a return in that situation,
> but I don't think the situation at hand is unimaginable.
> 
> 
> Orjan Friberg
> Axis Communications AB
> E-mail: orjan.friberg@axis.com 
> Phone:  +46 46 272 17 68

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]