static int fromhex (int a);
-static int hex2bin (const char *hex, char *bin, int);
+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;
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);
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)
{
someday have a notion of debugging several processes. */
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 (PIDGET (inferior_ptid));
+ {
+ 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)
{
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 (PIDGET (inferior_ptid));
+ {
+ 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)
{
int i;
- /* May use a length, or a nul-terminated string as input. */
- if (count == 0)
- count = strlen (hex) / 2;
-
for (i = 0; i < count; i++)
{
if (hex[0] == 0 || hex[1] == 0)
}
static int
-bin2hex (char *bin, char *hex, int count)
+bin2hex (const char *bin, char *hex, int count)
{
int i;
/* May use a length, or a nul-terminated string as input. */
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;
}
}
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. */
{
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);
- if (hex2bin (p, regs, REGISTER_RAW_SIZE (regno))
- < REGISTER_RAW_SIZE (regno))
+ 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);
}
{
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);
- if (hex2bin (p, regs, REGISTER_RAW_SIZE (regno))
- < REGISTER_RAW_SIZE (regno))
+ 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);
}
/* Normal mode: Send target system values byte by byte, in
increasing byte addresses. Each byte is encoded as a two hex
value. */
- bin2hex (myaddr, p, todo);
+ nr_bytes = bin2hex (myaddr, p, todo);
+ p += 2 * nr_bytes;
break;
case PACKET_SUPPORT_UNKNOWN:
internal_error (__FILE__, __LINE__,
{
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. */
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)
{
/* 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;
}
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,