[DTrace-devel] [PATCH 2/4] Add an offsetof() function for CTF types

Nick Alcock nick.alcock at oracle.com
Fri May 19 17:00:21 UTC 2023


On 19 May 2023, Nick Alcock via DTrace-devel verbalised:

> On 18 May 2023, eugene loh verbalised:
>
>> +/*
>> + * Get offsetof(structname, membername) information from CTF.
>> + * Optionally, also get member size.
>> + */
>> +static int
>> +dt_cg_ctf_offsetof(const char *structname, const char *membername, size_t *sizep)
>> +{
>> +	ctf_file_t *cfp = yypcb->pcb_hdl->dt_shared_ctf;
>> +	ctf_id_t type;
>> +	ctf_membinfo_t ctm;
>> +
>> +	if (!cfp)
>> +		longjmp(yypcb->pcb_jmpbuf, EDT_NOCTF);
>> +	type = ctf_lookup_by_name(cfp, structname);
>
> If you want to look up a struct or a union foo, you should look up
> "struct foo" or "union foo". What you've got here will I believe work

Pardon me, I didn't look at how this was being used. The name you pass
in *already contains* 'struct ' etc, so...

Reviewed-by: Nick Alcock <nick.alcock at oracle.com>

-- 
NULL && (void)



More information about the DTrace-devel mailing list