Add gdb.Architecture.integer_type Python function

This adds a new Python function, gdb.Architecture.integer_type, which
can be used to look up an integer type of a given size and
signed-ness.  This is useful to avoid dependency on debuginfo when a
particular integer type would be useful.

v2 moves this to be a method on gdb.Architecture and addresses other
review comments.
This commit is contained in:
Tom Tromey 2021-10-22 10:49:19 -06:00
parent 7a72f09da5
commit d3771fe234
4 changed files with 89 additions and 0 deletions

View file

@ -63,6 +63,20 @@ if { ![is_address_zero_readable] } {
"test bad memory access"
}
foreach size {0 1 2 3 4 8 16} {
foreach sign {"" ", True" ", False"} {
set fullsize [expr 8 * $size]
gdb_test_no_output "python t = arch.integer_type($fullsize$sign)" \
"get integer type for $size$sign"
gdb_test "python print(t.sizeof)" "$size" \
"print size of integer type for $size$sign"
}
}
gdb_test "python arch.integer_type(95)" \
".*ValueError: no integer type of that size is available.*" \
"call integer_type with invalid size"
# Test for gdb.architecture_names(). First we're going to grab the
# complete list of architecture names using the 'complete' command.
set arch_names []