pahole: Introduce --fixup_silly_bitfields
$ pahole -C acpi_device_perf_flags ac.o struct acpi_device_perf_flags { u8 reserved:8; /* 0: 0 1 */ /* size: 1, cachelines: 1, members: 1 */ /* last cacheline: 1 bytes */ }; $ pahole --fixup_silly_bitfields -C acpi_device_perf_flags ac.o struct acpi_device_perf_flags { u8 reserved; /* 0 1 */ /* size: 1, cachelines: 1, members: 1 */ /* last cacheline: 1 bytes */ }; $ Used in ctfdwdiff as in CTF land we can't express such sillyness. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
aff24d3517
commit
ac7778099a
|
@ -8,10 +8,12 @@ ctf=$dir/$obj.ctf.c
|
|||
dwarf=$dir/$obj.dwarf.c
|
||||
pahole -Z $obj
|
||||
pahole -F ctf $obj > $ctf
|
||||
pahole --flat_arrays --show_private_classes -F dwarf $obj > $dwarf
|
||||
pahole --flat_arrays \
|
||||
--show_private_classes \
|
||||
--fixup_silly_bitfields -F dwarf $obj > $dwarf
|
||||
diff -up $ctf $dwarf > $diff
|
||||
if [ -s $diff ] ; then
|
||||
# vim $dir/$obj.diff
|
||||
[ $# -gt 1 ] && vim $dir/$obj.diff
|
||||
exit 0
|
||||
else
|
||||
rm -f $diff $ctf $dwarf
|
||||
|
|
|
@ -1715,9 +1715,10 @@ static void die__process(Dwarf_Die *die, struct cu *cu)
|
|||
}
|
||||
|
||||
static int class_member__cache_byte_size(struct tag *self, struct cu *cu,
|
||||
void *cookie __unused)
|
||||
void *cookie)
|
||||
{
|
||||
if (self->tag == DW_TAG_member || self->tag == DW_TAG_inheritance) {
|
||||
struct conf_load *conf_load = cookie;
|
||||
struct class_member *member;
|
||||
|
||||
if (member->bitfield_size != 0) {
|
||||
|
@ -1742,8 +1743,15 @@ static int class_member__cache_byte_size(struct tag *self, struct cu *cu,
|
|||
*/
|
||||
member->byte_size = integral_bit_size / 8;
|
||||
|
||||
if (integral_bit_size == 0 || type_bit_size == integral_bit_size) {
|
||||
if (integral_bit_size == 0)
|
||||
return 0;
|
||||
|
||||
if (type_bit_size == integral_bit_size) {
|
||||
member->bit_size = integral_bit_size;
|
||||
if (conf_load && conf_load->fixup_silly_bitfields) {
|
||||
member->bitfield_size = 0;
|
||||
member->bitfield_offset = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1785,7 +1793,7 @@ static int cus__load_module(struct cus *self, struct conf_load *conf,
|
|||
cu->extra_dbg_info = conf ? conf->extra_dbg_info : 0;
|
||||
die__process(cu_die, cu);
|
||||
base_type_name_to_size_table__init();
|
||||
cu__for_all_tags(cu, class_member__cache_byte_size, NULL);
|
||||
cu__for_all_tags(cu, class_member__cache_byte_size, conf);
|
||||
off = noff;
|
||||
if (conf && conf->steal) {
|
||||
switch (conf->steal(cu, conf)) {
|
||||
|
|
|
@ -32,13 +32,15 @@ enum load_steal_kind {
|
|||
/** struct conf_load - load configuration
|
||||
* @extra_dbg_info - keep original debugging format extra info
|
||||
* (e.g. DWARF's decl_{line,file}, id, etc)
|
||||
* @fixup_silly_bitfields - Fixup silly things such as "int foo:32;"
|
||||
*/
|
||||
struct conf_load {
|
||||
bool extra_dbg_info;
|
||||
enum load_steal_kind (*steal)(struct cu *self,
|
||||
struct conf_load *conf);
|
||||
void *cookie;
|
||||
char *format_path;
|
||||
bool extra_dbg_info;
|
||||
bool fixup_silly_bitfields;
|
||||
};
|
||||
|
||||
/** struct conf_fprintf - hints to the __fprintf routines
|
||||
|
|
|
@ -165,6 +165,10 @@ Flatten arrays, so that array[10][2] becomes array[20].
|
|||
Useful when generating from both CTF and DWARF encodings
|
||||
for the same binary for testing purposes.
|
||||
|
||||
.TP
|
||||
.B \-\-fixup_silly_bitfields
|
||||
Converts silly bitfields such as "int foo:32" to plain "int foo".
|
||||
|
||||
.TP
|
||||
.B \-V, \-\-verbose
|
||||
be verbose
|
||||
|
|
12
pahole.c
12
pahole.c
|
@ -704,8 +704,9 @@ static void print_containers(const struct cu *cu, uint16_t type, int ident)
|
|||
/* Name and version of program. */
|
||||
ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
|
||||
|
||||
#define ARGP_flat_arrays 300
|
||||
#define ARGP_show_private_classes 301
|
||||
#define ARGP_flat_arrays 300
|
||||
#define ARGP_show_private_classes 301
|
||||
#define ARGP_fixup_silly_bitfields 302
|
||||
|
||||
static const struct argp_option pahole__options[] = {
|
||||
{
|
||||
|
@ -914,6 +915,11 @@ static const struct argp_option pahole__options[] = {
|
|||
.key = ARGP_show_private_classes,
|
||||
.doc = "Show classes that are defined inside other classes or in functions",
|
||||
},
|
||||
{
|
||||
.name = "fixup_silly_bitfields",
|
||||
.key = ARGP_fixup_silly_bitfields,
|
||||
.doc = "Fix silly bitfields such as int foo:32",
|
||||
},
|
||||
{
|
||||
.name = NULL,
|
||||
}
|
||||
|
@ -986,6 +992,8 @@ static error_t pahole__options_parser(int key, char *arg,
|
|||
case ARGP_flat_arrays: conf.flat_arrays = 1; break;
|
||||
case ARGP_show_private_classes:
|
||||
show_private_classes = true; break;
|
||||
case ARGP_fixup_silly_bitfields:
|
||||
conf_load.fixup_silly_bitfields = 1; break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue