* Restart remote application
@ 2007-08-08 13:30 Petr Koloros
2007-08-08 14:24 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Petr Koloros @ 2007-08-08 13:30 UTC (permalink / raw)
To: GDB Mailing list
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Restart remote application
2007-08-08 13:30 Restart remote application Petr Koloros
@ 2007-08-08 14:24 ` Daniel Jacobowitz
2007-08-09 9:32 ` Petr Koloros
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-08-08 14:24 UTC (permalink / raw)
To: Petr Koloros; +Cc: GDB Mailing list
On Wed, Aug 08, 2007 at 03:29:56PM +0200, Petr Koloros wrote:
> 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.
The extended protocol doesn't work very well. I have a sketch for
improvements to running more than one remote application, and some
code, which I hope I'll be working on for the next release of GDB
after 6.7. However, what you're describing here normally works.
Here's some bits of that code plus another related fix I noticed;
does it help for you?
--
Daniel Jacobowitz
CodeSourcery
2007-08-08 Daniel Jacobowitz <dan@codesourcery.com>
* remote.c (remote_wait, remote_async_wait): Stop if we receive
an error.
(extended_remote_mourn): Mourn the target and reset inferior_ptid.
* linux-low.c (linux_kill): Clear the inferior list.
(linux_detach): Clear the process list.
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.265
diff -u -p -r1.265 remote.c
--- remote.c 3 Jul 2007 15:58:42 -0000 1.265
+++ remote.c 8 Aug 2007 14:21:59 -0000
@@ -3219,8 +3219,12 @@ remote_wait (ptid_t ptid, struct target_
switch (buf[0])
{
case 'E': /* Error of some sort. */
+ /* We're out of sync with the target now. Did it continue or not?
+ Not is more likely, so report a stop. */
warning (_("Remote failure reply: %s"), buf);
- continue;
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_0;
+ goto got_status;
case 'F': /* File-I/O request. */
remote_fileio_request (buf);
continue;
@@ -3432,8 +3436,12 @@ remote_async_wait (ptid_t ptid, struct t
switch (buf[0])
{
case 'E': /* Error of some sort. */
+ /* We're out of sync with the target now. Did it continue or not?
+ Not is more likely, so report a stop. */
warning (_("Remote failure reply: %s"), buf);
- continue;
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_0;
+ goto got_status;
case 'F': /* File-I/O request. */
remote_fileio_request (buf);
continue;
@@ -5135,14 +5143,16 @@ remote_async_mourn (void)
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.
+ /* Unlike "target remote", we do not want to unpush the target; then
+ the next time the user says "run", we won't be connected. */
- FIXME: What is the right thing to do here? */
-#if 0
- remote_mourn_1 (&extended_remote_ops);
-#endif
+ /* Call common code to mark the inferior as not running. */
+ generic_mourn_inferior ();
+
+ /* Assume that the target has been restarted. Set inferior_ptid
+ so that bits of core GDB realizes there's something here, e.g.,
+ so that the user can say "kill" again. */
+ inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
}
/* Worker function for remote_mourn. */
Index: gdbserver/linux-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.59
diff -u -p -r1.59 linux-low.c
--- gdbserver/linux-low.c 2 Jul 2007 15:35:36 -0000 1.59
+++ gdbserver/linux-low.c 8 Aug 2007 14:21:59 -0000
@@ -280,6 +280,10 @@ linux_kill (void)
/* Make sure it died. The loop is most likely unnecessary. */
wstat = linux_wait_for_event (thread);
} while (WIFSTOPPED (wstat));
+
+ clear_inferiors ();
+ free (all_processes.head);
+ all_processes.head = all_processes.tail = NULL;
}
static void
@@ -318,6 +322,8 @@ linux_detach (void)
delete_all_breakpoints ();
for_each_inferior (&all_threads, linux_detach_one_process);
clear_inferiors ();
+ free (all_processes.head);
+ all_processes.head = all_processes.tail = NULL;
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Restart remote application
2007-08-08 14:24 ` Daniel Jacobowitz
@ 2007-08-09 9:32 ` Petr Koloros
2007-08-09 11:20 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Petr Koloros @ 2007-08-09 9:32 UTC (permalink / raw)
To: GDB Mailing list
> Here's some bits of that code plus another related fix I noticed;
> does it help for you?
Thanks for the patch. Unfortunately it does not work yet. It was able to
pass the k,R sequence as expected but then the application is somewhat
lost. Here's the output:
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Sending packet: $k#6b...Ack
target_mourn_inferior ()
target_kill ()
Starting program: /home/pko/zkgdb
Sending packet: $R0#82...Ack
Sending packet: $?#3f...Ack
Packet received: T0505:00000000;04:9004abbf;08:1018fbb7;
target_memory_map ()
extended-remote:target_xfer_partial (7, (null), 0x836e7b0, 0x0, 0x0,
4095) = -1
Sending packet: $Z0,b7f70fb0,1#71...Ack
Packet received:
Packet Z0 (software-breakpoint) is NOT supported
Sending packet: $mb7f70fb0,1#28...Ack
Packet received: E01
extended-remote:target_xfer_partial (2, (null), 0x834bc58, 0x0,
0xb7f70fb0, 1) = -1
target_insert_breakpoint (0xb7f70fb0, xxx) = 5
target_terminal_ours_for_output ()
target_terminal_ours ()
Warning:
Cannot insert breakpoint -3.
Error accessing memory address 0xb7f70fb0: Input/output error.
Petr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Restart remote application
2007-08-09 9:32 ` Petr Koloros
@ 2007-08-09 11:20 ` Daniel Jacobowitz
2007-08-09 12:26 ` Petr Koloros
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-08-09 11:20 UTC (permalink / raw)
To: Petr Koloros; +Cc: GDB Mailing list
On Thu, Aug 09, 2007 at 11:31:09AM +0200, Petr Koloros wrote:
> Warning:
> Cannot insert breakpoint -3.
> Error accessing memory address 0xb7f70fb0: Input/output error.
And... what's that address supposed to be? Try 'maint info break'.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Restart remote application
2007-08-09 11:20 ` Daniel Jacobowitz
@ 2007-08-09 12:26 ` Petr Koloros
0 siblings, 0 replies; 5+ messages in thread
From: Petr Koloros @ 2007-08-09 12:26 UTC (permalink / raw)
To: GDB Mailing list
On Thu, Aug 09, 2007 at 07:19:56AM -0400, Daniel Jacobowitz wrote:
> On Thu, Aug 09, 2007 at 11:31:09AM +0200, Petr Koloros wrote:
> > Warning:
> > Cannot insert breakpoint -3.
> > Error accessing memory address 0xb7f70fb0: Input/output error.
>
> And... what's that address supposed to be? Try 'maint info break'.
..
Cannot insert breakpoint -3.
Error accessing memory address 0xb7fd4fb0: Input/output error.
..
(gdb) maintenance info break
Num Type Disp Enb Address What
-3 shlib events keep y 0xb7fd4fb0
-4 longjmp resume keep n 0x00000000
Petr
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-08-09 12:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-08 13:30 Restart remote application Petr Koloros
2007-08-08 14:24 ` Daniel Jacobowitz
2007-08-09 9:32 ` Petr Koloros
2007-08-09 11:20 ` Daniel Jacobowitz
2007-08-09 12:26 ` Petr Koloros
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox