I am attempting to have gdb
automatically debug a c
program that I am reviewing, where there is a small, but real chance (ie: one in
chance) of a crash occurring due to a known bug. I contend with another engineer that it's serious enough to address, so I need to actually cause the crash to occur to justify putting the time into fixing it. To speed up testing, I plan to write a script to have the application run in GDB, for days if need be, until it crashes.
I've found out how to run simple applications through GDB until segfaulting via a separate answer on StackOverflow
, but I need to extend the problem a bit. So, I know I can run a program repeatedly until it crashes via:
set pagination off
What I need to do is figure out how to issue certain commands. After my program runs for a few seconds, it will ask the user to enter (via
) a number in the range of
, and hit ENTER
. I would like it to enter
, on the first iteration,
, on the second iteration, etc. I realize this would b a lot easier if I added command-line arguments to the application, but I'm not allowed to change it at this time, and must rely on the interactive mode of operation it provides.
How would I create a command to automatically generate these keystrokes/patterns with GDB
? I'm guessing I could write some sort of
script, but I mostly use GDB interactively for getting backtraces, analyzing memory, etc, and am not overly familiar with automating tasks like these.