From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 8ACA03885C14; Wed, 18 Aug 2021 02:37:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8ACA03885C14 Received: by mail-pg1-x52a.google.com with SMTP id n18so708882pgm.12; Tue, 17 Aug 2021 19:37:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MshyRhPIAuxMl2tI6TydVVqqd2qVng1CpyNI5w2+tHg=; b=WTHGrETa/xA06GUumBOzXzHCxR6fKE8k0EzTc+9wwyHPqbGLW08Le9qVhhqCWub3cL aeXCktJpTJZMbLa/qQ/DIp9Vy+FS6peFb8zmrzld/w8SThQSZcpnwGKTCqLYUZuBHEgg ZWrdRMXNsy54X4EojWcXgTDVw6xHrvssgX9/BYLWVHFRVprnFTqkTzF78nq+hX+Yqtug zjIs9IrEp95NizUSVOCMJPaResrgzTzMN+Ob7y4foTFgvD1u8LqeciDi37TijHC6kZVO diLV0EkAqMlHBZmuprkCAptFw7hj0whdrEtJ8khuP+NrJuUkP/Mg+MA0b18Bpks4TXDg 7bPg== X-Gm-Message-State: AOAM531rvgY1OBDNjqofv6HHbtrWRnLgJ6j30LAt1gR0IvmOGR4sYfSU 5BqSXAwpUshh3H9KvUstnsz7YbEOQI41vzkcUwY= X-Google-Smtp-Source: ABdhPJzNjwWzF381zfd5P6aXWl6CRr0E1R0RMEy6FNItvQY1aRaXBS9U7ONYPkW9WUADfLKpbmlQ4pZdnmbyi5vMtUc= X-Received: by 2002:a63:83c1:: with SMTP id h184mr6636666pge.37.1629254245713; Tue, 17 Aug 2021 19:37:25 -0700 (PDT) MIME-Version: 1.0 References: <20210817010629.593479-1-hjl.tools@gmail.com> <20210817010629.593479-3-hjl.tools@gmail.com> <20210817175733.GI1633923@zorba> In-Reply-To: From: "H.J. Lu" Date: Tue, 17 Aug 2021 19:36:49 -0700 Message-ID: Subject: Re: [PATCH v2 2/2] Extend struct r_debug to support multiple namespaces To: Daniel Walker Cc: GNU C Library , GDB Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3025.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 02:37:37 -0000 On Tue, Aug 17, 2021 at 5:21 PM H.J. Lu wrote: > > On Tue, Aug 17, 2021 at 1:26 PM H.J. Lu wrote: > > > > On Tue, Aug 17, 2021 at 10:57 AM Daniel Walker wrote: > > > > > > On Mon, Aug 16, 2021 at 06:06:29PM -0700, H.J. Lu wrote: > > > > 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). > > > > > > > > Based on the patch from Conan C Huang : > > > > > > > > https://sourceware.org/pipermail/libc-alpha/2020-June/115448.html > > > > > > > > 1. Bump r_version to 2. This triggers the GDB bug: > > > > > > > > https://sourceware.org/bugzilla/show_bug.cgi?id=28236 > > > > > > > > 2. Add struct r_debug_extended to extend struct r_debug into a linked-list, > > > > where each element correlates to an unique namespace. > > > > 3. Add a hidden symbol, _r_debug_extended, for struct r_debug_extended. > > > > 4. Provide the compatibility symbol, _r_debug, with size of struct r_debug, > > > > as an alise of _r_debug_extended, for programs which reference _r_debug. > > > > > > > > > I've attached the GDB patch which was created at Cisco to support our version of > > > this type of feature which is similar to what you've created. You might be able > > > to make some small modifications to make it work for you. > > > > > > Daniel > > > > > > It seems to work pretty well with some cleanup: > > https://gitlab.com/x86-binutils/binutils-gdb/-/commit/ea336450f484fc8c0aa512a60bc99f69309a46d8 > > (gdb) set stop-on-solib-events 1 > (gdb) r --direct > Starting program: > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/tst-dlmopen4 > --direct > Stopped due to shared library event (no libraries added or removed) > (gdb) c > Continuing. > warning: Unable to find libthread_db matching inferior's thread > library, thread debugging will not be available. > Stopped due to shared library event: > Inferior loaded > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc.so.6 > (gdb) > Continuing. > Stopped due to shared library event (no libraries added or removed) > (gdb) > Continuing. > warning: .dynamic section for > "/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/ld-linux-x86-64.so.2" > is not at the expected address (wrong library or version mismatch?) > warning: Unable to find libthread_db matching inferior's thread > library, thread debugging will not be available. > Stopped due to shared library event: > Inferior loaded > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/tst-dlmopen1mod.so > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc.so.6 > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/ld-linux-x86-64.so.2 > (gdb) > Continuing. > Stopped due to shared library event (no libraries added or removed) > (gdb) > Continuing. > Stopped due to shared library event: > Inferior unloaded > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/tst-dlmopen1mod.so > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc.so.6 > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/ld-linux-x86-64.so.2 > (gdb) > Continuing. > [Inferior 1 (process 638559) exited normally] > (gdb) > > (gdb) r --direct > Starting program: > /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/tst-dlmopen4 > --direct > warning: Unable to find libthread_db matching inferior's thread > library, thread debugging will not be available. > warning: .dynamic section for > "/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/ld-linux-x86-64.so.2" > is not at the expected address (wrong library or version mismatch?) > warning: Unable to find libthread_db matching inferior's thread > library, thread debugging will not be available. > [Inferior 1 (process 638480) exited normally] > (gdb) > > It looks like l_ld of ld.so in the new namespace isn't set properly: > > (gdb) p debug->r_next->r_map > $5 = (struct link_map *) 0x408360 > (gdb) p *debug->r_next->r_map > $6 = {l_addr = 140737351757824, > l_name = 0x4082f0 > "/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/tst-dlmopen1mod.so", > l_ld = 0x7ffff7dbee10, l_next = 0x408900, > l_prev = 0x0} > (gdb) p *debug->r_next->r_map->l_next > $7 = {l_addr = 140737349664768, > l_name = 0x4088a0 > "/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc.so.6", > l_ld = 0x7ffff7daabc0, l_next = 0x408e90, l_prev = 0x408360} > (gdb) p *debug->r_next->r_map->l_next->l_next > $8 = {l_addr = 0, > l_name = 0x408e20 > "/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/ld-linux-x86-64.so.2", > l_ld = 0x0, l_next = 0x0, l_prev = 0x408900} > (gdb) > > Please try glibc users/hjl/pr15971/r_version branch: https://gitlab.com/x86-glibc/glibc/-/tree/users/hjl/pr15971/r_version and GDB users/hjl/pr11839/master branch: https://gitlab.com/x86-binutils/binutils-gdb/-/tree/users/hjl/pr11839/master -- H.J.