unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Minor fixes to .gdbinit
@ 2018-02-10 16:51 Tom Tromey
  2018-02-12  1:35 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2018-02-10 16:51 UTC (permalink / raw)
  To: emacs-devel; +Cc: Tom Tromey

I noticed a couple of small problems in .gdbinit while debugging Emacs
recently.

First, "xcompiled" doesn't emit a trailing newline.

Second, in some cases, when gdb uses Python 2, casting a pointer to a
Python 'int' will fail.  The solution is to cast to 'long' instead --
but because Python 3 does not have 'long', this requires a small
compatibility shim.

This patch fixes both of these problems.  Let me know what you think.

* src/.gdbinit (xcompiled): Emit a final newline.
(python): Define "long" if not already defined.  Use casts to long,
not int.
---
 src/.gdbinit | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/.gdbinit b/src/.gdbinit
index a5411e66d5..9fdcaf8661 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -819,6 +819,7 @@ define xcompiled
   xgetptr $
   print (struct Lisp_Vector *) $ptr
   output ($->contents[0])@($->header.size & 0xff)
+  echo \n
 end
 document xcompiled
 Print $ as a compiled function pointer.
@@ -1270,6 +1271,12 @@ end
 
 python
 
+# Python 3 compatibility.
+try:
+  long
+except:
+  long = int
+
 # Omit pretty-printing in older (pre-7.3) GDBs that lack it.
 if hasattr(gdb, 'printing'):
 
@@ -1306,13 +1313,13 @@ if hasattr(gdb, 'printing'):
       # symbol table, guess reasonable defaults.
       sym = gdb.lookup_symbol ("EMACS_INT_WIDTH")[0]
       if sym:
-        EMACS_INT_WIDTH = int (sym.value ())
+        EMACS_INT_WIDTH = long (sym.value ())
       else:
         sym = gdb.lookup_symbol ("EMACS_INT")[0]
         EMACS_INT_WIDTH = 8 * sym.type.sizeof
       sym = gdb.lookup_symbol ("USE_LSB_TAG")[0]
       if sym:
-        USE_LSB_TAG = int (sym.value ())
+        USE_LSB_TAG = long (sym.value ())
       else:
         USE_LSB_TAG = 1
 
@@ -1334,7 +1341,7 @@ if hasattr(gdb, 'printing'):
       # integer.  Also, val.cast (gdb.lookup.type ("EMACS_UINT"))
       # would have problems with GDB 7.12.1; see
       # <http://patchwork.sourceware.org/patch/11557/>.
-      ival = int (val)
+      ival = long (val)
 
       # For nil, yield "XIL(0)", which is easier to read than "XIL(0x0)".
       if not ival:
-- 
2.13.6




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

* Re: [PATCH] Minor fixes to .gdbinit
  2018-02-10 16:51 [PATCH] Minor fixes to .gdbinit Tom Tromey
@ 2018-02-12  1:35 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2018-02-12  1:35 UTC (permalink / raw)
  To: Tom Tromey, emacs-devel

Thanks, this patch looks good, and I suggesting installing it into master at 
your convenience.



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

end of thread, other threads:[~2018-02-12  1:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-10 16:51 [PATCH] Minor fixes to .gdbinit Tom Tromey
2018-02-12  1:35 ` Paul Eggert

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