From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QdzcH2UUxmo0NA0AWB0awg (envelope-from ) for ; Wed, 07 Oct 2026 05:44:05 -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=qtExZIRs; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=u+3w7QMW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=yJKALXL8; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=po6sQ/rT; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7AE391E051; Wed, 07 Oct 2026 05:44:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 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 DFA7E1E04E for ; Wed, 07 Oct 2026 05:44:03 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 888474BA2E2E for ; Wed, 7 Oct 2026 09:44:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 888474BA2E2E 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=qtExZIRs; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=u+3w7QMW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=yJKALXL8; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=po6sQ/rT Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 841DB4BA2E22 for ; Wed, 7 Oct 2026 09:41:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 841DB4BA2E22 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 841DB4BA2E22 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=1791366065; cv=none; b=dHqqoxIdtGV0sCiXXdQ3yvzy+p1gi6VhjHok1pbPgj97biddDYSA6b9lP344Ydv3EzP5v0Z2NEWnLghSmsL1ljLcrBeHY38TYxqhkYNgqRBI/HJexJvKdDIeb0RhQSlbg5gWriMTXCMQIqPjv900g75T/RDjMYjdlgREP4qMNq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791366065; c=relaxed/simple; bh=UIWlWMzzndNR69UzAVxJRyvsqt0jHp+CzAykVJg/2a8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=llmkB6vmWD48AQ2rVL4asmY3i4OPuPoTgHLDIY3WUE4TAEySeyT6/xd68pWfyAuZufHYUgidS1XufOki7DpeQCLiOO91q9KOCKFNN4h/RwqFSxPQ29yf0hoZ1aa/R2CTfUNTrRx0NUtUiDsz9svR/NrdrF2u+dlvWJJrC1fhGDM= 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=qtExZIRs; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=u+3w7QMW; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=yJKALXL8; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=po6sQ/rT DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 841DB4BA2E22 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 944AC21F7D for ; Wed, 7 Oct 2026 09:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1791366064; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h3n6K/NURP+1VyHqDXNMQb1ChFMIxYB7QnYTkPvFhSI=; b=qtExZIRspHNpyC8Wlp1PfxUgEBsuJ6KwACE4imb2kxb230g/2+eyGsTLB9MUXWrlbu5Joi hS9+U2QsGOb6HWF+V4UOLoad+sIlNe0bxLtSeSxqOW8sjC/HZKtJ+yjisV4MNG2hx/lEUf Sj0z6LUeq0LbL/VfO6+QSePBigdMBxk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1791366064; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h3n6K/NURP+1VyHqDXNMQb1ChFMIxYB7QnYTkPvFhSI=; b=u+3w7QMWvlpiMIycSCriBJy4E7ZWe2fd8n5jsKawIBFirxbgGmd3/A5r4HYw2DmbGq+C2j Yx5DIcWFnEJ+n1BA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=yJKALXL8; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="po6sQ/rT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1791366060; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h3n6K/NURP+1VyHqDXNMQb1ChFMIxYB7QnYTkPvFhSI=; b=yJKALXL8Pl6O6ODQJRavEV1+0KZ9U4h4M9vtZjQEeqX4IL+TOagC7GcuGAq2ioSg+T0K4k Gz0HFTuDlEJTi/41qu4fBxFXMBmcdu9SMaCapCAP+DP08Nii/Gf7cZzUyEhir0Wvn8RbVX YRkOO6llpJ2QluKhxyDJOatmspgnkYk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1791366060; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h3n6K/NURP+1VyHqDXNMQb1ChFMIxYB7QnYTkPvFhSI=; b=po6sQ/rT5Q4murB+xrT3L3wItSakUW9fZKf2h18IA03vKY4+fNUzP9eV+MBp7a8YfRLPoG 7nm6xX6LPfkTNbDA== 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 8BCDB13B9B for ; Wed, 7 Oct 2026 09:40:59 +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 JEXHFKoTxmo3EwAAD6G6ig:T10 (envelope-from ) for ; Wed, 07 Oct 2026 09:40:59 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v4 09/11] [gdb] Handle sections when disassembling Date: Wed, 7 Oct 2026 11:40:55 +0200 Message-ID: <20261007094057.1811886-10-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20261007094057.1811886-1-tdevries@suse.de> References: <20261007094057.1811886-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; 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)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,gnu.org:url,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 944AC21F7D 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 Consider the following session: ... $ gdb -q -batch a.out -ex start -ex "disassemble _init,0x0000000000401030" ... Dump of assembler code from 0x401000 to 0x401030: ... 0x000000000040101a <_init+26>: ret 0x000000000040101b: add %al,(%rax) 0x000000000040101d: add %al,(%rax) 0x000000000040101f: add %bh,%bh 0x0000000000401021: xor $0x2fca,%eax 0x0000000000401026: jmp *0x2fcc(%rip) 0x000000000040102c: nopl 0x0(%rax) End of assembler dump. ... If disassemble with objdump instead, we get: ... Disassembly of section .init: 0000000000401000 <_init>: ... 40101a: c3 ret Disassembly of section .plt: 0000000000401020 : 401020: ff 35 ca 2f 00 00 push 0x2fca(%rip) 401026: ff 25 cc 2f 00 00 jmp *0x2fcc(%rip) 40102c: 0f 1f 40 00 nopl 0x0(%rax) ... Note the xor vs push. So gdb: - first disassembles the .init section - then disassembles the section hole in between .init and .plt - interprets the first byte of .plt as the last byte of an instruction starting in the section hole - continues disassembling at .plt+1 instead of .plt+0 Fix this in gdb_disassembly by making it section-aware, and not disassembling across a section change, getting us instead: ... 0x000000000040101a <_init+26>: ret 0x000000000040101b: add %al,(%rax) 0x000000000040101d: add %al,(%rax) 0x000000000040101f: add %bh,%bh 0x0000000000401020: push 0x2fca(%rip) # 0x403ff0 0x0000000000401026: jmp *0x2fcc(%rip) # 0x403ff8 0x000000000040102c: nopl 0x0(%rax) ... Likewise in tui_disassemble. Also add a test-case for the fix in gdb_disassembly: gdb.base/disasm-section-sync.exp. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34617 --- gdb/disasm.c | 50 +++++++++- gdb/testsuite/gdb.base/disasm-section-sync.S | 47 +++++++++ .../gdb.base/disasm-section-sync.exp | 28 ++++++ gdb/tui/tui-disasm.c | 99 ++++++++++++++----- 4 files changed, 195 insertions(+), 29 deletions(-) create mode 100644 gdb/testsuite/gdb.base/disasm-section-sync.S create mode 100644 gdb/testsuite/gdb.base/disasm-section-sync.exp diff --git a/gdb/disasm.c b/gdb/disasm.c index ec922fbd323..23d0c880777 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -34,6 +34,7 @@ #include "cli/cli-style.h" #include "objfiles.h" #include "inferior.h" +#include "addrmap.h" /* Disassemble functions. FIXME: We should get rid of all the duplicate code in gdb that does @@ -1145,12 +1146,12 @@ gdb_disassembler::print_insn (CORE_ADDR memaddr, return length; } -/* See disasm.h. */ +/* Helper function for gdb_disassembly. */ -int -gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, - gdb_disassembly_flags flags, int how_many, - CORE_ADDR low, CORE_ADDR high) +static int +gdb_disassembly_1 (struct gdbarch *gdbarch, struct ui_out *uiout, + gdb_disassembly_flags flags, int how_many, + CORE_ADDR low, CORE_ADDR high) { struct symtab *symtab; int nlines = -1; @@ -1182,6 +1183,45 @@ gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, return num_displayed; } +/* See disasm.h. */ + +int +gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, + gdb_disassembly_flags flags, int how_many, + CORE_ADDR low, CORE_ADDR high) +{ + std::unique_ptr map = section_addrmap (); + bool update_how_many = how_many != -1; + int num_displayed = 0; + while (low < high) + { + CORE_ADDR tmp_high = high; + + CORE_ADDR range_high; + map->find (low, nullptr, &range_high); + + /* Don't disassemble past a section change. */ + if (range_high != (CORE_ADDR)-1) + tmp_high = std::min (tmp_high, range_high + 1); + + int res + = gdb_disassembly_1 (gdbarch, uiout, flags, how_many, low, + tmp_high); + num_displayed += res; + + if (update_how_many) + { + how_many -= res; + if (how_many <= 0) + break; + } + + low = tmp_high; + } + + return num_displayed; +} + /* Print the instruction at address MEMADDR in debugged memory, on STREAM. Returns the length of the instruction, in bytes, and, if requested, the number of branch delay slot instructions. */ diff --git a/gdb/testsuite/gdb.base/disasm-section-sync.S b/gdb/testsuite/gdb.base/disasm-section-sync.S new file mode 100644 index 00000000000..06949c4b444 --- /dev/null +++ b/gdb/testsuite/gdb.base/disasm-section-sync.S @@ -0,0 +1,47 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright (C) 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 . */ + + .section .text_1,"ax",@progbits + .globl foo_1 + .type foo_1, @function +foo_1: + endbr64 + sub $0x8,%rsp + mov 0x2fd1(%rip),%rax + test %rax,%rax + je 401016 + call *%rax + add $0x8,%rsp + ret + + # Get instruction decoding out of sync. + .byte 0 + + .section .text_2,"ax",@progbits + .globl foo_2 + .type foo_2, @function +foo_2: + push 0x2fca(%rip) + jmp *0x2fcc(%rip) + nopl 0x0(%rax) + + .globl foo_3 + .type foo_3, @function +foo_3: + nop + + .section .note.GNU-stack,"",@progbits diff --git a/gdb/testsuite/gdb.base/disasm-section-sync.exp b/gdb/testsuite/gdb.base/disasm-section-sync.exp new file mode 100644 index 00000000000..2f8b01cae52 --- /dev/null +++ b/gdb/testsuite/gdb.base/disasm-section-sync.exp @@ -0,0 +1,28 @@ +# Copyright (C) 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 . + +# Check that disassembling stops and starts at section boundaries. + +require is_x86_64_m64_target + +standard_testfile .S main.c + +if { [prepare_for_testing "failed to prepare" $testfile \ + [list $srcfile $srcfile2] {nodebug}] } { + return +} + +# Regression test for PR34617. +gdb_test "disassemble foo_1,foo_3" "push.*" diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index c242614be45..ba11b8e8188 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -38,6 +38,7 @@ #include "tui/tui-location.h" #include "gdbsupport/selftest.h" #include "inferior.h" +#include "addrmap.h" struct tui_asm_line { @@ -80,23 +81,13 @@ len_without_escapes (const std::string &str) return len; } -/* 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 after the last disassembled instruction. - When ADDR_SIZE is non-null then place the maximum size of an address and - label into the value pointed to by ADDR_SIZE, and set the addr_size - field on each item in ASM_LINES, otherwise the addr_size fields within - ASM_LINES are undefined. +/* Helper function for tui_disassemble. */ - It is worth noting that ASM_LINES might not have COUNT entries when this - function returns. If the disassembly is truncated for some other - reason, for example, we hit invalid memory, then ASM_LINES can have - fewer entries than requested. */ static CORE_ADDR -tui_disassemble (struct gdbarch *gdbarch, - std::vector &asm_lines, - CORE_ADDR pc, int count, - size_t *addr_size = nullptr) +tui_disassemble_1 (struct gdbarch *gdbarch, + std::vector &asm_lines, CORE_ADDR pc, + std::optional high_pc, int count, + size_t *addr_size) { bool term_out = disassembler_styling && gdb_stdout->can_emit_style_escape (); string_file gdb_dis_out (term_out); @@ -104,20 +95,29 @@ tui_disassemble (struct gdbarch *gdbarch, ? (decltype (stream))&null_stream : (decltype (stream))&gdb_dis_out); - /* Must start with an empty list. */ - asm_lines.clear (); - /* Now construct each line. */ for (int i = 0; i < count; ++i) { tui_asm_line tal; + if (high_pc.has_value () && pc >= *high_pc) + break; + /* Save the instruction address. */ tal.addr = pc; try { - pc += gdb_print_insn (gdbarch, pc, stream, NULL); + int len = gdb_print_insn (gdbarch, pc, stream, NULL); + CORE_ADDR next_pc = pc + len; + if (high_pc.has_value () && next_pc > *high_pc) + { + /* Instruction spans high_pc. */ + gdb_dis_out = "(bad)"; + next_pc = *high_pc; + } + + pc = next_pc; } catch (const gdb_exception_error &except) { @@ -153,6 +153,53 @@ tui_disassemble (struct gdbarch *gdbarch, return pc; } +/* 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 after the last disassembled instruction. + When ADDR_SIZE is non-null then place the maximum size of an address and + label into the value pointed to by ADDR_SIZE, and set the addr_size + field on each item in ASM_LINES, otherwise the addr_size fields within + ASM_LINES are undefined. + + MAP contains a map from adressess to sections and corresponding ranges. + + It is worth noting that ASM_LINES might not have COUNT entries when this + function returns. If the disassembly is truncated for some other + reason, for example, we hit invalid memory, then ASM_LINES can have + fewer entries than requested. */ + +static CORE_ADDR +tui_disassemble (struct gdbarch *gdbarch, + std::vector &asm_lines, + addrmap_mutable &map, CORE_ADDR pc, int count, + size_t *addr_size = nullptr) +{ + /* Must start with an empty list. */ + asm_lines.clear (); + + while (count > 0) + { + CORE_ADDR range_high; + map.find (pc, nullptr, &range_high); + + /* Don't disassemble past a section change. */ + std::optional high_pc; + if (range_high != (CORE_ADDR)-1) + high_pc = range_high + 1; + + int prev_nr_lines = asm_lines.size (); + pc = tui_disassemble_1 (gdbarch, asm_lines, pc, high_pc, count, + addr_size); + int nr_lines = asm_lines.size () - prev_nr_lines; + if (nr_lines == 0) + break; + + count -= nr_lines; + } + + return pc; +} + /* Look backward from ADDR for an address from which we can start disassembling, this needs to be something we can be reasonably confident will fall on an instruction boundary. We use msymbol @@ -197,13 +244,14 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) return pc; std::vector asm_lines; + std::unique_ptr map = section_addrmap (); if (from > 0) { /* Always disassemble 1 extra instruction here, then if the last instruction fails to disassemble we will take the address of the previous instruction that did disassemble as the result. */ - tui_disassemble (gdbarch, asm_lines, pc, max_lines + 1); + tui_disassemble (gdbarch, asm_lines, *map, pc, max_lines + 1); if (asm_lines.empty ()) return pc; return asm_lines.back ().addr; @@ -249,7 +297,8 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) break; /* Disassemble forward. */ - next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines); + next_addr + = tui_disassemble (gdbarch, asm_lines, *map, new_low, max_lines); if (asm_lines.empty ()) { new_low = prev_low; @@ -280,7 +329,8 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) /* Take the best possible match we have. */ new_low = *possible_new_low; - next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines); + next_addr + = tui_disassemble (gdbarch, asm_lines, *map, new_low, max_lines); } /* The following walk forward assumes that ASM_LINES contains exactly @@ -303,7 +353,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) CORE_ADDR old_next_addr = next_addr; std::vector single_asm_line; next_addr = tui_disassemble (gdbarch, single_asm_line, - next_addr, 1); + *map, next_addr, 1); /* If there are some problems while disassembling exit. */ if (next_addr <= old_next_addr) return pc; @@ -347,8 +397,9 @@ tui_disasm_window::set_contents (struct gdbarch *arch, /* Get temporary table that will hold all strings (addr & insn). */ std::vector asm_lines; + std::unique_ptr map = section_addrmap (); size_t addr_size = 0; - tui_disassemble (m_gdbarch, asm_lines, pc, max_lines, &addr_size); + tui_disassemble (m_gdbarch, asm_lines, *map, pc, max_lines, &addr_size); /* Align instructions to the same column. */ insn_pos = (1 + (addr_size / tab_len)) * tab_len; -- 2.51.0