From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id y1VqCvg3oWpudTkAWB0awg (envelope-from ) for ; Wed, 09 Sep 2026 06:42:00 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Mk7+HrQ5; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bQh99+8K; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=r1uyhp7Z; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RrcBdcZ+; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 16DAC1E09E; Wed, 09 Sep 2026 06:42:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 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 099451E091 for ; Wed, 09 Sep 2026 06:41:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A0AB4BB24EC for ; Wed, 9 Sep 2026 10:41:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A0AB4BB24EC Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Mk7+HrQ5; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bQh99+8K; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=r1uyhp7Z; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RrcBdcZ+ Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 23B364B99F79 for ; Wed, 9 Sep 2026 10:41:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23B364B99F79 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 23B364B99F79 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788950492; cv=none; b=u03Phy0kzPawC//Xa6v/v+DG4h2+GFI4exAeVan6vh+S2F29Tl30CRdqXU7rMpnIephWJCc91WY3/nKOWlFq7YBl6LBIJxZe6u3nU6KpvaNgmRuVtY17rmvef7KwhCZFmEsGuWlKONAlLWgfGWmX/pFyId6VZw+lBigIAPEeYgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788950492; c=relaxed/simple; bh=gasXbQg/7i44HreEcXNDg9Or2sQ1HDQD5w58yzxrdr0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=BjYq+9nArEBRuljCS5haiM7VQ6xoiyzSbOZOLmPM6VGoyq1Yr37ISF8dGmWxFdnq2e+n1o+AuLSMPPJVo8vEwWvRAYYakwhRIlau0noaUJUjcEJtDK7ugpTXah3aU4pDxlhw2SPRM08p1Nxn5YNuhq2+l2axSd10oj3uh9D3+g8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Mk7+HrQ5; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bQh99+8K; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=r1uyhp7Z; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RrcBdcZ+ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23B364B99F79 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CF4FC219C4; Wed, 9 Sep 2026 10:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788950487; h=from:from:reply-to: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=u9088gsS3NKywDglLxBsMB/nuzLp08asdGNb4ydsoJI=; b=Mk7+HrQ5wnPVCVZO1suQzdo7yvqcGBGqUaC/8ThEvtJWrnnAJR0wYUtNBv3Y7Lw8ARBxAX 2dqTKN/X7m5dshhc/w7v3XDgn8L+1EcjOYN4lwq4IJHZaWZwaVOJGDwqdmZoUEY8u9P7JG 7xu9tecp1ualuHa9OdCDbdmc/LL2uYs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788950487; h=from:from:reply-to: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=u9088gsS3NKywDglLxBsMB/nuzLp08asdGNb4ydsoJI=; b=bQh99+8KxEoqNvRCxJbR1fABffryKyqOMtZufLJ/1OSk2PWksxZRkKiEZBdmaN4IT6j//A LbUOVuaabmCxCLCw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=r1uyhp7Z; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=RrcBdcZ+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788950482; h=from:from:reply-to: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=u9088gsS3NKywDglLxBsMB/nuzLp08asdGNb4ydsoJI=; b=r1uyhp7Z/8Lra1W7PhjcBxeAeJ14bQnIObEL1KVLY0Gqqp19XnzVU81l5f6XO2Dr6tR2vh O6iPOkYB+tiKU7z6OcnWuvTYZoi+jS4lyvh8VhAoCyK4+rdByVK0AOgoxeMv9FgbwaQI2z yJl6q8m49jHcIXQe7tKO4Z5R+OYis5U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788950482; h=from:from:reply-to: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=u9088gsS3NKywDglLxBsMB/nuzLp08asdGNb4ydsoJI=; b=RrcBdcZ+wCXbtEuor2c+ZFrtPOikarDvOqSvd4f5kJ1zz5kWQVH5LuhauN28sV2lmGctva XUqNh/Z1VA0tPyAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9C7FF1347F; Wed, 9 Sep 2026 10:41:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id RTYVH9I3oWrvOgAAD6G6ig (envelope-from ); Wed, 09 Sep 2026 10:41:22 +0000 Message-ID: <3af17c22-ef82-4825-8c49-702466da7d43@suse.de> Date: Wed, 9 Sep 2026 12:41:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/tui] Don't disassemble non-code sections and section holes To: Guinevere Larsen , gdb-patches@sourceware.org References: <20260819143514.2221499-1-tdevries@suse.de> <7c55b686-2067-4dbd-8eaa-c7a77ad11afa@redhat.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <7c55b686-2067-4dbd-8eaa-c7a77ad11afa@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CF4FC219C4 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid]; DKIM_TRACE(0.00)[suse.de:+] 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 9/4/26 1:39 PM, Guinevere Larsen wrote: > On 8/19/26 11:35 AM, Tom de Vries wrote: >> I was investigating TUI behaviour on ppc64-linux using the executable >> from >> test-case gdb.tui/basic.exp, and after scrolling in the asm window >> ended up >> with: >> ... >> +----------------------------------------------------------------------------+ >> |   0x920 <__libc_start_main@plt+4> b       0x8f0 >> <__glink_PLTresolve>       | >> |   0x924 <__gmon_start__@plt>      li >> r0,1                             | >> |   0x928 <__gmon_start__@plt+4>    b       0x8f0 >> <__glink_PLTresolve>       | >> |   0x92c <__cxa_finalize@plt>      li >> r0,2                             | >> |   0x930 <__cxa_finalize@plt+4>    b       0x8f0 >> <__glink_PLTresolve>       | >> |   0x934 <._fini>                  mflr >> r0                               | >> |   0x938 <._fini+4>                std >> r0,16(r1)                        | >> |   0x93c <._fini+8>                stdu >> r1,-112(r1)                      | >> |   0x940 <._fini+12>               addi >> r1,r1,112                        | >> |   0x944 <._fini+16>               ld >> r0,16(r1)                        | >> |   0x948 <._fini+20>               mtlr >> r0                               | >> |   0x94c <._fini+24> >> blr                                      | >> |   0x950 <_IO_stdin_used>          .long >> 0x20001                            | >> |   0x954                           .long >> 0x11b033b                          | >> |   0x958                           .long >> 0x18                               | >> |   0x95c                           .long >> 0x2                                | >> |   0x960                           .long >> 0xffffff60                         | >> |   0x964                           .long >> 0x48                               | >> |   0x968                           .long >> 0xffffff9c                         | >> |   0x96c                           .long >> 0x30                               | >> +----------------------------------------------------------------------------+ >> exec No process (asm) In:                                        L?? >> PC: ?? >> (gdb) >> ... >> >> The view corresponds to this objdump -D output: >> ... >> Disassembly of section .text: >> >>    ... >> >> 000000000000091c <__libc_start_main@plt>: >>   91c:   38 00 00 00     li      r0,0 >>   920:   4b ff ff d0     b       8f0 <__glink_PLTresolve> >> >> 0000000000000924 <__gmon_start__@plt>: >>   924:   38 00 00 01     li      r0,1 >>   928:   4b ff ff c8     b       8f0 <__glink_PLTresolve> >> >> 000000000000092c <__cxa_finalize@plt>: >>   92c:   38 00 00 02     li      r0,2 >>   930:   4b ff ff c0     b       8f0 <__glink_PLTresolve> >> >> Disassembly of section .fini: >> >> 0000000000000934 <._fini>: >>   934:   7c 08 02 a6     mflr    r0 >>   938:   f8 01 00 10     std     r0,16(r1) >>   93c:   f8 21 ff 91     stdu    r1,-112(r1) >>   940:   38 21 00 70     addi    r1,r1,112 >>   944:   e8 01 00 10     ld      r0,16(r1) >>   948:   7c 08 03 a6     mtlr    r0 >>   94c:   4e 80 00 20     blr >> >> Disassembly of section .rodata: >> >> 0000000000000950 <_IO_stdin_used>: >>   950:   00 02 00 01     .long 0x20001 >> >> Disassembly of section .eh_frame_hdr: >> >> 0000000000000954 <__GNU_EH_FRAME_HDR>: >>   954:   01 1b 03 3b     .long 0x11b033b >>   958:   00 00 00 18     .long 0x18 >>   95c:   00 00 00 02     .long 0x2 >>   960:   ff ff ff 60     .long 0xffffff60 >>   964:   00 00 00 48     .long 0x48 >>   968:   ff ff ff 9c     .long 0xffffff9c >>   96c:   00 00 00 30     .long 0x30 >> ... >> >> ISTM that we should not be disassembling the .rodata section. >> >> My first thought was to require tui_disassemble to stay in the same >> section, >> but after thinking about it a bit more decided that that was too >> restrictive, >> and instead went for requiring that we stay in code sections. >> >> So, I came up with this fix: >> ... >>        struct obj_section *section = find_pc_section (pc); >>        if (section != nullptr >>       && (bfd_section_flags (section->the_bfd_section) & SEC_CODE) == 0) >>     return pc; >> ... >> >> Then I stumbled on PR tui/34399, which reports not being able to >> scroll back >> up after scrolling down.  The problem there is that we disassemble >> code from a >> section hole (0x401034-0x402000): >> ... >> Section Headers: >>    [Nr] Name              Type             Address           Offset >>         Size              EntSize          Flags  Link  Info  Align >>    [ 0]                   NULL             0000000000000000  00000000 >>         0000000000000000  0000000000000000           0     0     0 >>    [ 1] .note.gnu.pr[...] NOTE             0000000000400190  00000190 >>         0000000000000030  0000000000000000   A       0     0     8 >>    [ 2] .note.gnu.bu[...] NOTE             00000000004001c0  000001c0 >>         0000000000000024  0000000000000000   A       0     0     4 >>    [ 3] .text             PROGBITS         0000000000401000  00001000 >>         0000000000000034  0000000000000000  AX       0     0     1 >>    [ 4] .rodata           PROGBITS         0000000000402000  00002000 >>         0000000000000006  0000000000000000   A       0     0     1 >>    [ 5] .symtab           SYMTAB           0000000000000000  00002008 >>         0000000000000078  0000000000000018           6     1     8 >>    [ 6] .strtab           STRTAB           0000000000000000  00002080 >>         0000000000000019  0000000000000000           0     0     1 >>    [ 7] .shstrtab         STRTAB           0000000000000000  00002099 >>         000000000000004f  0000000000000000           0     0     1 >> Key to Flags: >>    W (write), A (alloc), X (execute), M (merge), S (strings), I (info), >>    L (link order), O (extra OS processing required), G (group), T (TLS), >>    C (compressed), x (unknown), o (OS specific), E (exclude), >>    D (mbind), l (large), p (processor specific) >> ... >> and once we call tui_find_backward_disassembly_start_address with an >> address >> ADDR for which find_pc_section (ADDR - 1) == nullptr, we are stuck in the >> section hole. >> >> Fix this by not disassembling section holes. >> >> This is achieved by slightly modifying the earlier fix: >> ... >>        if (section == nullptr >>       || (bfd_section_flags (section->the_bfd_section) & SEC_CODE) == 0) >>     return pc; >> ... >> >> Tested on x86_64-linux and ppc64-linux. >> >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34399 >> --- > > Hi! > > Thank you for working on this! > Hi Guinevere, thanks for the review. > I think your fix makes perfect sense, but I noticed an inaccuracy in the > function comment. It predates your change, but I think now would be a > reasonable time to fix it. The comment reads: > >     Function to disassemble up to COUNT instructions starting from > address PC >     into the ASM_LINES vector (which will be emptied of any previous > contents). >     Return the address of the COUNT'th instruction after pc. > > Considering that returning early is possible, I think this comment > should say that we return the address right after the last disassembled > instruction, or something to that effect. > Agreed. I've added a patch in a v2 ( https://sourceware.org/pipermail/gdb-patches/2026-September/230205.html ). > Also, I tried to reproduce this issue in x86 but couldn't. It would be > nice if there was a test that exercised this, but it isn't a requirement > for me. As for reproducing, initially I worked with the exec reported in the PR, but Andrew's comment in his review made me realize I could use the disassemble command to update the asm window. Then I managed to reproduce it quite easily using a hello world exec: ... $ gcc -g hello.c ... The steps are: - find a section hole using readelf -S a.out. I found one in between .init and .plt. - use the disassemble command to disassemble the section before the section hole. In my case: "disassemble _init" - scroll forward until .init is no longer visible (and maybe one instruction more) - try to scroll back into _init I used this command for most of the setup: ... $ gdb -q -iex "set debuginfod enabled off" a.out -ex start -ex "layout asm" -ex "disassemble _init" ... Note that there's a start in there. If that's not there, then we can't scroll forward through the section hole to begin with. Indeed IWBN if there was a test-case, but I'm not sure how to build a non-fragile architecture-neutral assembly file that is sure to have a section hole. Thanks, - Tom