* m2-typeprint.c:m2_range's use of TYPE_DOMAIN_TYPE: Eh?
@ 2015-01-19 18:30 Doug Evans
2015-01-20 22:25 ` Gaius Mulley
0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2015-01-19 18:30 UTC (permalink / raw)
To: gdb-patches, gaius
Hi.
Does anyone know why m2_range uses TYPE_DOMAIN_TYPE here?
AFAICT, use of TYPE_DOMAIN_TYPE is wrong here.
It is only used for TYPE_CODE_{MEMBERPTR,METHODPTR,METHOD}.
ref: gdbtypes.h:
/* * For types with virtual functions (TYPE_CODE_STRUCT),
VPTR_BASETYPE is the base class which defined the virtual
function table pointer.
For types that are pointer to member types (TYPE_CODE_METHODPTR,
TYPE_CODE_MEMBERPTR), VPTR_BASETYPE is the type that this pointer
is a member of.
For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate
type that contains the method.
Unused otherwise. */
struct type *vptr_basetype;
I ask because one symbol table improvement I want to make
may be best implemented if I add a new field to struct main_type.
However, this struct is space-critical, so I'm trying to find
some cleanup that can be done.
Question: Why doesn't vptr_fieldno, vptr_basetype live in
type_specific.cplus_specific?
Alas, vptr_basetype is overloaded and is used also for TYPE_DOMAIN_TYPE:
#define TYPE_DOMAIN_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype
hence wondering why in the world m2_range is using it. :-)
For TYPE_CODE_{MEMBERPTR,METHODPTR,METHOD},
any reason why their "domain type" (I'll want to rename that)
cannot live in type_specific?
---
void
m2_range (struct type *type, struct ui_file *stream, int show,
int level, const struct type_print_options *flags)
{
if (TYPE_HIGH_BOUND (type) == TYPE_LOW_BOUND (type))
m2_print_type (TYPE_DOMAIN_TYPE (type), "", stream, show, level,
flags);
else
{
struct type *target = TYPE_TARGET_TYPE (type);
fprintf_filtered (stream, "[");
print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
fprintf_filtered (stream, "..");
print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
fprintf_filtered (stream, "]");
}
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: m2-typeprint.c:m2_range's use of TYPE_DOMAIN_TYPE: Eh?
2015-01-19 18:30 m2-typeprint.c:m2_range's use of TYPE_DOMAIN_TYPE: Eh? Doug Evans
@ 2015-01-20 22:25 ` Gaius Mulley
2015-01-21 4:15 ` Doug Evans
0 siblings, 1 reply; 4+ messages in thread
From: Gaius Mulley @ 2015-01-20 22:25 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
Doug Evans <xdje42@gmail.com> writes:
> Hi.
>
> Does anyone know why m2_range uses TYPE_DOMAIN_TYPE here?
>
> AFAICT, use of TYPE_DOMAIN_TYPE is wrong here.
> It is only used for TYPE_CODE_{MEMBERPTR,METHODPTR,METHOD}.
>
> ref: gdbtypes.h:
>
> /* * For types with virtual functions (TYPE_CODE_STRUCT),
> VPTR_BASETYPE is the base class which defined the virtual
> function table pointer.
>
> For types that are pointer to member types (TYPE_CODE_METHODPTR,
> TYPE_CODE_MEMBERPTR), VPTR_BASETYPE is the type that this pointer
> is a member of.
>
> For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate
> type that contains the method.
>
> Unused otherwise. */
>
> struct type *vptr_basetype;
>
> I ask because one symbol table improvement I want to make
> may be best implemented if I add a new field to struct main_type.
> However, this struct is space-critical, so I'm trying to find
> some cleanup that can be done.
> Question: Why doesn't vptr_fieldno, vptr_basetype live in
> type_specific.cplus_specific?
>
> Alas, vptr_basetype is overloaded and is used also for TYPE_DOMAIN_TYPE:
>
> #define TYPE_DOMAIN_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype
>
> hence wondering why in the world m2_range is using it. :-)
Hi Doug,
feel free to clean up the code and make it comply with other languages.
I've a feeling that this code will need an overhaul against gm2-1.1.1
(grafted on gcc-4.7.4). The gcc/gm2 interface has pretty much all
been rewritten since gm2-1.0 (which was grafted onto gcc-4.1.2).
> For TYPE_CODE_{MEMBERPTR,METHODPTR,METHOD},
> any reason why their "domain type" (I'll want to rename that)
> cannot live in type_specific?
>
> ---
>
> void
> m2_range (struct type *type, struct ui_file *stream, int show,
> int level, const struct type_print_options *flags)
> {
> if (TYPE_HIGH_BOUND (type) == TYPE_LOW_BOUND (type))
> m2_print_type (TYPE_DOMAIN_TYPE (type), "", stream, show, level,
> flags);
> else
> {
> struct type *target = TYPE_TARGET_TYPE (type);
>
> fprintf_filtered (stream, "[");
> print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
> fprintf_filtered (stream, "..");
> print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
> fprintf_filtered (stream, "]");
> }
> }
regards,
Gaius
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: m2-typeprint.c:m2_range's use of TYPE_DOMAIN_TYPE: Eh?
2015-01-20 22:25 ` Gaius Mulley
@ 2015-01-21 4:15 ` Doug Evans
2015-01-21 11:05 ` Gaius Mulley
0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2015-01-21 4:15 UTC (permalink / raw)
To: Gaius Mulley; +Cc: gdb-patches
On Tue, Jan 20, 2015 at 2:25 PM, Gaius Mulley
<gaius.mulley@southwales.ac.uk> wrote:
> Doug Evans <xdje42@gmail.com> writes:
>
>> Hi.
>>
>> Does anyone know why m2_range uses TYPE_DOMAIN_TYPE here?
>>
>> [...]
>> Alas, vptr_basetype is overloaded and is used also for TYPE_DOMAIN_TYPE:
>>
>> #define TYPE_DOMAIN_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype
>>
>> hence wondering why in the world m2_range is using it. :-)
>
> Hi Doug,
>
> feel free to clean up the code and make it comply with other languages.
> I've a feeling that this code will need an overhaul against gm2-1.1.1
> (grafted on gcc-4.7.4). The gcc/gm2 interface has pretty much all
> been rewritten since gm2-1.0 (which was grafted onto gcc-4.1.2).
Thanks.
Alas cleaning up this code is non-obvious.
What do I replace TYPE_DOMAIN_TYPE with?
I'm tempted to just go with TYPE_TARGET_TYPE
and let y'all fix it later if that's wrong.
>
>> For TYPE_CODE_{MEMBERPTR,METHODPTR,METHOD},
>> any reason why their "domain type" (I'll want to rename that)
>> cannot live in type_specific?
>>
>> ---
>>
>> void
>> m2_range (struct type *type, struct ui_file *stream, int show,
>> int level, const struct type_print_options *flags)
>> {
>> if (TYPE_HIGH_BOUND (type) == TYPE_LOW_BOUND (type))
>> m2_print_type (TYPE_DOMAIN_TYPE (type), "", stream, show, level,
>> flags);
>> else
>> {
>> struct type *target = TYPE_TARGET_TYPE (type);
>>
>> fprintf_filtered (stream, "[");
>> print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
>> fprintf_filtered (stream, "..");
>> print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
>> fprintf_filtered (stream, "]");
>> }
>> }
>
> regards,
> Gaius
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: m2-typeprint.c:m2_range's use of TYPE_DOMAIN_TYPE: Eh?
2015-01-21 4:15 ` Doug Evans
@ 2015-01-21 11:05 ` Gaius Mulley
0 siblings, 0 replies; 4+ messages in thread
From: Gaius Mulley @ 2015-01-21 11:05 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
Doug Evans <xdje42@gmail.com> writes:
>
> Thanks.
> Alas cleaning up this code is non-obvious.
> What do I replace TYPE_DOMAIN_TYPE with?
> I'm tempted to just go with TYPE_TARGET_TYPE
> and let y'all fix it later if that's wrong.
Hi Doug,
sure this sounds pragmatic - I'll look at the code next week
in the light of gm2-1.1.1
regards,
Gaius
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-21 11:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19 18:30 m2-typeprint.c:m2_range's use of TYPE_DOMAIN_TYPE: Eh? Doug Evans
2015-01-20 22:25 ` Gaius Mulley
2015-01-21 4:15 ` Doug Evans
2015-01-21 11:05 ` Gaius Mulley
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).