guile: fix make-value with pointer type
authorGeorge Barrett <bob@bob131.so>
Thu, 29 Jul 2021 15:12:18 +0000 (01:12 +1000)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 29 Jul 2021 16:55:16 +0000 (12:55 -0400)
commitb5b591a865b3021453a47c612ece5e7574b47d04
treefd2005dd4656f5414fc395b1fa64081e1ff36933
parentc3c1e6459f89167fc01de9376c6b34574d710278
guile: fix make-value with pointer type

Calling the `make-value' procedure with an integer value and a pointer
type for the #:type argument triggers a failed assertion in
`get_unsigned_type_max', as that function doesn't consider pointers to
be an unsigned type. This commit fixes the issue by adding a separate
code path for pointers.

As previously suggested, range checking is done using a new helper
function in gdbtypes.

gdb/ChangeLog:

2021-07-30  George Barrett  <bob@bob131.so>

* gdbtypes.h (get_pointer_type_max): Add declaration.
* gdbtypes.c (get_pointer_type_max): Add definition for new
helper function.
* guile/scm-math.c (vlscm_convert_typed_number): Add code path
for handling conversions to pointer types without failing an
assert.

gdb/testsuite/ChangeLog:

2021-07-30  George Barrett  <bob@bob131.so>

* gdb.guile/scm-math.exp (test_value_numeric_ops): Add test
for creating pointers with make-value.
(test_make_pointer_value, test_pointer_numeric_range): Add
test procedures containing checks for integer-to-pointer
validation.

Change-Id: I9994dd1c848840a3d995f745e6d72867732049f0
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/guile/scm-math.c
gdb/testsuite/gdb.guile/scm-math.exp