unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
@ 2012-01-24  6:46 Kaushik Srenevasan
  2012-01-24 11:44 ` Juanma Barranquero
  0 siblings, 1 reply; 8+ messages in thread
From: Kaushik Srenevasan @ 2012-01-24  6:46 UTC (permalink / raw)
  To: emacs-devel

All,

GUD-MI's disassembly buffer only works when the current frame has debug
information. While debugging dynamically generated code it'd be useful
to simply follow the program counter. I understand that newer GDBs
expose an API that lets a JIT compiler register debug information for
dynamically generated code, but JITs typically only do so for real
functions. So, having the disassembly buffer follow $PC would still be
useful while stepping through dynamically generated, shorter sequences
of code (like call stubs, inline caches etc.). 

The latest GDB (7.4.50.20120122-cvs) does this in its TUI mode while my
stable GDB's (7.0.1-debian) behavior is the same as Emacs 23 GUD.

Please review and merge.

         Thanks,
            -Kaushik

=== modified file 'lisp/progmodes/gdb-mi.el'
--- lisp/progmodes/gdb-mi.el	2012-01-05 09:46:05 +0000
+++ lisp/progmodes/gdb-mi.el	2012-01-24 05:13:10 +0000
@@ -3259,8 +3259,12 @@
   (let* ((frame (gdb-current-buffer-frame))
          (file (bindat-get-field frame 'fullname))
          (line (bindat-get-field frame 'line)))
-    (when file
-      (format "-data-disassemble -f %s -l %s -n -1 -- 0" file line)))
+    (if file
+      (format "-data-disassemble -f %s -l %s -n -1 -- 0" file line)
+    ;; If we're unable to get a file name / line for $PC, simply
+    ;; follow $PC, disassembling the next 10 (x ~15 (on IA) ==
+    ;; 150 bytes) instructions.
+    "-data-disassemble -s $pc -e \"$pc + 150\" -- 0"))
   gdb-disassembly-handler
   ;; We update disassembly only after we have actual frame information
   ;; about all threads, so no there's `update' signal in this list
@@ -3319,8 +3323,12 @@
       (gdb-table-add-row table
                          (list
                           (bindat-get-field instr 'address)
-                          (apply #'format "<%s+%s>:"
-                                 (gdb-get-many-fields instr 'func-name 'offset))
+                          (let
+                              ((func-name (bindat-get-field instr 'func-name))
+                               (offset (bindat-get-field instr 'offset)))
+                            (if func-name
+                                (format "<%s+%s>:" func-name offset)
+                              ""))
                           (bindat-get-field instr 'inst)))
       (when (string-equal (bindat-get-field instr 'address)
                           address)






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
  2012-01-24  6:46 Kaushik Srenevasan
@ 2012-01-24 11:44 ` Juanma Barranquero
  0 siblings, 0 replies; 8+ messages in thread
From: Juanma Barranquero @ 2012-01-24 11:44 UTC (permalink / raw)
  To: ksrenevasan; +Cc: emacs-devel

On Tue, Jan 24, 2012 at 07:46, Kaushik Srenevasan <ksrenevasan@gmail.com> wrote:

> Please review and merge.

Please send proposed patches to the bug tracker
<bug-gnu-emacs@gnu.org>, starting the message with

Package: emacs
Tags: patch

and also appropriate "Version:" and "Severity:" pseudo-headers, if required.

The file admin/notes/bugtracker contains additional information on the
use of the Emacs bug tracker.

Thanks,

    Juanma



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
@ 2012-01-29  9:17 Nick Roberts
  2012-01-30 21:52 ` Kaushik Srenevasan
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Roberts @ 2012-01-29  9:17 UTC (permalink / raw)
  To: ksrenevasan; +Cc: emacs-devel

That looks fine but would it be better to place the overlay arrow
further down the window so that the user can see previous instructions?

e.g, 

"-data-disassemble -s \"$pc - 80\" -e \"$pc + 80\" -- 0"

Nick




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
  2012-01-29  9:17 [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information Nick Roberts
@ 2012-01-30 21:52 ` Kaushik Srenevasan
  2012-01-31  5:53   ` Nick Roberts
  0 siblings, 1 reply; 8+ messages in thread
From: Kaushik Srenevasan @ 2012-01-30 21:52 UTC (permalink / raw)
  To: Nick Roberts; +Cc: emacs-devel

On Sun, 2012-01-29 at 22:17 +1300, Nick Roberts wrote:
> That looks fine but would it be better to place the overlay arrow
> further down the window so that the user can see previous instructions?
> 
> e.g, 
> 
> "-data-disassemble -s \"$pc - 80\" -e \"$pc + 80\" -- 0"

Yes, that would definitely be useful except I couldn't figure out how to
reliably get to an instruction boundary while subtracting from $PC. GDB
doesn't seem to do it automatically. Ideas?

         - Kaushik





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
  2012-01-30 21:52 ` Kaushik Srenevasan
@ 2012-01-31  5:53   ` Nick Roberts
  2012-01-31  7:19     ` Kaushik Srenevasan
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Roberts @ 2012-01-31  5:53 UTC (permalink / raw)
  To: ksrenevasan; +Cc: emacs-devel

Kaushik Srenevasan writes:
 > On Sun, 2012-01-29 at 22:17 +1300, Nick Roberts wrote:
 > > That looks fine but would it be better to place the overlay arrow
 > > further down the window so that the user can see previous instructions?
 > > 
 > > e.g, 
 > > 
 > > "-data-disassemble -s \"$pc - 80\" -e \"$pc + 80\" -- 0"
 > 
 > Yes, that would definitely be useful except I couldn't figure out how to
 > reliably get to an instruction boundary while subtracting from $PC. GDB
 > doesn't seem to do it automatically. Ideas?


It seemed work OK when I tried it on x86_64.  I don't know in what situations
it wouldn't work or how to fix it when it doesn't.

Nick



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
  2012-01-31  5:53   ` Nick Roberts
@ 2012-01-31  7:19     ` Kaushik Srenevasan
  2012-02-04 10:36       ` Nick Roberts
  0 siblings, 1 reply; 8+ messages in thread
From: Kaushik Srenevasan @ 2012-01-31  7:19 UTC (permalink / raw)
  To: Nick Roberts; +Cc: emacs-devel

On Tue, 2012-01-31 at 18:53 +1300, Nick Roberts wrote:
> It seemed work OK when I tried it on x86_64.  I don't know in what situations
> it wouldn't work or how to fix it when it doesn't.
> 

It generally works except, AFAIK, when making a call where both the
callee and the caller don't have debug information. In such a situation,
executing a step while stopped at a CALL instruction produces the wrong
disassembly. 

There are other GDB commands too (such as NEXTI) that don't work when
both the caller and callee don't have debug information, that I'm trying
to fix (in GDB); and would prefer to fix GUD-MI (to display a few
instructions before $PC) once GDB works as expected in these cases. What
do you think?

         -Kaushik





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
  2012-01-31  7:19     ` Kaushik Srenevasan
@ 2012-02-04 10:36       ` Nick Roberts
  2012-02-06  9:14         ` Kaushik Srenevasan
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Roberts @ 2012-02-04 10:36 UTC (permalink / raw)
  To: ksrenevasan; +Cc: emacs-devel

Kaushik Srenevasan writes:
 > ...
 > There are other GDB commands too (such as NEXTI) that don't work when
 > both the caller and callee don't have debug information, that I'm trying
 > to fix (in GDB); and would prefer to fix GUD-MI (to display a few
 > instructions before $PC) once GDB works as expected in these cases. What
 > do you think?

I think you have a good understanding of the issues and recommend that the
maintainers install any patch you may submit if I don't see it on the mailing
list first.

Nick



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information.
  2012-02-04 10:36       ` Nick Roberts
@ 2012-02-06  9:14         ` Kaushik Srenevasan
  0 siblings, 0 replies; 8+ messages in thread
From: Kaushik Srenevasan @ 2012-02-06  9:14 UTC (permalink / raw)
  To: Nick Roberts; +Cc: emacs-devel

On Sat, Feb 4, 2012 at 2:36 AM, Nick Roberts <nickrob@snap.net.nz> wrote:
> I think you have a good understanding of the issues and recommend that the
> maintainers install any patch you may submit if I don't see it on the mailing
> list first.
>

Thanks for reviewing this Nick!

         Kaushik



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-06  9:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-29  9:17 [PATCH] GUD-MI's disassembly buffer should follow $PC in the absence of debug information Nick Roberts
2012-01-30 21:52 ` Kaushik Srenevasan
2012-01-31  5:53   ` Nick Roberts
2012-01-31  7:19     ` Kaushik Srenevasan
2012-02-04 10:36       ` Nick Roberts
2012-02-06  9:14         ` Kaushik Srenevasan
  -- strict thread matches above, loose matches on Subject: below --
2012-01-24  6:46 Kaushik Srenevasan
2012-01-24 11:44 ` Juanma Barranquero

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).