I am trying to write tests that interact with GDB, but I have problems getting the result. I would like a log file to be generated that looks like it would be visible in the terminal if the test was performed manually. GDB is very stubborn when it comes to its release.
I managed to write Expect scripts that can interact with GDB and whose output can be redirected to a log file, but I do not want to write my tests in TCL. I hope to use Groovy, which is compatible with Java. For some reason, Perl Expect and ExpectJ the output of the program always goes to the terminal and cannot be redirected to the file.
I tried to start the GDB process with Java using ProcessBuilder, and it works mostly, but the output of print statements never appears on stdout and cannot be captured. I thought that if Expect works, then I will start to expect from Java and interact with GDB, but in this case most of the program output is lost, never appearing in the stdout of the created process.
So my question is: how can I write a test in Groovy (Java will be fine too) that interacts with GDB and can capture all the output?
Pseudo Code:
process = "gdb -q".execute() waitForPrompt() send("file exec") waitForPrompt() send("run") send("quit")
Log file:
(gdb) file exec Reading symbols from exec...done. (gdb) run Starting program: exec <... output ...> Program exited normally. (gdb) quit
java groovy gdb expect
dromodel Feb 23 '10 at 19:34 2010-02-23 19:34
source share