From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AI5FA7SKKWrV6D8AWB0awg (envelope-from ) for ; Wed, 10 Jun 2026 12:03:00 -0400 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=YKgFPbBT; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E8A151E070; Wed, 10 Jun 2026 12:02:59 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 21F591E070 for ; Wed, 10 Jun 2026 12:02:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F5D24C31851 for ; Wed, 10 Jun 2026 16:02:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F5D24C31851 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=YKgFPbBT Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 2B4064BA543C for ; Wed, 10 Jun 2026 16:01:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B4064BA543C 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 2B4064BA543C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781107309; cv=none; b=ERPeEYPuMHR4qPs4OSBkiS6BqL+Bhcads77ra2llrHOnfMr1maQcxuYDj53EbGwJECRvyPZMCWttph8TKdaKk2fY0Rrtimq/q4qaQm4BcMmslkdgUee1E0gh7FyuEewv9A0LoTNCRQhNxbOp3snSYEhrMzYN5QXpfFQ8WPui8e4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781107309; c=relaxed/simple; bh=qo3qJcOYFI0Ux8p213+jKJKzdVK8Mdk2MhKkp8YW70k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kCpa2MhRUJHK0cGPlYzNGGCP9+iv6VjVXq8zFCYqizNfVNZaAevP+AeyWvNiMBi63z3vIVOu7RoC6RUL8Pne3venQBk+KW0GUUXmIkt3jV8F5I8p6GKJPljAi8QwgcmeYqb6tupaeGGrs7Ygw2F8F0/tACpaoE8+AKwSRGQXNuE= 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=YKgFPbBT DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B4064BA543C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781107308; 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=1H3yezgkhMILmco4OYrKe7M+CGQ3CdO/aHZPFkdKKW0=; b=YKgFPbBTpoUD88rVHpin4qjvTaCWon4+BZzCTRvw1ND9SXwGmpavhgkcPrIVKkKRV8H3iG IIyJhtjZV1oe+vaFWVfbtGtjvHOSOUw9iez3Ag2123eGnJNtWmnD/hJ+E0Tl75B1V3XrKr HAc+gVbRTz4Jo63l2LGpe7FpcBxUzVo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-5hP6BidVNRWw_cHfnnPVuA-1; Wed, 10 Jun 2026 12:01:46 -0400 X-MC-Unique: 5hP6BidVNRWw_cHfnnPVuA-1 X-Mimecast-MFC-AGG-ID: 5hP6BidVNRWw_cHfnnPVuA_1781107305 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-45efa7755faso2735408f8f.1 for ; Wed, 10 Jun 2026 09:01:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781107305; x=1781712105; 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=1H3yezgkhMILmco4OYrKe7M+CGQ3CdO/aHZPFkdKKW0=; b=ONGW80slvHQeVGl01RPDn8od3R4liYrQsTkH11beFHEgrMDcjwihRrEPb1TTf1LqTs JqJDHSgZhjDrs+XLhYKhgtbURABRJjMUbnGAE7ZS6kiX9HRHzLzCyb3A8CFmz6XQ4RP9 kb9V+UVgmN+LH6MJYuYDjzVOHGawkGZVKr/sWm2MdSAKJ6lv5yPo/h9y09Z8K25DoWHf 6ZblpAiP+N00GfecwwjkMglVvfiVQKml/1TZHrBtwRKoZSI6pIkuWIVsohE0RomB1yTO ffCazVta/JUKFo+Chhl0Vw38okrRo8+mJMNqzQOK2v9umozFBI2Xzp8cSyj8gubgsWtn r9ew== X-Forwarded-Encrypted: i=1; AFNElJ8baKIpAfQKVHkBf/raiOBdi98ib9ailg6DBpoA2kwLJt9h/5L4okA4g41jR2SSowjVzuds6XWEBsVXmw==@sourceware.org X-Gm-Message-State: AOJu0YzDe19JNjaQ4LNJug9zDVaJg2JhcbWS1xu6ZA1R8EVNzXr+HMw/ w+olopMPGVNaR8CiB42gjVRlqsWs2GTlUA90DVRwHt6bIeg66zp+RXTQhyY59+YNrJsUQap3N1e yi/K0OciNVzrPEn+1j4v66VswORHR3ilq+N5QRkP6JPk9SV4ecJpo1S6FK5U4DRRV0lNT2eI= X-Gm-Gg: Acq92OHvgRihRLW3eEM/vAm3xqIv9naja23Taef/5zGByLISE+KBMsAGV2dFd/fe4Lv cQvj6VDctQYhv3Jl9pEJ0chf9eEGGoVViXZ2Dw1+VcHCRN3osKey01wXOczlsN4Vs6wv5Xkg8ii U5hnR8mxTh0fCRJ5bHotgyrgNKyW3vVyo4hp+rBWMIpNg7gcOkwyE1abCAS9eNS/o+GLqHL+Okb xWmWueOUQDAzbzNfcgJJBWCPxuLBWo74Br3z573SSqHP7CL9l64nuwNXAif8J9eShsu4/LZD1aw 1Poawb5TS70DOc0yCl5U6g2HcL/65n+sJpAoRkhxteJOaqE24GfUj2BVNVlPCQJN8Fy5kdasinl gtnz7Ig479dS1rkOoZNUT9Z5m28ptTryJjoPTtBwcBhQm7yOwYrs= X-Received: by 2002:a05:600c:628c:b0:48f:e26a:1744 with SMTP id 5b1f17b1804b1-490c25a87f5mr418627975e9.9.1781107305042; Wed, 10 Jun 2026 09:01:45 -0700 (PDT) X-Received: by 2002:a05:600c:628c:b0:48f:e26a:1744 with SMTP id 5b1f17b1804b1-490c25a87f5mr418627055e9.9.1781107304463; Wed, 10 Jun 2026 09:01:44 -0700 (PDT) Received: from localhost (19.81.93.209.dyn.plus.net. [209.93.81.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2f5612sm71004740f8f.15.2026.06.10.09.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 09:01:43 -0700 (PDT) From: Andrew Burgess To: Tom Tromey , gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH] Sort symtabs using their display filename In-Reply-To: <20260609163416.3421440-1-tromey@adacore.com> References: <20260609163416.3421440-1-tromey@adacore.com> Date: Wed, 10 Jun 2026 17:01:43 +0100 Message-ID: <87y0gmpeoo.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 71SCxzDsIEn1yR3HXni2w-TWAwVPwluxb7HNCG_unjI_1781107305 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 Tom Tromey writes: > While working on gnat-llvm, I found that many tests in > gdb.ada/info_auto_lang.exp were failing. Investigating this, the > difference turned out to be a different sort order for the output. I > then tracked this down to gnat-llvm emitting: > > DW_AT_name : (indirect string, offset: 0xdd4): pck.adb > ... > DW_AT_comp_dir : (indirect string, offset: 0xddc): /home/tromey/AdaCore/binutils-gdb/gdb/testsuite/gdb.ada/mi_dyn_arr/ > > ... whereas GCC emits: > > <108b> DW_AT_name : (indirect line string, offset: 0x10f): /home/tromey/gdb/binutils-gdb/gdb/testsuite/gdb.ada/mi_dyn_arr/pck.adb > <108f> DW_AT_comp_dir : (indirect line string, offset: 0): /home/tromey/gdb/build/gdb/testsuite/outputs/gdb.ada/mi_dyn_arr > > This distinction isn't relevant to the test, so I tried "set > filename-display basename". However, this setting had no effect. > > It seems to me that, for "info types" and the like, the output should > be sorted according to the user's display preferences. This patch > implements this and adds a new DWARF assembler test. I think this sounds like the right thing to do. Just a couple of minor nits... > > Finally, this updates info_auto_lang.exp to be insensitive to this > quirk of gnat-llvm. > --- > gdb/symtab.c | 6 +- > gdb/testsuite/gdb.ada/info_auto_lang.exp | 18 ++-- > gdb/testsuite/gdb.dwarf2/symtab-sorting.exp | 108 ++++++++++++++++++++ > 3 files changed, 122 insertions(+), 10 deletions(-) > create mode 100644 gdb/testsuite/gdb.dwarf2/symtab-sorting.exp > > diff --git a/gdb/symtab.c b/gdb/symtab.c > index 3c10e1fd750..00205c31975 100644 > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -4610,8 +4610,10 @@ symbol_search::compare_search_syms (const symbol_search &sym_a, > { > int c; > > - c = FILENAME_CMP (sym_a.symbol->symtab ()->filename (), > - sym_b.symbol->symtab ()->filename ()); > + /* The output is going to be displayed to the user, so sort the file > + names according to how they will be shown. */ > + c = FILENAME_CMP (symtab_to_filename_for_display (sym_a.symbol->symtab ()), > + symtab_to_filename_for_display (sym_b.symbol->symtab ())); > if (c != 0) > return c; > > diff --git a/gdb/testsuite/gdb.ada/info_auto_lang.exp b/gdb/testsuite/gdb.ada/info_auto_lang.exp > index e717802a8d2..2b060a4939b 100644 > --- a/gdb/testsuite/gdb.ada/info_auto_lang.exp > +++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp > @@ -44,6 +44,8 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } > > clean_restart ${testfile} > > +gdb_test_no_output "set filename-display basename" > + > set bp_location [gdb_get_line_number "STOP" ${testdir}/some_c.c] > if {![runto "some_c.c:$bp_location"]} { > return > @@ -119,10 +121,10 @@ foreach_with_prefix language_choice { "auto" "ada" "c" } { > [multi_line \ > "All functions matching regular expression \"proc_in_\":" \ > "" \ > - "File .*proc_in_ada.adb:" \ > + "File proc_in_ada.adb:" \ > $func_in_ada($ada_match) \ > "" \ > - "File .*some_c.c:" \ > + "File some_c.c:" \ > $func_in_c($c_match) > ] > > @@ -130,10 +132,10 @@ foreach_with_prefix language_choice { "auto" "ada" "c" } { > [multi_line \ > "All types matching regular expression \"some_type\":" \ > "" \ > - "File .*global_pack.ads:" \ > + "File global_pack.ads:" \ > $type_in_ada($ada_match)\ > "" \ > - "File .*some_c.c:" \ > + "File some_c.c:" \ > $type_in_c($c_match) > ] > > @@ -141,18 +143,18 @@ foreach_with_prefix language_choice { "auto" "ada" "c" } { > [multi_line \ > "All variables matching regular expression \"some_struct\":" \ > "" \ > - "File .*global_pack.ads:" \ > + "File global_pack.ads:" \ > $var_in_ada($ada_match) \ > "" \ > - "File .*some_c.c:" \ > + "File some_c.c:" \ > $var_in_c($c_match) > ] > > gdb_test "rbreak proc_in_" \ > [multi_line \ > - "Breakpoint.*file .*proc_in_ada.adb,.*" \ > + "Breakpoint.*file proc_in_ada.adb,.*" \ > $rbreak_func_in_ada($ada_match) \ > - "Breakpoint.*file .*some_c.c,.*" \ > + "Breakpoint.*file some_c.c,.*" \ > $rbreak_func_in_c($c_match) \ > "Successfully created breakpoints $decimal-$decimal." > ] > diff --git a/gdb/testsuite/gdb.dwarf2/symtab-sorting.exp b/gdb/testsuite/gdb.dwarf2/symtab-sorting.exp > new file mode 100644 > index 00000000000..833c08ec4f1 > --- /dev/null > +++ b/gdb/testsuite/gdb.dwarf2/symtab-sorting.exp > @@ -0,0 +1,108 @@ > +# Copyright 2026 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 . > + > +# Test handling of an array type whose bound comes from the field of a > +# structure. Copy and paste comment? This doesn't seem to describe this test. > + > +load_lib dwarf.exp > + > +# This test can only be run on targets which support DWARF-2 and use gas. > +require dwarf2_support > + > +standard_testfile main.c -debug.S > + > +# Set up the DWARF for the test. > + > +set asm_file [standard_output_file $srcfile2] > +Dwarf::assemble $asm_file { > + global srcdir subdir srcfile > + > + cu {} { > + DW_TAG_compile_unit { > + DW_AT_language @DW_LANG_C > + DW_AT_name /tmp/aaaa.c > + } { > + DW_TAG_base_type { > + DW_AT_byte_size 1 DW_FORM_sdata > + DW_AT_encoding @DW_ATE_unsigned > + DW_AT_name byte1 > + } > + } > + } > + cu {} { > + DW_TAG_compile_unit { > + DW_AT_language @DW_LANG_C > + DW_AT_name bbbb.c > + DW_AT_comp_dir /tmp > + } { > + DW_TAG_base_type { > + DW_AT_byte_size 1 DW_FORM_sdata > + DW_AT_encoding @DW_ATE_unsigned > + DW_AT_name byte2 > + } > + } > + } > + cu {} { > + DW_TAG_compile_unit { > + DW_AT_language @DW_LANG_C > + DW_AT_name /tmp/cccc.c > + } { > + DW_TAG_base_type { > + DW_AT_byte_size 1 DW_FORM_sdata > + DW_AT_encoding @DW_ATE_unsigned > + DW_AT_name byte3 > + } > + } > + } > +} > + > +if { [prepare_for_testing "failed to prepare" ${testfile} \ > + [list $srcfile $asm_file] {nodebug}] } { > + return > +} > + > +gdb_test_no_output "set filename-display relative" > + > +# Here, bbbb.c is at the end because it sorts after "/tmp/cccc.c". > +gdb_test "info types byte" \ > + [multi_line \ > + "All types matching regular expression \"byte\":" \ > + "" \ > + "File /tmp/aaaa.c:" \ > + " byte1" \ > + "" \ > + "File /tmp/cccc.c:" \ > + " byte3" \ > + "" \ > + "File bbbb.c:" \ > + " byte2"] \ > + "info types relative filenames" > + > +gdb_test_no_output "set filename-display basename" > + > +# Here the order is by basename. > +gdb_test "info types byte" \ > + [multi_line \ > + "All types matching regular expression \"byte\":" \ > + "" \ > + "File aaaa.c:" \ > + " byte1" \ > + "" \ > + "File bbbb.c:" \ > + " byte2" \ > + "" \ > + "File cccc.c:" \ > + " byte3"] \ > + "info types basenames" > For completeness, would it be worth adding a third test here using "set filename-display absolute"? With these two issues fixed: Approved-By: Andrew Burgess Thanks, Andrew > base-commit: 1eed06ae51d73a195b78ce0903ada9c9c2c14cfb > -- > 2.54.0