* [RFC] syntax change for "record save"
@ 2009-11-27 2:25 Michael Snyder
2009-11-27 7:55 ` Joel Brobecker
0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2009-11-27 2:25 UTC (permalink / raw)
To: gdb, Hui Zhu
This proposal follows from Teawater's thread
"A question about gdb script", in which Teawater
wants to know how to use a gdb local variable
to append a sequence number to the file name
of a record log file.
Here is my proposal.
We change the syntax of the "record save" command
so that it expects an additional, optional argument.
If the 2nd argument is present, we evaluate it as an
integer expression and suffix it to the filename (with
a period). Evaluating it as an expression means that
it can be anything from an integer to a dollar-variable,
and the expression can even increment it.
So, for instance:
(gdb) rec save
Saved core file gdb_record.19165 with execution log.
(gdb) rec save foo 1
Saved core file foo.1 with execution log.
(gdb) rec save foo 2
Saved core file foo.2 with execution log.
(gdb) set $a = 1
(gdb) rec save foo $a++
Saved core file foo.1 with execution log.
(gdb) step
foo ()
at
/data/home/msnyder/cvs/localhost/quilt/gdb/testsuite/gdb.reverse/break-reverse.c:28
28 xyz = 1; /* break in foo */
(gdb) rec save foo $a++
Saved core file foo.2 with execution log.
(gdb) step
29 return bar ();
(gdb) rec save foo $a++
Saved core file foo.3 with execution log.
I'll submit a patch momentarily.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC] syntax change for "record save"
2009-11-27 2:25 [RFC] syntax change for "record save" Michael Snyder
@ 2009-11-27 7:55 ` Joel Brobecker
2009-11-27 15:17 ` Hui Zhu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Joel Brobecker @ 2009-11-27 7:55 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb, Hui Zhu
> This proposal follows from Teawater's thread
> "A question about gdb script", in which Teawater
> wants to know how to use a gdb local variable
> to append a sequence number to the file name
> of a record log file.
This is not an objection, but I am really not fond of that extension.
It feels ad hoc that the extension, if provided, should be evaluated
as an integer. What if the user wanted a more general scheme? Or what
if he wanted to the suffix to be in hex?
If I were Teawater, I'd probably look at writing a python script
rather than a GDB script. In particular, it's easy to compose the
right CLI command from python using:
(gdb) python gdb.execute("rec save file.%d" % 1)
You can replace the "1" above by an python variable, including
one obtained by evaluating an expression as a long.
One thing that you might want to look at, to make things even easier,
is providing a Python interface to the record layer... Combine that
with the work done on getting inferior "events" (I can't remember
exactly the name of that project - I think it was a GSOC), and it
should be possible to script really nice things...
--
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC] syntax change for "record save"
2009-11-27 7:55 ` Joel Brobecker
@ 2009-11-27 15:17 ` Hui Zhu
2009-11-30 12:37 ` Michael Snyder
2009-12-01 12:56 ` Jakob Engblom
2 siblings, 0 replies; 7+ messages in thread
From: Hui Zhu @ 2009-11-27 15:17 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Michael Snyder, gdb
Hi Joel,
I think python must can make prec work very powerful.
But let record save can do small thing can make it more flexible. It
still can be use when the gdb did't support python.
BTW, maybe we can put example about use prec together with python to wiki.
Thanks,
Hui
On Fri, Nov 27, 2009 at 09:37, Joel Brobecker <brobecker@adacore.com> wrote:
>> This proposal follows from Teawater's thread
>> "A question about gdb script", in which Teawater
>> wants to know how to use a gdb local variable
>> to append a sequence number to the file name
>> of a record log file.
>
> This is not an objection, but I am really not fond of that extension.
> It feels ad hoc that the extension, if provided, should be evaluated
> as an integer. What if the user wanted a more general scheme? Or what
> if he wanted to the suffix to be in hex?
>
> If I were Teawater, I'd probably look at writing a python script
> rather than a GDB script. In particular, it's easy to compose the
> right CLI command from python using:
>
> (gdb) python gdb.execute("rec save file.%d" % 1)
>
> You can replace the "1" above by an python variable, including
> one obtained by evaluating an expression as a long.
>
> One thing that you might want to look at, to make things even easier,
> is providing a Python interface to the record layer... Combine that
> with the work done on getting inferior "events" (I can't remember
> exactly the name of that project - I think it was a GSOC), and it
> should be possible to script really nice things...
>
> --
> Joel
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC] syntax change for "record save"
2009-11-27 7:55 ` Joel Brobecker
2009-11-27 15:17 ` Hui Zhu
@ 2009-11-30 12:37 ` Michael Snyder
2009-12-01 12:56 ` Jakob Engblom
2 siblings, 0 replies; 7+ messages in thread
From: Michael Snyder @ 2009-11-30 12:37 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb, Hui Zhu
Joel Brobecker wrote:
>> This proposal follows from Teawater's thread
>> "A question about gdb script", in which Teawater
>> wants to know how to use a gdb local variable
>> to append a sequence number to the file name
>> of a record log file.
>
> This is not an objection, but I am really not fond of that extension.
> It feels ad hoc that the extension, if provided, should be evaluated
> as an integer. What if the user wanted a more general scheme? Or what
> if he wanted to the suffix to be in hex?
Replying here before starting a new thread...
Well, nobody asked for it to be more general.
Whereas, I think this is not the first time I have
heard a request for this sort of functionality.
Could be the last request was regarding the 'gcore'
command, or maybe something else (set logging file?).
Now I'll start a new thread. ;-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [RFC] syntax change for "record save"
2009-11-27 7:55 ` Joel Brobecker
2009-11-27 15:17 ` Hui Zhu
2009-11-30 12:37 ` Michael Snyder
@ 2009-12-01 12:56 ` Jakob Engblom
2009-12-01 19:35 ` Tom Tromey
2 siblings, 1 reply; 7+ messages in thread
From: Jakob Engblom @ 2009-12-01 12:56 UTC (permalink / raw)
To: 'Joel Brobecker', 'Michael Snyder'; +Cc: gdb, 'Hui Zhu'
> > This proposal follows from Teawater's thread
> > "A question about gdb script", in which Teawater
> > wants to know how to use a gdb local variable
> > to append a sequence number to the file name
> > of a record log file.
>
> This is not an objection, but I am really not fond of that extension.
> It feels ad hoc that the extension, if provided, should be evaluated
> as an integer. What if the user wanted a more general scheme? Or what
> if he wanted to the suffix to be in hex?
>
> If I were Teawater, I'd probably look at writing a python script
> rather than a GDB script. In particular, it's easy to compose the
> right CLI command from python using:
>
> (gdb) python gdb.execute("rec save file.%d" % 1)
>
> You can replace the "1" above by an python variable, including
> one obtained by evaluating an expression as a long.
To take some input from a different (commercial, closed-source, if someone asks)
tool with a similar interface of script + Python, in Simics, we solve that by
having our CLI (quite similar to gdb in many ways) be able to construct strings.
So we would do something like this:
simics> save ("file." + $a)
(when the first argument to + is a string, the next argument is forced to a
string)
Or
Simics> save ("file.%d" % [$a]) ## Support for Python-style % operator in CLI
I think supporting string generation would solve many more problems easily.
The save name INDEX to me seems silly, if you are doing this manually, why don't
you just type a different name each time?
Best regards,
/jakob
_______________________________________________________
Jakob Engblom, PhD, Technical Marketing Manager
Virtutech Direct: +46 8 690 07 47
Drottningholmsvägen 22 Mobile: +46 709 242 646
11243 Stockholm Web: www.virtutech.com
Sweden
________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC] syntax change for "record save"
2009-12-01 12:56 ` Jakob Engblom
@ 2009-12-01 19:35 ` Tom Tromey
2009-12-02 17:46 ` Jakob Engblom
0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2009-12-01 19:35 UTC (permalink / raw)
To: Jakob Engblom
Cc: 'Joel Brobecker', 'Michael Snyder',
gdb, 'Hui Zhu'
>>>>> "Jakob" == Jakob Engblom <jakob@virtutech.com> writes:
Jakob> So we would do something like this:
simics> save ("file." + $a)
Jakob> (when the first argument to + is a string, the next argument is
Jakob> forced to a string)
Jakob> I think supporting string generation would solve many more
Jakob> problems easily.
The problem is that it is not obvious how to integrate this into the
existing gdb CLI. The CLI is not like a normal programming language,
with a regular syntax and a parser. Any regularity is just by
convention; each command is just passed a char* that it parses itself.
Of course, we could invent something. We could even turn the CLI into a
much more expressive language. I'd rather not, though -- we have Python
for that, and I think it is generally better to just reuse an existing
language than to try to invent a new one.
Jakob> The save name INDEX to me seems silly, if you are doing this
Jakob> manually, why don't you just type a different name each time?
Yeah, presumably this is only done via scripting. That's why I think it
is ok if the spelling of the commands is a bit verbose.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [RFC] syntax change for "record save"
2009-12-01 19:35 ` Tom Tromey
@ 2009-12-02 17:46 ` Jakob Engblom
0 siblings, 0 replies; 7+ messages in thread
From: Jakob Engblom @ 2009-12-02 17:46 UTC (permalink / raw)
To: tromey
Cc: 'Joel Brobecker', 'Michael Snyder',
gdb, 'Hui Zhu'
> Jakob> So we would do something like this:
> simics> save ("file." + $a)
> Jakob> (when the first argument to + is a string, the next argument is
> Jakob> forced to a string)
>
> Jakob> I think supporting string generation would solve many more
> Jakob> problems easily.
>
> The problem is that it is not obvious how to integrate this into the
> existing gdb CLI. The CLI is not like a normal programming language,
> with a regular syntax and a parser. Any regularity is just by
> convention; each command is just passed a char* that it parses itself.
>
> Of course, we could invent something. We could even turn the CLI into a
> much more expressive language. I'd rather not, though -- we have Python
> for that, and I think it is generally better to just reuse an existing
> language than to try to invent a new one.
I see. I had believed that the gdb command-line was more general than that.
Sorry for my lack of insight. That's why I did not say "we should do this", just
asking if this would work.
> Jakob> The save name INDEX to me seems silly, if you are doing this
> Jakob> manually, why don't you just type a different name each time?
>
> Yeah, presumably this is only done via scripting. That's why I think it
> is ok if the spelling of the commands is a bit verbose.
On the other hand, in a script, can't you do this in two steps?
Add a command to build strings into variables, and then use that variable in teh
command?
Gdb> concat $n "foo" $a
Gdb> save $n
?
Best regards,
/jakob
_______________________________________________________
Jakob Engblom, PhD, Technical Marketing Manager
Virtutech Direct: +46 8 690 07 47
Drottningholmsvägen 22 Mobile: +46 709 242 646
11243 Stockholm Web: www.virtutech.com
Sweden
________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-12-02 17:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-27 2:25 [RFC] syntax change for "record save" Michael Snyder
2009-11-27 7:55 ` Joel Brobecker
2009-11-27 15:17 ` Hui Zhu
2009-11-30 12:37 ` Michael Snyder
2009-12-01 12:56 ` Jakob Engblom
2009-12-01 19:35 ` Tom Tromey
2009-12-02 17:46 ` Jakob Engblom
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox