Unix Technical Forum

gdb to file question

This is a discussion on gdb to file question within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Hi, I'm trying to find a way to send gdb output to some "text" file like gdb myprog > ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-20-2008, 05:59 PM
salta
 
Posts: n/a
Default gdb to file question

Hi,

I'm trying to find a way to send gdb output to some "text" file
like gdb myprog > gdb.txt, so I wouldn't have to copy all the output by
hand, but I've been unable to do so so far.

Is it possible at all ?

Any help would be greatly appreciated ;-)

Thanks

---------
Salta,
On Slackware since 1993 ( true ;-) )



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-20-2008, 05:59 PM
Sylvain Robitaille
 
Posts: n/a
Default Re: gdb to file question

salta wrote:

> I'm trying to find a way to send gdb output to some "text" file like
> gdb myprog > gdb.txt, so I wouldn't have to copy all the output by
> hand, but I've been unable to do so so far.


What I've done for that is something along the lines of the following:

script gdb.txt
gdb myprog
exit # (exits from script subshell)
vim gdb.txt # (fix up line endings)

If you want something that's scriptable, it's possible that gdb's
"-batch" option might be useful for you. I've never used that option,
but I imagine that it can be used only in conjunction with other options
(to feed commands to gdb from an input file, for example).

> Is it possible at all ?


I hope the above helps ...

--
----------------------------------------------------------------------
Sylvain Robitaille syl@alcor.concordia.ca

Systems and Network analyst Concordia University
Instructional & Information Technology Montreal, Quebec, Canada
----------------------------------------------------------------------
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-20-2008, 05:59 PM
Thomas Overgaard
 
Posts: n/a
Default Re: gdb to file question


salta@mynet.net wrote :

> Is it possible at all ?


You could try pipe the output through the 'tee' command like this:
'gdb myprog | tee gdb.txt'
--
Thomas O.

This area is designed to become quite warm during normal operation.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-20-2008, 06:00 PM
Ayaz Ahmed Khan
 
Posts: n/a
Default Re: gdb to file question

"salta" typed:
> I'm trying to find a way to send gdb output to some "text" file like
> gdb myprog > gdb.txt, so I wouldn't have to copy all the output by
> hand, but I've been unable to do so so far.
>
> Is it possible at all ?
>
> Any help would be greatly appreciated ;-)


One way I can think of (and have actually tried and found to work) is
to put all the GDB commands that you would execute in a file, one on a
line, and then call GDB with the -x argument and redirect its output
to another file. For example, if the file with all t thneeded GDB
commands is file.gdb_cmd, you could do:

ayaz$ gdb -q -x file.gdb_cmd > file.out

Of course, this will make the GDB session non-interactive, which might
be a problem.

--
Ayaz Ahmed Khan

Then, gently touching my face, she hesitated for a moment as her
incredible eyes poured forth into mine love, joy, pain, tragedy,
acceptance, and peace. "'Bye for now," she said warmly.
-- Thea Alexander, "2150 A.D."

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-20-2008, 06:00 PM
Steve Youngs
 
Posts: n/a
Default Re: gdb to file question

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

* salta <salta@mynet.net> writes:

> I'm trying to find a way to send gdb output to some "text" file
> like gdb myprog > gdb.txt, so I wouldn't have to copy all the output
> by hand, but I've been unable to do so so far.


> Is it possible at all ?


Certainly!

$ gdb myprog core 2>&1 | tee gdb.txt

Is one way. But if you use emacs, `M-x gdb' is _much_ easier. :-)

--
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
| Genius - Is the ability to reduce |
| the complicated to the simple |
|----------------------------------<steve@youngs.au.com>---|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
Comment: The SXEmacs Project <http://www.sxemacs.org>
Comment: Eicq - The SXEmacs ICQ Client <http://www.eicq.org/>

iEYEARECAAYFAkUP3roACgkQHSfbS6lLMANphACfejltERcX5/CIptF8yhzFnWQq
figAni3jqR84CwfmCiUA5YR+XpgYPA+z
=froe
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-20-2008, 06:04 PM
salta
 
Posts: n/a
Default Re: gdb to file question

Hi

Many thanks to all

Steve Youngs wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> NotDashEscaped: You need GnuPG to verify this message
>
> * salta <salta@mynet.net> writes:
>
> > I'm trying to find a way to send gdb output to some "text" file
> > like gdb myprog > gdb.txt, so I wouldn't have to copy all the output
> > by hand, but I've been unable to do so so far.

>
> > Is it possible at all ?

>
> Certainly!
>
> $ gdb myprog core 2>&1 | tee gdb.txt
>
> Is one way. But if you use emacs, `M-x gdb' is _much_ easier. :-)
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:50 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com