pahole: Introduce --hex to print offsets and sizes in hexadecimal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
0412efb401
commit
6476d24d73
|
@ -70,6 +70,7 @@ struct conf_fprintf {
|
|||
uint8_t flat_arrays:1;
|
||||
uint8_t no_parm_names:1;
|
||||
uint8_t classes_as_structs:1;
|
||||
uint8_t hex_fmt:1;
|
||||
};
|
||||
|
||||
struct cus {
|
||||
|
|
|
@ -703,7 +703,9 @@ static size_t struct_member__fprintf(struct class_member *self,
|
|||
if (!sconf.suppress_offset_comment) {
|
||||
/* Check if this is a anonymous union */
|
||||
const int slen = cm_name ? (int)strlen(cm_name) : -1;
|
||||
printed += fprintf(fp, "%*s/* %5u %5u */",
|
||||
printed += fprintf(fp, sconf.hex_fmt ?
|
||||
"%*s/* %#5x %#5x */" :
|
||||
"%*s/* %5u %5u */",
|
||||
(sconf.type_spacing +
|
||||
sconf.name_spacing - slen - 3),
|
||||
" ", offset, size);
|
||||
|
@ -719,17 +721,21 @@ static size_t struct_member__fprintf(struct class_member *self,
|
|||
if (!sconf.suppress_offset_comment) {
|
||||
int size_spacing = 5;
|
||||
|
||||
printed += fprintf(fp, "%*s/* %5u",
|
||||
printed += fprintf(fp, sconf.hex_fmt ?
|
||||
"%*s/* %#5x" : "%*s/* %5u",
|
||||
spacing > 0 ? spacing : 0, " ",
|
||||
offset);
|
||||
|
||||
if (self->bitfield_size != 0) {
|
||||
printed += fprintf(fp, ":%2d",
|
||||
printed += fprintf(fp, sconf.hex_fmt ?
|
||||
":%#2x" : ":%2u",
|
||||
self->bitfield_offset);
|
||||
size_spacing -= 3;
|
||||
}
|
||||
|
||||
printed += fprintf(fp, " %*u */", size_spacing, size);
|
||||
printed += fprintf(fp, sconf.hex_fmt ?
|
||||
" %#*x */" : " %*u */",
|
||||
size_spacing, size);
|
||||
}
|
||||
}
|
||||
return printed;
|
||||
|
@ -755,7 +761,9 @@ static size_t union_member__fprintf(struct class_member *self,
|
|||
* '} member_name;' last line of the type printed in the
|
||||
* above call to type__fprintf.
|
||||
*/
|
||||
printed += fprintf(fp, ";%*s/* %11zd */",
|
||||
printed += fprintf(fp, conf->hex_fmt ?
|
||||
";%*s/* %#11zx */" :
|
||||
";%*s/* %11zd */",
|
||||
(conf->type_spacing +
|
||||
conf->name_spacing - slen - 3), " ", size);
|
||||
}
|
||||
|
@ -764,7 +772,9 @@ static size_t union_member__fprintf(struct class_member *self,
|
|||
|
||||
if (!conf->suppress_offset_comment) {
|
||||
const int spacing = conf->type_spacing + conf->name_spacing - printed;
|
||||
printed += fprintf(fp, "%*s/* %11zd */",
|
||||
printed += fprintf(fp, conf->hex_fmt ?
|
||||
"%*s/* %#11zx */" :
|
||||
"%*s/* %11zd */",
|
||||
spacing > 0 ? spacing : 0, " ", size);
|
||||
}
|
||||
}
|
||||
|
|
8
pahole.c
8
pahole.c
|
@ -741,6 +741,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
|
|||
#define ARGP_fixup_silly_bitfields 302
|
||||
#define ARGP_first_obj_only 303
|
||||
#define ARGP_classes_as_structs 304
|
||||
#define ARGP_hex_fmt 305
|
||||
|
||||
static const struct argp_option pahole__options[] = {
|
||||
{
|
||||
|
@ -958,6 +959,11 @@ static const struct argp_option pahole__options[] = {
|
|||
.key = ARGP_classes_as_structs,
|
||||
.doc = "Use 'struct' when printing classes",
|
||||
},
|
||||
{
|
||||
.name = "hex",
|
||||
.key = ARGP_hex_fmt,
|
||||
.doc = "Print offsets and sizes in hexadecimal",
|
||||
},
|
||||
{
|
||||
.name = NULL,
|
||||
}
|
||||
|
@ -1035,6 +1041,8 @@ static error_t pahole__options_parser(int key, char *arg,
|
|||
first_obj_only = true; break;
|
||||
case ARGP_classes_as_structs:
|
||||
conf.classes_as_structs = 1; break;
|
||||
case ARGP_hex_fmt:
|
||||
conf.hex_fmt = 1; break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue