aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-03-30 11:50:35 -0600
committerTom Tromey <tromey@adacore.com>2020-03-30 11:54:50 -0600
commitd8af906814bd69dad694e475288401b1dee6ac3a (patch)
tree0e95af57f2a2ff0ca8fb515d6b12ff62c2d7498d /gdb
parent00386881a3d0f7ac89fcc5cc912da8cd69c04324 (diff)
downloadfsf-binutils-gdb-d8af906814bd69dad694e475288401b1dee6ac3a.zip
fsf-binutils-gdb-d8af906814bd69dad694e475288401b1dee6ac3a.tar.gz
fsf-binutils-gdb-d8af906814bd69dad694e475288401b1dee6ac3a.tar.bz2
Change ada_which_variant_applies to value API
While debugging an Ada regression, I noticed that all the callers of ada_which_variant_applies desconstruct a value, only to have it be reconstructed by this function. This patch removes this inefficiency in favor of simply passing in the value directly. Tested on x86-64 Fedora 30. gdb/ChangeLog 2020-03-30 Tom Tromey <tromey@adacore.com> * ada-valprint.c (print_variant_part): Update. * ada-lang.h (ada_which_variant_applies): Update. * ada-lang.c (ada_which_variant_applies): Remove outer_type and outer_valaddr parameters; replace with "outer" value parameter. (to_fixed_variant_branch_type): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/ada-lang.c13
-rw-r--r--gdb/ada-lang.h3
-rw-r--r--gdb/ada-valprint.c4
4 files changed, 13 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 203d89c..af7e151 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2020-03-30 Tom Tromey <tromey@adacore.com>
+
+ * ada-valprint.c (print_variant_part): Update.
+ * ada-lang.h (ada_which_variant_applies): Update.
+ * ada-lang.c (ada_which_variant_applies): Remove outer_type and
+ outer_valaddr parameters; replace with "outer" value parameter.
+ (to_fixed_variant_branch_type): Update.
+
2020-03-30 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* ppc-linux-nat.c: Include <algorithm>, <unordered_map>, and
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2822d40..565299a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7661,26 +7661,21 @@ is_unchecked_variant (struct type *var_type, struct type *outer_type)
/* Assuming that VAR_TYPE is the type of a variant part of a record (a union),
- within a value of type OUTER_TYPE that is stored in GDB at
- OUTER_VALADDR, determine which variant clause (field number in VAR_TYPE,
+ within OUTER, determine which variant clause (field number in VAR_TYPE,
numbering from 0) is applicable. Returns -1 if none are. */
int
-ada_which_variant_applies (struct type *var_type, struct type *outer_type,
- const gdb_byte *outer_valaddr)
+ada_which_variant_applies (struct type *var_type, struct value *outer)
{
int others_clause;
int i;
const char *discrim_name = ada_variant_discrim_name (var_type);
- struct value *outer;
struct value *discrim;
LONGEST discrim_val;
/* Using plain value_from_contents_and_address here causes problems
because we will end up trying to resolve a type that is currently
being constructed. */
- outer = value_from_contents_and_address_unresolved (outer_type,
- outer_valaddr, 0);
discrim = ada_value_struct_elt (outer, discrim_name, 1);
if (discrim == NULL)
return -1;
@@ -8555,9 +8550,7 @@ to_fixed_variant_branch_type (struct type *var_type0, const gdb_byte *valaddr,
if (is_unchecked_variant (var_type, value_type (dval)))
return var_type0;
- which =
- ada_which_variant_applies (var_type,
- value_type (dval), value_contents (dval));
+ which = ada_which_variant_applies (var_type, dval);
if (which < 0)
return empty_record (var_type);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 1f427b0..bb9e3c3 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -284,8 +284,7 @@ extern struct value *ada_delta (struct type *);
extern struct value *ada_scaling_factor (struct type *);
-extern int ada_which_variant_applies (struct type *, struct type *,
- const gdb_byte *);
+extern int ada_which_variant_applies (struct type *, struct value *);
extern struct type *ada_to_fixed_type (struct type *, const gdb_byte *,
CORE_ADDR, struct value *,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 59ada24..2f2375a 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -560,9 +560,7 @@ print_variant_part (struct value *value, int field_num,
{
struct type *type = value_type (value);
struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
- int which = ada_which_variant_applies (var_type,
- value_type (outer_value),
- value_contents (outer_value));
+ int which = ada_which_variant_applies (var_type, outer_value);
if (which < 0)
return 0;