Results 1 to 9 of 9
Because i also need shell scripting help ill just post my questions here.
How do I make him just write this:
gdb a.out
break main
run
ptype CA
I wrote ...
- 02-07-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
need shell scripting help
Because i also need shell scripting help ill just post my questions here.
How do I make him just write this:
gdb a.out
break main
run
ptype CA
I wrote this and when i run it, it just executed first line.
- 02-07-2008 #2Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
I hope you understand what i mean.
- 02-07-2008 #3Linux Newbie
- Join Date
- Jan 2008
- Location
- UK
- Posts
- 211
I mean this in the nicest possible way, but,I think you need to re-think how you put your question across & state what you are trying to achieve.
- 02-07-2008 #4Just Joined!
- Join Date
- Jan 2008
- Posts
- 25
Its not at all clear from your post, what you want to do.
Is it that you want to write a shell script which run a gdb debugger for you? break the loop when something criteria is failed, etc.? Could you please a bit more clear.
- 02-08-2008 #5Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
Yes i want my script to run gdb debuger and then set a breakpoint at main
and run the debug. Then the script should write ptype CA so i get my whole CA
class writen on screen or if it is possible to save it in a .txt file
(ptype CA > some.txt doesnt work).
I wrote this shell script:
gdb a.out
break main
run
ptype CA
But it didnt work.
It just ran gdb debuger and nothing else.
I hope you understand what i mean now.
Sorry for my previous post.
- 02-08-2008 #6Just Joined!
- Join Date
- Oct 2007
- Posts
- 7
Create a file with your GDB command inside say "cmd1" then run:
ScorpCode:gdb -x cmd1 a.out
- 02-10-2008 #7Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
I dont understand what does this do scorp?
Tnx for your reply
- 02-10-2008 #8
Alrighty. We need to go back to a few basics.
A Bash script is a script for the Bash shell. When you execute it, Bash will execute each command in sequence. So your script tells Bash: "Run the command 'gdb a.out'. When that finishes, run the command 'break main'. When that finishes, run the command 'run'. When that finishes, run the command 'ptype CA'." Obviously, this is not what you want.
What you want is to run "gdb a.out", and have it automatically run those commands. And by looking at the gdb man page, I see the following:
So this is where scorp's advice comes in. Let's create a new file called "gdb_commands", and in it, we will put:Code:-command=file -x file Execute GDB commands from file file.
Now, we can run gdb by saying:Code:break main run ptype CA
gdb will read this list of commands and process it.Code:gdb -x gdb_commands a.out
Does that make sense?DISTRO=Arch
Registered Linux User #388732
- 02-10-2008 #9Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
yes Cabhan that was a very helpful explenation.
Thank you i understand now.


Reply With Quote