diff -urN oldgdb/gdb/defs.h newgdb/gdb/defs.h --- oldgdb/gdb/defs.h Thu Aug 1 20:18:32 2002 +++ newgdb/gdb/defs.h Fri Mar 28 05:02:00 2003 @@ -549,7 +549,7 @@ extern void set_next_address (CORE_ADDR); -extern void print_address_symbolic (CORE_ADDR, struct ui_file *, int, +extern unsigned int print_address_symbolic (CORE_ADDR, struct ui_file *, int, char *); extern int build_address_symbolic (CORE_ADDR addr, @@ -562,7 +562,7 @@ extern void print_address_numeric (CORE_ADDR, int, struct ui_file *); -extern void print_address (CORE_ADDR, struct ui_file *); +extern unsigned int print_address (CORE_ADDR, struct ui_file *); /* From source.c */ diff -urN oldgdb/gdb/printcmd.c newgdb/gdb/printcmd.c --- oldgdb/gdb/printcmd.c Thu Jul 11 23:46:19 2002 +++ newgdb/gdb/printcmd.c Fri Mar 28 05:50:41 2003 @@ -543,7 +543,8 @@ form. However note that DO_DEMANGLE can be overridden by the specific settings of the demangle and asm_demangle variables. */ -void +/* Return the number of characters took-up by the offset. */ +unsigned int print_address_symbolic (CORE_ADDR addr, struct ui_file *stream, int do_demangle, char *leadin) { @@ -552,7 +553,9 @@ int unmapped = 0; int offset = 0; int line = 0; - + unsigned int aux; /* auxiliary var used to compute the value to store in chars */ + unsigned int chars = 0; /* number of chars used for the offset */ + /* throw away both name and filename */ struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &name); make_cleanup (free_current_contents, &filename); @@ -560,7 +563,7 @@ if (build_address_symbolic (addr, do_demangle, &name, &offset, &filename, &line, &unmapped)) { do_cleanups (cleanup_chain); - return; + return 0; } fputs_filtered (leadin, stream); @@ -569,9 +572,22 @@ else fputs_filtered ("<", stream); fputs_filtered (name, stream); - if (offset != 0) - fprintf_filtered (stream, "+%u", (unsigned int) offset); - + if (offset != 0) + { + /* This is for the '+' in "+%u" */ + chars++; + fprintf_filtered (stream, "+%u", (unsigned int) offset); + /* Compute the number of characters took-up by offset. */ + aux = offset; + while(aux /= 10) + chars++; + chars++; + } + else + /* offset took-up 0 characters, because we don't print anything in this case. */ + chars = 0; + + /* Append source filename and line number if desired. Give specific line # of this addr, if we have it; else line # of the nearest symbol. */ if (print_symbol_filename && filename != NULL) @@ -587,6 +603,7 @@ fputs_filtered (">", stream); do_cleanups (cleanup_chain); + return chars; } /* Given an address ADDR return all the elements needed to print the @@ -747,11 +764,14 @@ First print it as a number. Then perhaps print after the number. */ -void +/* Return the number of characters took-up by the offset in print_address_symbolic. + We use this in disassemble_command for correct text alignment. */ +unsigned int print_address (CORE_ADDR addr, struct ui_file *stream) { print_address_numeric (addr, 1, stream); - print_address_symbolic (addr, stream, asm_demangle, " "); + /* Return the number of characters took-up by the offset. */ + return print_address_symbolic (addr, stream, asm_demangle, " "); } /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE @@ -2276,6 +2296,7 @@ char *name; CORE_ADDR pc, pc_masked; char *space_index; + unsigned int more_spaces; /* the number of extra characters for printing the offset in print_address_symbolic */ #if 0 asection *section; #endif @@ -2345,8 +2366,16 @@ while (pc_masked < high) { QUIT; - print_address (pc_masked, gdb_stdout); - printf_filtered (":\t"); + /* Get the number of extra characters used by the offset on this line. */ + more_spaces = print_address (pc_masked, gdb_stdout); + /* We allow for maximum 8 extra characters - adjust this how you see fit. */ + more_spaces = 8 - more_spaces; + + printf_filtered(": "); + /* We print the extra spaces needed for this line so that we get a correct alignment. */ + while(more_spaces--) + printf_filtered(" "); + /* We often wrap here if there are long symbolic names. */ wrap_here (" "); pc += print_insn (pc, gdb_stdout);