From 7a5a839f3a82e23f7745dd9905191716c74e34df Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 18 Feb 2014 23:35:46 +0100 Subject: [PATCH] guile: Add 'history-append!' procedure. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit gdb/ 2014-02-26 Ludovic Courtès * guile/scm-value.c (gdbscm_history_append_x): New function. (value_functions): Add it. gdb/testsuite/ 2014-02-26 Ludovic Courtès * gdb.guile/scm-value.exp (test_value_in_inferior): Add test for 'history-append!'. gdb/doc/ 2014-02-26 Ludovic Courtès * gdb/doc/guile.texi (Basic Guile): Document 'history-append!'. --- gdb/ChangeLog | 5 +++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/guile.texi | 9 +++++++++ gdb/guile/scm-value.c | 25 +++++++++++++++++++++++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.guile/scm-value.exp | 8 ++++++++ 6 files changed, 56 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bb7060cbbf0..e55f70fefc4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-02-26 Ludovic Courtès + + * guile/scm-value.c (gdbscm_history_append_x): New function. + (value_functions): Add it. + 2014-02-27 Joel Brobecker * dwarf2read.c (attr_value_as_address): New function. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index cfde65c3a61..47f5f385042 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-02-26 Ludovic Courtès + + * gdb/doc/guile.texi (Basic Guile): Document 'history-append!'. + 2014-02-20 Joel Brobecker * gdb.texinfo (Files): Document "add-shared-symbol-files" diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi index ceb98dc2767..56d817edf27 100644 --- a/gdb/doc/guile.texi +++ b/gdb/doc/guile.texi @@ -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{}, 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{}. diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index f7f27ceea80..8ca076211c4 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -1297,6 +1297,27 @@ gdbscm_history_ref (SCM index) return vlscm_scm_from_value (res_val); } + +/* (history-append! ) -> 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); +} /* Initialize the Scheme value code. */ @@ -1459,6 +1480,10 @@ Evaluates string in gdb and returns the result as a 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 }; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 431e3cacf76..835338fca8a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-26 Ludovic Courtès + + * gdb.guile/scm-value.exp (test_value_in_inferior): Add + test for 'history-append!'. + 2014-02-26 Joel Brobecker * gdb.dwarf2/dw2-abs-hi-pc-hello-dbg.S: New file. diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp index 3ebdd585b3a..89f0ff1d610 100644 --- a/gdb/testsuite/gdb.guile/scm-value.exp +++ b/gdb/testsuite/gdb.guile/scm-value.exp @@ -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_test "p \$" "= 42" + # Test dereferencing the argv pointer. # Just get inferior variable argv the value history, available to guile. -- 2.30.2