From: Wei-min Pan <weimin.pan@oracle.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH PR gdb/20057] Internal error on trying to set {char[]}$pc="string"
Date: Thu, 01 Feb 2018 01:46:00 -0000 [thread overview]
Message-ID: <1d28e9c6-6377-0c46-6bce-1dc25a7fa2d5@oracle.com> (raw)
In-Reply-To: <20180131074526.rqbsjxyxp3p26js5@adacore.com>
On 1/30/2018 11:45 PM, Joel Brobecker wrote:
>> Is there any reason why the gdbarch structure, which won't be freed
>> until the corresponding architecture is, needs to have a lifetime that
>> matches the objfiles?
> Unfortunately, I only have vague answers for you. I know it's not
> as satisfactory as a firm one, but I haven't had time to investigate
> further.
>
> My feeling is that it's (intuitively) a bad idea to start mixing
> and matching the ownership type for a give type chain. It just
> muddies the waters, and makes memory management more complex.
Given there are functions such as arch_integer_type(),
arch_character_type(),
and arch_float_type() that can be used to add types to an arch, it doesn't
seem terribly wrong to add a type which is not associated with any objfile
to gdbarch? Also a type can actually exist in both an arch and an objfile.
> Parallel to that, there is another obstacle if you want to enhance
> copy_type to handle arch-owned types, as the current implementation
> explicitly assumes that the type is objfile-owned, and therefore
> references its objfile's obstack:
>
> if (TYPE_DYN_PROP_LIST (type) != NULL)
> TYPE_DYN_PROP_LIST (new_type)
> = copy_dynamic_prop_list (&TYPE_OBJFILE (type) -> objfile_obstack,
> TYPE_DYN_PROP_LIST (type));
Good point. The following statement
 if (TYPE_DYN_PROP_LIST (type) != NULL)
needs to be changed to:
 if (TYPE_DYN_PROP_LIST (type) != NULL && TYPE_OBJFILE_OWNED(type))
>>> I happen to have hit the same issue as you, but from an Ada expression,
>>> and sent it a fix not long ago:
>>> https://www.sourceware.org/ml/gdb-patches/2018-01/msg00240.html
>>>
>>> Does it fix your problem too?
>>>
>> Yes, it does fix my problem of gdb asserting on the "set {char[]}$pc="hi""
>> command, as
>> reported in the PR,
> Good!
>
>> but still asserts on a slightly modified "set {unsigned char[]}$pc="hi"
>> command.
> It's should be something fairly similar. Can you track down which type
> it is which is arch-owned, and where it comes from? I have a feeling
> that there is a simple fix similar to mine to be made that would
> fix that.
Your fix in lookup_array_range_type() takes care the case where
"element_type"
was owned by an objfile but still creates an arch-owned index type if it
was not.
Here is the test case that comes with the PR:
% cat x.c
char p[] = "hello";
int main()
{
 return ((int)(p[0]));
}
Please note that the test case declares base type "char" which has an
associated objfile and is picked up by lookup_symbol_aux() when
command "set {char[]}$pc="hi" is parsed and eventually is passed as
the element type argument to lookup_array_range_type(). Using any
other type, such as "unsigned char", in that gdb command results in
the element type that is picked up from gdbarch and has no associated
objfile.
>
> I can help taking a look, but I'm a little tied up this week...
>
I'd really appreciate it if you can take a look at your convenience. It
doesn't
have to be this week. Thanks.
next prev parent reply other threads:[~2018-02-01 1:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 2:12 Weimin Pan
2018-01-25 4:14 ` Joel Brobecker
2018-01-25 22:24 ` Wei-min Pan
2018-01-31 7:45 ` Joel Brobecker
2018-02-01 1:46 ` Wei-min Pan [this message]
2018-02-01 8:00 ` Joel Brobecker
2018-02-02 1:14 ` Wei-min Pan
2018-11-14 23:38 ` Wei-min Pan
2018-11-14 23:51 ` Joel Brobecker
2018-11-15 0:16 ` Wei-min Pan
2018-11-29 19:18 ` Tom Tromey
2018-11-29 21:10 ` Wei-min Pan
2018-11-29 21:52 ` Tom Tromey
2018-11-29 23:26 ` Wei-min Pan
2018-11-30 15:37 ` Tom Tromey
2018-11-30 17:31 ` Wei-min Pan
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=1d28e9c6-6377-0c46-6bce-1dc25a7fa2d5@oracle.com \
--to=weimin.pan@oracle.com \
--cc=brobecker@adacore.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