diff options
author | George Barrett <bob@bob131.so> | 2021-04-29 03:32:56 +1000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-05-12 12:35:36 +0100 |
commit | ee35ce8200dcd1754061d5dc90fb53f9504c6394 (patch) | |
tree | 436b3d555f9ce56c920fee03627b5badbd7d5a84 | |
parent | 9d4fc61d41a0aef2d199e2b18d238603a8e4be98 (diff) | |
download | binutils-ee35ce8200dcd1754061d5dc90fb53f9504c6394.zip binutils-ee35ce8200dcd1754061d5dc90fb53f9504c6394.tar.gz binutils-ee35ce8200dcd1754061d5dc90fb53f9504c6394.tar.bz2 |
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.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/NEWS | 5 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/guile.texi | 5 | ||||
-rw-r--r-- | gdb/guile/scm-value.c | 23 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.guile/scm-value.exp | 3 |
7 files changed, 51 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f29f60a..8ef5eb6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2021-05-12 George Barrett <bob@bob131.so> + * 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. + +2021-05-12 George Barrett <bob@bob131.so> + * NEWS (Guile API): Note the addition of new procedures. * guile/scm-value.c (gdbscm_reference_value): Add helper function for reference value creation. @@ -207,8 +207,9 @@ QMemTags value-referenced-value procedure now handles rvalue reference values. - ** New procedures for obtaining reference values: - value-reference-value and value-rvalue-reference-value. + ** New procedures for obtaining value variants: + value-reference-value, value-rvalue-reference-value and + value-const-value. *** Changes in GDB 10 diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 029e240..290ad48 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,6 +1,11 @@ 2021-05-12 George Barrett <bob@bob131.so> * guile.texi (Values From Inferior In Guile): Add documentation + for value-const-value. + +2021-05-12 George Barrett <bob@bob131.so> + + * guile.texi (Values From Inferior In Guile): Add documentation for value-reference-value. Add documentation for value-rvalue-reference-value. diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi index cca3a94..c7e43c8 100644 --- a/gdb/doc/guile.texi +++ b/gdb/doc/guile.texi @@ -811,6 +811,11 @@ Return a new @code{<gdb:value>} object which is an rvalue reference to the value encapsulated by @code{<gdb:value>} object @var{value}. @end deffn +@deffn {Scheme Procedure} value-const-value value +Return a new @code{<gdb:value>} object which is a @samp{const} version +of @code{<gdb:value>} object @var{value}. +@end deffn + @deffn {Scheme Procedure} value-field value field-name Return field @var{field-name} from @code{<gdb:value>} object @var{value}. @end deffn 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 <gdb:value>) -> <gdb: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 <gdb:value>) -> <gdb:type> */ static SCM @@ -1394,6 +1412,11 @@ Return a <gdb:value> object which is a reference to the given value." }, "\ Return a <gdb:value> 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 <gdb:value> 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\ diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 691e83c..e0f6496 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2021-05-12 George Barrett <bob@bob131.so> * gdb.guile/scm-value.exp (test_value_in_inferior): Add test for + value-const-value. + +2021-05-12 George Barrett <bob@bob131.so> + + * gdb.guile/scm-value.exp (test_value_in_inferior): Add test for value-reference-value. Add test for value-rvalue-reference-value. 2021-05-11 Tom de Vries <tdevries@suse.de> diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp index b3f785c..982b9bf 100644 --- a/gdb/testsuite/gdb.guile/scm-value.exp +++ b/gdb/testsuite/gdb.guile/scm-value.exp @@ -183,6 +183,9 @@ proc test_value_in_inferior {} { "test value-rvalue-reference-value" gdb_test "gu (equal? argv (value-referenced-value argv-rref))" "#t" gdb_test "gu (eqv? (type-code (value-type argv-rref)) TYPE_CODE_RVALUE_REF)" "#t" + + gdb_test "gu (equal? (value-type (value-const-value argv)) (type-const (value-type argv)))" \ + "#t" } proc test_strings {} { |