Hello
I am trying to use expect perl to control a gdb session running an
application. I can easily communicate with gdb when attaching to the pid of
the application initially. However, when I do a continue and the application
is now running again, I can't seem to get it to respond when I send the gdb
expect object a control-c. In "real-life" that's how one can get control
back to the keyboard of the debugger.
My kludge which still doesn't work, is to send a SIGINT signal to the
process directly. Problem is that when gdb responds, the
gdb->expect("SIGINT") never sees the response because it's after the kill 2,
$targetpid command. Something of a race....
My theory why this doesn't work is that gdb is doing things with the
terminal that the gdb object is referring to. Has anyone worked with gdb
before using expect?
my code is summarized below
$gdb = new Expect;
....
$gdb->spawn("gdb", ($target));
$gdb->expect (10, "\(gdb\)", etc....);
$gdb->send("attach $targetpid\r");
$gdb->expect (10, "\(gdb\)", etc....);
$gdb->send("continue\r");
$gdb->expect(10, "Continue", etc....);
taget app is now in control. in this case it's a network server.
...
$gdb->send("\cC"); #seems to hang here and never gets to the expect. i
confirmed with gdb->debug(2)
#my sneaking suspicion is i am sending
controlc to gdb but it's not the correct place to send it
# really i need to send to the target
(which isn't an object)
$gdb->expect (10, "\(gdb\)", etc....);
kludge (that doesn't work either but does get a response equivalent to
sending controlC)
$gdb = new Expect;
....
$gdb->spawn("gdb", ($target));
$gdb->expect (10, "\(gdb\)", etc....);
$gdb->send("attach $targetpid\r");
$gdb->expect (10, "\(gdb\)", etc....);
$gdb->send("continue\r");
$gdb->expect(10, "Continue", etc....);
taget app is now in control. in this case it's a network server.
...
kill 2, $targetgdb->expect (10, "\(gdb\)", etc....);
$gdb->expect (10, "\(gdb\)", etc....); #never sees the gdb process
output even though it scrolls across the screen.
thanks.
aw
|