2

I am running GDB in "mi interpreter" mode and I am using user defined hooks to detect events such as stop,quit etc.

Whenever the event occurs the hook will print some information which are redirected to a different log file.

Another application will read the contents from this log file and process it.

I have written a hook to detect GDB exit, as illustrated:

define hook-quit
set logging file D:\log\task.log
set logging on
print "GDB end detected"
set logging off
end

In GDB's console mode, the above hook executes successfully when GDB exits.

However in GDB's "mi interpreter mode", the hook fails to execute.

Is there any alternative hook (or any method) for detecting GDB exit in "mi interpreter mode".

Tested Environment:

Windows 7
Toolchain: arm-none-eabi (command: arm-none-eabi-gdb.exe --interpreter=mi D:\test.elf)

1 Answers1

2

A couple of ways to do this come to mind.

One is to use Python to write at "at exit" hook that prints to the log. The Python exit hooks should be run during gdb exit.

Another is to do the writing at a different layer: either in whatever is invoking gdb -i=mi, or by writing a wrapper script that invokes gdb and then writes to the log when gdb exits.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63