1

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.