* A question about gdb script
@ 2009-11-25 19:19 Hui Zhu
2009-11-26 8:30 ` Daniel Jacobowitz
2009-11-26 15:39 ` Michael Snyder
0 siblings, 2 replies; 10+ messages in thread
From: Hui Zhu @ 2009-11-25 19:19 UTC (permalink / raw)
To: gdb
Hi guys,
I got a trouble in line:
/* Make sure there is at least one LWP that has been resumed. */
gdb_assert (iterate_over_lwps (ptid, resumed_callback, NULL));
I set a breakpoint in the begin of this function and add commands:
silent
record
c
to it.
And set a bp in the end of this function and add commands:
silent
record stop
c
to it.
And I set a bp in internal_error.
Then I found the bug.
But I found that still have 2 ways not very easy to implement. I know
nothing about it. could you help me with it?
1. If I want get the gdb_record.xxx file of each record cycle. It's
still hard to me. Because if I add "record save" to commands, each
time it will save record entry to same file.
Does gdb have some way to handle it? like:
$a=1
record save $a
$a++
2. Sometime, I want just record a function, I want:
b functon_name
commands
silent
record
finish
#Maybe we can record save in this line, this is first question.
record stop
end
But when I really do it. I found that gdb stop running after finish.
Could you help me with them?
Thanks,
Hui
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-25 19:19 A question about gdb script Hui Zhu
@ 2009-11-26 8:30 ` Daniel Jacobowitz
2009-11-26 8:51 ` Pedro Alves
2009-11-26 15:39 ` Michael Snyder
1 sibling, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2009-11-26 8:30 UTC (permalink / raw)
To: Hui Zhu; +Cc: gdb
On Wed, Nov 25, 2009 at 04:42:54PM +0800, Hui Zhu wrote:
> 1. If I want get the gdb_record.xxx file of each record cycle. It's
> still hard to me. Because if I add "record save" to commands, each
> time it will save record entry to same file.
> Does gdb have some way to handle it? like:
> $a=1
> record save $a
> $a++
Not directly, but you can do this using Python scripting.
> 2. Sometime, I want just record a function, I want:
> b functon_name
> commands
> silent
> record
> finish
> #Maybe we can record save in this line, this is first question.
> record stop
> end
> But when I really do it. I found that gdb stop running after finish.
>
> Could you help me with them?
This is a known limitation of breakpoint commands. It's very
difficult.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-26 8:30 ` Daniel Jacobowitz
@ 2009-11-26 8:51 ` Pedro Alves
2009-11-26 15:54 ` Hui Zhu
0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2009-11-26 8:51 UTC (permalink / raw)
To: gdb; +Cc: Daniel Jacobowitz, Hui Zhu
On Wednesday 25 November 2009 15:11:51, Daniel Jacobowitz wrote:
> > 2. Sometime, I want just record a function, I want:
> > b functon_name
> > commands
> > silent
> > record
> > finish
> > #Maybe we can record save in this line, this is first question.
> > record stop
> > end
> > But when I really do it. I found that gdb stop running after finish.
> >
> > Could you help me with them?
>
> This is a known limitation of breakpoint commands. It's very
> difficult.
Try using the hook-stop instead. Something like this:
set $stop_recording_on_next_stop=0
b functon_name
commands
silent
record
set $stop_recording_on_next_stop=1
finish
end
define hook-stop
if $stop_recording_on_next_stop
set $stop_recording_on_next_stop=0
record save
record stop
end
end
--
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-25 19:19 A question about gdb script Hui Zhu
2009-11-26 8:30 ` Daniel Jacobowitz
@ 2009-11-26 15:39 ` Michael Snyder
2009-11-26 16:01 ` Hui Zhu
1 sibling, 1 reply; 10+ messages in thread
From: Michael Snyder @ 2009-11-26 15:39 UTC (permalink / raw)
To: Hui Zhu; +Cc: gdb
Hui Zhu wrote:
> 1. If I want get the gdb_record.xxx file of each record cycle. It's
> still hard to me. Because if I add "record save" to commands, each
> time it will save record entry to same file.
> Does gdb have some way to handle it? like:
> $a=1
> record save $a
> $a++
If you look at cmd_record_save, you see it has (char *args).
GDB will pass "$a" as "args", so at that point you have the
opportunity to say, eg. "if (args[0] == '$') then do something".
One possibility would be to create your default name, eg.
gdb_record.12345, and then append $a making gdb_record.12345.1
That's the quick and dirty way. Something more elegant might
be better.
> 2. Sometime, I want just record a function, I want:
> b functon_name
> commands
> silent
> record
> finish
> #Maybe we can record save in this line, this is first question.
> record stop
> end
> But when I really do it. I found that gdb stop running after finish.
That is unfortunately a long-standing gdb "limitation" (I mean ,
known bug). It is so old that it is not likely to be fixed soon.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-26 8:51 ` Pedro Alves
@ 2009-11-26 15:54 ` Hui Zhu
2009-11-26 17:16 ` Marc Khouzam
2009-11-27 0:32 ` Michael Snyder
0 siblings, 2 replies; 10+ messages in thread
From: Hui Zhu @ 2009-11-26 15:54 UTC (permalink / raw)
To: Pedro Alves, Daniel Jacobowitz, Michael Snyder; +Cc: gdb
On Thu, Nov 26, 2009 at 00:06, Pedro Alves <pedro@codesourcery.com> wrote:
> On Wednesday 25 November 2009 15:11:51, Daniel Jacobowitz wrote:
>> > 2. Sometime, I want just record a function, I want:
>> > b functon_name
>> > commands
>> > silent
>> > record
>> > finish
>> > #Maybe we can record save in this line, this is first question.
>> > record stop
>> > end
>> > But when I really do it. I found that gdb stop running after finish.
>> >
>> > Could you help me with them?
>>
>> This is a known limitation of breakpoint commands. It's very
>> difficult.
>
> Try using the hook-stop instead. Something like this:
>
> set $stop_recording_on_next_stop=0
>
> b functon_name
> commands
> silent
> record
> set $stop_recording_on_next_stop=1
> finish
> end
>
> define hook-stop
> if $stop_recording_on_next_stop
> set $stop_recording_on_next_stop=0
> record save
> record stop
> end
> end
>
Cool. I change hook-stop to:
define hook-stop
if $stop_recording_on_next_stop
set $stop_recording_on_next_stop=0
record save
record stop
c
end
end
It looks not bad, but got a lot of:
---Type <return> to continue, or q <return> to quit---q
If you don't mind, I will post a patch to change each fprintf_filtered
in record.c to fprintf_unfiltered.
Thanks,
Hui
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-26 15:39 ` Michael Snyder
@ 2009-11-26 16:01 ` Hui Zhu
2009-11-27 1:37 ` Michael Snyder
0 siblings, 1 reply; 10+ messages in thread
From: Hui Zhu @ 2009-11-26 16:01 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb, Pedro Alves, Daniel Jacobowitz
On Thu, Nov 26, 2009 at 03:15, Michael Snyder <msnyder@vmware.com> wrote:
> Hui Zhu wrote:
>
>> 1. If I want get the gdb_record.xxx file of each record cycle. It's
>> still hard to me. Because if I add "record save" to commands, each
>> time it will save record entry to same file.
>> Does gdb have some way to handle it? like:
>> $a=1
>> record save $a
>> $a++
>
> If you look at cmd_record_save, you see it has (char *args).
> GDB will pass "$a" as "args", so at that point you have the
> opportunity to say, eg. "if (args[0] == '$') then do something".
>
> One possibility would be to create your default name, eg.
> gdb_record.12345, and then append $a making gdb_record.12345.1
>
> That's the quick and dirty way. Something more elegant might
> be better.
I try this way but got:
(gdb) set $record = 3
(gdb) record save core.$record
Saved core file core.$record with execution log.
Maybe I can post a patch for it. What about following:
(gdb) set record not_overwrite_save on
(gdb) record save core
Saved core file core with execution log.
(gdb) record save core
Saved core file core.0 with execution log.
(gdb) record save core
Saved core file core.1 with execution log.
Thanks,
Hui
>
>> 2. Sometime, I want just record a function, I want:
>> b functon_name
>> commands
>> silent
>> record
>> finish
>> #Maybe we can record save in this line, this is first question.
>> record stop
>> end
>> But when I really do it. I found that gdb stop running after finish.
>
> That is unfortunately a long-standing gdb "limitation" (I mean ,
> known bug). It is so old that it is not likely to be fixed soon.
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: A question about gdb script
2009-11-26 15:54 ` Hui Zhu
@ 2009-11-26 17:16 ` Marc Khouzam
2009-11-27 0:32 ` Michael Snyder
1 sibling, 0 replies; 10+ messages in thread
From: Marc Khouzam @ 2009-11-26 17:16 UTC (permalink / raw)
To: Hui Zhu, Pedro Alves, Daniel Jacobowitz, Michael Snyder; +Cc: gdb
> -----Original Message-----
> From: gdb-owner@sourceware.org
> [mailto:gdb-owner@sourceware.org] On Behalf Of Hui Zhu
> Sent: November-26-09 9:30 AM
> To: Pedro Alves; Daniel Jacobowitz; Michael Snyder
> Cc: gdb@sourceware.org
> Subject: Re: A question about gdb script
>
> On Thu, Nov 26, 2009 at 00:06, Pedro Alves
> <pedro@codesourcery.com> wrote:
> > On Wednesday 25 November 2009 15:11:51, Daniel Jacobowitz wrote:
> >> > 2. Sometime, I want just record a function, I want:
> >> > b functon_name
> >> > commands
> >> > silent
> >> > record
> >> > finish
> >> > #Maybe we can record save in this line, this is first question.
> >> > record stop
> >> > end
> >> > But when I really do it. I found that gdb stop running
> after finish.
> >> >
> >> > Could you help me with them?
> >>
> >> This is a known limitation of breakpoint commands. It's very
> >> difficult.
> >
> > Try using the hook-stop instead. Something like this:
> >
> > set $stop_recording_on_next_stop=0
> >
> > b functon_name
> > commands
> > silent
> > record
> > set $stop_recording_on_next_stop=1
> > finish
> > end
> >
> > define hook-stop
> > if $stop_recording_on_next_stop
> > set $stop_recording_on_next_stop=0
> > record save
> > record stop
> > end
> > end
> >
>
> Cool. I change hook-stop to:
> define hook-stop
> if $stop_recording_on_next_stop
> set $stop_recording_on_next_stop=0
> record save
> record stop
> c
> end
> end
>
> It looks not bad, but got a lot of:
> ---Type <return> to continue, or q <return> to quit---q
I think the command
set pagination off
will prevent this.
> If you don't mind, I will post a patch to change each fprintf_filtered
> in record.c to fprintf_unfiltered.
>
> Thanks,
> Hui
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-26 15:54 ` Hui Zhu
2009-11-26 17:16 ` Marc Khouzam
@ 2009-11-27 0:32 ` Michael Snyder
2009-11-27 8:05 ` Hui Zhu
1 sibling, 1 reply; 10+ messages in thread
From: Michael Snyder @ 2009-11-27 0:32 UTC (permalink / raw)
To: Hui Zhu; +Cc: Pedro Alves, Daniel Jacobowitz, gdb
Hui Zhu wrote:
> It looks not bad, but got a lot of:
> ---Type <return> to continue, or q <return> to quit---q
That can be fixed by saying "set height 0".
> If you don't mind, I will post a patch to change each fprintf_filtered
> in record.c to fprintf_unfiltered.
No, I don't agree with that. If you do that, then user has
no choice about pagination. "Set height" gives user a choice.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-26 16:01 ` Hui Zhu
@ 2009-11-27 1:37 ` Michael Snyder
0 siblings, 0 replies; 10+ messages in thread
From: Michael Snyder @ 2009-11-27 1:37 UTC (permalink / raw)
To: Hui Zhu; +Cc: gdb, Pedro Alves, Daniel Jacobowitz
Hui Zhu wrote:
> On Thu, Nov 26, 2009 at 03:15, Michael Snyder <msnyder@vmware.com> wrote:
>> Hui Zhu wrote:
>>
>>> 1. If I want get the gdb_record.xxx file of each record cycle. It's
>>> still hard to me. Because if I add "record save" to commands, each
>>> time it will save record entry to same file.
>>> Does gdb have some way to handle it? like:
>>> $a=1
>>> record save $a
>>> $a++
>> If you look at cmd_record_save, you see it has (char *args).
>> GDB will pass "$a" as "args", so at that point you have the
>> opportunity to say, eg. "if (args[0] == '$') then do something".
>>
>> One possibility would be to create your default name, eg.
>> gdb_record.12345, and then append $a making gdb_record.12345.1
>>
>> That's the quick and dirty way. Something more elegant might
>> be better.
>
> I try this way but got:
> (gdb) set $record = 3
> (gdb) record save core.$record
> Saved core file core.$record with execution log.
No, what I meant was
(gdb) set $foo = 3
(gdb) record save $foo
That way you can look at the *first character* of "args", and
use an 'if' to do something special with it, such as
char *filename = strcat("gdb_record.core", args);
> Maybe I can post a patch for it. What about following:
> (gdb) set record not_overwrite_save on
> (gdb) record save core
> Saved core file core with execution log.
> (gdb) record save core
> Saved core file core.0 with execution log.
> (gdb) record save core
> Saved core file core.1 with execution log.
That's also a possibility, although I think we are headed
in the direction of having too many mode variables associated
with process rec.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: A question about gdb script
2009-11-27 0:32 ` Michael Snyder
@ 2009-11-27 8:05 ` Hui Zhu
0 siblings, 0 replies; 10+ messages in thread
From: Hui Zhu @ 2009-11-27 8:05 UTC (permalink / raw)
To: Michael Snyder, Pedro Alves, Daniel Jacobowitz, Marc Khouzam; +Cc: gdb
Cool.
What I did is:
set $stop_recording_on_next_stop=0
set height 0
b functon_name
commands
record
set $stop_recording_on_next_stop=1
finish
end
define hook-stop
if $stop_recording_on_next_stop
set $stop_recording_on_next_stop=0
record save
record stop
c
end
end
It works very well. When we done the record name issue, I will post it to wiki.
Thanks everyone. :)
Hui
On Fri, Nov 27, 2009 at 02:24, Michael Snyder <msnyder@vmware.com> wrote:
> Hui Zhu wrote:
>
>> It looks not bad, but got a lot of:
>> ---Type <return> to continue, or q <return> to quit---q
>
> That can be fixed by saying "set height 0".
>
>> If you don't mind, I will post a patch to change each fprintf_filtered
>> in record.c to fprintf_unfiltered.
>
> No, I don't agree with that. If you do that, then user has
> no choice about pagination. "Set height" gives user a choice.
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-11-27 2:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-25 19:19 A question about gdb script Hui Zhu
2009-11-26 8:30 ` Daniel Jacobowitz
2009-11-26 8:51 ` Pedro Alves
2009-11-26 15:54 ` Hui Zhu
2009-11-26 17:16 ` Marc Khouzam
2009-11-27 0:32 ` Michael Snyder
2009-11-27 8:05 ` Hui Zhu
2009-11-26 15:39 ` Michael Snyder
2009-11-26 16:01 ` Hui Zhu
2009-11-27 1:37 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox