Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* automated trace output with gdb
@ 2008-10-29  7:02 Edward Peschko
  2008-10-29 17:17 ` Michael Snyder
  0 siblings, 1 reply; 9+ messages in thread
From: Edward Peschko @ 2008-10-29  7:02 UTC (permalink / raw)
  To: gdb

All,

Solaris' dbx had the ability to record runs of programs - ie: you
could say 'trace step' and you could then see - printed out - all the
lines of code execute as the debugger executed them..

Does gdb have something similar? I see the concept of tracepoints, but
that's not exactly what I had in mind.. I just want a running
commentary of the code as it runs, without having to press 'n' and/or
's' all the time.. Could this be implemented in terms of tracepoints?

Thanks much,

Ed


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-29  7:02 automated trace output with gdb Edward Peschko
@ 2008-10-29 17:17 ` Michael Snyder
  2008-10-29 17:58   ` Edward Peschko
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Snyder @ 2008-10-29 17:17 UTC (permalink / raw)
  To: Edward Peschko; +Cc: gdb

Edward Peschko wrote:
> All,
> 
> Solaris' dbx had the ability to record runs of programs - ie: you
> could say 'trace step' and you could then see - printed out - all the
> lines of code execute as the debugger executed them..
> 
> Does gdb have something similar? I see the concept of tracepoints, but
> that's not exactly what I had in mind.. I just want a running
> commentary of the code as it runs, without having to press 'n' and/or
> 's' all the time.. Could this be implemented in terms of tracepoints?

First of all, I don't think tracepoints are related.

What you ask is not a built-in feature of gdb, but
I often do something like it by writing a short gdb
script.  For a not-very-general example, I'll do
something like:

   set $foo = 100
   while $foo--
     step
   end

You could make $foo a parameter, or you could define some
more useful condition for stopping.  You could also use
"while 1" if you wanted it to run forever.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-29 17:17 ` Michael Snyder
@ 2008-10-29 17:58   ` Edward Peschko
  2008-10-29 18:03     ` Michael Snyder
  0 siblings, 1 reply; 9+ messages in thread
From: Edward Peschko @ 2008-10-29 17:58 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

Michael,

Just curious, but how do you redirect the output to a file using that
script? And how fast is it (ie: say I'm stepping through thousands of
steps.)

Basically, what I'm looking to do is take a inkblot test of a
program.. ie: do one thing, record it, do another, record it, and then
look at the difference..

Thanks,

Ed

On Wed, Oct 29, 2008 at 10:11 AM, Michael Snyder <msnyder@vmware.com> wrote:
> Edward Peschko wrote:
>>
>> All,
>>
>> Solaris' dbx had the ability to record runs of programs - ie: you
>> could say 'trace step' and you could then see - printed out - all the
>> lines of code execute as the debugger executed them..
>>
>> Does gdb have something similar? I see the concept of tracepoints, but
>> that's not exactly what I had in mind.. I just want a running
>> commentary of the code as it runs, without having to press 'n' and/or
>> 's' all the time.. Could this be implemented in terms of tracepoints?
>
> First of all, I don't think tracepoints are related.
>
> What you ask is not a built-in feature of gdb, but
> I often do something like it by writing a short gdb
> script.  For a not-very-general example, I'll do
> something like:
>
>  set $foo = 100
>  while $foo--
>    step
>  end
>
> You could make $foo a parameter, or you could define some
> more useful condition for stopping.  You could also use
> "while 1" if you wanted it to run forever.
>
>
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-29 17:58   ` Edward Peschko
@ 2008-10-29 18:03     ` Michael Snyder
  2008-10-29 19:03       ` Edward Peschko
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Snyder @ 2008-10-29 18:03 UTC (permalink / raw)
  To: Edward Peschko; +Cc: gdb

Edward Peschko wrote:
> Michael,
> 
> Just curious, but how do you redirect the output to a file using that
> script?

Set logging, set logging file...

 > And how fast is it (ie: say I'm stepping through thousands of
> steps.)

Well... it's as fast as it is.  The only way to find out
if it's fast enough to suit you is to try it.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-29 18:03     ` Michael Snyder
@ 2008-10-29 19:03       ` Edward Peschko
  2008-10-29 21:35         ` Michael Snyder
  0 siblings, 1 reply; 9+ messages in thread
From: Edward Peschko @ 2008-10-29 19:03 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

Ok, I'm trying it, and it seems to be working - so far, speed isn't
really that great (ie: perl's tracemode in *its* debugger is faster,
line per line, in tracing perl code), but it's workable, with caveat.
For some things it'd be really painful (eg: debugging vim)

Just for future record, here are the commands that I used, and they
have to be done in the right order:

(gdb) set logging redirect on
(gdb) set logging file 'myfile'
(gdb) set logging on
(gdb) set pagination off
(gdb) b <certain_point>
(gdb) while 1
> step
> end

If they aren't in this order, then the behavior is indeterminate, and
if pagination isn't set off, you get 'hit <return> to continue' even
though everything else goes to the file..

I don't know - all in all, IMO this should be a feature of gdb itself,
just for simplicity's sake, and to avoid the overhead of the scripting
language. I'm just guessing, but I'd bet that if this was done in a
tight loop, it would be an order of magnitude faster..

Thanks,

Ed

On Wed, Oct 29, 2008 at 10:57 AM, Michael Snyder <msnyder@vmware.com> wrote:
> Edward Peschko wrote:
>>
>> Michael,
>>
>> Just curious, but how do you redirect the output to a file using that
>> script?
>
> Set logging, set logging file...
>
>> And how fast is it (ie: say I'm stepping through thousands of
>>
>> steps.)
>
> Well... it's as fast as it is.  The only way to find out
> if it's fast enough to suit you is to try it.
>
>
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-29 19:03       ` Edward Peschko
@ 2008-10-29 21:35         ` Michael Snyder
  2008-10-31  8:20           ` Edward Peschko
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Snyder @ 2008-10-29 21:35 UTC (permalink / raw)
  To: Edward Peschko; +Cc: gdb

Edward Peschko wrote:

> (gdb) set pagination off

FYI, you can also use "set height 0" in place of the above.

> 
> I don't know - all in all, IMO this should be a feature of gdb itself,
> just for simplicity's sake, and to avoid the overhead of the scripting
> language. I'm just guessing, but I'd bet that if this was done in a
> tight loop, it would be an order of magnitude faster..

Well -- it's an open source project, we welcome contributions.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-31  8:20           ` Edward Peschko
@ 2008-10-30 21:49             ` Edward Peschko
  2008-10-31 12:43             ` Jeremy Bennett
  1 sibling, 0 replies; 9+ messages in thread
From: Edward Peschko @ 2008-10-30 21:49 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

Michael,

I'd be glad to contribute, but I'm not sure I know the infrastructure
of gdb well enough to do it correctly. Any pointers on what would be
involved in making a change like this?

Ed

On Wed, Oct 29, 2008 at 2:29 PM, Michael Snyder <msnyder@vmware.com> wrote:
> Edward Peschko wrote:
>
>> (gdb) set pagination off
>
> FYI, you can also use "set height 0" in place of the above.
>
>>
>> I don't know - all in all, IMO this should be a feature of gdb itself,
>> just for simplicity's sake, and to avoid the overhead of the scripting
>> language. I'm just guessing, but I'd bet that if this was done in a
>> tight loop, it would be an order of magnitude faster..
>
> Well -- it's an open source project, we welcome contributions.
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-29 21:35         ` Michael Snyder
@ 2008-10-31  8:20           ` Edward Peschko
  2008-10-30 21:49             ` Edward Peschko
  2008-10-31 12:43             ` Jeremy Bennett
  0 siblings, 2 replies; 9+ messages in thread
From: Edward Peschko @ 2008-10-31  8:20 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

Michael,

I'd be glad to contribute, but I'm not sure I know the infrastructure
of gdb well enough to do it correctly. Any pointers on what would be
involved in making a change like this?

Ed

On Wed, Oct 29, 2008 at 2:29 PM, Michael Snyder <msnyder@vmware.com> wrote:
> Edward Peschko wrote:
>
>> (gdb) set pagination off
>
> FYI, you can also use "set height 0" in place of the above.
>
>>
>> I don't know - all in all, IMO this should be a feature of gdb itself,
>> just for simplicity's sake, and to avoid the overhead of the scripting
>> language. I'm just guessing, but I'd bet that if this was done in a
>> tight loop, it would be an order of magnitude faster..
>
> Well -- it's an open source project, we welcome contributions.
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: automated trace output with gdb
  2008-10-31  8:20           ` Edward Peschko
  2008-10-30 21:49             ` Edward Peschko
@ 2008-10-31 12:43             ` Jeremy Bennett
  1 sibling, 0 replies; 9+ messages in thread
From: Jeremy Bennett @ 2008-10-31 12:43 UTC (permalink / raw)
  To: gdb; +Cc: Edward Peschko

On Thu, 2008-10-30 at 10:45 -0700, Edward Peschko wrote:

> I'd be glad to contribute, but I'm not sure I know the infrastructure
> of gdb well enough to do it correctly. Any pointers on what would be
> involved in making a change like this?

Hi Ed,

Key resources for developers that should help you are

- the GDB Internals document (gdb/doc/gdb.texinfo in the distribution,
or online at sourceware.org/gdb/current/onlinedocs/gdbint_toc.html

- the GDB IRC channel #gdb on irc.freenode.net, port 6667 (lots of
helpful developers to answer your questions live)

- the GDB Wiki at sourceware.org/gdb/wiki

I wrote an application note on porting GDB, which you may find useful
for an overview of the internals at www.embecosm.com/download/ean3.html
(also on the GDB Wiki).

HTH,


Jeremy
-- 
Tel:      +44 (1202) 416955
Cell:     +44 (7970) 676050
SkypeID: jeremybennett
Email:   jeremy.bennett@embecosm.com
Web:     www.embecosm.com



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-10-31  8:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-29  7:02 automated trace output with gdb Edward Peschko
2008-10-29 17:17 ` Michael Snyder
2008-10-29 17:58   ` Edward Peschko
2008-10-29 18:03     ` Michael Snyder
2008-10-29 19:03       ` Edward Peschko
2008-10-29 21:35         ` Michael Snyder
2008-10-31  8:20           ` Edward Peschko
2008-10-30 21:49             ` Edward Peschko
2008-10-31 12:43             ` Jeremy Bennett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox