aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
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 /gdbserver
parentad10f44e568806c2399f9405f4588f3e27f7d9ae (diff)
downloadgdb-2733d9d5d62c62023dc2d7a93fa5afa22f386ffd.zip
gdb-2733d9d5d62c62023dc2d7a93fa5afa22f386ffd.tar.gz
gdb-2733d9d5d62c62023dc2d7a93fa5afa22f386ffd.tar.bz2
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 'gdbserver')
-rw-r--r--gdbserver/linux-low.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index e83ccce..4754366 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6489,8 +6489,8 @@ static const link_map_offsets lmo_64bit_offsets =
/* 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;
@@ -6525,9 +6525,9 @@ read_link_map (std::string &document, CORE_ADDR lm_addr, CORE_ADDR lm_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;
@@ -6547,7 +6547,7 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
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;
@@ -6581,7 +6581,9 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
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;
@@ -6600,19 +6602,25 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
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);
@@ -6678,7 +6686,7 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
}
}
- 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;