emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master aaffae8 2/3: Add debug facility for formatting in r


From: Daniel Colascione
Subject: [Emacs-diffs] master aaffae8 2/3: Add debug facility for formatting in rr sessions
Date: Sat, 9 Jun 2018 20:50:00 -0400 (EDT)

branch: master
commit aaffae8458dcd774540e7e6b4219c8b5a9902075
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    Add debug facility for formatting in rr sessions
    
    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 |  6 ++++++
 src/print.c  | 11 +++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/.gdbinit b/src/.gdbinit
index 67dcf71..3cebdff 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -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
diff --git a/src/print.c b/src/print.c
index 8394375..234f44a 100644
--- a/src/print.c
+++ b/src/print.c
@@ -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));
+}
+
 
 DEFUN ("error-message-string", Ferror_message_string, Serror_message_string,
        1, 1, 0,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]