Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC][patch] Allow to disassemble line.
Date: Mon, 19 Oct 2009 18:09:00 -0000	[thread overview]
Message-ID: <8ac60eac0910191109v62794c33g6712090912b5c11f@mail.gmail.com> (raw)
In-Reply-To: <m38wf78edn.fsf@fleche.redhat.com>

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

On Mon, Oct 19, 2009 at 10:47 AM, Tom Tromey <tromey@redhat.com> wrote:

> Why not directly call ui_out_text in dump_insns?

I am not sure how I arrived at the proposed patch ...
Doing it the way you suggesed simplifies it a bit :-)

I've also changed the "current PC marker" from "* " to "=> " (as Eli
suggested), so the output looks like this:

(top) disas
Dump of assembler code for function gdb_main:
   0x0000000000454c9e <gdb_main+0>:     push   %rbp
   0x0000000000454c9f <gdb_main+1>:     mov    %rsp,%rbp
   0x0000000000454ca2 <gdb_main+4>:     sub    $0x10,%rsp
   0x0000000000454ca6 <gdb_main+8>:     mov    %rdi,-0x8(%rbp)
=> 0x0000000000454caa <gdb_main+12>:    mov    -0x8(%rbp),%rax
   0x0000000000454cae <gdb_main+16>:    mov    0x10(%rax),%eax
   0x0000000000454cb1 <gdb_main+19>:    mov    %eax,0x678475(%rip) #
0xacd12c <use_windows>


This patch still lacks documentation and test case updates. I'll work up
the complete patch if this one is OK.

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, print_pc_prefix): New function.
       * stack.c (print_frame_info): Disassemble entire current line.

[-- Attachment #2: gdb-disas-20091019.txt --]
[-- Type: text/plain, Size: 3201 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:08:37 -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:08:37 -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:08:37 -0000
@@ -725,6 +725,32 @@ 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 "   ";
+}
+
+static void
+print_pc_prefix (CORE_ADDR addr, struct ui_file *stream)
+{
+  fputs_filtered (pc_prefix (addr), stream);
+}
+
 /* 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 +843,8 @@ do_examine (struct format_data fmt, stru
   while (count > 0)
     {
       QUIT;
+      if (format == 'i')
+	print_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:08:37 -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)

  reply	other threads:[~2009-10-19 18:09 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-02  0:50 Paul Pluzhnikov
2009-10-02  6:52 ` Joel Brobecker
2009-10-02 18:31   ` Paul Pluzhnikov
2009-10-02 18:49     ` Joel Brobecker
2009-10-02 15:17 ` Tom Tromey
2009-10-08 16:16 ` Paul Pluzhnikov
2009-10-08 16:23   ` Daniel Jacobowitz
2009-10-08 16:25     ` Joel Brobecker
2009-10-08 16:52     ` Paul Pluzhnikov
2009-10-08 17:29       ` Daniel Jacobowitz
2009-10-08 17:33         ` Joel Brobecker
2009-10-16 23:07       ` Paul Pluzhnikov
2009-10-16 23:11         ` Paul Pluzhnikov
2009-10-17  8:33           ` Eli Zaretskii
2009-10-17 15:50             ` Paul Pluzhnikov
2009-10-17 16:49               ` Eli Zaretskii
2009-10-17 17:08                 ` Paul Pluzhnikov
2009-10-17 19:55                   ` Eli Zaretskii
2009-10-19 17:47         ` Tom Tromey
2009-10-19 18:09           ` Paul Pluzhnikov [this message]
2009-10-19 18:20             ` Paul Pluzhnikov
2009-10-19 18:30             ` Tom Tromey
2009-10-21  0:22               ` Paul Pluzhnikov
2009-10-21  4:07                 ` Eli Zaretskii
2009-10-21 18:06                   ` Paul Pluzhnikov
2009-10-21 18:16                     ` Eli Zaretskii
2009-10-21 17:24                 ` Tom Tromey
2009-10-19 18:49             ` Daniel Jacobowitz
2009-10-19 19:40               ` Joel Brobecker
2009-10-19 19:56                 ` Daniel Jacobowitz
2009-10-19 20:03                   ` Tom Tromey
2009-10-19 20:10                     ` Joel Brobecker
2009-10-19 20:23                       ` Paul Pluzhnikov
2009-10-19 20:47                         ` Daniel Jacobowitz
2009-10-19 19:40               ` Eli Zaretskii
2009-10-19 19:55                 ` Daniel Jacobowitz
2009-10-20 16:04               ` Tom Tromey
2009-10-08 16:24   ` Joel Brobecker
2009-10-08 17:16     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ac60eac0910191109v62794c33g6712090912b5c11f@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox