From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 56D6C388A41F; Wed, 18 Aug 2021 13:35:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 56D6C388A41F Received: by mail-pf1-x42d.google.com with SMTP id i21so2154401pfd.8; Wed, 18 Aug 2021 06:35:19 -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=mSYA2s9FBpJFhYZ+us3ePfcTesxDaXuqq+C0j/McQoU=; b=JuALfZdaqkt7WHHZ3ScXTBlfILWDS+skO0TiNH0xfOtgjWvEBrHhcDl6S+0dzOFymW uhN2O9Vdncb7NA2brWYokaMrAZSSArVhKrfzX41Vbu4852ZYIGHblU/CczwDV0vGKu86 xQuaWMSy52b8PEk+KzWJM0GtV8G5y/m205CtzbQq933Hs0xTK15Rpo3v0RgkVd06u7Sr 9bJijNkqd22YSwzIAsStLIQWSe9nFDNsZWVY62XeBVYC17ljsVc4pxoAy9KR9RGobk4/ tF8S8OIZm/fHfDLAXXP0YEHkDHNBeDDCmRHhJlP+9Bxfdnfl4WDwQu2wKL1zGJ6L8ECO 3BDQ== X-Gm-Message-State: AOAM532A6wAXYLLSS90Z/hWCSZS+Ov+ufe+XgMuhCkIx6NDLeNEjFQbO f+FlBgTnKY6zqOaSLGXgNkYjw05Wze4VBJLBv/g= X-Google-Smtp-Source: ABdhPJypz4IMKHAxrWJnV7mVZrl9Zh6P7xfLfEETU+cRk9K6/Pqf18ww6VU7wkwRX93V56SqZ/xmFMHNJS6bSjl/o1c= X-Received: by 2002:a62:7e41:0:b029:3e0:9c3f:ab50 with SMTP id z62-20020a627e410000b02903e09c3fab50mr9320234pfc.57.1629293718288; Wed, 18 Aug 2021 06:35:18 -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: Wed, 18 Aug 2021 06:34:42 -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=-3024.9 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 13:35:29 -0000 On Tue, Aug 17, 2021 at 7:36 PM H.J. Lu wrote: > > 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 > I updated glibc branch with minor improvements and fixed gdbserver on GDB branch. They work well together. -- H.J.