From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCHv2 2/2] gdb/fortran: Access elements of a structure with dynamic type
Date: Wed, 22 Jul 2020 13:19:12 -0600 [thread overview]
Message-ID: <87h7tzbbnz.fsf@tromey.com> (raw)
In-Reply-To: <f73c8dadb4e7cdfbf6d5ff7ef80b6250cb022acc.1594647094.git.andrew.burgess@embecosm.com> (Andrew Burgess's message of "Mon, 13 Jul 2020 14:33:22 +0100")
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
Andrew> case STRUCTOP_STRUCT:
Andrew> tem = longest_to_int (exp->elts[pc + 1].longconst);
Andrew> (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
Andrew> + oldpos = *pos;
Andrew> arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
Andrew> if (noside == EVAL_SKIP)
Andrew> return eval_skip_value (exp);
Andrew> + if (noside == EVAL_AVOID_SIDE_EFFECTS)
Andrew> + {
Andrew> + /* If the element of the structure has a dynamic type then we
Andrew> + need to get the real value representing the containing
Andrew> + structure so that we can correctly evaluate the type of the
Andrew> + element. If we're not already avoiding side effects then we
Andrew> + already have the real value of the containing structure, so
Andrew> + this is not needed. */
Andrew> + type = lookup_struct_elt_type (value_type (arg1),
Andrew> + &exp->elts[pc + 2].string, 1);
Andrew> + if (type != nullptr && is_dynamic_type (type))
Andrew> + {
Andrew> + *pos = oldpos;
Andrew> + arg1 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_NORMAL);
Re-evaluating a subexpression like this can lead to problems; see for
example commit 6830f270e ("Avoid exponential behavior in rust_evaluate_subexp").
I don't know if there's another way to do this, though.
Tom
next prev parent reply other threads:[~2020-07-22 19:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-10 15:22 [PATCH 0/2] Fortran dynamic type related fixes Andrew Burgess
2020-07-10 15:22 ` [PATCH 1/2] gdb/fortran: resolve dynamic types when readjusting after an indirection Andrew Burgess
2020-07-10 15:22 ` [PATCH 2/2] gdb/fortran: Access elements of a structure with dynamic type Andrew Burgess
2020-07-13 13:33 ` [PATCHv2 0/2] Fortran dynamic type related fixes Andrew Burgess
2020-07-13 13:33 ` [PATCHv2 1/2] gdb/fortran: resolve dynamic types when readjusting after an indirection Andrew Burgess
2020-07-22 19:10 ` Tom Tromey
2020-07-25 0:31 ` Andrew Burgess
2020-07-13 13:33 ` [PATCHv2 2/2] gdb/fortran: Access elements of a structure with dynamic type Andrew Burgess
2020-07-22 19:19 ` Tom Tromey [this message]
2020-07-23 10:28 ` Andrew Burgess
2020-07-24 20:03 ` Tom Tromey
2020-07-26 19:31 ` Tom Tromey
2020-08-04 19:19 ` Tom Tromey
2020-08-06 15:38 ` Andrew Burgess
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=87h7tzbbnz.fsf@tromey.com \
--to=tom@tromey.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).