Re: [RFC][patch] Allow to disassemble line.

Paul Pluzhnikov
2009-10-19T18:20:09Z

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

On Mon, Oct 19, 2009 at 11:09 AM, Paul Pluzhnikov
<ppluzhnikov@google.com> wrote:

> Doing it the way you suggesed simplifies it a bit :-)

The one-line print_pc_prefix() with a single caller doesn't really buy
anything either. Eliminated.

Thanks,
--
Paul Pluzhnikov

2009-10-19 Paul Pluzhnikov <ppluzhnikov@google.com>

* defs.h (pc_prefix): New prototype.
* disasm.c (dump_insns): Mark current instruction.
* printcmd.c (do_examine): Likewise.
(pc_prefix): New function.
* stack.c (print_frame_info): Disassemble entire current line.

[-- Attachment #2: gdb-disas-20091019-2.txt --]
[-- Type: text/plain, Size: 3087 bytes --]

Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.256
diff -u -p -u -r1.256 defs.h
--- defs.h 19 Oct 2009 09:51:40 -0000 1.256
+++ defs.h 19 Oct 2009 18:16:51 -0000
@@ -608,6 +608,7 @@ extern int build_address_symbolic (CORE_
int *unmapped);

extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *);
+extern const char *pc_prefix (CORE_ADDR);

/* From source.c */

Index: disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/disasm.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 disasm.c
--- disasm.c 11 Jul 2009 14:04:23 -0000 1.33
+++ disasm.c 19 Oct 2009 18:16:51 -0000
@@ -113,6 +113,7 @@ dump_insns (struct gdbarch *gdbarch, str
num_displayed++;
}
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ ui_out_text (uiout, pc_prefix (pc));
ui_out_field_core_addr (uiout, "address", gdbarch, pc);

if (!build_address_symbolic (pc, 0, &name, &offset, &filename,
Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.165
diff -u -p -u -r1.165 printcmd.c
--- printcmd.c 19 Oct 2009 09:51:41 -0000 1.165
+++ printcmd.c 19 Oct 2009 18:16:51 -0000
@@ -725,6 +725,26 @@ print_address (struct gdbarch *gdbarch,
print_address_symbolic (addr, stream, asm_demangle, " ");
}

+/* Return a prefix for instruction address:
+ "=> " for current instruction, else " ". */
+
+const char *
+pc_prefix (CORE_ADDR addr)
+{
+ if (has_stack_frames ())
+ {
+ struct frame_info *frame;
+ CORE_ADDR pc;
+
+ frame = get_selected_frame (NULL);
+ pc = get_frame_pc (frame);
+
+ if (pc == addr)
+ return "=> ";
+ }
+ return " ";
+}
+
/* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
controls whether to print the symbolic name "raw" or demangled.
Global setting "addressprint" controls whether to print hex address
@@ -817,6 +837,8 @@ do_examine (struct format_data fmt, stru
while (count > 0)
{
QUIT;
+ if (format == 'i')
+ fputs_filtered (pc_prefix (next_address), gdb_stdout);
print_address (next_gdbarch, next_address, gdb_stdout);
printf_filtered (":");
for (i = maxelts;
Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.208
diff -u -p -u -r1.208 stack.c
--- stack.c 19 Oct 2009 09:51:42 -0000 1.208
+++ stack.c 19 Oct 2009 18:16:51 -0000
@@ -643,8 +643,7 @@ print_frame_info (struct frame_info *fra
/* If disassemble-next-line is set to on and there is line debug
messages, output assembly codes for next line. */
if (disassemble_next_line == AUTO_BOOLEAN_TRUE)
- do_gdb_disassembly (get_frame_arch (frame), -1,
- get_frame_pc (frame), sal.end);
+ do_gdb_disassembly (get_frame_arch (frame), -1, sal.pc, sal.end);
}

if (print_what != LOCATION)