Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Tom Tromey <tromey@redhat.com>,
	gdb-patches@sourceware.org,
	        Paul Pluzhnikov <ppluzhnikov@google.com>
Subject: [patch] Omit function name when disassembling one function [Was: Re:  	[RFC][patch] Allow to disassemble line.]
Date: Wed, 21 Oct 2009 22:45:00 -0000	[thread overview]
Message-ID: <8ac60eac0910211545s143ae258s81b3a647c6873351@mail.gmail.com> (raw)

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

On Mon, Oct 19, 2009 at 1:23 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> On Mon, Oct 19, 2009 at 1:10 PM, Joel Brobecker <brobecker@adacore.com> wrote:
>
>> I really like the idea of not printing the name of the function
>> in the disassembly output, though.

> I can do that in a separate patch.

Here is proposed patch.
Tested on Linux/x86_64 with no regressions.

Thanks,
-- 
Paul Pluzhnikov

doc/ChangeLog:

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

	* gdb.texinfo (Machine Code): Mention function name in disasssembly
	and adjust example.

testsuite/ChangeLog:

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

	* gdb.asm/asm-source.exp: Adjust.

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

	* disasm.h (DISASSEMBLY_OMIT_FNAME) New define.
	(gdb_disassembly): Correct parameter name.
	* disasm.c (dump_insns): Adjust.
	(gdb_disassembly): Fix indentation.
	* cli/cli-cmds.c (disassemble_command): Adjust.

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

Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.635
diff -u -p -u -r1.635 gdb.texinfo
--- doc/gdb.texinfo	21 Oct 2009 18:02:26 -0000	1.635
+++ doc/gdb.texinfo	21 Oct 2009 22:37:41 -0000
@@ -6524,7 +6524,9 @@ The default memory range is the function
 program counter of the selected frame.  A single argument to this
 command is a program counter value; @value{GDBN} dumps the function
 surrounding this value.  Two arguments specify a range of addresses
-(first inclusive, second exclusive) to dump.
+(first inclusive, second exclusive) to dump.  In that case, the name of
+the function is also printed (since there could be several functions in
+the given range).
 
 If the range of memory being disassembled contains current program counter,
 the instruction at that location is shown with a @code{=>} marker.
@@ -6554,21 +6556,21 @@ program is stopped just after function p
 (@value{GDBP}) disas /m main
 Dump of assembler code for function main:
 5       @{
-   0x08048330 <main+0>:    push   %ebp
-   0x08048331 <main+1>:    mov    %esp,%ebp
-   0x08048333 <main+3>:    sub    $0x8,%esp
-   0x08048336 <main+6>:    and    $0xfffffff0,%esp
-   0x08048339 <main+9>:    sub    $0x10,%esp
+   0x08048330 <+0>:    push   %ebp
+   0x08048331 <+1>:    mov    %esp,%ebp
+   0x08048333 <+3>:    sub    $0x8,%esp
+   0x08048336 <+6>:    and    $0xfffffff0,%esp
+   0x08048339 <+9>:    sub    $0x10,%esp
 
 6         printf ("Hello.\n");
-=> 0x0804833c <main+12>:   movl   $0x8048440,(%esp)
-   0x08048343 <main+19>:   call   0x8048284 <puts@@plt>
+=> 0x0804833c <+12>:   movl   $0x8048440,(%esp)
+   0x08048343 <+19>:   call   0x8048284 <puts@@plt>
 
 7         return 0;
 8       @}
-   0x08048348 <main+24>:   mov    $0x0,%eax
-   0x0804834d <main+29>:   leave
-   0x0804834e <main+30>:   ret
+   0x08048348 <+24>:   mov    $0x0,%eax
+   0x0804834d <+29>:   leave
+   0x0804834e <+30>:   ret
 
 End of assembler dump.
 @end smallexample
Index: disasm.h
===================================================================
RCS file: /cvs/src/src/gdb/disasm.h,v
retrieving revision 1.13
diff -u -p -u -r1.13 disasm.h
--- disasm.h	11 Jul 2009 14:04:23 -0000	1.13
+++ disasm.h	21 Oct 2009 22:37:41 -0000
@@ -21,14 +21,14 @@
 
 #define DISASSEMBLY_SOURCE	(0x1 << 0)
 #define DISASSEMBLY_RAW_INSN	(0x1 << 1)
+#define DISASSEMBLY_OMIT_FNAME	(0x1 << 2)
 
 struct ui_out;
 struct ui_file;
 
 extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
-			     char *file_string,
-			     int mixed_source_and_assembly,
-			     int how_many, CORE_ADDR low, CORE_ADDR high);
+			     char *file_string, int flags, int how_many,
+			     CORE_ADDR low, CORE_ADDR high);
 
 /* Print the instruction at address MEMADDR in debugged memory,
    on STREAM.  Returns the length of the instruction, in bytes,
Index: disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/disasm.c,v
retrieving revision 1.34
diff -u -p -u -r1.34 disasm.c
--- disasm.c	21 Oct 2009 18:02:25 -0000	1.34
+++ disasm.c	21 Oct 2009 22:37:41 -0000
@@ -122,7 +122,8 @@ dump_insns (struct gdbarch *gdbarch, str
 	  /* We don't care now about line, filename and
 	     unmapped. But we might in the future. */
 	  ui_out_text (uiout, " <");
-	  ui_out_field_string (uiout, "func-name", name);
+	  if ((flags & DISASSEMBLY_OMIT_FNAME) == 0)
+	    ui_out_field_string (uiout, "func-name", name);
 	  ui_out_text (uiout, "+");
 	  ui_out_field_int (uiout, "offset", offset);
 	  ui_out_text (uiout, ">:\t");
@@ -373,9 +374,8 @@ gdb_disassemble_info (struct gdbarch *gd
 
 void
 gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
-		char *file_string,
-		int flags,
-		int how_many, CORE_ADDR low, CORE_ADDR high)
+		 char *file_string, int flags, int how_many,
+		 CORE_ADDR low, CORE_ADDR high)
 {
   struct ui_stream *stb = ui_out_stream_new (uiout);
   struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb);
Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.92
diff -u -p -u -r1.92 cli-cmds.c
--- cli/cli-cmds.c	11 Jul 2009 14:04:23 -0000	1.92
+++ cli/cli-cmds.c	21 Oct 2009 22:37:41 -0000
@@ -936,8 +936,7 @@ print_disassembly (struct gdbarch *gdbar
 }
 
 /* Subroutine of disassemble_command to simplify it.
-   Print a disassembly of the current function.
-   MIXED is non-zero to print source with the assembler.  */
+   Print a disassembly of the current function according to FLAGS.  */
 
 static void
 disassemble_current_function (int flags)
@@ -1018,6 +1017,7 @@ disassemble_command (char *arg, int from
 
   if (! arg || ! *arg)
     {
+      flags |= DISASSEMBLY_OMIT_FNAME;
       disassemble_current_function (flags);
       return;
     }
@@ -1039,6 +1039,7 @@ disassemble_command (char *arg, int from
 	low = tui_get_low_disassembly_address (gdbarch, low, pc);
 #endif
       low += gdbarch_deprecated_function_start_offset (gdbarch);
+      flags |= DISASSEMBLY_OMIT_FNAME;
     }
   else
     {
Index: testsuite/gdb.asm/asm-source.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
retrieving revision 1.74
diff -u -p -u -r1.74 asm-source.exp
--- testsuite/gdb.asm/asm-source.exp	18 May 2009 13:25:34 -0000	1.74
+++ testsuite/gdb.asm/asm-source.exp	21 Oct 2009 22:37:41 -0000
@@ -461,7 +461,7 @@ test_dis "x/i &staticvar" "staticvar"
 test_dis "disassem &staticvar &staticvar+1" "staticvar"
 
 # See if we can look at a static function
-gdb_test "disassem foostatic" ".*<foostatic\\+0>:.*End of assembler dump." \
+gdb_test "disassem foostatic" ".*<\\+0>:.*End of assembler dump." \
 	"look at static function"
 
 remote_exec build "rm -f ${subdir}/arch.inc"

             reply	other threads:[~2009-10-21 22:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-21 22:45 Paul Pluzhnikov [this message]
2009-10-22  4:04 ` Eli Zaretskii
2009-10-23  0:24 ` [patch] Omit function name when disassembling one function Tom Tromey
2009-10-23  0:51   ` Paul Pluzhnikov

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=8ac60eac0910211545s143ae258s81b3a647c6873351@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=brobecker@adacore.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