From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YMCsI2a0kGj1twMAWB0awg (envelope-from ) for ; Mon, 04 Aug 2025 09:23:50 -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=cnQyqS0G; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=r2ErCL4Y; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=cnQyqS0G; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=r2ErCL4Y; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8AF921E102; Mon, 4 Aug 2025 09:23:50 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.1 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,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE 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 6CA771E091 for ; Mon, 4 Aug 2025 09:23:49 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E910A385843F for ; Mon, 4 Aug 2025 13:23:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E910A385843F 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=cnQyqS0G; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=r2ErCL4Y; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=cnQyqS0G; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=r2ErCL4Y Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id B7A3F3858428 for ; Mon, 4 Aug 2025 13:20:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7A3F3858428 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 B7A3F3858428 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754313610; cv=none; b=i2NeM51vWiIJ3wYjqKkovMUQuObOSSqxYVkgCHth2t3Mg/alqUb5i/gIfMbDnGI4h9yLDJnRpUceZlpqGvQ2gDhnEWZ3yhyMKJ1FGB+oHfHiZF1KY1Z5A0sR/pVy+hUpW6IzAlOl3xUw4czOOcNRyPggs81u6YZVr5RpYMkvXj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754313610; c=relaxed/simple; bh=30ZEn153Dz/0LHRpDjYj3vNQgeXvyfEzTTDFeLQUPfI=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=Ux320TZbKvxW89n2ihsjUtYJgZ4drXfdB9Doi4QhBphpxHA6C5WVPubvwTujaLPmENDimJKZ1kLrqp6B4xhZ0kmGNM9Md6dCwNgA6laRIBbfVl8D8QLxuBG/p88H7uRR+HuhGBOcpHY5TNmlGlllLLEbfFTYHBLlSE6JRUidrNY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7A3F3858428 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-out2.suse.de (Postfix) with ESMTPS id 7D5361F44F for ; Mon, 4 Aug 2025 13:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1754313607; 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=3/tvqRGRhO+LXYDMr+W9Kqy3FZCVLr2M6CKdfS0MZwk=; b=cnQyqS0GoTIrUpCHHQWAA63hDfGtnNdvvRZXZc7meSre/m1nbQpeuLzGyaLUEW5YUz2uEa vzumh3T8ZRPy0HbtpBxKcASOptCeMPU64QuwJw95jI+HmkYTdlvOdn8ynpW9yQdCist5C8 J2MDVhq7x4OLFYYxnwKq5kQQWvzJxtg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1754313607; 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=3/tvqRGRhO+LXYDMr+W9Kqy3FZCVLr2M6CKdfS0MZwk=; b=r2ErCL4YeNyg0YuIxeFfd0KD2sxNMwjf3ur63a7/sCeIklPSCC2QGYXMZBKYshiNwxObzq NhAtzxzwCBcRk1Ag== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=cnQyqS0G; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=r2ErCL4Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1754313607; 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=3/tvqRGRhO+LXYDMr+W9Kqy3FZCVLr2M6CKdfS0MZwk=; b=cnQyqS0GoTIrUpCHHQWAA63hDfGtnNdvvRZXZc7meSre/m1nbQpeuLzGyaLUEW5YUz2uEa vzumh3T8ZRPy0HbtpBxKcASOptCeMPU64QuwJw95jI+HmkYTdlvOdn8ynpW9yQdCist5C8 J2MDVhq7x4OLFYYxnwKq5kQQWvzJxtg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1754313607; 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=3/tvqRGRhO+LXYDMr+W9Kqy3FZCVLr2M6CKdfS0MZwk=; b=r2ErCL4YeNyg0YuIxeFfd0KD2sxNMwjf3ur63a7/sCeIklPSCC2QGYXMZBKYshiNwxObzq NhAtzxzwCBcRk1Ag== 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 63AE913695 for ; Mon, 4 Aug 2025 13:20:07 +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 vwCUFoezkGjZTAAAD6G6ig (envelope-from ) for ; Mon, 04 Aug 2025 13:20:07 +0000 Message-ID: <31f5329b-e7eb-414f-84a0-a8b12a81ef2f@suse.de> Date: Mon, 4 Aug 2025 15:20:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/tui] Improve asm window From: Tom de Vries To: gdb-patches@sourceware.org References: <20250803150031.28468-1-tdevries@suse.de> <53f6f2e9-d15e-4302-a1c8-cefaa2ae3790@suse.de> Content-Language: en-US In-Reply-To: <53f6f2e9-d15e-4302-a1c8-cefaa2ae3790@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MID_RHS_MATCH_FROM(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:dkim]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: 7D5361F44F X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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 8/3/25 19:21, Tom de Vries wrote: > On 8/3/25 17:00, Tom de Vries wrote: >> The TUI asm window is (ignoring borders) currently structured as >> follows, from >> left to right: >> - exec info string (3 chars) >> - numeric address (hex with 0x prefix) >> - space >> - symbolic address of the form or (with n decimal) >> - spaces left-aligning the following item to a multiple of tui tab-width, >>    relative to the start of the numeric address >> - disassembled instruction >> >> For example, the main function in a hello world exec looks like this: >> ... >> +---------------------------------------------------------------+ >> |   0x4005d7
         push   %rbp                         | >> |   0x4005d8        mov    %rsp,%rbp                    | >> |   0x4005db        mov    $0x4005fc,%edi               | >> |   0x4005e0        call   0x4004d0           | >> |   0x4005e5       mov    $0x0,%eax                    | >> |   0x4005ea       pop    %rbp                         | >> |   0x4005eb       ret                                 | >> |   0x4005ec <_fini>        sub    $0x8,%rsp                    | >> |   0x4005f0 <_fini+4>      add    $0x8,%rsp                    | >> +---------------------------------------------------------------+ >> ... >> >> A known problem with this approach is that the symbolic address can be >> very >> long, for instance when dealing with C++ symbols, with the result that >> the >> disassembled instruction is not visible unless the user scrolls to it. >> >> And after stepping the cursor position may be reset, again requiring >> scrolling. >> >> I've tried to address this in the following way. >> >> I've divided the window into 4 parts: >> - exec info string >> - numeric address >> - symbolic address >> - disassembled instruction >> >> First, we decide which parts will be shown, depending on the available >> width. >> >> In the minimal case, we have: >> - exec info string >> - disassembled instruction >> >> With a bit more space available, we have: >> - exec info string >> - numeric address >> - disassembled instruction >> >> And with yet a bit more space available, we have the current layout >> with all 4 >> parts. >> >> [ Note that this is similar to how the status line is handled. ] >> >> In the latter case, after reserving space for the exec info string and >> the >> numeric address, the remaining space is divided between the symbolic >> address >> and the disassembled instruction. >> >> If the available space for the symbolic address is insufficient, the >> symbolic >> address is abbreviated. >> >> If the available space for the disassembled instruction is >> insufficient, it's >> truncated at the end, as is the case currently. >> >> Without this patch, with the example from PR tui/25347, we have: >> ... >> +---------------------------------------------------------------+ >> |   0x401697 <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |   0x401698 <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |   0x40169b <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |   0x40169f <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |B+>0x4016a3 <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |   0x4016a7 <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |   0x4016ab <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |   0x4016af <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> |   0x4016b2 <_Z3fooN5boost5units8quantityINS0_4unitINS0_4listIN| >> +---------------------------------------------------------------+ >> ... >> and with this patch we have instead: >> ... >> +---------------------------------------------------------------+ >> |   0x401697 push   %rbp                                        | >> |   0x401698 mov    %rsp,%rbp                                   | >> |   0x40169b sub    $0x20,%rsp                                  | >> |   0x40169f mov    %rdi,-0x18(%rbp)                            | >> |B+>0x4016a3 lea    -0x8(%rbp),%rax                             | >> |   0x4016a7 mov    -0x18(%rbp),%rdx                            | >> |   0x4016ab mov    -0x18(%rbp),%rcx                            | >> |   0x4016af mov    %rcx,%rsi                                   | >> |   0x4016b2 mov    %rax,%rdi                                   | >> +---------------------------------------------------------------+ >> ... >> and after resizing that to a bit more lines and columns: >> ... >> +-----------------------------------------------------------------------------+ >> |   0x401697 <_Z3fooN5b...EEEvEEdEE>           push >> %rbp                    | >> |   0x401698 <_Z3fooN5b...EEEvEEdEE+1>         mov    %rsp, >> %rbp               | >> |   0x40169b <_Z3fooN5b...EEEvEEdEE+4>         sub    $0x20, >> %rsp              | >> |   0x40169f <_Z3fooN5b...EEEvEEdEE+8>         mov >> %rdi,-0x18(%rbp)        | >> |B+>0x4016a3 <_Z3fooN5b...EEEvEEdEE+12>        lea    -0x8(%rbp), >> %rax         | >> |   0x4016a7 <_Z3fooN5b...EEEvEEdEE+16>        mov    -0x18(%rbp), >> %rdx        | >> |   0x4016ab <_Z3fooN5b...EEEvEEdEE+20>        mov    -0x18(%rbp), >> %rcx        | >> |   0x4016af <_Z3fooN5b...EEEvEEdEE+24>        mov    %rcx, >> %rsi               | >> |   0x4016b2 <_Z3fooN5b...EEEvEEdEE+27>        mov    %rax, >> %rdi               | >> |   0x4016b5 <_Z3fooN5b...EEEvEEdEE+30>        call   0x403bd7 >> <_ZN5boost5unit| >> |   0x4016ba <_Z3fooN5b...EEEvEEdEE+35>        lea    -0x8(%rbp), >> %rax         | >> |   0x4016be <_Z3fooN5b...EEEvEEdEE+39>        mov    %rax, >> %rsi               | >> +-----------------------------------------------------------------------------+ >> ... >> >> The patch uses 2 hardcoded constants: >> - const size_t min_sym_addr_size = 30 >> - const size_t min_insn_size = 30 >> to choose which parts will be shown. >> >> The patch also uses the hardcoded 50/50 ratio to divide space between the >> symbolic address and the disassembled instruction parts, in case >> they're both >> used. >> > > Hmm, I did: > ... > $ echo $COLUMNS > 94 > $ echo $LINES > 26 > $ gdb -q  build/gdb/gdb -ex "b captured_main_1" -ex "layout asm" -ex run > ... > and got: > ... > │   0xb75847 sub    $0x218,%rsp >                     │ > │   0xb7584e          mov > %rdi,-0x228(%rbp)               │ > ... > so clearly there's some bug in the patch.  Both lines are in the same > function, so either both should abbreviate, or both should not. > I've fixed this in a v2 ( https://sourceware.org/pipermail/gdb-patches/2025-August/219701.html ). Thanks, - Tom >> Tested on x86_64-linux. >> >> There was one update required in the TUI testsuite due to this failure: >> ... >> FAIL: gdb.tui/new-layout.exp: \ >>    layout=h {{-horizontal asm 1 src 1} 1 status 0 cmd 1} \ >>    {{0 0 40 15} {39 0 41 15}} {0x[0-9A-Fa-f]+
.*21.*return 0}: \ >>    contents in layout h >> ... >> where using a small asm window now means that the address and the >> symbolic >> address are no longer there: >> ... >>      0 +--------------------------------------+ >>      1 |   push   %rbp                        | >>      2 |   mov    %rsp,%rbp                   | >>      3 |   mov    $0x0,%eax                   | >>      4 |   pop    %rbp                        | >>      5 |   ret                                | >>      6 |                                      | >>      7 |                                      | >>      8 |                                      | >>      9 |                                      | >>     10 |                                      | >>     11 |                                      | >>     12 |                                      | >>     13 |                                      | >>     14 +--------------------------------------+ >> ... >> --- >>   gdb/defs.h                           |  3 + >>   gdb/printcmd.c                       | 80 +++++++++++++++++++++++++ >>   gdb/testsuite/gdb.tui/new-layout.exp |  2 +- >>   gdb/tui/tui-disasm.c                 | 88 ++++++++++++++++++++++------ >>   4 files changed, 153 insertions(+), 20 deletions(-) >> >> diff --git a/gdb/defs.h b/gdb/defs.h >> index bb1e11925da..569bc4f88ac 100644 >> --- a/gdb/defs.h >> +++ b/gdb/defs.h >> @@ -209,6 +209,9 @@ extern int print_address_symbolic (struct gdbarch >> *, CORE_ADDR, >>                      struct ui_file *, int, >>                      const char *); >> +extern int print_address_symbolic_maxlen (struct gdbarch *, CORE_ADDR, >> +                      struct ui_file *, int, int); >> + >>   extern void print_address (struct gdbarch *, CORE_ADDR, struct >> ui_file *); >>   extern const char *pc_prefix (CORE_ADDR); >> diff --git a/gdb/printcmd.c b/gdb/printcmd.c >> index 19fbc20074e..2857ee02ed9 100644 >> --- a/gdb/printcmd.c >> +++ b/gdb/printcmd.c >> @@ -56,6 +56,7 @@ >>   #include >>   #include "gdbsupport/gdb-safe-ctype.h" >>   #include "inferior.h" >> +#include >>   /* Chain containing all defined memory-tag subcommands.  */ >> @@ -591,6 +592,85 @@ print_address_symbolic (struct gdbarch *gdbarch, >> CORE_ADDR addr, >>     return 1; >>   } >> +/* Return the number of digits required to display COUNT in decimal.  */ >> + >> +static int >> +index_digits (unsigned int count) >> +{ >> +  return ((int) log10 ((double) count)) + 1; >> +} >> + >> +/* Optionally print address ADDR symbolically as on >> STREAM, >> +   using not more than MAX chars, possibly abbreviating SYMBOL. >> +   Print nothing if no symbolic name is found nearby. >> +   DO_DEMANGLE controls whether to print a symbol in its native "raw" >> form, >> +   or to interpret it as a possible C++ name and convert it back to >> source >> +   form.  However note that DO_DEMANGLE can be overridden by the >> specific >> +   settings of the demangle and asm_demangle variables.  Returns >> +   non-zero if anything was printed; zero otherwise.  */ >> + >> +int >> +print_address_symbolic_maxlen (struct gdbarch *gdbarch, CORE_ADDR addr, >> +                   struct ui_file *stream, >> +                   int do_demangle, int max) >> +{ >> +  std::string name, filename; >> +  int unmapped = 0; >> +  int offset = 0; >> +  int line = 0; >> + >> +  if (build_address_symbolic (gdbarch, addr, do_demangle, false, &name, >> +                  &offset, &filename, &line, &unmapped)) >> +    return 0; >> + >> +  /* Count "<**> or "<>".  */ >> +  max -= unmapped ? 4 : 2; >> +  /* Count offset.  */ >> +  max -= index_digits (max_symbolic_offset); >> + >> +  bool do_abbrev = false; >> +  if (strlen (name.c_str ()) > max) >> +    { >> +      /* If we don't have at least 3 chars on either size of the >> "...", we >> +     consider there's not enough space.  */ >> +      if (max < 9) >> +    return 0; >> + >> +      do_abbrev = true; >> +    } >> + >> +  if (unmapped) >> +    gdb_puts ("<*", stream); >> +  else >> +    gdb_puts ("<", stream); >> + >> +  if (do_abbrev) >> +    { >> +      max -= 3; >> +      int start_len = max / 2 + max % 2; >> +      int end_len = max / 2 + max % 2; >> + >> +      fputs_styled (name.substr (0, start_len).c_str (), >> +            function_name_style.style (), stream); >> + >> +      fputs_styled ("...", function_name_style.style (), stream); >> + >> +      fputs_styled (name.c_str () + strlen (name.c_str ()) - end_len, >> +            function_name_style.style (), stream); >> +    } >> +  else >> +    fputs_styled (name.c_str (), function_name_style.style (), stream); >> + >> +  if (offset != 0) >> +    gdb_printf (stream, "%+d", offset); >> +  if (unmapped) >> +    gdb_puts ("*>", stream); >> +  else >> +    gdb_puts (">", stream); >> + >> +  return 1; >> +} >> + >>   /* See valprint.h.  */ >>   int >> diff --git a/gdb/testsuite/gdb.tui/new-layout.exp b/gdb/testsuite/ >> gdb.tui/new-layout.exp >> index f5179973e5b..355ab2bf80a 100644 >> --- a/gdb/testsuite/gdb.tui/new-layout.exp >> +++ b/gdb/testsuite/gdb.tui/new-layout.exp >> @@ -70,7 +70,7 @@ set layouts \ >>             {{0 0 80 15}} ""] \ >>        [list h "{-horizontal asm 1 src 1} 1 status 0 cmd 1" \ >>             {{0 0 40 15} {39 0 41 15}} \ >> -          "$hex
.*21.*return 0"] \ >> +          "21.*return 0"] \ >>        [list example3 "{-horizontal src 1 cmd 1} 1 status 0 asm 1" \ >>             {{0 0 40 11} {0 12 80 12}} \ >>             "21.*return 0.*$hex
"] \ >> diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c >> index 627f71cb366..85aae4eedea 100644 >> --- a/gdb/tui/tui-disasm.c >> +++ b/gdb/tui/tui-disasm.c >> @@ -44,6 +44,8 @@ struct tui_asm_line >>     CORE_ADDR addr; >>     std::string addr_string; >>     size_t addr_size; >> +  std::string sym_addr_string; >> +  size_t sym_addr_size; >>     std::string insn; >>   }; >> @@ -80,6 +82,11 @@ len_without_escapes (const std::string &str) >>     return len; >>   } >> +extern int >> +print_address_symbolic_maxlen (struct gdbarch *gdbarch, CORE_ADDR addr, >> +                   struct ui_file *stream, >> +                   int do_demangle, int max); >> + >>   /* 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. >> @@ -129,20 +136,23 @@ tui_disassemble (struct gdbarch *gdbarch, >>         /* And capture the address the instruction is at.  */ >>         tal.addr = orig_pc; >> -      print_address (gdbarch, orig_pc, &gdb_dis_out); >> +      fputs_styled (paddress (gdbarch, tal.addr), address_style.style >> (), >> +            &gdb_dis_out); >>         tal.addr_string = gdb_dis_out.release (); >> +      tal.addr_size = (term_out >> +               ? len_without_escapes (tal.addr_string) >> +               : tal.addr_string.size ()); >> + >> +      /* And capture the symbolic address the instruction is at.  */ >> +      print_address_symbolic (gdbarch, orig_pc, &gdb_dis_out, >> +                  asm_demangle, ""); >> +      tal.sym_addr_string = gdb_dis_out.release (); >> +      tal.sym_addr_size = (term_out >> +               ? len_without_escapes (tal.sym_addr_string) >> +               : tal.sym_addr_string.size ()); >>         if (addr_size != nullptr) >> -    { >> -      size_t new_size; >> - >> -      if (term_out) >> -        new_size = len_without_escapes (tal.addr_string); >> -      else >> -        new_size = tal.addr_string.size (); >> -      *addr_size = std::max (*addr_size, new_size); >> -      tal.addr_size = new_size; >> -    } >> +    *addr_size = std::max (*addr_size, tal.addr_size); >>         asm_lines.push_back (std::move (tal)); >>       } >> @@ -321,8 +331,6 @@ tui_disasm_window::set_contents (struct gdbarch >> *arch, >>     int i; >>     int max_lines; >>     CORE_ADDR cur_pc; >> -  int tab_len = tui_tab_width; >> -  int insn_pos; >>     CORE_ADDR pc = sal.pc; >>     if (pc == 0) >> @@ -341,10 +349,26 @@ tui_disasm_window::set_contents (struct gdbarch >> *arch, >>     size_t addr_size = 0; >>     tui_disassemble (m_gdbarch, asm_lines, pc, max_lines, &addr_size); >> -  /* Align instructions to the same column.  */ >> -  insn_pos = (1 + (addr_size / tab_len)) * tab_len; >> +  const size_t min_sym_addr_size = 30; >> +  const size_t min_insn_size = 30; >> + >> +  size_t sym_addr_size = 0; >> +  bool have_addr = false; >> +  bool have_sym_addr = false; >> +  int avail_width = width - box_size () - TUI_EXECINFO_SIZE; >> +  if (avail_width >= addr_size + 1 + min_sym_addr_size + 1 + >> min_insn_size) >> +    { >> +      have_addr = true; >> +      have_sym_addr = true; >> +      sym_addr_size = (avail_width - addr_size) / 2; >> +    } >> +  else if (avail_width >= addr_size + 1 + min_insn_size) >> +    have_addr = true; >>     /* Now construct each line.  */ >> +  bool term_out >> +    = disassembler_styling && gdb_stdout->can_emit_style_escape (); >> +  string_file gdb_dis_out (term_out); >>     m_content.resize (max_lines); >>     m_max_length = -1; >>     for (i = 0; i < max_lines; i++) >> @@ -356,10 +380,36 @@ tui_disasm_window::set_contents (struct gdbarch >> *arch, >>         if (i < asm_lines.size ()) >>       { >> -      line >> -        = (asm_lines[i].addr_string >> -           + n_spaces (insn_pos - asm_lines[i].addr_size) >> -           + asm_lines[i].insn); >> +      if (have_sym_addr && asm_lines[i].sym_addr_size <= sym_addr_size) >> +        line >> +          = (asm_lines[i].addr_string >> +         + " " >> +         + asm_lines[i].sym_addr_string >> +         + n_spaces (sym_addr_size - asm_lines[i].sym_addr_size) >> +         + " " >> +         + asm_lines[i].insn); >> +      else if (have_sym_addr) >> +        { >> +          print_address_symbolic_maxlen (m_gdbarch, asm_lines[i].addr, >> +                         &gdb_dis_out, asm_demangle, >> +                         sym_addr_size); >> +          std::string abbrev = gdb_dis_out.release (); >> +          int abbrev_len = (term_out >> +                ? len_without_escapes (abbrev) >> +                : abbrev.size ()); >> +          line >> +        = (asm_lines[i].addr_string >> +           + " " >> +           + abbrev >> +           + n_spaces (sym_addr_size - abbrev_len) >> +           + " " >> +           + asm_lines[i].insn); >> +        } >> +      else if (have_addr) >> +        line = asm_lines[i].addr_string + " " + asm_lines[i].insn; >> +      else >> +        line = asm_lines[i].insn; >> + >>         addr = asm_lines[i].addr; >>       } >>         else >> >> base-commit: 891d1654d7314fa520f708dbc5f1bf855d15bd40 >