This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 11/25] Use VEC for target_desc.reg_defs
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Wed, 28 Jun 2017 20:01:22 +0100
- Subject: Re: [PATCH 11/25] Use VEC for target_desc.reg_defs
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A53353D97C
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A53353D97C
- References: <1497256916-4958-1-git-send-email-yao.qi@linaro.org> <1497256916-4958-12-git-send-email-yao.qi@linaro.org>
On 06/12/2017 09:41 AM, Yao Qi wrote:
> Nowadays, target_desc.reg_defs is a pointer points to a pre-generated
> array, which is not flexible. This patch changes it from an array
> to a VEC so that GDBserver can create target descriptions dynamically
> later. Instead of using pre-generated array, the -generated.c calls
> VEC_safe_push to add each register to vector.
>
> Since target_desc.reg_defs is used in IPA, we need to build common/vec.c
> for IPA too.
Can you say more about the choice of VEC? It feels
like new uses should come with a rationale for why it'd
be preferred over std::vector.
I'm guessing that it's because the gdb side uses VEC too?
Or is it something else? (I can guess other reasons, but
the point is that we shouldn't have to guess.)
[Note that the IPA avoids calling the inferior's malloc during
normal operation, to avoid deadlocking the inferior.
This is initialization code, so it's not covered by the exact
same level of concern, even though one of the original goals was
to also be able to inject the IPA into a running inferior (e.g., by
calling dlopen via gdb). That does work (or at least used to),
but it's a little unsafe because the IPA initialization code
already calls malloc and other non-async-signal-safe functions.
I guess std::vector would make it possible to use a custom
allocator in the IPA that would allocate memory with mmap
directly (or we'd make the IPA's xmalloc allocate with mmap,
and then the allocator would use xmalloc).]
Thanks,
Pedro Alves