From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27299 invoked by alias); 8 Aug 2007 13:30:57 -0000 Received: (qmail 27046 invoked by uid 22791); 8 Aug 2007 13:30:54 -0000 X-Spam-Check-By: sourceware.org Received: from mail.sysgo.com (HELO mail.sysgo.com) (62.8.134.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 08 Aug 2007 13:30:39 +0000 Received: from donald.sysgo.com (unknown [172.20.1.30]) by mail.sysgo.com (Postfix) with ESMTP id 171DFCC0C2 for ; Wed, 8 Aug 2007 15:30:37 +0200 (CEST) Received: from blanice.sysgo.cz (unknown [172.24.12.10]) by donald.sysgo.com (Postfix) with ESMTP id 23AFA26901F for ; Wed, 8 Aug 2007 15:30:37 +0200 (CEST) Received: from localhost.localdomain (pko.sysgo.cz [172.24.12.22]) by blanice.sysgo.cz (Postfix) with ESMTP id 90491131021 for ; Wed, 8 Aug 2007 15:30:36 +0200 (CEST) Received: from pko by localhost.localdomain with local (Exim 4.63) (envelope-from ) id 1IIlbo-0002zt-A5 for gdb@sourceware.org; Wed, 08 Aug 2007 15:29:56 +0200 Date: Wed, 08 Aug 2007 13:30:00 -0000 From: Petr Koloros To: GDB Mailing list Subject: Restart remote application Message-ID: <20070808132955.GB10087@pko.sysgo.cz> Reply-To: pko@sysgo.com MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline X-GPG-Key: http://aa.vslib.cz/silk/mygpgkey.txt X-GPG-Fingerprint: 693F 5F55 3E6D B709 ED70 8611 5255 7630 724B C713 X-Operating-System: GNU/Linux User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00084.txt.bz2 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