Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: tromey@redhat.com
Cc: Andreas Schwab <schwab@linux-m68k.org>, gdb-patches@sourceware.org
Subject: Re: [patch] Allow "disassemble 'Foo::bar(char *)'"
Date: Thu, 19 Nov 2009 23:41:00 -0000	[thread overview]
Message-ID: <8ac60eac0911191539w4245739ka6405ba072b79395@mail.gmail.com> (raw)
In-Reply-To: <8ac60eac0911161028of5f2352lf1857db7a46a94b2@mail.gmail.com>

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);


  reply	other threads:[~2009-11-19 23:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-14  0:10 Paul Pluzhnikov
2009-11-15  8:54 ` Andreas Schwab
2009-11-15 17:17   ` Paul Pluzhnikov
2009-11-15 17:26     ` Daniel Jacobowitz
2009-11-16 18:26     ` Tom Tromey
2009-11-16 18:29       ` Paul Pluzhnikov
2009-11-19 23:41         ` Paul Pluzhnikov [this message]
2009-11-20 17:28           ` Tom Tromey
2009-11-20 17:41             ` Paul Pluzhnikov
2009-11-21  0:44             ` Paul Pluzhnikov
2009-11-21  1:00               ` Daniel Jacobowitz
2009-11-21  1:09                 ` Paul Pluzhnikov
2009-11-21  8:36                   ` Eli Zaretskii
2009-11-22  2:40                     ` Paul Pluzhnikov
2009-11-22  4:28                       ` Eli Zaretskii
2009-11-23  7:45                         ` Paul Pluzhnikov
2009-11-23 11:58                           ` Eli Zaretskii
2009-11-23 17:42                             ` Paul Pluzhnikov
2009-11-23 18:40                               ` Eli Zaretskii
2009-11-23 17:30                       ` Tom Tromey

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=8ac60eac0911191539w4245739ka6405ba072b79395@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=schwab@linux-m68k.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