[DTrace-devel] [PATCH 03/20] Do not print an offset for builtin variables

Eugene Loh eugene.loh at oracle.com
Wed Jun 9 08:27:15 PDT 2021


Actually, speaking of testing, how does this patch do with the test 
suite?  It seems to me that it causes 
test/unittest/variables/gvar/tst.undecl-offset.sh to FAIL.

On 6/2/21 1:38 PM, Eugene Loh wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> though it would be nice to have tests accompany patches.
>
> On 6/2/21 1:47 AM, Kris Van Hees wrote:
>> Builtin variables are global variables but their value is not stored
>> in the gvars BPF map.  Therefore, their offset is always -1 which is
>> displayed as ffffffff.  That value is too wide for the OFFSET field
>> in the variable list in the disassembly listing.  Since the offset
>> value is not meaningful in this case, it is no longer printed.
>>
>> Offsets are now also printed in decimal rather than hexadecimal to be
>> consistent with other offset values in disassembly listings.
>>
>> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
>> ---
>>   libdtrace/dt_dis.c | 10 +++++++---
>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/libdtrace/dt_dis.c b/libdtrace/dt_dis.c
>> index a8c4e1ca..fdd10dc3 100644
>> --- a/libdtrace/dt_dis.c
>> +++ b/libdtrace/dt_dis.c
>> @@ -716,7 +716,11 @@ dt_dis_difo(const dtrace_difo_t *dp, FILE *fp, 
>> const dt_ident_t *idp,
>>         for (i = 0; i < dp->dtdo_varlen; i++) {
>>           dtrace_difv_t *v = &dp->dtdo_vartab[i];
>> -        char kind[4], scope[4], range[12], flags[16] = { 0 };
>> +        char offset[11] = { 0 }, flags[16] = { 0 };
>> +        char kind[4], scope[4], range[12];
>> +
>> +        if (v->dtdv_offset != -1)
>> +            snprintf(offset, sizeof(offset), "%u", v->dtdv_offset);
>>             switch (v->dtdv_kind) {
>>           case DIFV_KIND_AGGREGATE:
>> @@ -759,9 +763,9 @@ dt_dis_difo(const dtrace_difo_t *dp, FILE *fp, 
>> const dt_ident_t *idp,
>>           if (v->dtdv_flags & DIFV_F_MOD)
>>               strcat(flags, "/w");
>>   -        fprintf(fp, "%-16s %-4x %-6x %-3s %-3s %-11s %-4s %s\n",
>> +        fprintf(fp, "%-16s %-4x %-6s %-3s %-3s %-11s %-4s %s\n",
>>               &dp->dtdo_strtab[v->dtdv_name], v->dtdv_id,
>> -            v->dtdv_offset, kind, scope, range, flags + 1,
>> +            offset, kind, scope, range, flags + 1,
>>               dt_dis_typestr(&v->dtdv_type, type, sizeof(type)));
>>       }


More information about the DTrace-devel mailing list