Reputation: 930
I am writing a script to examine the core dump. The goal is to execute a gdb command using a while loop to analyze.
#!/usr/local/bin/bash
#
# A script to extract core-file informations
#
#Binary image
binimg=$1
# Today and yesterdays cores
core=$2
gdblogfile=$3
loop = 3
gdb -batch \
-ex "set logging file $gdblogfile" \
-ex "set logging on" \
-ex "set pagination off" \
-ex "file $binimg" \
-ex "core-file $core" \
-ex "bt" \
-ex "frame 8" \
-ex "while $loop > 0 { print this->_tag; set $loop = $loop - 1; end }"
-ex "quit"
This script does not execute after the while loop. It stops at the while loop, expecting command line gdb commands. I am not sure why it does not go ahead and print the value of tag and continue looping. Can you please let me know what I am doing wrong?
Upvotes: 1
Views: 5369
Reputation: 22549
Braces don't work for grouping in gdb. Not sure why you'd think so, but whatever source you got that from is wrong -- you should let them know.
If you want to continue on this path, put the commands into a file and use "gdb -x" instead of "-ex".
You may have a better experience doing the scripting in Python, though.
Upvotes: 1