This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Restart remote application
- From: Petr Koloros <pko at sysgo dot com>
- To: GDB Mailing list <gdb at sourceware dot org>
- Date: Wed, 8 Aug 2007 15:29:56 +0200
- Subject: Restart remote application
- Reply-to: pko at sysgo dot com
Hi all,
I'm having problems with restarting the remote application. Some time ago it
was advised to use extended protocol and 'run' command but it doesn't work.
(gdb) set debug remote 1
(gdb) target extended-remote 192.168.14.2:5555
.. a lot of packets ..
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Sending packet: $k#6b...Ack
Starting program: /usr/bin/top
Sending packet: $R0#82...Ack
Sending packet: $?#3f...Sending packet: $?#3f...Sending packet:
$?#3f...Sending packet: $?#3f...Timed out.
Timed out.
Timed out.
There is no answer from the gdbserver any more because it is in the endless
loop:
recv(4, "$k#6b", 8192, 0) = 5
send(4, "+", 1, 0) = 1
--- SIGIO (I/O possible) @ 0 (0) ---
write(2, "Killing inferior\n", 17) = 17
ptrace(PTRACE_KILL, 2706, 0, 0) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(2706, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}], WNOHANG) = 2706
'k' command from the remote protocol causes the debugged application to be
killed.
write(2, "GDBserver restarting\n", 21) = 21
rt_sigaction(SIGTTOU, {SIG_DFL}, {SIG_IGN}, 8) = 0
rt_sigaction(SIGTTIN, {SIG_DFL}, {SIG_IGN}, 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
child_tidptr=0xb7dc8b08) = 2709
write(2, "Process /usr/bin/top created; pi"..., 41) = 41
--- SIGCHLD (Child exited) @ 0 (0) ---
rt_sigaction(SIGTTOU, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTTIN, {SIG_IGN}, {SIG_DFL}, 8) = 0
ioctl(2, TIOCGPGRP, [2706]) = 0
ioctl(2, TIOCSPGRP, [2709]) = 0
rt_sigaction(SIGIO, {0x804c080, [IO], SA_RESTART}, {SIG_IGN}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [IO], NULL, 8) = 0
waitpid(-1, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGTRAP}], WNOHANG) = 2709
ptrace(PTRACE_GETREGS, 2709, 0, 0x8059650) = 0
ptrace(PTRACE_GETFPXREGS, 2709, 0, 0x8059698) = 0
ptrace(PTRACE_GETFPREGS, 2709, 0, 0x80598a0) = 0
ptrace(PTRACE_PEEKTEXT, 2709, 0xb7fe080c, [0]) = 0
rt_sigaction(SIGIO, {SIG_IGN}, {0x804c080, [IO], SA_RESTART}, 8) = 0
Then a 'restart' command arrives in the remote protocol
recv(4, "$R0#82", 8192, 0) = 6
send(4, "+", 1, 0) = 1
--- SIGIO (I/O possible) @ 0 (0) ---
ptrace(PTRACE_KILL, 2709, 0, 0) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(2709, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}], WNOHANG) = 2709
.. and because the pid was not cleaned up by extended_remote_mourn:
static void
extended_remote_mourn (void)
{
/* We do _not_ want to mourn the target like this; this will
remove the extended remote target from the target stack,
and the next time the user says "run" it'll fail.
FIXME: What is the right thing to do here? */
#if 0
remote_mourn_1 (&extended_remote_ops);
#endif
}
ptrace(PTRACE_KILL, 2706, 0, 0) = -1 ESRCH (No such process)
waitpid(2706, 0xbf877128, WNOHANG) = -1 ECHILD (No child processes)
waitpid(2706, 0xbf877128, WNOHANG|__WCLONE) = -1 ECHILD (No child processes)
.. it just kills it again and wait for the status which never comes:
nanosleep({0, 1000000}, NULL) = 0
waitpid(2706, 0xbf877128, WNOHANG) = -1 ECHILD (No child processes)
waitpid(2706, 0xbf877128, WNOHANG|__WCLONE) = -1 ECHILD (No child processes)
nanosleep({0, 1000000}, NULL) = 0
waitpid(2706, 0xbf877128, WNOHANG) = -1 ECHILD (No child processes)
waitpid(2706, 0xbf877128, WNOHANG|__WCLONE) = -1 ECHILD (No child processes)
.. endless loop.
It worked in the past I believe and it doesn't now. Is there some other way
please?
Thanks for your help,
Petr Koloros