From ee35ce8200dcd1754061d5dc90fb53f9504c6394 Mon Sep 17 00:00:00 2001 From: George Barrett Date: Thu, 29 Apr 2021 03:32:56 +1000 Subject: Guile: add value-const-value The Guile API doesn't currently have an equivalent to the Python API's gdb.Value.const_value(). This commit adds a procedure with equivalent semantics to the Guile API. gdb/ChangeLog: * NEWS (Guile API): Note the addition of the new procedure. * guile/scm-value.c (gdbscm_value_const_value): Add implementation of value-const-value procedure. (value_functions): Add value-const-value procedure. gdb/doc/ChangeLog: * guile.texi (Values From Inferior In Guile): Add documentation for value-const-value. gdb/testsuite/ChangeLog: * gdb.guile/scm-value.exp (test_value_in_inferior): Add test for value-const-value. --- gdb/guile/scm-value.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gdb/guile') diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index a07bc7d..24bb554 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -520,6 +520,24 @@ gdbscm_value_rvalue_reference_value (SCM self) return gdbscm_reference_value (self, TYPE_CODE_RVALUE_REF); } +/* (value-const-value ) -> */ + +static SCM +gdbscm_value_const_value (SCM self) +{ + value_smob *v_smob + = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); + struct value *value = v_smob->value; + + return gdbscm_wrap ([=] + { + scoped_value_mark free_values; + + struct value *res_val = make_cv_value (1, 0, value); + return vlscm_scm_from_value (res_val); + }); +} + /* (value-type ) -> */ static SCM @@ -1394,6 +1412,11 @@ Return a object which is a reference to the given value." }, "\ Return a object which is an rvalue reference to the given value." }, + { "value-const-value", 1, 0, 0, + as_a_scm_t_subr (gdbscm_value_const_value), + "\ +Return a object which is a 'const' version of the given value." }, + { "value-field", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_field), "\ Return the specified field of the value.\n\ -- cgit v1.1