unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Walker via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org
Cc: Conan C Huang <conhuang@cisco.com>,
	Jeremy Stenglein <jstengle@cisco.com>,
	xe-linux-external@cisco.com
Subject: [RFC PATCH 3/3] add r_debug multiple namespaces support
Date: Fri, 26 Jun 2020 12:32:28 -0700	[thread overview]
Message-ID: <20200626193228.1953-4-danielwa@cisco.com> (raw)

From: Conan C Huang <conhuang@cisco.com>

GLIBC Bugzilla: 15971
GDB Bugzilla: 11839

Glibc does not provide an interface for debugger to access libraries loaded in
multiple namespaces via dlmopen.

The current rtld-debugger interface is described in the file
elf/rtld-debugger-interface.txt under the "Standard debugger interface" heading.
This interface only provides access to the first link-map (LM_ID_BASE).

This solution converts r_debug into a linked-list, where each element correlates
to an unique namespace. Debugger (GDB) can traverse r_debug linked-list to
retrieve information for all loaded namespaces.
---
 elf/dl-debug.c | 13 ++++++++++---
 elf/link.h     |  4 ++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/elf/dl-debug.c b/elf/dl-debug.c
index 4b3d3ad6ba..7eba477fd3 100644
--- a/elf/dl-debug.c
+++ b/elf/dl-debug.c
@@ -44,20 +44,27 @@ struct r_debug _r_debug;
 struct r_debug *
 _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
 {
-  struct r_debug *r;
+  struct r_debug *r, *rp;
 
   if (ns == LM_ID_BASE)
     r = &_r_debug;
   else
-    r = &GL(dl_ns)[ns]._ns_debug;
+    {
+      r = &GL(dl_ns)[ns]._ns_debug;
+      rp = &GL(dl_ns)[ns - 1]._ns_debug;
+      rp->next = r;
+      if (ns - 1 == LM_ID_BASE)
+        _r_debug.next = r;
+    }
 
   if (r->r_map == NULL || ldbase != 0)
     {
       /* Tell the debugger where to find the map of loaded objects.  */
-      r->r_version = 1	/* R_DEBUG_VERSION XXX */;
+      r->r_version = 3  /* R_DEBUG_VERSION XXX */;
       r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
       r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
       r->r_brk = (ElfW(Addr)) &_dl_debug_state;
+      r->next = NULL;
     }
 
   return r;
diff --git a/elf/link.h b/elf/link.h
index 0048ad5d4d..5a42511636 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -61,6 +61,10 @@ struct r_debug
       } r_state;
 
     ElfW(Addr) r_ldbase;	/* Base address the linker is loaded at.  */
+
+    /* Link to next r_debug struct. Each r_debug struct represents a
+       different namespace.  The first r_debug struct is the default.  */
+    struct r_debug *next;
   };
 
 /* This is the instance of that structure used by the dynamic linker.  */
-- 
2.17.1


             reply	other threads:[~2020-06-26 19:32 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 19:32 Daniel Walker via Libc-alpha [this message]
2020-06-26 21:05 ` [RFC PATCH 3/3] add r_debug multiple namespaces support Florian Weimer via Libc-alpha
2020-06-26 21:19   ` Carlos O'Donell via Libc-alpha
2020-06-26 21:24     ` Florian Weimer via Libc-alpha
2020-06-26 21:44       ` Carlos O'Donell via Libc-alpha
2020-06-27  9:34         ` Florian Weimer
2020-06-28 12:34           ` Carlos O'Donell via Libc-alpha
2020-06-29  8:51             ` Florian Weimer via Libc-alpha
2021-07-23 23:38               ` H.J. Lu via Libc-alpha
2021-07-27 17:39                 ` Daniel Walker via Libc-alpha
2021-07-27 18:14                   ` H.J. Lu via Libc-alpha
2021-07-28 15:15                     ` H.J. Lu via Libc-alpha
2021-07-28 15:44                       ` Daniel Walker via Libc-alpha
2021-07-28 17:14                         ` H.J. Lu via Libc-alpha
2021-07-28 19:02                           ` Daniel Walker via Libc-alpha
2021-07-28 20:04                             ` H.J. Lu via Libc-alpha
2021-08-02  4:24                               ` RFC: Add DT_GNU_DEBUG H.J. Lu via Libc-alpha
2021-08-02  5:22                                 ` Florian Weimer via Libc-alpha
2021-08-02 13:10                                   ` H.J. Lu via Libc-alpha
2021-08-03 16:39                                     ` Daniel Walker via Libc-alpha
2021-08-03 18:08                                       ` H.J. Lu via Libc-alpha
2021-08-03 20:04                                         ` Daniel Walker via Libc-alpha
2021-08-03 18:12                                       ` Florian Weimer via Libc-alpha
2021-08-03 18:23                                         ` H.J. Lu via Libc-alpha
2021-08-03 20:13                                           ` Florian Weimer via Libc-alpha
2021-08-03 20:21                                             ` H.J. Lu via Libc-alpha
2021-08-09 14:32                                               ` RFC: 2 choices of DT_XXX for dlmopen H.J. Lu via Libc-alpha
2021-08-09 17:16                                                 ` Daniel Walker via Libc-alpha
2021-08-15  0:33                                                   ` [PATCH] Extend struct r_debug to support multiple namespaces H.J. Lu via Libc-alpha
2021-08-16 16:20                                                     ` Daniel Walker via Libc-alpha
2021-08-17  1:07                                                       ` H.J. Lu via Libc-alpha
2020-06-27  1:21       ` [RFC PATCH 3/3] add r_debug multiple namespaces support Daniel Walker (danielwa) via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200626193228.1953-4-danielwa@cisco.com \
    --to=libc-alpha@sourceware.org \
    --cc=conhuang@cisco.com \
    --cc=danielwa@cisco.com \
    --cc=jstengle@cisco.com \
    --cc=xe-linux-external@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).