This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA]: Remote protocol symbol lookup service.
- To: cagney at cygnus dot com, gdb-patches at sources dot redhat dot com
- Subject: Re: [RFA]: Remote protocol symbol lookup service.
- From: Michael Snyder <msnyder at cygnus dot com>
- Date: Wed, 02 May 2001 15:56:46 -0700
- Organization: Red Hat
- References: <3AF08427.3522D20E@cygnus.com>
Michael Snyder wrote:
>
> Andrew,
>
> I've changed the initial message from "Q" to "q" as you suggested, and
> I've hexified the filenames and symbol names, so that they are not
> vulnerable to embedded special characters. If you have a name for the
> initial message that you would prefer over "qSharedObject", I'm open
> to suggestions.
And I seem to have sent it without the attachment. Try again...
2001-05-02 Michael Snyder <msnyder@redhat.com>
* remote.c (remote_open_1): Call no_shared_libraries, so that
symbols for shared libraries can be reloaded per session.
(remote_async_open_1): Ditto.
(remote_new_objfile): New function. Send notification to target
for each new object file (shared library), and answer any requests
from the target for symbol lookup.
*** save/remote.hex2bin.c Wed May 2 14:48:17 2001
--- ./remote.c Wed May 2 14:54:45 2001
*************** serial device is attached to the remote
*** 2130,2135 ****
--- 2130,2140 ----
someday have a notion of debugging several processes. */
inferior_pid = 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). */
*************** serial device is attached to the remote
*** 2148,2159 ****
putpkt ("!");
getpkt (buf, PBUFSIZ, 0);
}
/* 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
if (exec_bfd) /* No use without an exec file. */
SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
#endif
--- 2153,2166 ----
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. */
!
! /* Set up to detect and load shared libraries. */
if (exec_bfd) /* No use without an exec file. */
SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
#endif
*************** serial device is attached to the remote
*** 2230,2235 ****
--- 2237,2246 ----
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). */
*************** serial device is attached to the remote
*** 2251,2262 ****
putpkt ("!");
getpkt (buf, PBUFSIZ, 0);
}
/* 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
if (exec_bfd) /* No use without an exec file. */
SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
#endif
--- 2262,2275 ----
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. */
!
! /* Set up to detect and load shared libraries. */
if (exec_bfd) /* No use without an exec file. */
SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
#endif
*************** build_remote_gdbarch_data (void)
*** 5705,5710 ****
--- 5718,5778 ----
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)
+ {
+ char *msg, *reply, *prev, *tmp;
+ struct minimal_symbol *sym;
+
+ if (remote_desc != 0) /* Have a remote connection */
+ {
+ msg = alloca (PBUFSIZ);
+ reply = alloca (PBUFSIZ);
+
+ /* Inform target of new objfile. */
+
+ /* NOTE: you might say that I should use SLASH_CHAR here, but
+ not so! SLASH_CHAR is defined for the host, while the shared
+ libraries are relevant to the target. */
+ if (objfile)
+ {
+ tmp = strrchr (objfile->name, '/');
+ if (tmp == NULL)
+ tmp = strrchr (objfile->name, '\\');
+ if (tmp == NULL)
+ tmp = objfile->name;
+ bin2hex (tmp + 1, reply, 0);
+ sprintf (msg, "qSharedObject:%s", reply);
+ }
+ else
+ strcpy (msg, "qSharedObject:");
+
+ putpkt (msg);
+ getpkt (reply, PBUFSIZ, 0);
+ while (strncmp (reply, "qSymbol:", 8) == 0)
+ {
+ msg[hex2bin (&reply[8], msg, 0)] = '\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);
+ }
+ }
+ /* Call predecessor on chain, if any. */
+ if (remote_new_objfile_chain != 0 &&
+ remote_desc == 0)
+ remote_new_objfile_chain (objfile);
+ }
+
void
_initialize_remote (void)
{
*************** _initialize_remote (void)
*** 5734,5739 ****
--- 5802,5811 ----
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 ();