NAME
Devel::GDB - open and communicate a gdb session, Version 1.0
SYNOPSIS
use Devel::GDB ;
$gdb = new Devel::GDB (?options?) ;
DESCRIPTION
Devel::GDB is an Expect like module, designed to communicate with gdb.
It is using IPC::Open3 to open gdb process, send commands and return responses,
and was designed to provide max flexibility 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 gdb usage are: 'new', 'get' and 'signal'.
- $gdb = Devel::GDB -> new (?options?)
-
This function opens gdb process, send it some initialize commands and returns the object associated with it.
Options
- -file
-
File to open (like 'a.out'). No default. This is an easy way to try loading the target file during initialization.
- -execfile
-
File to execute as a gdb process. Default is 'gdb'.
- -params
-
Parameters to -execfile. Default is " -q -nx -nw ". Note that parameters can be also set as part of the -execfile string.
- -timeout
-
Default timeout in get method, to limit waiting for gdb response. Default is 9999 ;
- -prompt
-
Default prompt in get method, identify the prompt in the end of the response. Deafult is qr/\(s?gdb.*\)|^\s*\>|(y or n)/s .
-item -notyet
Default function in get method, to be executed every second while waiting for gdb response (how about Tk update?). If the function returns non false, stop waiting (in those cases, gdb keeps running, so it might be a good idea to signal it).
- -alldone
-
Default function in get method, to be executed when done.
Note that one can use the method new_shell to get the same as the new method, but without setting defaults and running initial commands. This (actualy internal) method can be used to open and manipulate any kind of prompting shell. Well, any kind of flushing prompting shell (see open3 documentation).
- $gdb -> get ( ?command?, ?timeout?, ?prompt?, ?notyet?, ?alldone? )
-
This method will send the command to gdb and return the response. In array contest, get will return (response, error, actual prompt). In scalar contest it will return the response only (errors will be saved in $gdb->{'last_error'}).
Parameters:
- command
-
Command to be sent to gdb. If command match /^\s*$/, get will clear and return the gdb output and error buffers without sending any command to gdb. Default is '' (just clears the buffer).
- timeout
-
Limit the waiting time for gdb (in round seconds). If timeout expires, get returns without interrupting the gdb proccess. Default is $gdb->{timeout}
- prompt
-
Return the response when this prompt matchs the end of it. (Expect like). Default is $gdb->{prompt}
- notyet
-
Code to be executed every second while waiting for response (see above). Default is $gdb->{notyet} (if exists).
- alldone
-
Code to be executed when done (see above). Default is $gdb->{alldone} (if exists).
- $gdb -> signal(?signum?)
-
Send a signal to gdb. Default signum is 0. Note that althogh signal 0 (SIGHUP) is the right way to interrupt gdb commands, other unix programs will probably ignore this signal.
6 POD Errors
The following errors were encountered while parsing the POD:
- Around line 37:
You forgot a '=back' before '=head2'
- Around line 55:
=back without =over
- Around line 68:
You forgot a '=back' before '=head2'
- Around line 113:
'=item' outside of any '=over'
- Around line 119:
You forgot a '=back' before '=head2'
- Around line 153:
'=item' outside of any '=over'