]> git.eshelyaron.com Git - emacs.git/commitdiff
Add debug facility for formatting in rr sessions
authorDaniel Colascione <dancol@dancol.org>
Sat, 9 Jun 2018 22:41:29 +0000 (15:41 -0700)
committerDaniel Colascione <dancol@dancol.org>
Sun, 10 Jun 2018 00:46:05 +0000 (17:46 -0700)
The existing debug print commands don't work in rr, since they touch
stderr. The new xfmt command just calls Fformat and doesn't touch the
stdio streams.

* src/.gdbinit:
(xfmt): New GDB command.

* src/print.c:
(debug_format): New function.

src/.gdbinit
src/print.c

index 67dcf718e3c0ad1bd983e22fce3c115dd078b1f1..3cebdff5e7b720874fbb70697cabaa38f11bd950 100644 (file)
@@ -119,6 +119,12 @@ Print the value of the lisp variable given as argument.
 Works only when an inferior emacs is executing.
 end
 
+# Format the value and print it as a string. Works in
+# an rr session and during live debugging. Calls into lisp.
+define xfmt
+  printf "%s\n", debug_format("%S", $arg0)
+end
+
 # Print out current buffer point and boundaries
 define ppt
   set $b = current_buffer
index 839437522042f0832b1f4176895041ebf4bb3a3d..234f44a4a5d2ec70ecdc29e971098e56e432a0ad 100644 (file)
@@ -855,6 +855,17 @@ safe_debug_print (Lisp_Object arg)
     }
 }
 
+/* This function formats the given object and returns the result as a
+   string. Use this in contexts where you can inspect strings, but
+   where stderr output won't work --- e.g., while replaying rr
+   recordings.  */
+const char * debug_format (const char *, Lisp_Object) EXTERNALLY_VISIBLE;
+const char *
+debug_format (const char *fmt, Lisp_Object arg)
+{
+  return SSDATA (CALLN (Fformat, build_string (fmt), arg));
+}
+
 \f
 DEFUN ("error-message-string", Ferror_message_string, Serror_message_string,
        1, 1, 0,