From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99671 invoked by alias); 23 Jul 2017 06:38:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 99608 invoked by uid 89); 23 Jul 2017 06:38:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=aligning X-HELO: mail-lf0-f45.google.com Received: from mail-lf0-f45.google.com (HELO mail-lf0-f45.google.com) (209.85.215.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Jul 2017 06:38:09 +0000 Received: by mail-lf0-f45.google.com with SMTP id t128so4612933lff.2 for ; Sat, 22 Jul 2017 23:38:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IV3hEgx1FPSIsO6q8hsUUILuu2K7iDwKq1YUohxpLlA=; b=YGhU0GT81pHAiiJSLjtCj4lvyiz8H01QDq6igCP/wwwZBoA++Z6XkzpaAbBMN/Kbpm KHCahvZYaep/oeaCFhyTe+Bla9WUBYQYnTQXh79Re3DBu9YzoFy4zpHkgHPIvP0bg89/ +Li058CqBDRuW7w05vl4dhLwRgzfaxyvgHxf+aBs/FFHz70nCvS/Uytm5sKiaZ8FO9jg XR5V9ITOHkQ2I96L8J5hCGdYVPBCXP9SemKVuCwzZFAaQ5MuB1oxi5DnEGP0tYDI/InV 6l7CbD6Ls1su+3xkAZ1s6dBHnEk80Zr8vg1tnsj0oMRm04nqZa6LXSKCUJmE/+6jZrpC tqBA== X-Gm-Message-State: AIVw1132w57sDf/X9mn2dFYmbKAsF2yAwvfgDg4EVMBGiVGkZXDA5Sn+ 9qUaufHnxfbpWFx2aQ8= X-Received: by 10.46.82.88 with SMTP id g85mr4280248ljb.123.1500791886768; Sat, 22 Jul 2017 23:38:06 -0700 (PDT) Received: from [192.168.0.204] ([91.215.122.25]) by smtp.gmail.com with ESMTPSA id g133sm1712208lfe.40.2017.07.22.23.38.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Jul 2017 23:38:05 -0700 (PDT) Subject: [PING][PATCH] Align natural-format register values to the same column To: gdb-patches@sourceware.org References: <1499607122-11131-1-git-send-email-b7.10110111@gmail.com> From: Ruslan Kabatsayev Message-ID: Date: Sun, 23 Jul 2017 06:38:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1499607122-11131-1-git-send-email-b7.10110111@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00336.txt.bz2 On 09/07/17 16:32, Ruslan Kabatsayev wrote: > Currently, commands such as "info reg", "info all-reg", as well as register > window in the TUI print badly aligned columns, like here: > > eax 0x1 1 > ecx 0xffffd3e0 -11296 > edx 0xffffd404 -11260 > ebx 0xf7fa5ff4 -134586380 > esp 0xffffd390 0xffffd390 > ebp 0xffffd3c8 0xffffd3c8 > esi 0x0 0 > edi 0x0 0 > eip 0x8048b60 0x8048b60 > eflags 0x286 [ PF SF IF ] > cs 0x23 35 > ss 0x2b 43 > ds 0x2b 43 > es 0x2b 43 > fs 0x0 0 > gs 0x63 99 > > After this patch, these commands print the third column values consistently > aligned one under another, provided the second column is not too long. > Originally, the third column was (attempted to be) aligned using a simple tab > character. Lots of tests in the test suite check for it, so this patch retains > the tab in the output after the second column. This allows these tests to > continue working unchanged. What is different is that now the tab may be > followed by several spaces, which complete the task of aligning the third > column when the sole tab doesn't work well. > > gdb/ChangeLog: > > * infcmd.c (default_print_one_register_info): Align natural- > format column value consistently one after another. > --- > gdb/infcmd.c | 27 ++++++++++++++++++--------- > 1 file changed, 18 insertions(+), 9 deletions(-) > > diff --git a/gdb/infcmd.c b/gdb/infcmd.c > index defa7b0..5de4e68 100644 > --- a/gdb/infcmd.c > +++ b/gdb/infcmd.c > @@ -2280,9 +2280,10 @@ default_print_one_register_info (struct ui_file *file, > { > struct type *regtype = value_type (val); > int print_raw_format; > + string_file format_stream; > > - fputs_filtered (name, file); > - print_spaces_filtered (15 - strlen (name), file); > + format_stream.puts (name); > + format_stream.puts (n_spaces (15 - strlen (name))); > > print_raw_format = (value_entirely_available (val) > && !value_optimized_out (val)); > @@ -2301,14 +2302,18 @@ default_print_one_register_info (struct ui_file *file, > > val_print (regtype, > value_embedded_offset (val), 0, > - file, 0, val, &opts, current_language); > + &format_stream, 0, val, &opts, current_language); > > if (print_raw_format) > { > - fprintf_filtered (file, "\t(raw "); > - print_hex_chars (file, valaddr, TYPE_LENGTH (regtype), byte_order, > + const int size_with_tab = format_stream.size () / 8 * 8 + 8; > + format_stream.putc ('\t'); > + if (size_with_tab < 32) > + format_stream.puts (n_spaces (32 - size_with_tab)); > + format_stream.puts ("(raw "); > + print_hex_chars (&format_stream, valaddr, TYPE_LENGTH (regtype), byte_order, > true); > - fprintf_filtered (file, ")"); > + format_stream.puts (")"); > } > } > else > @@ -2320,20 +2325,24 @@ default_print_one_register_info (struct ui_file *file, > opts.deref_ref = 1; > val_print (regtype, > value_embedded_offset (val), 0, > - file, 0, val, &opts, current_language); > + &format_stream, 0, val, &opts, current_language); > /* If not a vector register, print it also according to its > natural format. */ > if (print_raw_format && TYPE_VECTOR (regtype) == 0) > { > + const int size_with_tab = format_stream.size () / 8 * 8 + 8; > + format_stream.putc ('\t'); > + if (size_with_tab < 32) > + format_stream.puts (n_spaces (32 - size_with_tab)); > get_user_print_options (&opts); > opts.deref_ref = 1; > - fprintf_filtered (file, "\t"); > val_print (regtype, > value_embedded_offset (val), 0, > - file, 0, val, &opts, current_language); > + &format_stream, 0, val, &opts, current_language); > } > } > > + fputs_filtered (format_stream.c_str (), file); > fprintf_filtered (file, "\n"); > } > >