aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile
diff options
context:
space:
mode:
authorGeorge Barrett <bob@bob131.so>2021-04-29 03:32:47 +1000
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-05-12 12:35:36 +0100
commit9d4fc61d41a0aef2d199e2b18d238603a8e4be98 (patch)
tree6d14bbf4abcb031b467556465c1dab31060159ac /gdb/guile
parent97cef6b7b79c22a3cc14ef369c1dc09a8bcca357 (diff)
downloadgdb-9d4fc61d41a0aef2d199e2b18d238603a8e4be98.zip
gdb-9d4fc61d41a0aef2d199e2b18d238603a8e4be98.tar.gz
gdb-9d4fc61d41a0aef2d199e2b18d238603a8e4be98.tar.bz2
Guile: add value-{rvalue-,}reference-value
The Guile API doesn't currently have an equivalent to the Python API's Value.reference_value() or Value.rvalue_reference_value(). This commit adds a procedure with equivalent semantics to the Guile API. gdb/ChangeLog: * NEWS (Guile API): Note the addition of new procedures. * guile/scm-value.c (gdbscm_reference_value): Add helper function for reference value creation. (gdbscm_value_reference_value): Add implementation of value-reference-value procedure. (gdbscm_value_rvalue_reference_value): Add implementation of value-rvalue-reference-value procedure. (value_functions): Add value-reference-value procedure. Add value-rvalue-reference-value procedure. gdb/doc/ChangeLog: * guile.texi (Values From Inferior In Guile): Add documentation for value-reference-value. Add documentation for value-rvalue-reference-value. gdb/testsuite/ChangeLog: * gdb.guile/scm-value.exp (test_value_in_inferior): Add test for value-reference-value. Add test for value-rvalue-reference-value.
Diffstat (limited to 'gdb/guile')
-rw-r--r--gdb/guile/scm-value.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index f50e8b5..a07bc7d 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -488,6 +488,38 @@ gdbscm_value_referenced_value (SCM self)
});
}
+static SCM
+gdbscm_reference_value (SCM self, enum type_code refcode)
+{
+ 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 = value_ref (value, refcode);
+ return vlscm_scm_from_value (res_val);
+ });
+}
+
+/* (value-reference-value <gdb:value>) -> <gdb:value> */
+
+static SCM
+gdbscm_value_reference_value (SCM self)
+{
+ return gdbscm_reference_value (self, TYPE_CODE_REF);
+}
+
+/* (value-rvalue-reference-value <gdb:value>) -> <gdb:value> */
+
+static SCM
+gdbscm_value_rvalue_reference_value (SCM self)
+{
+ return gdbscm_reference_value (self, TYPE_CODE_RVALUE_REF);
+}
+
/* (value-type <gdb:value>) -> <gdb:type> */
static SCM
@@ -1352,6 +1384,16 @@ For example, for a value which is a reference to an 'int' pointer ('int *'),\n\
value-dereference will result in a value of type 'int' while\n\
value-referenced-value will result in a value of type 'int *'." },
+ { "value-reference-value", 1, 0, 0,
+ as_a_scm_t_subr (gdbscm_value_reference_value),
+ "\
+Return a <gdb:value> object which is a reference to the given value." },
+
+ { "value-rvalue-reference-value", 1, 0, 0,
+ as_a_scm_t_subr (gdbscm_value_rvalue_reference_value),
+ "\
+Return a <gdb:value> object which is an rvalue reference to the given value." },
+
{ "value-field", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_field),
"\
Return the specified field of the value.\n\