In gdb, I can call one function with command "call", but how can I step in the function? I don't want to restart the program, but the function had been executed, gdb will execute next statement, and I don't know how to recall the function.
Use the shortcut "s" to step into the function.
--ahamed
---------- Post updated at 06:48 AM ---------- Previous update was at 06:45 AM ----------
root@bt:/tmp# gdb ./a.out
...
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/a.out...done.
(gdb) b main
Breakpoint 1 at 0x8048732: file run.cpp, line 16.
(gdb) run
Starting program: /tmp/a.out
Breakpoint 1, main (argc=1, argv=0xbffff604) at run.cpp:16
16 callme();
(gdb) step
callme () at run.cpp:6
6 cout<<"callme()"<<endl;
(gdb)
--ahamed
Thanks
#include <stdio.h>
void callme(){
fputs( "hello\n", stdout );
}
void main() {
fputs( "begin\n", stdout );
callme();
fputs( "end\n", stdout );
}
gdb :
(gdb) n
begin
24 callme();
(gdb)
hello
25 fputs( "end\n", stdout );
(gdb)
end
26 }
(gdb) call callme
$1 = {void ()} 0x80483e4 <callme>
(gdb) call callme()
hello
I can use command "call callme()" to test one function more, but how can I step in callme() after gdb have execute the statement "callme();" and gdb will execute next statement "fputs( "end\n", stdout );" .
I want to call callme() and then step in callme()
You need to set a break point first on the callme() function and then do call callme.
root@bt:/tmp# gdb a.out
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/a.out...done.
(gdb) break callme
Breakpoint 1 at 0x80486da: file run.cpp, line 6.
(gdb) call callme
$1 = {void (void)} 0x80486d4 <callme>
(gdb) run
Starting program: /tmp/a.out
Breakpoint 1, callme () at run.cpp:6
6 cout<<"callme1"<<endl;
(gdb)
--ahamed
Thanks,
(gdb) call callme $1 = {void (void)} 0x80486d4 <callme>
gdb does not step in function after "call callme" .