* How to store function-name and its return values while program runs
@ 2008-11-21 10:36 Sandeep222
2008-11-21 11:02 ` Gaius Mulley
0 siblings, 1 reply; 8+ messages in thread
From: Sandeep222 @ 2008-11-21 10:36 UTC (permalink / raw)
To: gdb
As we proceed with debugging a program, if I need to know the order of
functions being executed by printing on screen along with their return
values when a 'run' command or 'next' command is executed, how can i
proceed? I went thru frame.c but all the function seem to execute only when
a command is executed in the gdb. Plz help.
Reg,
Sandeep
--
View this message in context: http://www.nabble.com/How-to-store-function-name-and-its-return-values-while-program-runs-tp20618721p20618721.html
Sent from the Sourceware - gdb list mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to store function-name and its return values while program runs
2008-11-21 10:36 How to store function-name and its return values while program runs Sandeep222
@ 2008-11-21 11:02 ` Gaius Mulley
2008-11-21 19:05 ` Michael Snyder
0 siblings, 1 reply; 8+ messages in thread
From: Gaius Mulley @ 2008-11-21 11:02 UTC (permalink / raw)
To: Sandeep222; +Cc: gdb
Sandeep222 <sandeep.srikumar@honeywell.com> writes:
> As we proceed with debugging a program, if I need to know the order of
> functions being executed by printing on screen along with their return
> values when a 'run' command or 'next' command is executed, how can i
> proceed? I went thru frame.c but all the function seem to execute only when
> a command is executed in the gdb. Plz help.
> Reg,
> Sandeep
set a breakpoint at each of the functions of interest.
(gdb) break function1
(gdb) break function2
etc
now run the program
(gdb) run
when gdb hits a breakpoint you can finish the function and
print the result via:
(gdb) fin
regards,
Gaius
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to store function-name and its return values while program runs
2008-11-21 11:02 ` Gaius Mulley
@ 2008-11-21 19:05 ` Michael Snyder
2008-11-21 22:11 ` Paul Pluzhnikov
0 siblings, 1 reply; 8+ messages in thread
From: Michael Snyder @ 2008-11-21 19:05 UTC (permalink / raw)
To: Gaius Mulley; +Cc: Sandeep222, gdb
Gaius Mulley wrote:
> Sandeep222 <sandeep.srikumar@honeywell.com> writes:
>
>> As we proceed with debugging a program, if I need to know the order of
>> functions being executed by printing on screen along with their return
>> values when a 'run' command or 'next' command is executed, how can i
>> proceed? I went thru frame.c but all the function seem to execute only when
>> a command is executed in the gdb. Plz help.
>> Reg,
>> Sandeep
>
> set a breakpoint at each of the functions of interest.
>
> (gdb) break function1
> (gdb) break function2
>
> etc
>
> now run the program
>
> (gdb) run
>
> when gdb hits a breakpoint you can finish the function and
> print the result via:
>
> (gdb) fin
And indeed, you can make that automatic by attaching the
commands to the breakpoints:
(gdb) break function1
(gdb) commands
> finish
> continue
> end
(gdb)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to store function-name and its return values while program runs
2008-11-21 19:05 ` Michael Snyder
@ 2008-11-21 22:11 ` Paul Pluzhnikov
2008-11-21 22:29 ` Joel Brobecker
2008-11-22 0:47 ` Michael Snyder
0 siblings, 2 replies; 8+ messages in thread
From: Paul Pluzhnikov @ 2008-11-21 22:11 UTC (permalink / raw)
To: Michael Snyder; +Cc: Gaius Mulley, Sandeep222, gdb
On Fri, Nov 21, 2008 at 11:04 AM, Michael Snyder <msnyder@vmware.com> wrote:
> (gdb) break function1
> (gdb) commands
>> finish
>> continue
>> end
> (gdb)
I wished many times that above worked, but it doesn't: 'finish'
appears to interrupt flow of script, and subsequent commands are
never executed:
cat t.c
int foo() { return 42; }
int main() { return foo(); }
gcc -g t.c
gdb64-cvs ./a.out
GNU gdb (GDB) 6.8.50.20081118-cvs
Copyright (C) 2008 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 "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) b foo
Breakpoint 1 at 0x400310: file t.c, line 1.
(gdb) commands 1
>finish
>print/a $pc
>continue
>end
(gdb) r
Breakpoint 1, foo () at t.c:1
1 int foo() { return 42; }
0x0000000000400325 in main () at t.c:2
2 int main() { return foo(); }
Value returned is $1 = 42
# Neither 'print/a $pc' nor 'continue' executed :(
(gdb) q
Is this a bug?
--
Paul Pluzhnikov
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: How to store function-name and its return values while program runs
2008-11-21 22:11 ` Paul Pluzhnikov
@ 2008-11-21 22:29 ` Joel Brobecker
2008-11-22 0:48 ` Michael Snyder
2008-11-22 0:47 ` Michael Snyder
1 sibling, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2008-11-21 22:29 UTC (permalink / raw)
To: Paul Pluzhnikov; +Cc: Michael Snyder, Gaius Mulley, Sandeep222, gdb
> I wished many times that above worked, but it doesn't: 'finish'
> appears to interrupt flow of script, and subsequent commands are
> never executed:
[...]
> Is this a bug?
It actually isn't. The manual tries to explain why:
> Any other commands in the command list, after a command that resumes
> execution, are ignored. This is because any time you resume execution
> (even with a simple next or step), you may encounter another
> breakpoint--which could have its own command list, leading to
> ambiguities about which list to execute.
Most of the users at AdaCore view this as a limitation, but I haven't
really had the energy to look at improving this.
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to store function-name and its return values while program runs
2008-11-21 22:29 ` Joel Brobecker
@ 2008-11-22 0:48 ` Michael Snyder
2008-11-22 0:59 ` Joel Brobecker
0 siblings, 1 reply; 8+ messages in thread
From: Michael Snyder @ 2008-11-22 0:48 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Paul Pluzhnikov, Gaius Mulley, Sandeep222, gdb
Joel Brobecker wrote:
>> I wished many times that above worked, but it doesn't: 'finish'
>> appears to interrupt flow of script, and subsequent commands are
>> never executed:
> [...]
>> Is this a bug?
>
> It actually isn't. The manual tries to explain why:
>
>> Any other commands in the command list, after a command that resumes
>> execution, are ignored. This is because any time you resume execution
>> (even with a simple next or step), you may encounter another
>> breakpoint--which could have its own command list, leading to
>> ambiguities about which list to execute.
>
> Most of the users at AdaCore view this as a limitation, but I haven't
> really had the energy to look at improving this.
Mumble. I'm sorry -- of course I knew about that, but I
must have dreamed that somebody had done something about it
a while back...
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to store function-name and its return values while program runs
2008-11-22 0:48 ` Michael Snyder
@ 2008-11-22 0:59 ` Joel Brobecker
0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-11-22 0:59 UTC (permalink / raw)
To: Michael Snyder; +Cc: Paul Pluzhnikov, Gaius Mulley, Sandeep222, gdb
> Mumble. I'm sorry -- of course I knew about that, but I
> must have dreamed that somebody had done something about it
> a while back...
I *think* that what was done sometime ago was improve the situation
with function calls. An inferior function call technically restarts
the inferior, but they don't interrupt the command list anymore.
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to store function-name and its return values while program runs
2008-11-21 22:11 ` Paul Pluzhnikov
2008-11-21 22:29 ` Joel Brobecker
@ 2008-11-22 0:47 ` Michael Snyder
1 sibling, 0 replies; 8+ messages in thread
From: Michael Snyder @ 2008-11-22 0:47 UTC (permalink / raw)
To: Paul Pluzhnikov; +Cc: Gaius Mulley, Sandeep222, gdb
Paul Pluzhnikov wrote:
> On Fri, Nov 21, 2008 at 11:04 AM, Michael Snyder <msnyder@vmware.com> wrote:
>
>> (gdb) break function1
>> (gdb) commands
>>> finish
>>> continue
>>> end
>> (gdb)
>
> I wished many times that above worked, but it doesn't: 'finish'
> appears to interrupt flow of script, and subsequent commands are
> never executed:
Am I halucinating? I thought we fixed that a long time ago.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-11-22 0:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-21 10:36 How to store function-name and its return values while program runs Sandeep222
2008-11-21 11:02 ` Gaius Mulley
2008-11-21 19:05 ` Michael Snyder
2008-11-21 22:11 ` Paul Pluzhnikov
2008-11-21 22:29 ` Joel Brobecker
2008-11-22 0:48 ` Michael Snyder
2008-11-22 0:59 ` Joel Brobecker
2008-11-22 0:47 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox