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


> This sounds good to me too. Perhaps a compromise between what Eli
> suggested and what you have been suggesting would work. How about
> we implement a on/off knob for now. Later on, if we understand better
> in which direction to use the threshold, then we can enhance the knob
> to include "auto", and then have a second knob.
> 
> As long as we cross-reference each setting in the help text, I think
> users won't be confused.

No objection to the above, so far... Fingers crossed.

Would you know, it just occured to me that the above is what my last
patch actually implemented :). Assuming this intermediate approach is
ok, I'm resubmitting that patch again.

Note that the patch was first submitted in:

        http://sources.redhat.com/ml/gdb-patches/2005-09/msg00047.html

2005-09-22  Joel Brobecker  <brobecker@adacore.com>

        * language.h (language_defn): New field la_print_array_index.
        (LA_PRINT_ARRAY_INDEX): New macro.
        (default_print_array_index): Add declaration.
        * language.c (default_print_array_index): new function.
        (unknown_language): Add value for new field.
        (auto_language): Likewise.
        (local_language): Likewise.
        * c-lang.c (c_language_defn): Likewise.
        (cpluc_language_defn): Likewise.
        (asm_language_defn): Likewise.
        (minimal_language_defn): Likewise.
        * f-lang.c (f_language_defn): Likewise.
        * jv-lang.c (java_language_defn): Likewise.
        * m2-lang.c (m2_language_defn): Likewise.
        * objc-lang.c (objc_language_defn): Likewise.
        * p-lang.c (pascal_language_defn): Likewise.
        * ada-lang.c (ada_print_array_index): New function.
        (ada_language_defn): Add value for new field.
        * valprint.h (print_array_indexes_p): Add declaration.
        (maybe_print_array_index): Add declaration.
        (val_print_array_elements): Add new parameter to function profile.
        * valprint.c (print_array_indexes): New static variable.
        (show_print_array_indexes): New function.
        (print_array_indexes_p): New function.
        (maybe_print_array_index): New function.
        (val_print_array_elements): Add new parameter real_index_offset.
        Print the index of each element if required by the user.
        (_initialize_valprint): Add new array-indexes "set/show print" command.
        * c-valprint.c (c_val_print): Update call to val_print_array_elements.
        * p-valprint.c (pascal_val_print): Likewise.
        * ada-valprint.c (ada_get_array_low_bound_and_type): New function,
        mostly extracted from print_optional_low_bound().
        (print_optional_low_bound): Replace extracted code by call to
        ada_get_array_low_bound_and_type(). Stop printing the low bound
        if indexes will be printed for all elements of the array.
        (val_print_packed_array_elements): Print the index of each element
        of the array if necessary.
        (ada_val_print_1): For non-packed arrays, compute the array low
        bound, and pass it to val_print_array_elements().

Tested on x86-linux, no regression. Testcases and documentation to follow
after the review.

Thanks,
-- 
Joel

Attachment: indexes.diff
Description: Text document


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