static void remote_fetch_registers (int regno);
-static void remote_resume (int pid, int step, enum target_signal siggnal);
-static void remote_async_resume (int pid, int step,
+static void remote_resume (ptid_t ptid, int step,
+ enum target_signal siggnal);
+static void remote_async_resume (ptid_t ptid, int step,
enum target_signal siggnal);
static int remote_start_remote (PTR);
static int readchar (int timeout);
-static int remote_wait (int pid, struct target_waitstatus *status);
-static int remote_async_wait (int pid, struct target_waitstatus *status);
+static ptid_t remote_wait (ptid_t ptid,
+ struct target_waitstatus *status);
+static ptid_t remote_async_wait (ptid_t ptid,
+ struct target_waitstatus *status);
static void remote_kill (void);
static void remote_async_kill (void);
static void set_thread (int, int);
-static int remote_thread_alive (int);
+static int remote_thread_alive (ptid_t);
static void get_offsets (void);
static int stub_unpack_int (char *buff, int fieldlength);
-static int remote_current_thread (int oldpid);
+static ptid_t remote_current_thread (ptid_t oldptid);
static void remote_find_new_threads (void);
static void record_currthread (int currthread);
-/* exported functions */
+static int fromhex (int a);
-extern int fromhex (int a);
+static int hex2bin (const char *hex, char *bin, int count);
+
+static int bin2hex (const char *bin, char *hex, int count);
static int putpkt_binary (char *buf, int cnt);
/* Descriptor for I/O to remote machine. Initialize it to NULL so that
remote_open knows that we don't have a file open when the program
starts. */
-static serial_t remote_desc = NULL;
+static struct serial *remote_desc = NULL;
/* This is set by the target (thru the 'S' message)
to denote that the target is in kernel mode. */
}
}
+/* Should we try the 'qSymbol' (target symbol lookup service) request? */
+static struct packet_config remote_protocol_qSymbol;
+
+static void
+set_remote_protocol_qSymbol_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_packet_config (&remote_protocol_qSymbol);
+}
+
+static void
+show_remote_protocol_qSymbol_packet_cmd (char *args, int from_tty)
+{
+ show_packet_config_cmd (&remote_protocol_qSymbol);
+}
+
/* Should we try the 'e' (step over range) request? */
static struct packet_config remote_protocol_e;
/* If this is a new thread, add it to GDB's thread list.
If we leave it up to WFI to do this, bad things will happen. */
- if (!in_thread_list (currthread))
+ if (!in_thread_list (pid_to_ptid (currthread)))
{
- add_thread (currthread);
+ add_thread (pid_to_ptid (currthread));
#ifdef UI_OUT
ui_out_text (uiout, "[New ");
- ui_out_text (uiout, target_pid_to_str (currthread));
+ ui_out_text (uiout, target_pid_to_str (pid_to_ptid (currthread)));
ui_out_text (uiout, "]\n");
#else
- printf_filtered ("[New %s]\n", target_pid_to_str (currthread));
+ printf_filtered ("[New %s]\n",
+ target_pid_to_str (pid_to_ptid (currthread)));
#endif
}
}
/* Return nonzero if the thread TH is still alive on the remote system. */
static int
-remote_thread_alive (int tid)
+remote_thread_alive (ptid_t ptid)
{
+ int tid = PIDGET (ptid);
char buf[16];
if (tid < 0)
static int
remote_newthread_step (threadref *ref, void *context)
{
- int pid;
+ ptid_t ptid;
+
+ ptid = pid_to_ptid (threadref_to_int (ref));
- pid = threadref_to_int (ref);
- if (!in_thread_list (pid))
- add_thread (pid);
+ if (!in_thread_list (ptid))
+ add_thread (ptid);
return 1; /* continue iterator */
}
#define CRAZY_MAX_THREADS 1000
-static int
-remote_current_thread (int oldpid)
+static ptid_t
+remote_current_thread (ptid_t oldpid)
{
char *buf = alloca (PBUFSIZ);
putpkt ("qC");
getpkt (buf, PBUFSIZ, 0);
if (buf[0] == 'Q' && buf[1] == 'C')
- return strtol (&buf[2], NULL, 16);
+ return pid_to_ptid (strtol (&buf[2], NULL, 16));
else
return oldpid;
}
{
remote_threadlist_iterator (remote_newthread_step, 0,
CRAZY_MAX_THREADS);
- if (inferior_pid == MAGIC_NULL_PID) /* ack ack ack */
- inferior_pid = remote_current_thread (inferior_pid);
+ if (PIDGET (inferior_ptid) == MAGIC_NULL_PID) /* ack ack ack */
+ inferior_ptid = remote_current_thread (inferior_ptid);
}
/*
do
{
tid = strtol (bufp, &bufp, 16);
- if (tid != 0 && !in_thread_list (tid))
- add_thread (tid);
+ if (tid != 0 && !in_thread_list (pid_to_ptid (tid)))
+ add_thread (pid_to_ptid (tid));
}
while (*bufp++ == ','); /* comma-separated list */
putpkt ("qsThreadInfo");
if (use_threadextra_query)
{
- sprintf (bufp, "qThreadExtraInfo,%x", tp->pid);
+ sprintf (bufp, "qThreadExtraInfo,%x", PIDGET (tp->ptid));
putpkt (bufp);
getpkt (bufp, PBUFSIZ, 0);
if (bufp[0] != 0)
{
- char *p;
-
- for (p = display_buf;
- p < display_buf + sizeof(display_buf) - 1 &&
- bufp[0] != 0 &&
- bufp[1] != 0;
- p++, bufp+=2)
- {
- *p = fromhex (bufp[0]) * 16 + fromhex (bufp[1]);
- }
- *p = 0;
+ n = min (strlen (bufp) / 2, sizeof (display_buf));
+ result = hex2bin (bufp, display_buf, n);
+ display_buf [result] = '\0';
return display_buf;
}
}
use_threadextra_query = 0;
set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME
| TAG_MOREDISPLAY | TAG_DISPLAY;
- int_to_threadref (&id, tp->pid);
+ int_to_threadref (&id, PIDGET (tp->ptid));
if (remote_get_threadinfo (&id, set, &threadinfo))
if (threadinfo.active)
{
remote_close (int quitting)
{
if (remote_desc)
- SERIAL_CLOSE (remote_desc);
+ serial_close (remote_desc);
remote_desc = NULL;
}
immediate_quit++; /* Allow user to interrupt it */
/* Ack any packet which the remote side has already sent. */
- SERIAL_WRITE (remote_desc, "+", 1);
+ serial_write (remote_desc, "+", 1);
/* Let the stub know that we want it to return the thread. */
set_thread (-1, 0);
- inferior_pid = remote_current_thread (inferior_pid);
+ inferior_ptid = remote_current_thread (inferior_ptid);
get_offsets (); /* Get text, data & bss offsets */
update_packet_config (&remote_protocol_e);
update_packet_config (&remote_protocol_E);
update_packet_config (&remote_protocol_P);
+ update_packet_config (&remote_protocol_qSymbol);
for (i = 0; i < NR_Z_PACKET_TYPES; i++)
update_packet_config (&remote_protocol_Z[i]);
/* Force remote_write_bytes to check whether target supports binary
update_packet_config (&remote_protocol_binary_download);
}
+/* Symbol look-up. */
+
+static void
+remote_check_symbols (struct objfile *objfile)
+{
+ char *msg, *reply, *tmp;
+ struct minimal_symbol *sym;
+ int end;
+
+ if (remote_protocol_qSymbol.support == PACKET_DISABLE)
+ return;
+
+ msg = alloca (PBUFSIZ);
+ reply = alloca (PBUFSIZ);
+
+ /* Invite target to request symbol lookups. */
+
+ putpkt ("qSymbol::");
+ getpkt (reply, PBUFSIZ, 0);
+ packet_ok (reply, &remote_protocol_qSymbol);
+
+ while (strncmp (reply, "qSymbol:", 8) == 0)
+ {
+ tmp = &reply[8];
+ end = hex2bin (tmp, msg, strlen (tmp) / 2);
+ msg[end] = '\0';
+ sym = lookup_minimal_symbol (msg, NULL, NULL);
+ if (sym == NULL)
+ sprintf (msg, "qSymbol::%s", &reply[8]);
+ else
+ sprintf (msg, "qSymbol:%s:%s",
+ paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
+ &reply[8]);
+ putpkt (msg);
+ getpkt (reply, PBUFSIZ, 0);
+ }
+}
+
static void
remote_open_1 (char *name, int from_tty, struct target_ops *target,
int extended_p)
unpush_target (target);
- remote_desc = SERIAL_OPEN (name);
+ remote_desc = serial_open (name);
if (!remote_desc)
perror_with_name (name);
if (baud_rate != -1)
{
- if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
+ if (serial_setbaudrate (remote_desc, baud_rate))
{
- SERIAL_CLOSE (remote_desc);
+ serial_close (remote_desc);
perror_with_name (name);
}
}
- SERIAL_RAW (remote_desc);
+ serial_raw (remote_desc);
/* If there is something sitting in the buffer we might take it as a
response to a command, which would be bad. */
- SERIAL_FLUSH_INPUT (remote_desc);
+ serial_flush_input (remote_desc);
if (from_tty)
{
be split out into seperate variables, especially since GDB will
someday have a notion of debugging several processes. */
- inferior_pid = MAGIC_NULL_PID;
+ inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
+ /* First delete any symbols previously loaded from shared libraries. */
+ no_shared_libraries (NULL, 0);
+#endif
+
/* Start the remote connection; if error (0), discard this target.
In particular, if the user quits, be sure to discard it
(we'd be in an inconsistent state otherwise). */
putpkt ("!");
getpkt (buf, PBUFSIZ, 0);
}
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
/* FIXME: need a master target_open vector from which all
remote_opens can be called, so that stuff like this can
go there. Failing that, the following code must be copied
to the open function for any remote target that wants to
support svr4 shared libraries. */
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
+
+ /* Set up to detect and load shared libraries. */
if (exec_bfd) /* No use without an exec file. */
- SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
+ {
+ SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
+ remote_check_symbols (symfile_objfile);
+ }
#endif
}
unpush_target (target);
- remote_desc = SERIAL_OPEN (name);
+ remote_desc = serial_open (name);
if (!remote_desc)
perror_with_name (name);
if (baud_rate != -1)
{
- if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
+ if (serial_setbaudrate (remote_desc, baud_rate))
{
- SERIAL_CLOSE (remote_desc);
+ serial_close (remote_desc);
perror_with_name (name);
}
}
- SERIAL_RAW (remote_desc);
+ serial_raw (remote_desc);
/* If there is something sitting in the buffer we might take it as a
response to a command, which would be bad. */
- SERIAL_FLUSH_INPUT (remote_desc);
+ serial_flush_input (remote_desc);
if (from_tty)
{
flag indicating that a target is active. These functions should
be split out into seperate variables, especially since GDB will
someday have a notion of debugging several processes. */
- inferior_pid = MAGIC_NULL_PID;
+ inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
/* With this target we start out by owning the terminal. */
remote_async_terminal_ours_p = 1;
implemented. */
wait_forever_enabled_p = 0;
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
+ /* First delete any symbols previously loaded from shared libraries. */
+ no_shared_libraries (NULL, 0);
+#endif
+
/* Start the remote connection; if error (0), discard this target.
In particular, if the user quits, be sure to discard it
(we'd be in an inconsistent state otherwise). */
putpkt ("!");
getpkt (buf, PBUFSIZ, 0);
}
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
/* FIXME: need a master target_open vector from which all
remote_opens can be called, so that stuff like this can
go there. Failing that, the following code must be copied
to the open function for any remote target that wants to
support svr4 shared libraries. */
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
+
+ /* Set up to detect and load shared libraries. */
if (exec_bfd) /* No use without an exec file. */
- SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
+ {
+ SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
+ remote_check_symbols (symfile_objfile);
+ }
#endif
}
/* Unregister the file descriptor from the event loop. */
if (target_is_async_p ())
- SERIAL_ASYNC (remote_desc, NULL, 0);
+ serial_async (remote_desc, NULL, 0);
target_mourn_inferior ();
if (from_tty)
/* Convert hex digit A to a number. */
-int
+static int
fromhex (int a)
{
if (a >= '0' && a <= '9')
error ("Reply contains invalid hex digit %d", a);
}
+static int
+hex2bin (const char *hex, char *bin, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ if (hex[0] == 0 || hex[1] == 0)
+ {
+ /* Hex string is short, or of uneven length.
+ Return the count that has been converted so far. */
+ return i;
+ }
+ *bin++ = fromhex (hex[0]) * 16 + fromhex (hex[1]);
+ hex += 2;
+ }
+ return i;
+}
+
/* Convert number NIB to a hex digit. */
static int
else
return 'a' + nib - 10;
}
+
+static int
+bin2hex (const char *bin, char *hex, int count)
+{
+ int i;
+ /* May use a length, or a nul-terminated string as input. */
+ if (count == 0)
+ count = strlen (bin);
+
+ for (i = 0; i < count; i++)
+ {
+ *hex++ = tohex ((*bin >> 4) & 0xf);
+ *hex++ = tohex (*bin++ & 0xf);
+ }
+ *hex = 0;
+ return i;
+}
\f
/* Tell the remote machine to resume. */
static int last_sent_step;
static void
-remote_resume (int pid, int step, enum target_signal siggnal)
+remote_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
char *buf = alloca (PBUFSIZ);
+ int pid = PIDGET (ptid);
char *p;
if (pid == -1)
putpkt (buf);
getpkt (buf, PBUFSIZ, 0);
- if (packet_ok(buf, &remote_protocol_E) == PACKET_OK)
+ if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
return;
}
}
putpkt (buf);
getpkt (buf, PBUFSIZ, 0);
- if (packet_ok(buf, &remote_protocol_e) == PACKET_OK)
+ if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
return;
}
}
/* Same as remote_resume, but with async support. */
static void
-remote_async_resume (int pid, int step, enum target_signal siggnal)
+remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
char *buf = alloca (PBUFSIZ);
+ int pid = PIDGET (ptid);
char *p;
if (pid == -1)
putpkt (buf);
getpkt (buf, PBUFSIZ, 0);
- if (packet_ok(buf, &remote_protocol_E) == PACKET_OK)
+ if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
goto register_event_loop;
}
}
putpkt (buf);
getpkt (buf, PBUFSIZ, 0);
- if (packet_ok(buf, &remote_protocol_e) == PACKET_OK)
+ if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
goto register_event_loop;
}
}
fprintf_unfiltered (gdb_stdlog, "remote_stop called\n");
if (remote_break)
- SERIAL_SEND_BREAK (remote_desc);
+ serial_send_break (remote_desc);
else
- SERIAL_WRITE (remote_desc, "\003", 1);
+ serial_write (remote_desc, "\003", 1);
}
/* Ask the user what to do when an interrupt is received. */
Returns "pid", which in the case of a multi-threaded
remote OS, is the thread-id. */
-static int
-remote_wait (int pid, struct target_waitstatus *status)
+static ptid_t
+remote_wait (ptid_t ptid, struct target_waitstatus *status)
{
unsigned char *buf = alloca (PBUFSIZ);
int thread_num = -1;
{
unsigned char *p1;
char *p_temp;
+ int fieldsize;
/* Read the register number */
regno = strtol ((const char *) p, &p_temp, 16);
Packet: '%s'\n",
regno, p, buf);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i++)
- {
- if (p[0] == 0 || p[1] == 0)
- warning ("Remote reply is too short: %s", buf);
- regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
- p += 2;
- }
+ fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
+ p += 2 * fieldsize;
+ if (fieldsize < REGISTER_RAW_SIZE (regno))
+ warning ("Remote reply is too short: %s", buf);
supply_register (regno, regs);
}
got_status:
if (thread_num != -1)
{
- return thread_num;
+ return pid_to_ptid (thread_num);
}
- return inferior_pid;
+ return inferior_ptid;
}
/* Async version of remote_wait. */
-static int
-remote_async_wait (int pid, struct target_waitstatus *status)
+static ptid_t
+remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
{
unsigned char *buf = alloca (PBUFSIZ);
int thread_num = -1;
{
unsigned char *p1;
char *p_temp;
+ int fieldsize;
/* Read the register number */
regno = strtol ((const char *) p, &p_temp, 16);
Packet: '%s'\n",
regno, p, buf);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i++)
- {
- if (p[0] == 0 || p[1] == 0)
- warning ("Remote reply is too short: %s", buf);
- regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
- p += 2;
- }
+ fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
+ p += 2 * fieldsize;
+ if (fieldsize < REGISTER_RAW_SIZE (regno))
+ warning ("Remote reply is too short: %s", buf);
supply_register (regno, regs);
}
got_status:
if (thread_num != -1)
{
- return thread_num;
+ return pid_to_ptid (thread_num);
}
- return inferior_pid;
+ return inferior_ptid;
}
/* Number of bytes of registers this stub implements. */
char *p;
char *regs = alloca (REGISTER_BYTES);
- set_thread (inferior_pid, 1);
+ set_thread (PIDGET (inferior_ptid), 1);
sprintf (buf, "g");
remote_send (buf, PBUFSIZ);
sprintf (buf, "P%x=", regno);
p = buf + strlen (buf);
regp = register_buffer (regno);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); ++i)
- {
- *p++ = tohex ((regp[i] >> 4) & 0xf);
- *p++ = tohex (regp[i] & 0xf);
- }
- *p = '\0';
+ bin2hex (regp, p, REGISTER_RAW_SIZE (regno));
remote_send (buf, PBUFSIZ);
return buf[0] != '\0';
char *p;
char *regs;
- set_thread (inferior_pid, 1);
+ set_thread (PIDGET (inferior_ptid), 1);
if (regno >= 0)
{
regs = register_buffer (-1);
p = buf + 1;
/* remote_prepare_to_store insures that register_bytes_found gets set. */
- for (i = 0; i < register_bytes_found; i++)
- {
- *p++ = tohex ((regs[i] >> 4) & 0xf);
- *p++ = tohex (regs[i] & 0xf);
- }
- *p = '\0';
-
+ bin2hex (regs, p, register_bytes_found);
remote_send (buf, PBUFSIZ);
}
\f
/* Normal mode: Send target system values byte by byte, in
increasing byte addresses. Each byte is encoded as a two hex
value. */
- for (nr_bytes = 0; nr_bytes < todo; nr_bytes++)
- {
- *p++ = tohex ((myaddr[nr_bytes] >> 4) & 0xf);
- *p++ = tohex (myaddr[nr_bytes] & 0xf);
- }
- *p = '\0';
+ nr_bytes = bin2hex (myaddr, p, todo);
+ p += 2 * nr_bytes;
break;
case PACKET_SUPPORT_UNKNOWN:
internal_error (__FILE__, __LINE__,
each byte encoded as two hex characters. */
p = buf;
- for (i = 0; i < todo; i++)
+ if ((i = hex2bin (p, myaddr, todo)) < todo)
{
- if (p[0] == 0 || p[1] == 0)
- /* Reply is short. This means that we were able to read
- only part of what we wanted to. */
- return i + (origlen - len);
- myaddr[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
- p += 2;
+ /* Reply is short. This means that we were able to read
+ only part of what we wanted to. */
+ return i + (origlen - len);
}
myaddr += todo;
memaddr += todo;
{
int ch;
- ch = SERIAL_READCHAR (remote_desc, timeout);
+ ch = serial_readchar (remote_desc, timeout);
if (ch >= 0)
return (ch & 0x7f);
fprintf_unfiltered (gdb_stdlog, "...");
gdb_flush (gdb_stdlog);
}
- if (SERIAL_WRITE (remote_desc, buf2, p - buf2))
+ if (serial_write (remote_desc, buf2, p - buf2))
perror_with_name ("putpkt: write failed");
/* read until either a timeout occurs (-2) or '+' is read */
if (repeat > 0 && repeat <= 255
&& bc > 0
- && bc + repeat < sizeof_buf - 1)
+ && bc + repeat - 1 < sizeof_buf - 1)
{
memset (&buf[bc], buf[bc - 1], repeat);
bc += repeat;
fputstr_unfiltered (buf, 0, gdb_stdlog);
fprintf_unfiltered (gdb_stdlog, "\n");
}
- SERIAL_WRITE (remote_desc, "+", 1);
+ serial_write (remote_desc, "+", 1);
return 0;
}
/* Try the whole thing again. */
retry:
- SERIAL_WRITE (remote_desc, "-", 1);
+ serial_write (remote_desc, "-", 1);
}
/* We have tried hard enough, and just can't receive the packet. Give up. */
printf_unfiltered ("Ignoring packet error, continuing...\n");
- SERIAL_WRITE (remote_desc, "+", 1);
+ serial_write (remote_desc, "+", 1);
return 1;
}
\f
{
/* Unregister the file descriptor from the event loop. */
if (target_is_async_p ())
- SERIAL_ASYNC (remote_desc, NULL, 0);
+ serial_async (remote_desc, NULL, 0);
/* For some mysterious reason, wait_for_inferior calls kill instead of
mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */
error ("\"monitor\" command ``%s'' is too long\n", command);
/* Encode the actual command */
- for (i = 0; command[i]; i++)
- {
- *p++ = tohex ((command[i] >> 4) & 0xf);
- *p++ = tohex (command[i] & 0xf);
- }
- *p = '\0';
+ bin2hex (command, p, 0);
if (putpkt (buf) < 0)
error ("Communication problem with target\n");
{
int sample_thread = SAMPLE_THREAD;
- if (remote_thread_alive (sample_thread))
+ if (remote_thread_alive (pid_to_ptid (sample_thread)))
printf_filtered ("PASS: Thread alive test\n");
else
printf_filtered ("FAIL: Thread alive test\n");
buffer. */
static char *
-remote_pid_to_str (int pid)
+remote_pid_to_str (ptid_t ptid)
{
static char buf[30];
- sprintf (buf, "Thread %d", pid);
+ sprintf (buf, "Thread %d", PIDGET (ptid));
return buf;
}
remote_ops.to_mourn_inferior = remote_mourn;
remote_ops.to_thread_alive = remote_thread_alive;
remote_ops.to_find_new_threads = remote_threads_info;
- remote_ops.to_extra_thread_info = remote_threads_extra_info;
remote_ops.to_pid_to_str = remote_pid_to_str;
+ remote_ops.to_extra_thread_info = remote_threads_extra_info;
remote_ops.to_stop = remote_stop;
remote_ops.to_query = remote_query;
remote_ops.to_rcmd = remote_rcmd;
unpush_target (&remote_cisco_ops);
- remote_desc = SERIAL_OPEN (name);
+ remote_desc = serial_open (name);
if (!remote_desc)
perror_with_name (name);
*/
baud_rate = (baud_rate > 0) ? baud_rate : 9600;
- if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
+ if (serial_setbaudrate (remote_desc, baud_rate))
{
- SERIAL_CLOSE (remote_desc);
+ serial_close (remote_desc);
perror_with_name (name);
}
- SERIAL_RAW (remote_desc);
+ serial_raw (remote_desc);
/* If there is something sitting in the buffer we might take it as a
response to a command, which would be bad. */
- SERIAL_FLUSH_INPUT (remote_desc);
+ serial_flush_input (remote_desc);
if (from_tty)
{
flag indicating that a target is active. These functions should
be split out into seperate variables, especially since GDB will
someday have a notion of debugging several processes. */
- inferior_pid = MAGIC_NULL_PID;
+ inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
/* Start the remote connection; if error (0), discard this target. */
/* Make this a zero terminated string and write it out */
tty_input[tty_bytecount] = 0;
- if (SERIAL_WRITE (remote_desc, tty_input, tty_bytecount))
+ if (serial_write (remote_desc, tty_input, tty_bytecount))
{
perror_with_name ("readtty: write failed");
return FATAL_ERROR;
FD_ZERO (&input);
FD_SET (fileno (stdin), &input);
- FD_SET (DEPRECATED_SERIAL_FD (remote_desc), &input);
+ FD_SET (deprecated_serial_fd (remote_desc), &input);
status = select (tablesize, &input, 0, 0, 0);
if ((status == -1) && (errno != EINTR))
quit_flag = 0;
if (remote_break)
- SERIAL_SEND_BREAK (remote_desc);
+ serial_send_break (remote_desc);
else
- SERIAL_WRITE (remote_desc, "\003", 1);
+ serial_write (remote_desc, "\003", 1);
continue;
}
}
}
-static int
-remote_cisco_wait (int pid, struct target_waitstatus *status)
+static ptid_t
+remote_cisco_wait (ptid_t ptid, struct target_waitstatus *status)
{
if (minitelnet () != ENTER_DEBUG)
{
error ("Debugging session terminated by protocol error");
}
putpkt ("?");
- return remote_wait (pid, status);
+ return remote_wait (ptid, status);
}
static void
remote_cisco_ops.to_mourn_inferior = remote_cisco_mourn;
remote_cisco_ops.to_thread_alive = remote_thread_alive;
remote_cisco_ops.to_find_new_threads = remote_threads_info;
- remote_ops.to_extra_thread_info = remote_threads_extra_info;
+ remote_cisco_ops.to_pid_to_str = remote_pid_to_str;
+ remote_cisco_ops.to_extra_thread_info = remote_threads_extra_info;
remote_cisco_ops.to_stratum = process_stratum;
remote_cisco_ops.to_has_all_memory = 1;
remote_cisco_ops.to_has_memory = 1;
remote_can_async_p (void)
{
/* We're async whenever the serial device is. */
- return (current_target.to_async_mask_value) && SERIAL_CAN_ASYNC_P (remote_desc);
+ return (current_target.to_async_mask_value) && serial_can_async_p (remote_desc);
}
static int
remote_is_async_p (void)
{
/* We're async whenever the serial device is. */
- return (current_target.to_async_mask_value) && SERIAL_IS_ASYNC_P (remote_desc);
+ return (current_target.to_async_mask_value) && serial_is_async_p (remote_desc);
}
/* Pass the SERIAL event on and up to the client. One day this code
static serial_event_ftype remote_async_serial_handler;
static void
-remote_async_serial_handler (serial_t scb, void *context)
+remote_async_serial_handler (struct serial *scb, void *context)
{
/* Don't propogate error information up to the client. Instead let
the client find out about the error by querying the target. */
if (callback != NULL)
{
- SERIAL_ASYNC (remote_desc, remote_async_serial_handler, NULL);
+ serial_async (remote_desc, remote_async_serial_handler, NULL);
async_client_callback = callback;
async_client_context = context;
}
else
- SERIAL_ASYNC (remote_desc, NULL, NULL);
+ serial_async (remote_desc, NULL, NULL);
}
/* Target async and target extended-async.
remote_async_ops.to_mourn_inferior = remote_async_mourn;
remote_async_ops.to_thread_alive = remote_thread_alive;
remote_async_ops.to_find_new_threads = remote_threads_info;
- remote_ops.to_extra_thread_info = remote_threads_extra_info;
+ remote_async_ops.to_pid_to_str = remote_pid_to_str;
+ remote_async_ops.to_extra_thread_info = remote_threads_extra_info;
remote_async_ops.to_stop = remote_stop;
remote_async_ops.to_query = remote_query;
remote_async_ops.to_rcmd = remote_rcmd;
static void
set_remote_cmd (char *args, int from_tty)
{
-
}
static void
show_remote_protocol_e_packet_cmd (args, from_tty);
show_remote_protocol_E_packet_cmd (args, from_tty);
show_remote_protocol_P_packet_cmd (args, from_tty);
+ show_remote_protocol_qSymbol_packet_cmd (args, from_tty);
show_remote_protocol_binary_download_cmd (args, from_tty);
}
remote_address_size = TARGET_ADDR_BIT;
}
+/* Saved pointer to previous owner of the new_objfile event. */
+static void (*remote_new_objfile_chain) (struct objfile *);
+
+/* Function to be called whenever a new objfile (shlib) is detected. */
+static void
+remote_new_objfile (struct objfile *objfile)
+{
+ if (remote_desc != 0) /* Have a remote connection */
+ {
+ remote_check_symbols (objfile);
+ }
+ /* Call predecessor on chain, if any. */
+ if (remote_new_objfile_chain != 0 &&
+ remote_desc == 0)
+ remote_new_objfile_chain (objfile);
+}
+
void
_initialize_remote (void)
{
init_remote_cisco_ops ();
add_target (&remote_cisco_ops);
+ /* Hook into new objfile notification. */
+ remote_new_objfile_chain = target_new_objfile_hook;
+ target_new_objfile_hook = remote_new_objfile;
+
#if 0
init_remote_threadtests ();
#endif
&maintenancelist);
add_show_from_set
- (add_set_cmd ("remotebreak", no_class,
- var_boolean, (char *) &remote_break,
- "Set whether to send break if interrupted.\n",
- &setlist),
+ (add_set_boolean_cmd ("remotebreak", no_class, &remote_break,
+ "Set whether to send break if interrupted.\n",
+ &setlist),
&showlist);
/* Install commands for configuring memory read/write packets. */
add_info ("remote-process", remote_info_process,
"Query the remote system for process info.");
+ add_packet_config_cmd (&remote_protocol_qSymbol,
+ "qSymbol", "symbol-lookup",
+ set_remote_protocol_qSymbol_packet_cmd,
+ show_remote_protocol_qSymbol_packet_cmd,
+ &remote_set_cmdlist, &remote_show_cmdlist,
+ 0);
+
add_packet_config_cmd (&remote_protocol_e,
"e", "step-over-range",
set_remote_protocol_e_packet_cmd,