guile: Add 'history-append!' procedure.
authorLudovic Courtès <ludo@gnu.org>
Tue, 18 Feb 2014 22:35:46 +0000 (23:35 +0100)
committerLudovic Courtès <ludo@gnu.org>
Wed, 26 Feb 2014 21:59:42 +0000 (22:59 +0100)
gdb/
2014-02-26  Ludovic Courtès  <ludo@gnu.org>

* guile/scm-value.c (gdbscm_history_append_x): New function.
(value_functions): Add it.

gdb/testsuite/
2014-02-26  Ludovic Courtès  <ludo@gnu.org>

* gdb.guile/scm-value.exp (test_value_in_inferior): Add
test for 'history-append!'.

gdb/doc/
2014-02-26  Ludovic Courtès  <ludo@gnu.org>

* gdb/doc/guile.texi (Basic Guile): Document 'history-append!'.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/guile.texi
gdb/guile/scm-value.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.guile/scm-value.exp

index bb7060cbbf0b7e05518c114652252257fadfb71c..e55f70fefc4f8e230500d11a595d3c134b5656f3 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-26  Ludovic Courtès  <ludo@gnu.org>
+
+       * guile/scm-value.c (gdbscm_history_append_x): New function.
+       (value_functions): Add it.
+
 2014-02-27  Joel Brobecker  <brobecker@adacore.com>
 
        * dwarf2read.c (attr_value_as_address): New function.
index cfde65c3a61916f8e7fb3d5a2271f027c3419798..47f5f385042a51cd5266d79fd97d77ecdb2fd59e 100644 (file)
@@ -1,3 +1,7 @@
+2014-02-26  Ludovic Courtès  <ludo@gnu.org>
+
+       * gdb/doc/guile.texi (Basic Guile): Document 'history-append!'.
+
 2014-02-20  Joel Brobecker  <brobecker@adacore.com>
 
        * gdb.texinfo (Files): Document "add-shared-symbol-files"
index ceb98dc2767f11ef5bb191c1c25f314b4c7b7058..56d817edf2726356cc3705dec1cee0d925f0c657 100644 (file)
@@ -278,6 +278,15 @@ history contains the result of evaluating an expression from Guile's
 command line.
 @end deffn
 
+@deffn {Scheme Procedure} history-append! value
+Append @var{value}, an instance of @code{<gdb:value>}, to @value{GDBN}'s
+value history.  Return its index in the history.
+
+Putting into history values returned by Guile extensions will allow
+the user convenient access to those values via CLI history
+facilities.
+@end deffn
+
 @deffn {Scheme Procedure} parse-and-eval expression
 Parse @var{expression} as an expression in the current language,
 evaluate it, and return the result as a @code{<gdb:value>}.
index f7f27ceea8081c5a8c409249c41592277f8f6c08..8ca076211c4c963fa714a1cc4096f3c7ad7d21ea 100644 (file)
@@ -1297,6 +1297,27 @@ gdbscm_history_ref (SCM index)
 
   return vlscm_scm_from_value (res_val);
 }
+
+/* (history-append! <gdb:value>) -> index
+   Append VALUE to GDB's value history.  Return its index in the history.  */
+
+static SCM
+gdbscm_history_append_x (SCM value)
+{
+  int res_index = -1;
+  struct value *v;
+  volatile struct gdb_exception except;
+
+  v = vlscm_scm_to_value (value);
+
+  TRY_CATCH (except, RETURN_MASK_ALL)
+    {
+      res_index = record_latest_value (v);
+    }
+  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+
+  return scm_from_int (res_index);
+}
 \f
 /* Initialize the Scheme value code.  */
 
@@ -1459,6 +1480,10 @@ Evaluates string in gdb and returns the result as a <gdb:value> object." },
     "\
 Return the specified value from GDB's value history." },
 
+  { "history-append!", 1, 0, 0, gdbscm_history_append_x,
+    "\
+Append the specified value onto GDB's value history." },
+
   END_FUNCTIONS
 };
 
index 431e3cacf76dfb32e1b3d5f67745701827e1f2cc..835338fca8af1843e4bfcd0a1189cb1222594eba 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-26  Ludovic Courtès  <ludo@gnu.org>
+
+       * gdb.guile/scm-value.exp (test_value_in_inferior): Add
+       test for 'history-append!'.
+
 2014-02-26  Joel Brobecker  <brobecker@adacore.com>
 
        * gdb.dwarf2/dw2-abs-hi-pc-hello-dbg.S: New file.
index 3ebdd585b3a981ed307f188e879dc5f6c16f0dbb..89f0ff1d610e3e3cf04e08abf8d7759af7c8c31e 100644 (file)
@@ -59,6 +59,14 @@ proc test_value_in_inferior {} {
     gdb_test "gu (print (value-field s \"a\"))" \
        "= 3" "access element inside struct using string name"
 
+    # Append value in the value history.
+    gdb_scm_test_silent_cmd "gu (define i (history-append! (make-value 42)))" \
+       "append 42"
+
+    gdb_test "gu i" "\[0-9\]+"
+    gdb_test "gu (history-ref i)" "#<gdb:value 42>"
+    gdb_test "p \$" "= 42"
+
     # Test dereferencing the argv pointer.
 
     # Just get inferior variable argv the value history, available to guile.
This page took 0.053346 seconds and 4 git commands to generate.