From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFA] print arrays with indexes
Date: Tue, 04 Oct 2005 07:02:00 -0000 [thread overview]
Message-ID: <20051004070220.GZ8849@adacore.com> (raw)
In-Reply-To: <20051003061733.GL938@adacore.com>
Hmmmm, I was working on transforming one of our internal testcase
(which uses Ada) for the patch below into a dejagnu testcase. It should
all be smooth since I did the testing manually with the patch below,
but it appears I missed something. I'm seeing some unexpected failures.
> 2005-10-02 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.
> * ada-lang.c (ada_print_array_index): New function.
> (ada_language_defn): Add value for new field.
> * 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.
> * scm-lang.c (scm_language_defn): Likewise.
> * valprint.h (print_array_indexes_p): Add declaration.
> (get_array_low_bound): Add declaration.
> (maybe_print_array_index): Add declaration.
> * valprint.c (print_array_indexes): New static variable.
> (show_print_array_indexes): New function.
> (print_array_indexes_p): New function.
> (get_array_low_bound): New function.
> (maybe_print_array_index): New function.
> (val_print_array_elements): Print the index of each element if
> requested by the user.
> (_initialize_valprint): Add new array-indexes "set/show print" command.
> * ada-valprint.c (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.
Issues:
1. I now understand the why of the
if (TYPE_CODE (index_type) == RANGE_TYPE)
index_type = TYPE_TARGET_TYPE (index_type)
But this is an Ada-specific thing, and I'll take care of this in
a separate patch. And I'll add a testcase as a bonus.
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...
Sorry about that...
--
Joel
next prev parent reply other threads:[~2005-10-04 7:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-06 20:20 [RFC/RFA] " Joel Brobecker
2005-09-06 20:57 ` Daniel Jacobowitz
2005-09-07 5:40 ` Joel Brobecker
2005-09-07 13:23 ` Daniel Jacobowitz
2005-09-07 20:24 ` Joel Brobecker
2005-09-14 17:13 ` [RFA] " Joel Brobecker
2005-09-17 20:49 ` Daniel Jacobowitz
2005-09-17 21:51 ` Joel Brobecker
2005-09-17 22:07 ` Daniel Jacobowitz
2005-09-18 3:37 ` Eli Zaretskii
2005-09-18 3:46 ` Daniel Jacobowitz
2005-09-18 5:41 ` Joel Brobecker
2005-09-18 19:08 ` Eli Zaretskii
2005-09-18 19:19 ` Daniel Jacobowitz
2005-09-18 20:05 ` Eli Zaretskii
2005-09-20 7:31 ` Joel Brobecker
2005-09-20 19:18 ` Eli Zaretskii
2005-09-20 19:31 ` Joel Brobecker
2005-09-20 19:33 ` Daniel Jacobowitz
2005-09-20 19:39 ` Joel Brobecker
2005-09-21 3:44 ` Eli Zaretskii
2005-09-22 16:47 ` Joel Brobecker
2005-09-26 1:23 ` Daniel Jacobowitz
2005-09-27 1:04 ` Joel Brobecker
2005-10-02 22:42 ` Daniel Jacobowitz
2005-10-03 6:17 ` Joel Brobecker
2005-10-03 15:50 ` Daniel Jacobowitz
2005-10-03 21:23 ` Joel Brobecker
2005-10-04 7:02 ` Joel Brobecker [this message]
2005-10-04 7:41 ` Joel Brobecker
2005-09-21 3:44 ` Eli Zaretskii
2005-09-18 8:53 ` Mark Kettenis
2005-09-18 19:10 ` Eli Zaretskii
2005-09-07 20:39 ` [RFC/RFA] " Jim Blandy
2005-09-07 21:41 ` Joel Brobecker
2005-09-09 19:14 ` Jim Blandy
2005-09-06 21:45 ` Jim Blandy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051004070220.GZ8849@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox