This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 6/8] Create xml from target descriptions
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Philipp Rudo <prudo at linux dot vnet dot ibm dot com>
- Cc: Alan Hayward <Alan dot Hayward at arm dot com>, "gdb-patches\@sourceware.org" <gdb-patches at sourceware dot org>, nd <nd at arm dot com>
- Date: Thu, 25 Jan 2018 15:44:55 +0000
- Subject: Re: [PATCH v2 6/8] Create xml from target descriptions
- Authentication-results: sourceware.org; auth=none
- References: <7C97CC6A-92CB-4702-820D-206022F07102@arm.com> <B741D224-2DE6-42FD-8D32-59D68205EB6E@arm.com> <20180125141423.1ff34025@ThinkPad>
Philipp Rudo <prudo@linux.vnet.ibm.com> writes:
> Same for tdesc_type::make_gdb_type (patch #5). But here i would prefer to not
> even declare the method for GDBserver, i.e.
>
> struct tdesc_type
> {
>
> [...]
>
> #ifndef GDBSERVER
> virtual type *make_gdb_type (struct gdbarch *gdbarch) const = 0;
> #endif
> };
>
> The problem i see with implementing stubs calling error is that you cannot find
> out you made a mistake until you call the function during run-time. This gives
> room to nasty bugs which could easily be prevented when there is a compile bug.
make_gdb_type and gdbarch shouldn't be put into arch/tdesc.h at all, if
possible. You can create an sub-class of tdesc_element_visitor in gdb
side, and create the gdb type by visiting these elements, like this,
class gdb_type_creator : public tdesc_element_visitor
{
public:
gdb_type_createor (struct gdbarch *gdbarch)
: m_gdbarch (gdbarch)
{}
void visit (const tdesc_type_builtin *e) override
{
switch (e->kind)
{
case TDESC_TYPE_BOOL:
m_type = builtin_type (m_gdbarch)->builtin_bool;
break;
....
};
}
void visit (const tdesc_type_vector *e) override
{
// do what tdesc_type_vector::make_gdb_type does.
}
void visit (const tdesc_type_with_fields *e) override
{
// likewise.
}
private:
// input
struct * const m_gdbarch;
// output
type *m_type;
};
gdb_type_creator gdb_type (gdbarch);
tdesc_type->accept (gdb_type);
gdb_type.m_type is the type we need.
--
Yao (齐尧)