diff options
author | Michael Snyder <msnyder@vmware.com> | 2001-06-14 19:27:45 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2001-06-14 19:27:45 +0000 |
commit | dc8acb9740b89a3bd10511e53dbf24ad25e1c048 (patch) | |
tree | 88745fc2dee9e45032f55af3b85d58d45d06c24c | |
parent | 0f1f2b0a26ea24ac814531304e6c50201bdd3766 (diff) | |
download | gdb-dc8acb9740b89a3bd10511e53dbf24ad25e1c048.zip gdb-dc8acb9740b89a3bd10511e53dbf24ad25e1c048.tar.gz gdb-dc8acb9740b89a3bd10511e53dbf24ad25e1c048.tar.bz2 |
2001-06-14 Michael Snyder <msnyder@redhat.com>
* remote.c (show_remote_protocol_qSymbol_packet_cmd,
set_remote_protocol_qSymbol_packet_cmd): New functions.
(init_all_packet_configs, show_remote_cmd): Add qSymbol packet.
(remote_check_symbols): New function. Implement qSymbol packet,
allowing target to request symbol lookup service from gdb.
(remote_open_1, remote_async_open_1): Call remote_check_symbols,
allowing symbol lookup from exec_bfd on connection to target.
(remote_new_objfile): New function. Catch new objfile notifications
from shared library module, and call remote_check_symbols.
(_initialize_remote): Hook remote_new_objfile into the shared
library notification chain. Add "set remote symbol-lookup" command.
-rw-r--r-- | gdb/ChangeLog | 14 | ||||
-rw-r--r-- | gdb/remote.c | 99 |
2 files changed, 108 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 164eef9..eb9b7f6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2001-06-14 Michael Snyder <msnyder@redhat.com> + + * remote.c (show_remote_protocol_qSymbol_packet_cmd, + set_remote_protocol_qSymbol_packet_cmd): New functions. + (init_all_packet_configs, show_remote_cmd): Add qSymbol packet. + (remote_check_symbols): New function. Implement qSymbol packet, + allowing target to request symbol lookup service from gdb. + (remote_open_1, remote_async_open_1): Call remote_check_symbols, + allowing symbol lookup from exec_bfd on connection to target. + (remote_new_objfile): New function. Catch new objfile notifications + from shared library module, and call remote_check_symbols. + (_initialize_remote): Hook remote_new_objfile into the shared + library notification chain. Add "set remote symbol-lookup" command. + 2001-06-14 Keith Seitz <keiths@redhat.com> * tracepoint.c (trace_command): We now have tracepoint diff --git a/gdb/remote.c b/gdb/remote.c index e2e9f73..86ba3c1 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -188,9 +188,9 @@ static void record_currthread (int currthread); 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); +static int bin2hex (const char *bin, char *hex, int count); static int putpkt_binary (char *buf, int cnt); @@ -670,6 +670,22 @@ packet_ok (const char *buf, struct packet_config *config) } } +/* 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; @@ -2070,6 +2086,7 @@ init_all_packet_configs (void) 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 @@ -2077,6 +2094,44 @@ init_all_packet_configs (void) 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) @@ -2169,7 +2224,10 @@ serial device is attached to the remote system\n\ /* 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 } @@ -2279,7 +2337,10 @@ serial device is attached to the remote system\n\ /* 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 } @@ -5705,7 +5766,6 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", static void set_remote_cmd (char *args, int from_tty) { - } static void @@ -5716,6 +5776,7 @@ show_remote_cmd (char *args, int from_tty) 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); } @@ -5729,6 +5790,23 @@ build_remote_gdbarch_data (void) 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) { @@ -5759,6 +5837,10 @@ _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 @@ -5859,6 +5941,13 @@ in a memory packet.\n", 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, |