This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 2/2] typedef-checking for CU relative vs. absolute offsets [Re: RFC: problem with DW_OP_GNU_deref_type and dwarf's get_base_type callback]


> This is not maintainable IMO in its current form.
> 
> typedef struct { unsigned int co; } cu_offset;
> typedef struct { unsigned int so; } sect_offset;

[brainstorming]

I like the idea of having distinct types. If we were using Ada,
we would have been able to define distinct scalar types for our
offsets, and the compiler would catch invalid uses. It's a bit
more of a pain in C because the use of a struct makes it harder
to use, but it's certainly better to catch these errors at compile
time.  I do find "co" and "so" a little too short and confusing,
though.  So, here is another suggestion:

typedef struct { unsigned int val; } cu_offset;
typedef struct { unsigned int val; } sect_offset;

?

Would that be enough? Or maybe you really want different field names
to make the writer aware of which offset he really has. In that case,
perhaps field names that are a little more explicit? For instance:
"rel_off" and "abs_off" (for "relative" vs "absolute")?

-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]