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: [patch] Allow "disassemble 'Foo::bar(char *)'"


On Mon, Nov 16, 2009 at 10:28 AM, Paul Pluzhnikov
<ppluzhnikov@google.com> wrote:

> Yes: I will look at parse_to_comma_and_eval() (Daniel's suggestion),
> and see if this all can be handled in backward-compatible manner.

It works, but I can't make it backward-compatible and not require a comma
for two-argument invocation :-(

This works:

(gdb) disas 'Foo::bar(char const*, char const*)'
Dump of assembler code for function _ZN3Foo3barEPKcS1_:
   0x000000000040055a <+0>:     push   %rbp
   0x000000000040055b <+1>:     mov    %rsp,%rbp
   0x000000000040055e <+4>:     mov    %rdi,-0x8(%rbp)
   0x0000000000400562 <+8>:     mov    %rsi,-0x10(%rbp)
   0x0000000000400566 <+12>:    mov    %rdx,-0x18(%rbp)
   0x000000000040056a <+16>:    leaveq
   0x000000000040056b <+17>:    retq
End of assembler dump.

(gdb) disas 0x40055a + 1
Dump of assembler code for function _ZN3Foo3barEPKcS1_:
   0x000000000040055a <+0>:     push   %rbp
   0x000000000040055b <+1>:     mov    %rsp,%rbp
   0x000000000040055e <+4>:     mov    %rdi,-0x8(%rbp)
   0x0000000000400562 <+8>:     mov    %rsi,-0x10(%rbp)
   0x0000000000400566 <+12>:    mov    %rdx,-0x18(%rbp)
   0x000000000040056a <+16>:    leaveq
   0x000000000040056b <+17>:    retq
End of assembler dump.

(gdb) disas 0x40055a + 1, 0x40055a + 5
Dump of assembler code from 0x40055b to 0x40055f:
   0x000000000040055b <_ZN3Foo3barEPKcS1_+1>:   mov    %rsp,%rbp
   0x000000000040055e <_ZN3Foo3barEPKcS1_+4>:   mov    %rdi,-0x8(%rbp)
End of assembler dump.


But this doesn't:

(gdb) disas 0x400540 0x400553
A syntax error in expression, near `0x400553'.


If it's acceptable to require comma for two-argument command (which IMO
it is), I'll update documentation and testsuites, and produce a "real" patch.

Attaching what I've got so far.

Thanks,
-- 
Paul Pluzhnikov




Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.93
diff -u -p -u -r1.93 cli-cmds.c
--- cli/cli-cmds.c	23 Oct 2009 00:49:33 -0000	1.93
+++ cli/cli-cmds.c	19 Nov 2009 23:37:39 -0000
@@ -983,7 +983,6 @@ disassemble_command (char *arg, int from
   CORE_ADDR low, high;
   char *name;
   CORE_ADDR pc, pc_masked;
-  char *space_index;
   int flags;

   name = NULL;
@@ -1022,13 +1021,12 @@ disassemble_command (char *arg, int from
       return;
     }

-  /* FIXME: 'twould be nice to allow spaces in the expression for the first
-     arg.  Allow comma separater too?  */
-
-  if (!(space_index = (char *) strchr (arg, ' ')))
+  pc = value_as_address (parse_to_comma_and_eval (&arg));
+  if (arg[0] == ',')
+    ++arg;
+  if (arg[0] == '\0')
     {
       /* One argument.  */
-      pc = parse_and_eval_address (arg);
       if (find_pc_partial_function (pc, &name, &low, &high) == 0)
 	error (_("No function contains specified address."));
 #if defined(TUI)
@@ -1044,9 +1042,8 @@ disassemble_command (char *arg, int from
   else
     {
       /* Two arguments.  */
-      *space_index = '\0';
-      low = parse_and_eval_address (arg);
-      high = parse_and_eval_address (space_index + 1);
+      low = pc;
+      high = parse_and_eval_address (arg);
     }

   print_disassembly (gdbarch, name, low, high, flags);


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