Pete
Pete

Reputation: 1561

Automating GDB with IA32 and an fgets() call

I am slogging through a tricky GDB debug of IA-32 code. I've set up my .gdbinit file with all the commands I need to step through the early parts of the program. Trouble is, at about halfway through, the code makes a call to fgets():

x0x8049260  call   0x80487d0 <fgets@plt>

This is problematic because GDB halts at this point and waits for the human user to enter a string. I'd love it if the .gdbinit file could provide that string. But I don't see anything in the GDB documentation that says how to do this.

Does anyone know if what I want to do is possible? Or do I need an external Python script to run GDB for me?

Upvotes: 0

Views: 169

Answers (1)

Pete
Pete

Reputation: 1561

In the end, I stumbled on the .gdbinit file, which allows me to automate all commands proceeding the fgets() call and then all commands after. So all I had to do was set those commands in the file, run gdb and my program, and manually enter the fgets() input. It was a little cumbersome, but not terrible.

Upvotes: 0

Related Questions