LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-01-2009, 10:10 AM   #1
nayankk
LQ Newbie
 
Registered: Mar 2005
Location: Mysore
Distribution: Madrake, PCQLinux
Posts: 10

Rep: Reputation: 0
Question Automating 'stop', 'print' and 'continue' in GDB


Hey Guys,

I am debugging an real-time problem, where I cannot stop the execution for longer time. In this real-time use case, I get an even X at regular intervals and corresponding event handler function handle_x() gets called. I want to print the data within this event X, without stopping execution of program for longer time. Basically, I want to automate 'stop' (Ctrl-C), 'print' and 'cont' gdb commands such that this sequence of commands gets executed everytime when event X occurs in the system.

Is there any way to do so in GDB? I really appreciate any help.

Thank you,

Regards,
-Nayan
 
Old 06-02-2009, 05:00 AM   #2
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
I don't know the direct answer to your question, but when I get in situations like that, I often add temporary debug code to gather data. Declare a large text buffer and sprintf() debug information to the end of it and then later print it. Or even print it from a different thread or process. If memory or time is more critical you store only binary data.
 
Old 06-02-2009, 05:58 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Never this feature myself, but to me it sounds like GDB's "tracepoints" is what you're looking for.
 
Old 06-02-2009, 09:43 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Hmm
Quote:
The tracepoint facility is currently available only for remote targets. See section 17. Specifying a Debugging Target. In addition, your remote target must know how to collect trace data. This functionality is implemented in the remote stub; however, none of the stubs distributed with GDB support tracepoints as of this writing. The format of the remote packets used to implement tracepoints are described in D.6 Tracepoint Packets.
I think you could use Breakpoint Command Lists .

Quote:
For example, here is how you could use breakpoint commands to print the value of x at entry to foo whenever x is positive.



break foo if x>0
commands
silent
printf "x is %d\n",x
cont
end
Just replace "break foo if x>0" with "break handle_x".
 
Old 06-03-2009, 04:06 AM   #5
nayankk
LQ Newbie
 
Registered: Mar 2005
Location: Mysore
Distribution: Madrake, PCQLinux
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks for all in helping me. My target did not support tracepoint. Tried out 'command list' and it worked.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop / Continue signals in POSIX Linux threads beckerli Programming 4 03-30-2007 08:11 AM
syntax for gdb to print elements of 2D array? johnpaulodonnell Programming 4 03-26-2007 07:24 AM
print don't want to stop ... MargNat Linux - General 1 12-11-2006 09:25 AM
Bash: Print usage statement & exit; otherwise continue using Bash shorthand operators stefanlasiewski Programming 9 02-07-2006 05:20 PM
gdb + print struct alaios Programming 1 08-22-2005 12:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration