the remote stub will expect that no @samp{struct link_map}
exists prior to the starting point.
+@item lmid=@var{lmid}
+A hexadecimal number specifying a namespace identifier. This is
+currently only used together with @samp{start} to provide the
+namespace identifier back to @value{GDBN} in the response.
+@value{GDBN} will only provide values that were previously reported to
+it. If unset, the response will include @samp{lmid="0x0"}.
@end table
Arguments that are not understood by the remote stub will be silently
address the file was prelinked to during the library load.
@item
@code{l_ld}, which is memory address of the @code{PT_DYNAMIC} segment
+@item
+@code{lmid}, which is an identifier for a linker namespace, such as
+the memory address of the @code{r_debug} object that contains this
+namespace's load map or the namespace identifier returned by
+@code{dlinfo (3)}.
@end itemize
Additionally the single @code{main-lm} attribute specifies address of
@smallexample
<library-list-svr4 version="1.0" main-lm="0xe4f8f8">
<library name="/lib/ld-linux.so.2" lm="0xe4f51c" l_addr="0xe2d000"
- l_ld="0xe4eefc"/>
+ l_ld="0xe4eefc" lmid="0xfffe0"/>
<library name="/lib/libc.so.6" lm="0xe4fbe8" l_addr="0x154000"
- l_ld="0x152350"/>
+ l_ld="0x152350" lmid="0xfffe0"/>
</library-list-svr>
@end smallexample
<!ATTLIST library lm CDATA #REQUIRED>
<!ATTLIST library l_addr CDATA #REQUIRED>
<!ATTLIST library l_ld CDATA #REQUIRED>
+<!ATTLIST library lmid CDATA #IMPLIED>
@end smallexample
@node Memory Map Format
<!ATTLIST library lm CDATA #REQUIRED>
<!ATTLIST library l_addr CDATA #REQUIRED>
<!ATTLIST library l_ld CDATA #REQUIRED>
+<!-- added lmid attribute to what should have become version 1.1 but
+ since this generates a warning in GDB and since unknown attributes
+ are ignored, anyway, leaving the version at 1.0. -->
+<!ATTLIST library lmid CDATA #IMPLIED>
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. */
{ "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 }
};
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))
/* Get the loaded shared libraries from one namespace. */
static void
-read_link_map (std::string &document, CORE_ADDR lm_addr, CORE_ADDR lm_prev,
- int ptr_size, const link_map_offsets *lmo)
+read_link_map (std::string &document, CORE_ADDR lmid, CORE_ADDR lm_addr,
+ CORE_ADDR lm_prev, int ptr_size, const link_map_offsets *lmo)
{
CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev;
string_appendf (document, "<library name=\"");
xml_escape_text_append (&document, (char *) libname);
string_appendf (document, "\" lm=\"0x%s\" l_addr=\"0x%s\" "
- "l_ld=\"0x%s\"/>",
+ "l_ld=\"0x%s\" lmid=\"0x%s\"/>",
paddress (lm_addr), paddress (l_addr),
- paddress (l_ld));
+ paddress (l_ld), paddress (lmid));
}
lm_prev = lm_addr;
char filename[PATH_MAX];
int pid, is_elf64;
unsigned int machine;
- CORE_ADDR lm_addr = 0, lm_prev = 0;
+ CORE_ADDR lmid = 0, lm_addr = 0, lm_prev = 0;
if (writebuf != NULL)
return -2;
break;
name_len = sep - annex;
- if (name_len == 5 && startswith (annex, "start"))
+ if (name_len == 4 && startswith (annex, "lmid"))
+ addrp = &lmid;
+ else if (name_len == 5 && startswith (annex, "start"))
addrp = &lm_addr;
else if (name_len == 4 && startswith (annex, "prev"))
addrp = &lm_prev;
std::string document = "<library-list-svr4 version=\"1.0\"";
/* When the starting LM_ADDR is passed in the annex, only traverse that
- namespace.
+ namespace, which is assumed to be identified by LMID.
Otherwise, start with R_DEBUG and traverse all namespaces we find. */
if (lm_addr != 0)
{
document += ">";
- read_link_map (document, lm_addr, lm_prev, ptr_size, lmo);
+ read_link_map (document, lmid, lm_addr, lm_prev, ptr_size, lmo);
}
else
{
if (lm_prev != 0)
warning ("ignoring prev=0x%s without start", paddress (lm_prev));
+ /* We could interpret LMID as 'provide only the libraries for this
+ namespace' but GDB is currently only providing lmid, start, and
+ prev, or nothing. */
+ if (lmid != 0)
+ warning ("ignoring lmid=0x%s without start", paddress (lmid));
+
CORE_ADDR r_debug = priv->r_debug;
if (r_debug == 0)
r_debug = priv->r_debug = get_r_debug (pid, is_elf64);
}
}
- read_link_map (document, lm_addr, lm_prev, ptr_size, lmo);
+ read_link_map (document, r_debug, lm_addr, lm_prev, ptr_size, lmo);
if (r_version < 2)
break;