aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.guile
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-10-06 20:32:16 +0100
committerAndrew Burgess <aburgess@redhat.com>2024-10-21 10:36:32 +0100
commit9ee884981410d3d666e9b7b747b50908d891286b (patch)
tree7603bf825fababeb7f69157bd032d96e3643e98d /gdb/testsuite/gdb.guile
parentced885161b6e1dee89acc4bd3b68ba7a27815645 (diff)
downloadbinutils-9ee884981410d3d666e9b7b747b50908d891286b.zip
binutils-9ee884981410d3d666e9b7b747b50908d891286b.tar.gz
binutils-9ee884981410d3d666e9b7b747b50908d891286b.tar.bz2
gdb/guile: add get-basic-type
A question was asked on stackoverflow.com about the guile function get-basic-type[1] which is mentioned in the docs along with an example of its use. The problem is, the function was apparently never actually added to GDB. But it turns out that it's pretty easy to implement, so lets add it now. Better late than never. The implementation mirrors the Python get_basic_type function. I've added a test which is a copy of the documentation example. One issue is that the docs suggest that the type will be returned as just "int", however, I'm not sure what this actually means. It makes more sense that the function return a gdb:type object which would be represented as "#<gdb:type int>", so I've updated the docs to show this output. [1] https://stackoverflow.com/questions/79058691/unbound-variable-get-basic-type-in-gdb-guile-session Reviewed-By: Kevin Buettner <kevinb@redhat.com>
Diffstat (limited to 'gdb/testsuite/gdb.guile')
-rw-r--r--gdb/testsuite/gdb.guile/types-module.cc4
-rw-r--r--gdb/testsuite/gdb.guile/types-module.exp5
2 files changed, 9 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.guile/types-module.cc b/gdb/testsuite/gdb.guile/types-module.cc
index 9b32f67..f3992c0 100644
--- a/gdb/testsuite/gdb.guile/types-module.cc
+++ b/gdb/testsuite/gdb.guile/types-module.cc
@@ -31,6 +31,10 @@ class derived : public base
derived d;
+typedef const int const_int;
+const_int foo (3);
+const_int &foo_ref (foo);
+
int
main (void)
{
diff --git a/gdb/testsuite/gdb.guile/types-module.exp b/gdb/testsuite/gdb.guile/types-module.exp
index d95ff21..ee55804 100644
--- a/gdb/testsuite/gdb.guile/types-module.exp
+++ b/gdb/testsuite/gdb.guile/types-module.exp
@@ -59,3 +59,8 @@ gdb_test "guile (define bad-enum-htab (make-enum-hashtable #f))" \
gdb_test "guile (define bad-enum-htab (make-enum-hashtable (lookup-type \"int\")))" \
"Wrong type argument in position 1 \\(expecting enum\\): #<gdb:type int>.*" \
"make-enum-hashtable from int"
+
+gdb_test_no_output "guile (define foo-ref (parse-and-eval \"foo_ref\"))" \
+ "get foo-ref value"
+gdb_test "guile (get-basic-type (value-type foo-ref))" "#<gdb:type int>" \
+ "check get-basic-type"