hgdbmi-0.2: GDB Machine Interface: program-driven control of GDB

Safe HaskellSafe-Inferred



Control execution of a GDB instance, send commands and receive results, notifications and stream information.

Due to http://sourceware.org/bugzilla/show_bug.cgi?id=8759 the first command issued should be to set the output terminal for GDB to /dev/null. Unfortunatelly, there is no MI command for this, so we have to resort to the CLI command "tty". For example:

>>> ctx  <- setup config callback
>>> resp <- send_command ctx (cli_command "tty /dev/null")
>>> when (respClass resp /= RCDone) (error ("unexpected response: " ++ show resp))



data Config Source





confCommandLine :: [String]

command line to execute. The library will add "--interpreter mi".

confLogfile :: Maybe FilePath

optinonally a file path to a log file for GDB/MI input and output. '-' means stdout.

data Callback Source

Call-back functions for asynchronous GDB output.

The call-backs are called in a separate thread per GDB output, so they may block.

Stop events are Notification events with NotificationClass Exec and AsyncClass ACStop. If cbStopped is given stop events are delivered to that call-back instead of cbNotify.




cbStream :: [Stream] -> IO ()

call-back for Stream events

cbNotify :: [Notification] -> IO ()

call-back for Notification events

cbStopped :: Maybe ([Stopped] -> IO ())

optionally a special call-back for Stopped events

default_config :: ConfigSource

Default configuration: gdb command line, no log file

setup :: Config -> Callback -> IO ContextSource

Launch a GDB instance in Machine Interface mode.

The child process is run in a new session to avoid receiving SIGINTs when issuing -exec-interrupt.

shutdown :: Context -> IO ()Source

Shut down the GDB instance and all resources associated with the Context.

send_command :: Context -> Command -> IO ResponseSource

Send a GDB command and wait for the response.

This function is thread safe, i.e., it can be called by multiple threads in an interleaved fashion.