2002-01-17 Daniel Jacobowitz <drow@mvista.com>
* low-hppabsd.c (myattach): New function, returning -1. * low-lynx.c (myattach): Likewise. * low-nbsd.c (myattach): Likewise. * low-sim.c (myattach): Likewise. * low-sparc.c (myattach): Likewise. * low-sun3.c (myattach): Likewise. * low-linux.c (myattach): New function. * server.c (attach_inferior): New function. (main): Handle "--attach".
This commit is contained in:
parent
55baa95bb2
commit
45b7b34510
|
@ -1,3 +1,17 @@
|
||||||
|
2002-01-17 Daniel Jacobowitz <drow@mvista.com>
|
||||||
|
|
||||||
|
* low-hppabsd.c (myattach): New function, returning -1.
|
||||||
|
* low-lynx.c (myattach): Likewise.
|
||||||
|
* low-nbsd.c (myattach): Likewise.
|
||||||
|
* low-sim.c (myattach): Likewise.
|
||||||
|
* low-sparc.c (myattach): Likewise.
|
||||||
|
* low-sun3.c (myattach): Likewise.
|
||||||
|
|
||||||
|
* low-linux.c (myattach): New function.
|
||||||
|
|
||||||
|
* server.c (attach_inferior): New function.
|
||||||
|
(main): Handle "--attach".
|
||||||
|
|
||||||
2002-01-16 Andrew Cagney <ac131313@redhat.com>
|
2002-01-16 Andrew Cagney <ac131313@redhat.com>
|
||||||
|
|
||||||
* MAINTAINERS (language support): Daniel Jacobwitz is C++
|
* MAINTAINERS (language support): Daniel Jacobwitz is C++
|
||||||
|
|
|
@ -81,6 +81,13 @@ kill_inferior (void)
|
||||||
/*************inferior_died ();****VK**************/
|
/*************inferior_died ();****VK**************/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attaching is not supported. */
|
||||||
|
int
|
||||||
|
myattach (int pid)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return nonzero if the given thread is still alive. */
|
/* Return nonzero if the given thread is still alive. */
|
||||||
int
|
int
|
||||||
mythread_alive (int pid)
|
mythread_alive (int pid)
|
||||||
|
|
|
@ -78,6 +78,23 @@ create_inferior (char *program, char **allargs)
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attach to an inferior process. */
|
||||||
|
|
||||||
|
int
|
||||||
|
myattach (int pid)
|
||||||
|
{
|
||||||
|
if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid,
|
||||||
|
errno < sys_nerr ? sys_errlist[errno] : "unknown error",
|
||||||
|
errno);
|
||||||
|
fflush (stderr);
|
||||||
|
_exit (0177);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Kill the inferior process. Make us have no inferior. */
|
/* Kill the inferior process. Make us have no inferior. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -87,6 +87,13 @@ create_inferior (char *program, char **allargs)
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attaching is not supported. */
|
||||||
|
int
|
||||||
|
myattach (int pid)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Kill the inferior process. Make us have no inferior. */
|
/* Kill the inferior process. Make us have no inferior. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -145,6 +145,13 @@ create_inferior (char *program, char **allargs)
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attaching is not supported. */
|
||||||
|
int
|
||||||
|
myattach (int pid)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Kill the inferior process. Make us have no inferior. */
|
/* Kill the inferior process. Make us have no inferior. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -139,6 +139,13 @@ create_inferior (char *program, char **argv)
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attaching is not supported. */
|
||||||
|
int
|
||||||
|
myattach (int pid)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Kill the inferior process. Make us have no inferior. */
|
/* Kill the inferior process. Make us have no inferior. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -75,6 +75,13 @@ create_inferior (char *program, char **allargs)
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attaching is not supported. */
|
||||||
|
int
|
||||||
|
myattach (int pid)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Kill the inferior process. Make us have no inferior. */
|
/* Kill the inferior process. Make us have no inferior. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -72,6 +72,13 @@ create_inferior (char *program, char **allargs)
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attaching is not supported. */
|
||||||
|
int
|
||||||
|
myattach (int pid)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Kill the inferior process. Make us have no inferior. */
|
/* Kill the inferior process. Make us have no inferior. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -39,6 +39,21 @@ start_inferior (char *argv[], char *statusptr)
|
||||||
return mywait (statusptr);
|
return mywait (statusptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
attach_inferior (int pid, char *statusptr, unsigned char *sigptr)
|
||||||
|
{
|
||||||
|
/* myattach should return -1 if attaching is unsupported,
|
||||||
|
0 if it succeeded, and call error() otherwise. */
|
||||||
|
if (myattach (pid) != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
inferior_pid = pid;
|
||||||
|
|
||||||
|
*sigptr = mywait (statusptr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern int remote_debug;
|
extern int remote_debug;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -49,6 +64,10 @@ main (int argc, char *argv[])
|
||||||
unsigned char signal;
|
unsigned char signal;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
CORE_ADDR mem_addr;
|
CORE_ADDR mem_addr;
|
||||||
|
int bad_attach = 0;
|
||||||
|
int pid = 0;
|
||||||
|
int attached = 0;
|
||||||
|
char *arg_end;
|
||||||
|
|
||||||
if (setjmp (toplevel))
|
if (setjmp (toplevel))
|
||||||
{
|
{
|
||||||
|
@ -56,15 +75,44 @@ main (int argc, char *argv[])
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc >= 3 && strcmp (argv[2], "--attach") == 0)
|
||||||
error ("Usage: gdbserver tty prog [args ...]");
|
{
|
||||||
|
if (argc == 4
|
||||||
|
&& argv[3] != '\0'
|
||||||
|
&& (pid = strtoul (argv[3], &arg_end, 10)) != 0
|
||||||
|
&& *arg_end == '\0')
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
bad_attach = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc < 3 || bad_attach)
|
||||||
|
error ("Usage:\tgdbserver tty prog [args ...]\n"
|
||||||
|
"\tgdbserver tty --attach pid");
|
||||||
|
|
||||||
initialize_low ();
|
initialize_low ();
|
||||||
|
|
||||||
/* Wait till we are at first instruction in program. */
|
if (pid == 0)
|
||||||
signal = start_inferior (&argv[2], &status);
|
{
|
||||||
|
/* Wait till we are at first instruction in program. */
|
||||||
|
signal = start_inferior (&argv[2], &status);
|
||||||
|
|
||||||
/* We are now stopped at the first instruction of the target process */
|
/* We are now stopped at the first instruction of the target process */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (attach_inferior (pid, &status, &signal))
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
error ("Attaching not supported on this target");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
attached = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -83,8 +131,18 @@ main (int argc, char *argv[])
|
||||||
remote_debug = !remote_debug;
|
remote_debug = !remote_debug;
|
||||||
break;
|
break;
|
||||||
case '!':
|
case '!':
|
||||||
extended_protocol = 1;
|
if (attached == 0)
|
||||||
prepare_resume_reply (own_buf, status, signal);
|
{
|
||||||
|
extended_protocol = 1;
|
||||||
|
prepare_resume_reply (own_buf, status, signal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We can not use the extended protocol if we are
|
||||||
|
attached, because we can not restart the running
|
||||||
|
program. So return unrecognized. */
|
||||||
|
own_buf[0] = '\0';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
prepare_resume_reply (own_buf, status, signal);
|
prepare_resume_reply (own_buf, status, signal);
|
||||||
|
@ -250,8 +308,8 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Remote side has terminated connection. GDBserver will reopen the connection.\n");
|
fprintf (stderr, "Remote side has terminated connection. "
|
||||||
|
"GDBserver will reopen the connection.\n");
|
||||||
remote_close ();
|
remote_close ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue