Results 1 to 7 of 7
Hey.
I have a shell script that first runs gdb debuger, executes commands
and writes results in a .txt files.
So I have my first shell file written like so:
...
- 02-18-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
Error handling in shell
Hey.
I have a shell script that first runs gdb debuger, executes commands
and writes results in a .txt files.
So I have my first shell file written like so:
gdb -x gdb_commands.sh a.out > text.txt
With objdump I got names of classes which
i want to print in text.txt. So i put Ptype before them and made gdb_commands.sh.
In my gdb_commands.sh I have:
break main
run
Ptype CClassA #a class retrieved from objdump that is going to be printed in text.txt
Ptype CClassB # another class...
Ptype CClassC
Ptype __gnu_cxx # class I got from objdump but gdb doesnt find it.
Ptype CClassD #another class i want
This is what my script does... it succesfully prints first 3 classes
but at __gnu_cxx it prints an error and stops gdb_commands.sh script.
It doesnt quit from gdb debuger it just exits the gdb_comands.sh script.
How can I make it, so it WON'T exit the script or how
can I skip classes that are not found?
I get this error for gdb_commands.sh:
"Error in sourced command file:
No symbol "_gnu_cxx" in current context"
Please help me I realy want to get this to work.
- 02-18-2008 #2
Enter the following line at the bash prompt, and all will be revealed.
If man pages are not installed on your system, google this:Code:man expect
Code:man expect linux
--
Bill
Old age and treachery will overcome youth and skill.
- 02-18-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
TNx for the tip.
So with expect I can make a script that will execute commands and wont
be botherd by errors?
But I dont know how to write a expect script
I didnt find any tutorials on it.
- 02-18-2008 #4No, but you can build an expect script which sends a command to gdb for each class, and just blindly keeps going.So with expect I can make a script that will execute commands and wont
be botherd by errors?
google this:I dont know how to write a expect script I didnt find any tutorials on it.
Actually, I thought of two other alternatives, if you decide not to use expect:expect tutorial
- Loop through all your class names. For each one, build a file that looks like this:
and run gdb against that command file. Just let the loop run, and it should blindly go through the good and the bad.Code:break main run Ptype single_class_name
- If you still want to run gdb just once, don't include any class names that begin with underscore ("_").
--
Bill
Old age and treachery will overcome youth and skill.
- Loop through all your class names. For each one, build a file that looks like this:
- 02-18-2008 #5Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
What do you mean loop through?
you mean i should write first script like this:
and then commands1.sh would beCode:gdb -x commands1.sh a.out > text.txt gdb -x commands2.sh a.out > text.txt gdb -x commands3.sh a.out > text.txt gdb -x commands4.sh a.out > text.txt . . .
commands2.shCode:break main run Ptype CClassA quit
and so on....??Code:break main run Ptype CClassB quit
Well i did though of that and the problem is that when script in gdb stops
at Ptype __gnu_cxx it doesnt exit gdb and so you cant execute another
command in first script until gdb is closed.
- 02-18-2008 #6Enter the following line at the bash prompt.the problem is that when script in gdb stops at Ptype __gnu_cxx it doesnt exit gdb
If man pages are not installed on your system, google this:Code:man gdb
Within the man page, look for the -batch option.Code:man gdb linux
--
Bill
Old age and treachery will overcome youth and skill.
- 02-19-2008 #7Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
-batch did the trick thanks a lot.


Reply With Quote