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
This commit is contained in:
parent
c3c1e6459f
commit
b5b591a865
4 changed files with 71 additions and 2 deletions
|
@ -1924,6 +1924,21 @@ get_signed_type_minmax (struct type *type, LONGEST *min, LONGEST *max)
|
|||
*max = ((ULONGEST) 1 << (n - 1)) - 1;
|
||||
}
|
||||
|
||||
/* Return the largest value representable by pointer type TYPE. */
|
||||
|
||||
CORE_ADDR
|
||||
get_pointer_type_max (struct type *type)
|
||||
{
|
||||
unsigned int n;
|
||||
|
||||
type = check_typedef (type);
|
||||
gdb_assert (type->code () == TYPE_CODE_PTR);
|
||||
gdb_assert (TYPE_LENGTH (type) <= sizeof (CORE_ADDR));
|
||||
|
||||
n = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
|
||||
return ((((CORE_ADDR) 1 << (n - 1)) - 1) << 1) | 1;
|
||||
}
|
||||
|
||||
/* Internal routine called by TYPE_VPTR_FIELDNO to return the value of
|
||||
cplus_stuff.vptr_fieldno.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue