Project

General

Profile

Bug #3676

dt_print_enum hardcodes a value of zero

Added by Robert Mustacchi about 7 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
Normal
Category:
DTrace
Start date:
2013-04-03
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

From the Joyent bug report:

dtrace -qn 'typedef enum { a, b } a_t; BEGIN{ print(a); print(b); }'
enum  a
enum  a
dtrace -q -n 'BEGIN{ print((boolean_t)1); print((boolean_t)0); }'
boolean_t B_FALSE
boolean_t B_FALSE

If we look at the code:

456 static void
457 dt_print_enum(ctf_id_t base, ulong_t off, dt_printarg_t *pap)
458 {
459         FILE *fp = pap->pa_file;
460         ctf_file_t *ctfp = pap->pa_ctfp;
461         const char *ename;
462         int value = 0;
463 
464         if ((ename = ctf_enum_name(ctfp, base, value)) != NULL)
465                 (void) fprintf(fp, "%s", ename);
466         else
467                 (void) fprintf(fp, "%d", value);
468 }

value is hardcoded to zero. So we will never get the correct value from the enum.

History

#1

Updated by Robert Mustacchi about 7 years ago

  • % Done changed from 90 to 100
  • Status changed from New to Resolved

Resolved in b1fa6326238973aeaf12c34fcda75985b6c06be1.

Also available in: Atom PDF