From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sp46Cqvz72r18jIAWB0awg (envelope-from ) for ; Sat, 07 Nov 2026 22:59:39 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ugja6NEA; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 154F3378002; Sat, 07 Nov 2026 22:59:39 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 654671E043 for ; Sat, 07 Nov 2026 22:59:37 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 948C04BA23DD for ; Sun, 8 Nov 2026 03:59:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 948C04BA23DD Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ugja6NEA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 63CA64BA2E2E for ; Sun, 8 Nov 2026 03:59:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63CA64BA2E2E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 63CA64BA2E2E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794110343; cv=none; b=lu3/ePNzziS3XZ0p3bMczmHfvh8rR/xyyzYvPR7RI2GM5fv03025yBCsLimOhLWQLbbnoiM9z9BOlM1CEsqHCVBdW0uuVE24Wg1HIfy40dSpao1T2+3lOVtf6qhlfrTElLC4wMqKRXqXJhVT5KZDoYXijuEmxNEuO8nfC8QrIDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794110343; c=relaxed/simple; bh=PXJeOCDcvfDLIxm97Zct19AVZysc8JAkM28cWzbXPm8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=rWsx1vjchfnOYaOFO+K9upC/QTAEG+k/ivEaCagwh/FHRUcHyh9WZok0MSEj4pL5ARCeoUIGBFBNJ83bN+fudxhn6Rf1kn2BcPwp3eJpEk6r5oHhDP34Wy96USmaCXo9gkz6qItxokMBdAdmuQX09eDNvABzg979Qp+zyk/0O7w= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ugja6NEA DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63CA64BA2E2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794110343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aAq5x8FmpUKuU1zoNiIJg66DowXxGrjI7Fgb5tty3vg=; b=Ugja6NEA55ZHTTVY9qBOZ0MmzcplCP3uvd4KknBdz2HaH+TV/X7HErgrbzpWMe5quICo+L 8FPoylzv03m7XuleJgM0YrcOOaY12vuFWQuOlfJEhA+Uk9xorB870WSdE5icHE8oX3uOLs 1VAVs3j1DiHe53yKx41alCrd2ak3GCA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-0mcSN-l5Mcq7DrWExJZ6ZQ-1; Sat, 07 Nov 2026 22:59:01 -0500 X-MC-Unique: 0mcSN-l5Mcq7DrWExJZ6ZQ-1 X-Mimecast-MFC-AGG-ID: 0mcSN-l5Mcq7DrWExJZ6ZQ_1794110340 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A5D891956041 for ; Sun, 8 Nov 2026 03:59:00 +0000 (UTC) Received: from [100.90.172.125] (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 605A330000E3; Sun, 8 Nov 2026 03:58:59 +0000 (UTC) Message-ID: <4f1aeae3-fd3a-43ff-b419-ffec1965786d@redhat.com> Date: Sat, 7 Nov 2026 20:58:57 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 0/5] Introduce syntax for linker-namespace specific symbols To: Guinevere Larsen , gdb-patches@sourceware.org References: <20260601192251.60958-1-guinevere@redhat.com> From: Kevin Buettner In-Reply-To: <20260601192251.60958-1-guinevere@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JpxK28qnYmgV9k5O-e75yNtN2G1AmzKYiKpnPrje930_1794110340 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 6/1/26 12:22 PM, Guinevere Larsen wrote: > This series adds support for the syntax [[N]]::foo to find symbols that > belong to specific namespaces, while also making GDB's behavior more > consistent when a namespace is not specified. This needs 2 preparatory > patches and 2 patches actually implementing this feature, and one final > patch to make symtab searching more consistent with the [[N]]::foo > syntax. > > Patch 1 is a small refactor, creating a function to figure out the > current linker namespace. Patch 2 is an essential fix, updating how we > calculate a variable's copy relocation to take linker namespaces into > account. > > Patches 3 and 4 implement the new syntax, adding the necessary > supporting code and updating error messages when symbols can't be found > - where it made sense. Patch 5 is a small change to the find_symtab > function, to prefer symtabs from the current linker namespace. First, I'm sure that it'll come as no surprise that this series needs a rebase now. I had my AI code reviewers look at it - they were able to sort out the rebase and do a review anyway. The major finding is that the ]] token is a problem. I asked the AI to demo this for me in a terminal. Here is its example: ai-user@ai-sandbox:~$ mkdir -p ~/demo-dblbracket && cd ~/demo-dblbracket && cat > demo.c <<'EOF'> int a[3] = {10, 20, 30}; > int b[2] = {1, 2}; > int main (void) { return a[b[0]]; } > EOFai-user@ai-sandbox:demo-dblbracket$ gcc -g -O0 demo.c -o demo && ls -la demo -rwxr-xr-x 1 ai-user ai-user 13496 Nov 7 19:16 demo ai-user@ai-sandbox:demo-dblbracket$ ~/builds/binutils-gdb-patch-review-basel ine-install/bin/gdb -q ./demo Reading symbols from ./demo... (gdb) break main Breakpoint 1 at 0x40044a: file demo.c, line 3. (gdb) run Starting program: /home/ai-user/demo-dblbracket/demo [ debuginfod stuff snipped ] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Breakpoint 1, main () at demo.c:3 3 int main (void) { return a[b[0]]; } (gdb) print b[0] $1 = 1 (gdb) print a[b[0]] $2 = 20 (gdb) print a[b[1]] * 2 $3 = 60 (gdb) quit A debugging session is active. Inferior 1 [process 2232454] will be killed. Quit anyway? (y or n) y ai-user@ai-sandbox:demo-dblbracket$ ~/builds/binutils-gdb-patch-review-insta ll/bin/gdb -q ./demo Reading symbols from ./demo... (gdb) set debuginfod enabled off (gdb) break main Breakpoint 1 at 0x40044a: file demo.c, line 3. (gdb) run Starting program: /home/ai-user/demo-dblbracket/demo [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Breakpoint 1, main () at demo.c:3 3 int main (void) { return a[b[0]]; } (gdb) print a[b[0]] ❌️ A syntax error in expression, near `]]'. (gdb) print a[0] $1 = 10 (gdb) print [[0]]::b $2 = {1, 2} (gdb) quit A debugging session is active. Inferior 1 [process 2234693] will be killed. Quit anyway? (y or n) y GLM 5.3 Flash (whose suggestion was endorsed by Opus 5.5) made this recommendation: While reviewing the v7 series ("Introduce syntax for linker-namespace specific symbols") we found one problem worth fixing before the next round: patch 3/5 adds standalone double-square tokens for "[[" and "]]" in tokentab2, matched unconditionally by the lexer. Those two-character sequences are legitimate text in existing languages, so this breaks: * C nested subscripts: print a[b[0]] The trailing "]]" is consumed as one token, giving a syntax error. Without the series the same expression parses. * Objective-C nested message sends: print [[obj alloc] init] The leading "[[" is consumed as the namespace-open token, and the parse fails immediately. Both are confirmed by running the same expressions with and without the series applied, and neither case is covered by any existing test. Recommended fix: do not add standalone "[[" and "]]" tokens. Instead, have the lexer recognize only the complete namespace construct as a single token: * On seeing "[[", peek ahead. Emit the namespace token only when the input matches [[]] (whitespace already allowed by the grammar may be skipped within the match), carrying the integer as the token's value. * Otherwise, fall back to lexing "[" normally. In particular, no "]]" token is needed at all, which leaves "]]" free for array subscripts and Objective-C. The parser rule then consumes that one token and uses its numeric value. Since the grammar already restricts N to an integer, the integer check simply moves into the lexer. One error path needs care: "[[foo]]" should still produce a namespace-related diagnostic rather than a generic syntax error. Please also add tests for both cases above in v8; nothing in the current testsuite would have caught this. Additionally, Opus 5.5 also posited a scenario regarding non-stop mode. This is GLM 5.3's write-up: Another finding from the v7 review (5/5 and 3/5): new code paths can now throw from get_selected_frame. 1/5 adds get_current_linker_namespace (), which calls get_frame_pc (get_selected_frame ()). That is fine for the $_linker_namespace convenience variable, which already needed a selected frame. But 5/5's find_symtab calls it for every lookup_symtab / for_each_symtab call while more than one namespace is active, and those run from code that never needed a selected frame before: * linespec: break file.c:NN, and automatic breakpoint re-set * list * MI -symbol-list-lines and -data-disassemble * the ada, m2 and pascal parsers 3/5 also calls it from the name_not_typename minimal-symbol fallback. Scenario: in non-stop or background mode, with the selected thread running and dlmopen namespaces active, "break lib.c:30" now fails with "Selected thread is running." instead of working. Breakpoint re-set also runs at events where the user cannot control which thread is selected, so the failure can appear long after the original command. Suggested fix: get_current_linker_namespace () should return 0 (meaning "unknown" / do not restrict the search) when !has_stack_frames () or the selected thread is running, and that behaviour should be documented in solib.h. This one is confirmed by code reading only so far; the reproducer above has not been run against a rebased series. Kevin