summaryrefslogtreecommitdiff
path: root/gdb/solib-svr4.c
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2022-03-15 18:08:06 +0100
committerMarkus Metzger <markus.t.metzger@intel.com>2022-10-18 14:16:09 +0200
commit2733d9d5d62c62023dc2d7a93fa5afa22f386ffd (patch)
tree0f300db4630b2472d9187e3a89e0c0ae5dc6ca8e /gdb/solib-svr4.c
parentad10f44e568806c2399f9405f4588f3e27f7d9ae (diff)
downloadbinutils-gdb-2733d9d5d62c62023dc2d7a93fa5afa22f386ffd.tar.gz
gdb, gdbserver: extend RSP to support namespaces
Introduce a new qXfer:libraries-svr4:read annex key/value pair lmid=<namespace identifier> to be used together with start and prev to provide the namespace of start and prev to gdbserver. Unknown key/value pairs are ignored by gdbserver so no new supports check is needed. Introduce a new library-list-svr4 library attribute lmid to provide the namespace of a library entry to GDB. This implementation uses the address of a namespace's r_debug object as namespace identifier. This should have incremented the minor version but since unknown XML attributes are ignored, anyway, and since changing the version results in a warning from GDB, the version is left at 1.0.
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r--gdb/solib-svr4.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index a80e7e30561..295e9b8b69d 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1067,8 +1067,37 @@ library_list_start_library (struct gdb_xml_parser *parser,
new_elem->so_name[sizeof (new_elem->so_name) - 1] = 0;
strcpy (new_elem->so_original_name, new_elem->so_name);
- *list->tailp = new_elem;
- list->tailp = &new_elem->next;
+ /* Older versions did not supply lmid. Put the element into the flat
+ list of the special namespace zero in that case. */
+ gdb_xml_value *at_lmid = xml_find_attribute (attributes, "lmid");
+ if (at_lmid == nullptr)
+ {
+ *list->tailp = new_elem;
+ list->tailp = &new_elem->next;
+ }
+ else
+ {
+ ULONGEST lmid = *(ULONGEST *) at_lmid->value.get ();
+
+ /* Ensure that the element is actually initialized. */
+ if (list->solib_lists.find (lmid) == list->solib_lists.end ())
+ list->solib_lists[lmid] = nullptr;
+
+ so_list **psolist = &list->solib_lists[lmid];
+ so_list **pnext = psolist;
+
+ /* Walk to the end of the list if we have one. */
+ so_list *solist = *psolist;
+ if (solist != nullptr)
+ {
+ for (; solist->next != nullptr; solist = solist->next)
+ /* Nothing. */;
+
+ pnext = &solist->next;
+ }
+
+ *pnext = new_elem;
+ }
}
/* Handle the start of a <library-list-svr4> element. */
@@ -1108,6 +1137,7 @@ static const struct gdb_xml_attribute svr4_library_attributes[] =
{ "lm", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
{ "l_addr", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
{ "l_ld", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
+ { "lmid", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
@@ -1869,7 +1899,9 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base,
struct svr4_library_list library_list;
char annex[64];
- xsnprintf (annex, sizeof (annex), "start=%s;prev=%s",
+ /* Unknown key=value pairs are ignored by the gdbstub. */
+ xsnprintf (annex, sizeof (annex), "lmid=%s;start=%s;prev=%s",
+ phex_nz (debug_base, sizeof (debug_base)),
phex_nz (lm, sizeof (lm)),
phex_nz (prev_lm, sizeof (prev_lm)));
if (!svr4_current_sos_via_xfer_libraries (&library_list, annex))