This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/ada] fix crash when printing array bound


Hello,

This patch cures a crash when printing an array bound. It happens
when the array is indexed using a range type:

   type Index is (Zero, One, Two);
   type Vector is array (Index) of Integer;
   Table : Vector := (0, 1, 2);

If you try to print either bounds, you'll get:

   (gdb) p table'first
   [1]    3495 segmentation fault  ../obj/gdb/gdb bar

The code was assuming that the array was indexed using a integer type.
So we added handling for enum types too.

2008-01-03  Joel Brobecker  <brobecker@adacore.com>

        * ada-lang.c (ada_array_bound_from_type): Make non-static.
        Handle properly the case when the index type is an enumerated type.
        Do not return the subtype of the bounds type, just return the
        bounds type directly - this is not needed and is more consistent
        with what we do for arrays when no XA parallel type exists.

I also wrote a small testcase:

2008-01-03  Joel Brobecker  <brobecker@adacore.com>

        * gdb.ada/array_bounds/bar.adb: New file.
        * gdb.ada/array_bounds.exp: New testcase.

All tested on x86-linux, no regression.
Checked in.

-- 
Joel

Attachment: array-tick-first.diff
Description: Text document

Attachment: array-tick-first-tc.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]