From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by sourceware.org (Postfix) with ESMTPS id A57893858D20 for ; Thu, 3 Mar 2022 18:32:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A57893858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f41.google.com with SMTP id o18-20020a05600c4fd200b003826701f847so5258870wmq.4 for ; Thu, 03 Mar 2022 10:32:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=n0h5hUXI7RRAfyL+fqqK7H0MznmjA+iaxE9egNqZIdY=; b=6I/WZ0zRsrQQWULOzXKjUy4hKuruNp/5OnbFBAXiHi+evP9oKr6YW+TqWs2aoXu1Ml x0qMO0KcHvMQf0/015vb6tdCqMFzXfaBRBjKGVL7zwxZOvIyL+7tk4xgaRxVk/tC2dwh QSx9832rWnLhR8ZEWDrpIZzTW+APkNdZJksDM5wekhvyD/4EUhW4E98LiY8Qm9iDL2QJ hkLzB/ck0znO1nIsItosArwteMWh2mnZtWAbC1pCgG4bGD7UiF7sKuyz7PFO8/CTdols N7J+STIs7GKVsF2t/Se0cgAzFNqBvk1seN5mWJ1QTPXOvW42Rwn3aGOsa/WMMm7tzQS4 Pq2Q== X-Gm-Message-State: AOAM531jrr/3yTtaTiGQNe4VlwMuuqtTWdlUnx09PkshS3iUYpHmfuFk KLkQku1e9lzL5H2XrFEEITaJGVEpv4c= X-Google-Smtp-Source: ABdhPJxd2wCy+8xf+L92dTtVFNmIa96MRUenxYpcJLBEqYimijmUYupuzVH/5R0DVkC1jSD4KjCTWQ== X-Received: by 2002:a7b:c30e:0:b0:37f:a63d:3d1f with SMTP id k14-20020a7bc30e000000b0037fa63d3d1fmr4712174wmj.178.1646332345504; Thu, 03 Mar 2022 10:32:25 -0800 (PST) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id z16-20020a7bc7d0000000b00381004c643asm9138743wmk.30.2022.03.03.10.32.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Mar 2022 10:32:24 -0800 (PST) Message-ID: Date: Thu, 3 Mar 2022 18:32:23 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v4] gdb, gdbserver: support dlmopen() Content-Language: en-US To: Markus Metzger , gdb-patches@sourceware.org References: <20211117142812.3685162-1-markus.t.metzger@intel.com> From: Pedro Alves In-Reply-To: <20211117142812.3685162-1-markus.t.metzger@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2022 18:32:28 -0000 On 2021-11-17 14:28, Markus Metzger via Gdb-patches wrote: > This patch was originally developed by H.J. Last version: > https://sourceware.org/pipermail/gdb-patches/2021-October/182353.html > Should the commit have a Co-Authored-By: tag for H.J.? > Changes in v4: > > 1. add gdb.base/dlmopen.exp > 2. extend svr4_same() to compare the load offset in addition to the name > 3. supply l_addr_inferior for default DSO to make it work with #2 > 4. fix bugs in gdbserver/linux-low.cc > > Changes in v3: > > 1. Fix gdbserver support. > > Changes in v2: > > 1. Don't check shared libraries in other namespaces when updating shared > libraries in a new namespace. > > Regression-tested on x86-64 linux. > > --- > > In glibc, the r_debug structure contains (amongst others) the following > fields: > > int r_version: > Version number for this protocol. It should be greater than 0. > > If r_version is 2, struct r_debug is extended to struct r_debug_extended > with one additional field: > > struct r_debug_extended *r_next; > Link to the next r_debug_extended structure. Each r_debug_extended > structure represents a different namespace. The first r_debug_extended > structure is for the default namespace. > > 1. Change solib_svr4_r_map argument to take the debug base. > 2. Add solib_svr4_r_next to find the link map in the next namespace from > the r_next field. > 3. Update svr4_current_sos_direct to get the link map in the next namespace > from the r_next field. > 4. Don't check shared libraries in other namespaces when updating shared > libraries in a new namespace. > 5. Update svr4_same to check the load offset in addition to the name > 6. Update svr4_default_sos to also set l_addr_inferior > > Add gdb.base/dlmopen.exp to test this. I'm wondering whether ideally symbol lookup would be updated to handle different namespaces. I'm thinking of for example svr4_iterate_over_objfiles_in_search_order. Can you describe what xml changes were necessary? Do we need to update the manual where the xml/packet are described? > +++ b/gdb/testsuite/gdb.base/dlmopen.exp > @@ -0,0 +1,141 @@ > +# This testcase is part of GDB, the GNU debugger. > +# > +# Copyright 2021 Free Software Foundation, Inc. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + Please a short description of what is being tested, here. > +clean_restart $binfile > + > +# Start the test program. > +set test_spawn_id [spawn_wait_for_attach $binfile] > +set testpid [spawn_id_get_pid $test_spawn_id] > + > +# Attach. > +gdb_test "attach $testpid" "Attaching to program.*, process $testpid.*" Seems like a can_spawn_for_attach check is missing. > + > +with_test_prefix "attach" { > + # Remove the pause. We no longer need it. > + gdb_test "print pause = 0" "\\\$1 = 0" > + > + # Set the same breakpoints again. This time, however, we do not allow the > + # breakpoint to be pending since the library has already been loaded. > + gdb_breakpoint $srcfile_lib:$bp_inc > + gdb_breakpoint $srcfile:$bp_main > + > + test_dlmopen > +}