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]

Re: [RFA] print arrays with indexes


BTW, I forgot to mention a couple of things regarding:

> 2. More annoying, I just tried something else, which is to print an
>    empty Ada array. Ada allows you to create this by using declarations
>    such as this:
> 
>         Table : array (1 .. 0) of Integer;
> 
>    Basically, if the lower/left bound is greater than the right/higher
>    bound, then the array is empty.
> 
>    I just discovered that ada_val_print_1 calls val_print_array_elements
>    even if the array is empty.  This triggers one of the guards in
>    get_array_low_bound(), since the function expects a non-empty array.
> 
>    I'm happy to just put a check in the Ada part to avoid calling
>    val_print_array_elements for empty arrays. This should be fine, but
>    I'm wondering if other languages might be doing the same, in which
>    case it's probably going to be safer to modify a bit
>    val_print_array_elements to handle empty arrays...

  a. I tried with a C example, something like this:

        int table [] = {};

     And verified that GDB worked correctly (printed the address
     of the array, but no value). So there is no issue with C,
     at least. Don't have a pascal compiler handy, though.

  b. I prefer the second approach. It just feels safer and more elegant.
     In fact I just finished testing the attached patch. I will submit
     a proper patch together with a testcase tomorrow.

-- 
Joel

Attachment: valprint.c.diff
Description: Text document


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