aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-08-07 06:35:51 -0600
committerTom Tromey <tromey@adacore.com>2023-09-05 11:03:00 -0600
commit84914f598e5d48b78243b7e523804a28a4baf1eb (patch)
tree6e94a4e9e76cd3e358c051df710dc6a63ebb6922 /gdb/gdbtypes.c
parentcf1eca3cbbfe8b2092d867023df7dac4d00fa4ec (diff)
downloadgdb-84914f598e5d48b78243b7e523804a28a4baf1eb.zip
gdb-84914f598e5d48b78243b7e523804a28a4baf1eb.tar.gz
gdb-84914f598e5d48b78243b7e523804a28a4baf1eb.tar.bz2
Introduce type::is_array_like and value_to_array
This adds the type::is_array_like method and the value_to_array function. The former can be used to see whether a given type is known to be "array-like". This is the currently the case for certain compiler-generated structure types; in particular both the Ada and Rust compilers do this.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 6b2adc8..c932210 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -43,6 +43,8 @@
#include "f-lang.h"
#include <algorithm>
#include "gmp-utils.h"
+#include "rust-lang.h"
+#include "ada-lang.h"
/* The value of an invalid conversion badness. */
#define INVALID_CONVERSION 100
@@ -5945,6 +5947,20 @@ type::copy_fields (std::vector<struct field> &src)
size_t size = nfields * sizeof (*this->fields ());
memcpy (this->fields (), src.data (), size);
}
+
+bool
+type::is_array_like ()
+{
+ if (code () == TYPE_CODE_ARRAY)
+ return true;
+ if (HAVE_GNAT_AUX_INFO (this))
+ return (ada_is_constrained_packed_array_type (this)
+ || ada_is_array_descriptor_type (this));
+ if (HAVE_RUST_SPECIFIC (this))
+ return rust_slice_type_p (this);
+ return false;
+}
+
static const registry<gdbarch>::key<struct builtin_type> gdbtypes_data;