NAME
Devel::GDB - open and communicate a gdb session
SYNOPSIS
use Devel::GDB ;
$gdb = new Devel::GDB (-file => 'a.out' ) ;
$gdb -> get ( 'break main' ) ;
DESCRIPTION
Devel::GDB is an Expect like module, designed to communicate with gdb. It is opening a gdb process, sending commands and returning the responses. Devel::GDB was designed to provide good base for both interactive and automatic scripts.
Example Code
use Devel::GDB ;
our $gdb = new Devel::GDB (-execfile => 'gdb') ;
my $arch = $gdb -> get ( 'info arch' ) ;
my $endian = $gdb -> get ( 'show endian' ) ;
print $arch, $endian ;
METHODS
The three methods for normal gdb usage are: 'new', 'get' and 'signal'.
new
- $gdb = Devel::GDB -> new (?options?)
-
This function opens and initializes the gdb object.
Options:
- -file
-
File to open (like 'a.out'). No default. This is an easy way to load target file during initialization.
- -execfile
-
File or command to execute as gdb process. Default is 'gdb'.
- -params
-
Parameters to the 'execfile'. Default is " -q -nx -nw ". Parameters can be also set as part of the 'execfile' string.
- -timeout
-
Default timeout for get method. Default is 9999 ;
- -prompt
-
Default prompt for get method (to identify end of gdb response). Default is qr/\(s?gdb.*\)|^\s*\>|(y or n)/s.
- -notyet
-
Default code to be used at the get method while waiting for gdb response.
- -alldone
-
Default code to be used at the get method after waiting for gdb response.
The (actually internal) method new_shell can be used to open and manipulate any kind of flushing && prompting process. Unlike new, it would not set defaults or run initial commands.
get
- $gdb -> get ( ?command?, ?timeout?, ?prompt?, ?notyet?, ?alldone? )
-
Send command to gdb and return response. In array contest, return response, error, and matching prompt. In scalar contest, return response only ('' if error).
Parameters:
- command
-
Command to be sent to gdb. If undef or white-spaces, gdb buffers will be cleared and returned (timeouted old responses?).
- timeout
-
Limit the waiting time for gdb (integer seconds). If timeout expires, get returns without interrupting the gdb process (use signal for that). The default timeout (9999) can be overwritten in new.
- prompt
-
Expected regexpr prompt at the end of gdb response. The default prompt (qr/\(s?gdb.*\)|^\s*\>|(y or n)/s) can be overwritten in new.
- notyet
-
Code to be executed every second while waiting for response. Only valid code will be executed (i.e. ref $code eq 'CODE'). If this code returns true, get would stop waiting to gdb response. Then signal can be used to interrupt gdb process. Default notyet code can be set in new.
- alldone
-
Code to be executed when done. Only valid code will be executed. Default alldone code can be set in new.
signal
- $gdb -> signal(?signum?)
-
Send a signal to the gdb process. Default signum is 0 (functions as Control-c in gdb command prompt)
AUTHOR
Josef Ezra <jezra@emc.com>
SEE ALSO
IPC::Open3
8 POD Errors
The following errors were encountered while parsing the POD:
- Around line 36:
You forgot a '=back' before '=head2'
- Around line 52:
=back without =over
- Around line 60:
You forgot a '=back' before '=head2'
- Around line 62:
'=item' outside of any '=over'
- Around line 107:
You forgot a '=back' before '=head2'
- Around line 109:
'=item' outside of any '=over'
- Around line 149:
You forgot a '=back' before '=head2'
- Around line 151:
'=item' outside of any '=over'