From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Oa0PGi2lHGmiDRAAWB0awg (envelope-from ) for ; Tue, 18 Nov 2025 11:56:13 -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=i6uGrC0Q; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 66A6B1E0B6; Tue, 18 Nov 2025 11:56:13 -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.4 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_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 C7CFC1E048 for ; Tue, 18 Nov 2025 11:56:11 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D94E385737F for ; Tue, 18 Nov 2025 16:56:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D94E385737F 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=i6uGrC0Q 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 9481C3858C74 for ; Tue, 18 Nov 2025 16:55:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9481C3858C74 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 9481C3858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763484935; cv=none; b=A4KD+k2fkvm9uJcWTADf436zaiijnP7g3yufboYp+PD5t5E112AjxxaHAbn7W8uECk4GdkXn1bXEWOhinTDSgse3OEZozPxQ7t9LIJteddzPpJwYG+uegQPrq4lVuWTAsTtmgZOKAoixQsebZUdwcVm/YXQ0PW96SWGlpc/lkPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763484935; c=relaxed/simple; bh=L6ieIFLJhvKr2j2Yh/ky/DV1jghHG0rnwSdCUGTWh1Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Zpic8j1Xw7JAWT2FNCyLkXvxs4R4UOTPLDwFhUNSUZCcPN9nPcyYTpjvp2C0MNpnJtvUITF39F3KRSxPUkKL78WIQLIROXkCfIxdrePJcLb6Ksly5ZrWZsS7Ib0Qju/XB3oDmoHdT0s7LHabYa2G7avXkIOgDW7nKX8ElezbDho= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9481C3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763484935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K44gcSOJoMCMpaN2Z2wlZ6qvS4Xi75zqVjSLGjdbfUc=; b=i6uGrC0Q95mi97hi68pcjEpeSe1BBUFzMGT8fnyt9uPt/6cV6V5QjJsqi0N86R29jmpkjM 4Uz0/+y9SE+mALD3HVTDemJAovpLuVfS1cMIqLXXJPaPr16w5a715N5bJLknG7JLKX4be1 o0chZ6rSfM+F2LreGBglhJj90l6YaWo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-sWYlmkI_NqOhNRlg3HgNkw-1; Tue, 18 Nov 2025 11:55:34 -0500 X-MC-Unique: sWYlmkI_NqOhNRlg3HgNkw-1 X-Mimecast-MFC-AGG-ID: sWYlmkI_NqOhNRlg3HgNkw_1763484933 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4775d110fabso44709205e9.1 for ; Tue, 18 Nov 2025 08:55:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763484932; x=1764089732; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K44gcSOJoMCMpaN2Z2wlZ6qvS4Xi75zqVjSLGjdbfUc=; b=WgrfXMoJziW+uT72E3bTLTgKqT2MbqajceNZGy/16PCU2rhWxHhoPKszeAJgPUUYZq eE9T31souz6mIpIKi3O53GSS+5FWpWwPgBuM/uQUqQqwBuMLu3wIf+uQal82PzjxrRNl Rl0wNTzbXesJky/YP58RCzWC0qWBYHUoSOwfDbGtldDTF5eQ9YcJbXxUCsnfe7WQVii/ v390C7EiB0qHLi5/wOERYhprGeFUnnZNbQAIvN8bM4CtjMFg/Bfl0L2r1bShXeuVJ+Bc rczHh0o/stlSzI5vsicULroybBcmJ3dIPp8Fo+St25BFBF+jFzZHUuVmu9rv5z50F19X AsCg== X-Forwarded-Encrypted: i=1; AJvYcCWFL3jX5uSyq1ZNPDeKIFGY9KhAi4wseSTVdRQnzF6R0NBs6KWanDqNil8YQlet1Uyv7KWnRwVdewYkpA==@sourceware.org X-Gm-Message-State: AOJu0YzoRgFsyHZQIsmdTLC4xFuCzwBwgFocMzVPFvsii4/h5oARxnzm hWJcXxw4WdRN5wXPtPdOq67ZXGDaikwPS5P993m2TtB9I9II5mvlcEWCSPNJr60YqgNHOfvWaBz uUwh+G6Qh0wLRKBcSHYMQRQlGIIghpqp9glkjs0FogOy/n3a4OAtCgufk9UHQPQHw7m1Iy6Y= X-Gm-Gg: ASbGncvpiTrO2SmT3CsUviWNRVQizKdLsz83/VgWTemHullgUL3p3VbfIHde+u39z/y JCmlihQihz6cixX4lizqxQR9Ga6xnNATfKXJCsOzO/bDqqZH3MEvAbC6nQ6A1lKuCvoY6UmbfRP M/QYcNR83v50/Cmk+s+jl3QZ7neIxvzfDGoBBS1aG/wqSlt94kGv9AvBxWLHA9XkZoZZADDTXIy nG0G0VU11rtNn5Ep5xCM7S2wNzrHzBI4ADpCcmZxUf5FPmi95CxN8Ia/dY3R5tDtP1fJHQAyxEE 16YwIn50lS5Jc3YO+IIkL7ILltLWHa9iER6HvY/bYwyF1GUzN9y2s+56Y8LSPtqzTCARPQb4qM7 qgu7r X-Received: by 2002:a05:600c:3b94:b0:476:84e9:b571 with SMTP id 5b1f17b1804b1-4778fe49cc8mr162761745e9.14.1763484932334; Tue, 18 Nov 2025 08:55:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFxmcGIyKJ87OGhfDTzbNp/BVF09JSxTGNC/uC3TVloNkb7UmPDidBYXnVuzZcMR5n4jXgtw== X-Received: by 2002:a05:600c:3b94:b0:476:84e9:b571 with SMTP id 5b1f17b1804b1-4778fe49cc8mr162761555e9.14.1763484931831; Tue, 18 Nov 2025 08:55:31 -0800 (PST) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477a9dea7fcsm20904655e9.8.2025.11.18.08.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 08:55:31 -0800 (PST) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 1/6] gdb/testsuite/dwarf: use single abbrev table in .dwo files In-Reply-To: <20251107211041.520697-2-simon.marchi@efficios.com> References: <20251107211041.520697-1-simon.marchi@efficios.com> <20251107211041.520697-2-simon.marchi@efficios.com> Date: Tue, 18 Nov 2025 16:55:30 +0000 Message-ID: <87zf8jth4t.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WLVZzUWyULR1LSc4-ct6AnA8Grsv-a9I6GCxXS0nbAE_1763484933 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Simon Marchi writes: > From: Simon Marchi > > When I wrote test gdb.dwarf2/fission-with-type-unit.exp, I did not use > build_executable_and_dwo_files, because it wouldn't work to have > multiple units in the .dwo file, each referring to their own abbrev > table using labels. build_executable_and_dwo_files extracts the .dwo > file content from the .o using objcopy (just like gcc does, I learned), > meaning that the .dwo file never runs through a linker. Anything > needing relocation (like labels pointing to abbrev tables) doesn't work. > > I instead opted to use gdb_compile_shlib to build the .dwo file on its > own, so that those labels would get resolved. That causes problems now > that I'm trying to write a test with multiple type units in a .dwo file, > where each type unit should be in its own .debug_types section. Running > the .dwo file through the linker causes all the .debug_types section to > be collapsed into one. And generally, I think it was a bad idea to > generate a .dwo file using the linker, since the idea behind .dwo files > is that they do not need to be linked (therefore improving link > times). We want to produce files as close to what an actual compiler > would produce. > > This patch fixes this by doing what compilers do in the same situation: > use a single abbrev table shared by all units in the .dwo file. This > requires the following changes in lib/dwarf.exp: > > - Declare a new variable _dwo_abbrev_num, which holds the next > abbrev number to use in the .dwo file's abbrev section > (.debug_abbrev.dwo). Initialize this variable to 1. > - When producing a CU or TU in a .dwo file, use 0 as the abbrev table > offset. > - When generating a DIE, return $_dwo_abbrev_num or $_abbrev_num, > depending on whether the current CU is in a .dwo file. > - After producing a CU or TU in a .dwo file, don't append the > terminator byte. > - After finishing producing the CUs and TUs, append the terminator byte > in .debug_abbrev.dwo if we did output anything there. > > Update gdb.dwarf2/fission-with-type-units.exp to use > build_executable_and_dwo_files, as it should. > > Change-Id: Iabbcf00db97faf2a4fa5fc71652ad273081189f9 > --- > .../gdb.dwarf2/fission-with-type-unit.exp | 29 +++----- > gdb/testsuite/lib/dwarf.exp | 69 +++++++++++++++---- > 2 files changed, 67 insertions(+), 31 deletions(-) > > diff --git a/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp b/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp > index 58cda296c67b..5c73001ec66b 100644 > --- a/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp > +++ b/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp > @@ -21,25 +21,22 @@ load_lib dwarf.exp > # This test can only be run on targets which support DWARF-2 and use gas. > require dwarf2_support > > -standard_testfile .c -dw.S -dwo.S > +standard_testfile .c -dw.S > > -set main_asm_file [standard_output_file $srcfile2] > -set dwo_asm_file [standard_output_file $srcfile3] > +set asm_file [standard_output_file $srcfile2] > > -# Debug info in the main file. > -Dwarf::assemble $main_asm_file { > +Dwarf::assemble $asm_file { > + # In the main file. > cu { > version 5 > dwo_id 0xF00D > } { > compile_unit { > - DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp > + DW_AT_dwo_name ${::gdb_test_file_name}-dw.dwo DW_FORM_strp > } {} > } > -} > > -# Debug info in the DWO file. > -Dwarf::assemble $dwo_asm_file { > + # In the .dwo file. > tu { > fission 1 > version 5 > @@ -79,15 +76,11 @@ Dwarf::assemble $dwo_asm_file { > } > } > > -# Build main file. > -if { [build_executable "${testfile}.exp" $binfile \ > - [list ${srcfile} ${main_asm_file}] {nodebug}] } { > - return > -} > - > -# Build DWO file. > -set dwo_file [standard_output_file ${testfile}.dwo] > -if { [gdb_compile_shlib $dwo_asm_file $dwo_file nodebug] != "" } { > +set obj [standard_output_file "${testfile}-dw.o"] > +set dwo_file [standard_output_file "${testfile}.dwo"] The name of the dwo file here is now wrong. The auto generated name will be '${testfile}-dw.dwo', which is what you embed in the DWARF above. I was wondering why this wasn't causing problems for the later block in this file (not touched in this patch): if { [is_remote host] } { gdb_remote_download host $dwo_file } But it turns out that ... > +if {[build_executable_and_dwo_files "$testfile.exp" "${binfile}" {} \ ... build_executable_and_dwo_files includes this check: # Must be run on local host due to use of objcopy. if {[is_remote host]} { return -1 } So this test never gets past this point for remote host boards. I think you should: 1. Remove the 'set dwo_file ...' line. 2. Remove the 'gdb_remote_download host $dwo_file' line, and its containing 'if' block. 3. Add a 'require {!is_remote host}' line at the start of the file. Otherwise, this change looks good to me (along with the additional text you posted in the follow up, which I also replied to). Approved-By: Andrew Burgess Thanks, Andrew > + [list $asm_file {nodebug split-dwo} $obj] \ > + [list $srcfile {nodebug}]]} { > return > } > > diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp > index ba8197d0bb8e..919e2e05687f 100644 > --- a/gdb/testsuite/lib/dwarf.exp > +++ b/gdb/testsuite/lib/dwarf.exp > @@ -563,6 +563,9 @@ namespace eval Dwarf { > # table. > variable _abbrev_num > > + # The next available abbrev number in the (single) DWO abbrev table. > + variable _dwo_abbrev_num > + > # The string table for this assembly. The key is the string; the > # value is the label for that string. > variable _strings > @@ -1008,8 +1011,17 @@ namespace eval Dwarf { > # table. > proc _get_abbrev_num {} { > variable _abbrev_num > - set res $_abbrev_num > - incr _abbrev_num > + variable _dwo_abbrev_num > + variable _cu_is_fission > + > + if { $_cu_is_fission } { > + set res $_dwo_abbrev_num > + incr _dwo_abbrev_num > + } else { > + set res $_abbrev_num > + incr _abbrev_num > + } > + > return $res > } > > @@ -1538,8 +1550,17 @@ namespace eval Dwarf { > _section $section > > set cu_num [incr _cu_count] > - set my_abbrevs [_compute_label "abbrev${cu_num}_begin"] > - set _abbrev_num 1 > + > + # Since .dwo files are not linked, we can't use a label to point to a > + # specific place in the .debug_abbrev section. For .dwo files, we > + # therefore use a single abbrev table (at offset 0) shared by all units > + # in that file. > + if { $_cu_is_fission } { > + set my_abbrevs 0 > + } else { > + set my_abbrevs [_compute_label "abbrev${cu_num}_begin"] > + set _abbrev_num 1 > + } > > set _cu_label [_compute_label "cu${cu_num}_begin"] > set start_label [_compute_label "cu${cu_num}_start"] > @@ -1606,9 +1627,11 @@ namespace eval Dwarf { > > uplevel $_level $body > > - _defer_output $_abbrev_section { > - # Emit the terminator. > - _op .byte 0x0 "Abbrev end - Terminator" > + if { !$_cu_is_fission } { > + _defer_output $_abbrev_section { > + # Emit the terminator. > + _op .byte 0x0 "Abbrev end - Terminator" > + } > } > > define_label $end_label > @@ -1681,8 +1704,17 @@ namespace eval Dwarf { > _section $section > > set cu_num [incr _cu_count] > - set my_abbrevs [_compute_label "abbrev${cu_num}_begin"] > - set _abbrev_num 1 > + > + # Since .dwo files are not linked, we can't use a label to point to a > + # specific place in the .debug_abbrev section. For .dwo files, we > + # therefore use a single abbrev table (at offset 0) shared by all units > + # in that file. > + if { $_cu_is_fission } { > + set my_abbrevs 0 > + } else { > + set my_abbrevs [_compute_label "abbrev${cu_num}_begin"] > + set _abbrev_num 1 > + } > > set _cu_label [_compute_label "cu${cu_num}_begin"] > set start_label [_compute_label "cu${cu_num}_start"] > @@ -1736,9 +1768,11 @@ namespace eval Dwarf { > > uplevel $_level $body > > - _defer_output $_abbrev_section { > - # Emit the terminator. > - _op .byte 0x0 "Abbrev end - Terminator" > + if { !$_cu_is_fission } { > + _defer_output $_abbrev_section { > + # Emit the terminator. > + _op .byte 0x0 "Abbrev end - Terminator" > + } > } > > define_label $end_label > @@ -3507,6 +3541,7 @@ namespace eval Dwarf { > variable _debug_ranges_64_bit > variable _debug_addr_index > variable _level > + variable _dwo_abbrev_num > > if { [llength $options] == 1 } { > set options [list filename [lindex $options 0]] > @@ -3539,8 +3574,8 @@ namespace eval Dwarf { > > set _line_count 0 > set _debug_ranges_64_bit [is_64_target] > - > set _debug_addr_index 0 > + set _dwo_abbrev_num 1 > > # Dummy CU at the start to ensure that the first CU in $body is not > # the first in .debug_info. > @@ -3562,6 +3597,14 @@ namespace eval Dwarf { > dummy_cu > } > > + # If we wrote any abbrev in .debug_abbrev.dwo, write the terminator. > + if { $_dwo_abbrev_num > 1 } { > + _defer_output .debug_abbrev.dwo { > + # Emit the terminator. > + _op .byte 0x0 "Abbrev end - Terminator" > + } > + } > + > _write_deferred_output > > _section .note.GNU-stack "" progbits > -- > 2.51.2