From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YuL3McLnmmrwvCgAWB0awg (envelope-from ) for ; Fri, 04 Sep 2026 11:46:10 -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=CCdBNLXM; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 983121E166; Fri, 04 Sep 2026 11:46:10 -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 [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 12F771E033 for ; Fri, 04 Sep 2026 11:46:09 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F3BD4BB3BE9 for ; Fri, 4 Sep 2026 15:46:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F3BD4BB3BE9 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=CCdBNLXM 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 3E1A54BB3BD3 for ; Fri, 4 Sep 2026 15:45:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E1A54BB3BD3 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 3E1A54BB3BD3 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=1788536741; cv=none; b=LaIqeVrvSqX60ple0cf4zCs3Q9YzB2Xok4eC41EmyBi2bn5w5lKhhK0wXI52CGZBjF29fCBVU4ukTAUMTbHkTi4L1qDEOPxkdn+z09bxX0s1ad0BAZ0fR+8iKyULg+gIZZXqfTH6ViZWf27v2jcdteY+dJXESgsBRzJBV1KqMMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788536741; c=relaxed/simple; bh=IWYxYsYgs/Jc/HvQa1gu5W3gQgNIJXNoFuw1j2Nnfco=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RlQkv6UbY1yVSpXNdw0/oQLuUdYwUmLCfTDZnU/Gl4IBSx6iTH9krtUHDkobL3UkzwT4M1qXWQDRSgGQvWnDx+vkN/CdpxAh/T2UaOuOfAUDxDSlQe2bprxeXmpB+esVy3EYKXkbtiPMzw6J1zHDC9UiABsknhlqNby1vBN4zyw= 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=CCdBNLXM DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E1A54BB3BD3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788536740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wCopF4JfHHq8FyUtB9y1HX+DayoqLbfDxqJeL4DXO+Q=; b=CCdBNLXMcoy9ju8GJ7SIgJfeLxeJOrm5ipOKhaSXZ5iEqr0rd9O43FacgoESGsBG1c5jJC l8r0WxrSDHYnnRq8U/2YkYsfOy4RHcASEjPbYiFQt9YUlAtnlTEch2x+SFH8WoXJQBg9RM O+t3oizaTvpqt1IR+M0iJrPLbgV61jI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-Dt-B5CrKM-mF6UOwG_zTgg-1; Fri, 04 Sep 2026 11:45:39 -0400 X-MC-Unique: Dt-B5CrKM-mF6UOwG_zTgg-1 X-Mimecast-MFC-AGG-ID: Dt-B5CrKM-mF6UOwG_zTgg_1788536738 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4994cf6cdb9so8080305e9.3 for ; Fri, 04 Sep 2026 08:45:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788536738; x=1789141538; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wCopF4JfHHq8FyUtB9y1HX+DayoqLbfDxqJeL4DXO+Q=; b=WGd2aq0zXhUzzX6BE/sznL5aAvo691di5nZVpT1Ef7RWP7G06DChRFdZGDHCLeUWHs 9+QKvpbtjNskNRkYVEENH76Ll6FgXaEInLaiuoC4jAk7Qb5VIwCz2jaJCUT3O2heWLyf QXkZCRO0qNyusM4WzQwfDT7Q2MQJQ6hWoeEr9/f1IUv3/3RzBVdS0vfpSFyj14PTvAfK ALLSNVAzY/PruqQ9X9Splou7DV3A7Z1Qd/yB1Y1mvVJntlnVytJdgB8KYpop++0pF+FC G9DTSXcPQ5DgGA61LlFzNwsm+r2hJSqYlUA2rO1iMq59iLGoerniurlRAsP4IH7+z5fz jsOA== X-Forwarded-Encrypted: i=1; AKwUvBxqHZ2o+1/G9Vvz1Hx9YP8c3wa70Dcgqh9dAknIPW/J2DaVkwVKHAM3B/zBtjIDZ7+aVQKe3GgwMhJ7Cg==@sourceware.org X-Gm-Message-State: AFuF++nIdPu+w6BK7AzvwlahHAJYjSLKKzaOwa5ge2emLvo7LVpx0e4x E2GF7+sQjv3w/5b6Zj3Bv/txry7IKKzsWCHaat7mGJzBohzQPNk9x+75NLsPWM18XCPiH65IvNB xAHaWxFSvUSIdjlmat4ltT5Sjm2eJ9gn5xpZShUP62p9FOHfE++ZYZrAWkuPHHrc= X-Gm-Gg: AYBFou3EIj2XzxZOhAwmaDecahkxmlD3LA+56YmgRYS/zoViaZN54xZp2KLw7I55xxv 70HCb0muxAzJDSL15DT8e3kmK2mcJxQvi+FgBH+3Y9YSrg7RiJG4QjI7/qCLsNFMo4Y83z875Yf oCBILo/ItfmUC+jrulJqdF8MWA7IjeTHaRp4hD+ltdg4b6Ly+y0iN/evwWVq2fGdxYRiVkzZjvS Cwzpe8qQjLplp7KDp2R+VyZqzJHIljusbfcKlAnkgnSoZpahFMUiggSx1C1RXP5xr9lwUxvxyzA /ltg9/d8KrWJVzRFlqR6/yf/SbC7kT+jk8B22TM5JA1J89hwZZN1ez0DoEYJmpb15B57RR88z64 DngA74TEMf8Fawk1NJ0/7XYnt8TM= X-Received: by 2002:a05:600c:3550:b0:49c:d019:70c5 with SMTP id 5b1f17b1804b1-49cf7f4a6cfmr60808315e9.0.1788536737434; Fri, 04 Sep 2026 08:45:37 -0700 (PDT) X-Received: by 2002:a05:600c:3550:b0:49c:d019:70c5 with SMTP id 5b1f17b1804b1-49cf7f4a6cfmr60807585e9.0.1788536736835; Fri, 04 Sep 2026 08:45:36 -0700 (PDT) Received: from localhost (128.223.159.143.dyn.plus.net. [143.159.223.128]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cf770fcf5sm76403695e9.6.2026.09.04.08.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 08:45:35 -0700 (PDT) From: Andrew Burgess To: Tom de Vries , gdb-patches@sourceware.org Subject: Re: [PATCH] [gdb/tui] Don't disassemble non-code sections and section holes In-Reply-To: <20260819143514.2221499-1-tdevries@suse.de> References: <20260819143514.2221499-1-tdevries@suse.de> Date: Fri, 04 Sep 2026 16:45:35 +0100 Message-ID: <875x0lrpeo.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RLbewUBDXlY077CooZxJzsgo2nEpfB87CR0j0mOkT9I_1788536738 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 de Vries writes: > 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; > ... TUI disassembly has been an ongoing issue for as long as I've been contributing to GDB :-/ Getting the logic right for scrolling forward/backward has always been an issue. I'm not sure this change is the right fix though. I have two concerns. In CLI mode, if I stop the inferior and then use `disassemble START,END` syntax, then I can disassemble any range of memory, not just executable sections. If I switch to TUI mode, without this patch and try the same disassemble command then I'll get a screen full of instructions starting at START. Is that useful given these aren't code sections? I'm not really sure. But if I apply your patch and try the same disassemble command then I get a blank ASM window. There are for sure ways that a user can work around this, `x/i` will dump the instructions to the CMD window, even in TUI mode. But the blank window still looks wrong to me, and I think it is not what users will expect. The other problem I see is that this will, if I understand correctly, prevent disassembly of memory that is not backed by an ELF section. For example, a JIT compiling interpreter. Given such a tool I'd expect to be able to disassemble the generated code regions, but these will likely not be backed by an ELF section. Thanks, Andrew