aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-11-17 17:53:27 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2020-11-17 18:47:05 -0500
commit584903d3f5b2243ec6b179d0853726d3d7d83f2e (patch)
tree83227830cb2f2dff73323c813e4eb54e93dfcfb5
parent3d955acb36f483c05724181da5ffba46b1303c43 (diff)
downloadbinutils-584903d3f5b2243ec6b179d0853726d3d7d83f2e.zip
binutils-584903d3f5b2243ec6b179d0853726d3d7d83f2e.tar.gz
binutils-584903d3f5b2243ec6b179d0853726d3d7d83f2e.tar.bz2
gdb: make get_array_bounds return bool
Obvious change from int to bool. I took the opportunity to move the doc to the header file. gdb/ChangeLog: * gdbtypes.h (get_array_bounds): Return bool, adjust some callers. Move doc here. * gdbtypes.c (get_array_bounds): Return bool Change-Id: I8ed20298cb0927963c1f09b345966533d5ed06e2
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/compile/compile-c-types.c2
-rw-r--r--gdb/compile/compile-cplus-types.c2
-rw-r--r--gdb/gdbtypes.c15
-rw-r--r--gdb/gdbtypes.h11
5 files changed, 22 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a887a83..e0be2af 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-11-17 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * gdbtypes.h (get_array_bounds): Return bool, adjust some
+ callers. Move doc here.
+ * gdbtypes.c (get_array_bounds): Return bool
+
2020-11-17 Andrew Burgess <andrew.burgess@embecosm.com>
* arc-linux-tdep.c (arc_linux_sw_breakpoint_from_kind): Add an
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 82c9af3..87fc4e5 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -70,7 +70,7 @@ convert_array (compile_c_instance *context, struct type *type)
{
LONGEST low_bound, high_bound, count;
- if (get_array_bounds (type, &low_bound, &high_bound) == 0)
+ if (!get_array_bounds (type, &low_bound, &high_bound))
count = -1;
else
{
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 75b226d..e284ceb 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -491,7 +491,7 @@ compile_cplus_convert_array (compile_cplus_instance *instance,
{
LONGEST low_bound, high_bound, count;
- if (get_array_bounds (type, &low_bound, &high_bound) == 0)
+ if (!get_array_bounds (type, &low_bound, &high_bound))
count = -1;
else
{
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2f92887..cde0770 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1119,14 +1119,9 @@ get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
}
}
-/* Assuming TYPE is a simple, non-empty array type, compute its upper
- and lower bound. Save the low bound into LOW_BOUND if not NULL.
- Save the high bound into HIGH_BOUND if not NULL.
-
- Return 1 if the operation was successful. Return zero otherwise,
- in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
+/* See gdbtypes.h */
-int
+bool
get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
{
struct type *index = type->index_type ();
@@ -1135,11 +1130,11 @@ get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
int res;
if (index == NULL)
- return 0;
+ return false;
res = get_discrete_bounds (index, &low, &high);
if (res == -1)
- return 0;
+ return false;
if (low_bound)
*low_bound = low;
@@ -1147,7 +1142,7 @@ get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
if (high_bound)
*high_bound = high;
- return 1;
+ return true;
}
/* Assuming that TYPE is a discrete type and VAL is a valid integer
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 5f9ac27..2b6f599f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2435,8 +2435,15 @@ extern int get_vptr_fieldno (struct type *, struct type **);
extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
-extern int get_array_bounds (struct type *type, LONGEST *low_bound,
- LONGEST *high_bound);
+/* Assuming TYPE is a simple, non-empty array type, compute its upper
+ and lower bound. Save the low bound into LOW_BOUND if not NULL.
+ Save the high bound into HIGH_BOUND if not NULL.
+
+ Return true if the operation was successful. Return false otherwise,
+ in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
+
+extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
+ LONGEST *high_bound);
extern int discrete_position (struct type *type, LONGEST val, LONGEST *pos);