This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Why does ui_out_field_core_addr pad with leading zeroes?


On Thu, Mar 18, 2010 at 12:25 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Thu, 18 Mar 2010 20:19:11 +0100, Doug Evans wrote:
>> Having stared at both alignments, I don't see aligning the address to
>> the right as being easier to read than aligning them to the left, and
>> even less so.
>>
>> Right Aligned
>>
>> (gdb) i b
>> Num ? ? Type ? ? ? ? ? Disp Enb ? ? ? ? ? ?Address What
>> 2 ? ? ? breakpoint ? ? keep y ? ? ? ? ? ? 0x40049c in main at hello.c:6
>> 3 ? ? ? breakpoint ? ? keep y ? ? ? 0x7ffff7acbe40 <printf>
>> (gdb)
>>
>> Left Aligned
>>
>> (gdb) i b
>> Num ? ? Type ? ? ? ? ? Disp Enb Address ? ? ? ? ? ?What
>> 2 ? ? ? breakpoint ? ? keep y ? 0x40049c ? ? ? ? ? in main at hello.c:6
>> 3 ? ? ? breakpoint ? ? keep y ? 0x7ffff7acbe40 ? ? <printf>
>> (gdb)
>
> I am definitely for the "Right Aligned" one and against the "Left Aligned"
> one. ?While analyzing various crash dumps one looks for the same last three
> digits (ignoring PIC/PIE different PAGE_SIZE-aligned placement). ?Also
> sometimes sorting addresses from various sources by hand to find out the
> memory layout and having to additionally re-align even the GDB dump itself is
> not helpful.

[It seemed like ui-out should make this easy, and voila.]

2010-03-18  Doug Evans  <dje@google.com>

        * ui-out.c (ui_out_field_core_addr): Don't pad address with leading
        zeroes.
        * breakpoint.c (breakpoint_1): Right align breakpoint addresses.

Index: ui-out.c
===================================================================
RCS file: /cvs/src/src/gdb/ui-out.c,v
retrieving revision 1.45
diff -u -p -r1.45 ui-out.c
--- ui-out.c    12 Jan 2010 21:40:24 -0000      1.45
+++ ui-out.c    18 Mar 2010 17:19:07 -0000
@@ -498,12 +498,8 @@ ui_out_field_core_addr (struct ui_out *u
     address &= ((CORE_ADDR) 1 << addr_bit) - 1;

   /* FIXME: cagney/2002-05-03: Need local_address_string() function
-     that returns the language localized string formatted to a width
-     based on gdbarch_addr_bit.  */
-  if (addr_bit <= 32)
-    strcpy (addstr, hex_string_custom (address, 8));
-  else
-    strcpy (addstr, hex_string_custom (address, 16));
+     that returns the language localized string.  */
+  strcpy (addstr, hex_string (address));

   ui_out_field_string (uiout, fldname, addstr);
 }
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.462
diff -u -p -r1.462 breakpoint.c
--- breakpoint.c        16 Mar 2010 08:42:20 -0000      1.462
+++ breakpoint.c        18 Mar 2010 19:35:08 -0000
@@ -4743,9 +4743,9 @@ breakpoint_1 (int bnum, int allflag)
          if (nr_printable_breakpoints > 0)
            annotate_field (4);
          if (print_address_bits <= 32)
-           ui_out_table_header (uiout, 10, ui_left, "addr", "Address");/* 5 */
+           ui_out_table_header (uiout, 10, ui_right, "addr", "Address");/* 5 */
          else
-           ui_out_table_header (uiout, 18, ui_left, "addr", "Address");/* 5 */
+           ui_out_table_header (uiout, 18, ui_right, "addr", "Address");/* 5 */
        }
   if (nr_printable_breakpoints > 0)
     annotate_field (5);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]