pfunct: Introduce --no_parm_names
Because CTF doesn't encodes the names of the parameters and I want to test the upcoming CTF function section code in ctftwdiff. $ pfunct -V pahole > /tmp/before $ pfunct --no_parm_names -V pahole > /tmp/after $ diff -u /tmp/before /tmp/after | tail -3 -struct structure * structure__new(strings_t name); +struct structure * structure__new(strings_t); /* definitions: 1 */ $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
31fd625644
commit
2d8700009b
56
dwarves.c
56
dwarves.c
|
@ -475,7 +475,7 @@ size_t typedef__fprintf(const struct tag *tag_self, const struct cu *cu,
|
||||||
return printed + ftype__fprintf(tag__ftype(type), cu,
|
return printed + ftype__fprintf(tag__ftype(type), cu,
|
||||||
type__name(self),
|
type__name(self),
|
||||||
0, is_pointer, 0,
|
0, is_pointer, 0,
|
||||||
fp);
|
pconf, fp);
|
||||||
case DW_TAG_class_type:
|
case DW_TAG_class_type:
|
||||||
case DW_TAG_structure_type: {
|
case DW_TAG_structure_type: {
|
||||||
struct type *ctype = tag__type(type);
|
struct type *ctype = tag__type(type);
|
||||||
|
@ -1108,8 +1108,10 @@ const char *tag__name(const struct tag *self, const struct cu *cu,
|
||||||
break;
|
break;
|
||||||
case DW_TAG_subroutine_type: {
|
case DW_TAG_subroutine_type: {
|
||||||
FILE *bfp = fmemopen(bf, len, "w");
|
FILE *bfp = fmemopen(bf, len, "w");
|
||||||
|
|
||||||
if (bfp != NULL) {
|
if (bfp != NULL) {
|
||||||
ftype__fprintf(tag__ftype(self), cu, NULL, 0, 0, 0, bfp);
|
ftype__fprintf(tag__ftype(self), cu, NULL, 0, 0, 0,
|
||||||
|
&conf_fprintf__defaults, bfp);
|
||||||
fclose(bfp);
|
fclose(bfp);
|
||||||
} else
|
} else
|
||||||
snprintf(bf, len, "<ERROR(%s): fmemopen failed!>",
|
snprintf(bf, len, "<ERROR(%s): fmemopen failed!>",
|
||||||
|
@ -1257,7 +1259,7 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu,
|
||||||
printed += ftype__fprintf(tag__ftype(ptype),
|
printed += ftype__fprintf(tag__ftype(ptype),
|
||||||
cu, name, 0, 1,
|
cu, name, 0, 1,
|
||||||
conf->type_spacing,
|
conf->type_spacing,
|
||||||
fp);
|
conf, fp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1268,7 +1270,7 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu,
|
||||||
break;
|
break;
|
||||||
case DW_TAG_subroutine_type:
|
case DW_TAG_subroutine_type:
|
||||||
printed += ftype__fprintf(tag__ftype(type), cu, name, 0, 0,
|
printed += ftype__fprintf(tag__ftype(type), cu, name, 0, 0,
|
||||||
conf->type_spacing, fp);
|
conf->type_spacing, conf, fp);
|
||||||
break;
|
break;
|
||||||
case DW_TAG_array_type:
|
case DW_TAG_array_type:
|
||||||
printed += array_type__fprintf(type, cu, name, conf, fp);
|
printed += array_type__fprintf(type, cu, name, conf, fp);
|
||||||
|
@ -1583,7 +1585,8 @@ const char *function__prototype(const struct function *self,
|
||||||
FILE *bfp = fmemopen(bf, len, "w");
|
FILE *bfp = fmemopen(bf, len, "w");
|
||||||
|
|
||||||
if (bfp != NULL) {
|
if (bfp != NULL) {
|
||||||
ftype__fprintf(&self->proto, cu, NULL, 0, 0, 0, bfp);
|
ftype__fprintf(&self->proto, cu, NULL, 0, 0, 0,
|
||||||
|
&conf_fprintf__defaults, bfp);
|
||||||
fclose(bfp);
|
fclose(bfp);
|
||||||
} else
|
} else
|
||||||
snprintf(bf, len, "<ERROR(%s): fmemopen failed!>", __func__);
|
snprintf(bf, len, "<ERROR(%s): fmemopen failed!>", __func__);
|
||||||
|
@ -1864,7 +1867,7 @@ void cu__account_inline_expansions(struct cu *self)
|
||||||
|
|
||||||
static size_t ftype__fprintf_parms(const struct ftype *self,
|
static size_t ftype__fprintf_parms(const struct ftype *self,
|
||||||
const struct cu *cu, int indent,
|
const struct cu *cu, int indent,
|
||||||
FILE *fp)
|
const struct conf_fprintf *conf, FILE *fp)
|
||||||
{
|
{
|
||||||
struct parameter *pos;
|
struct parameter *pos;
|
||||||
int first_parm = 1;
|
int first_parm = 1;
|
||||||
|
@ -1882,7 +1885,7 @@ static size_t ftype__fprintf_parms(const struct ftype *self,
|
||||||
indent, tabs);
|
indent, tabs);
|
||||||
} else
|
} else
|
||||||
first_parm = 0;
|
first_parm = 0;
|
||||||
name = parameter__name(pos);
|
name = conf->no_parm_names ? NULL : parameter__name(pos);
|
||||||
type = cu__type(cu, pos->tag.type);
|
type = cu__type(cu, pos->tag.type);
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
snprintf(sbf, sizeof(sbf),
|
snprintf(sbf, sizeof(sbf),
|
||||||
|
@ -1902,13 +1905,13 @@ static size_t ftype__fprintf_parms(const struct ftype *self,
|
||||||
printed +=
|
printed +=
|
||||||
ftype__fprintf(tag__ftype(ptype),
|
ftype__fprintf(tag__ftype(ptype),
|
||||||
cu, name, 0, 1, 0,
|
cu, name, 0, 1, 0,
|
||||||
fp);
|
conf, fp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type->tag == DW_TAG_subroutine_type) {
|
} else if (type->tag == DW_TAG_subroutine_type) {
|
||||||
printed += ftype__fprintf(tag__ftype(type), cu, name,
|
printed += ftype__fprintf(tag__ftype(type), cu, name,
|
||||||
0, 0, 0, fp);
|
0, 0, 0, conf, fp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
stype = tag__name(type, cu, sbf, sizeof(sbf));
|
stype = tag__name(type, cu, sbf, sizeof(sbf));
|
||||||
|
@ -1928,8 +1931,8 @@ print_it:
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t function__tag_fprintf(const struct tag *tag, const struct cu *cu,
|
static size_t function__tag_fprintf(const struct tag *tag, const struct cu *cu,
|
||||||
struct function *function,
|
struct function *function, uint16_t indent,
|
||||||
uint16_t indent, FILE *fp)
|
const struct conf_fprintf *conf, FILE *fp)
|
||||||
{
|
{
|
||||||
char bf[512];
|
char bf[512];
|
||||||
size_t printed = 0, n;
|
size_t printed = 0, n;
|
||||||
|
@ -1959,7 +1962,7 @@ static size_t function__tag_fprintf(const struct tag *tag, const struct cu *cu,
|
||||||
namelen = strlen(name);
|
namelen = strlen(name);
|
||||||
n += ftype__fprintf_parms(&alias->proto, cu,
|
n += ftype__fprintf_parms(&alias->proto, cu,
|
||||||
indent + (namelen + 7) / 8,
|
indent + (namelen + 7) / 8,
|
||||||
fp);
|
conf, fp);
|
||||||
n += fprintf(fp, "; /* size=%zd, low_pc=%#llx */",
|
n += fprintf(fp, "; /* size=%zd, low_pc=%#llx */",
|
||||||
exp->size, (unsigned long long)exp->low_pc);
|
exp->size, (unsigned long long)exp->low_pc);
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1989,7 +1992,8 @@ static size_t function__tag_fprintf(const struct tag *tag, const struct cu *cu,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DW_TAG_lexical_block:
|
case DW_TAG_lexical_block:
|
||||||
printed = lexblock__fprintf(vtag, cu, function, indent, fp);
|
printed = lexblock__fprintf(vtag, cu, function, indent,
|
||||||
|
conf, fp);
|
||||||
fputc('\n', fp);
|
fputc('\n', fp);
|
||||||
return printed + 1;
|
return printed + 1;
|
||||||
default:
|
default:
|
||||||
|
@ -2005,7 +2009,8 @@ static size_t function__tag_fprintf(const struct tag *tag, const struct cu *cu,
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu,
|
size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu,
|
||||||
struct function *function, uint16_t indent, FILE *fp)
|
struct function *function, uint16_t indent,
|
||||||
|
const struct conf_fprintf *conf, FILE *fp)
|
||||||
{
|
{
|
||||||
struct tag *pos;
|
struct tag *pos;
|
||||||
size_t printed;
|
size_t printed;
|
||||||
|
@ -2026,7 +2031,8 @@ size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu,
|
||||||
}
|
}
|
||||||
printed += fprintf(fp, "\n");
|
printed += fprintf(fp, "\n");
|
||||||
list_for_each_entry(pos, &self->tags, node)
|
list_for_each_entry(pos, &self->tags, node)
|
||||||
printed += function__tag_fprintf(pos, cu, function, indent + 1, fp);
|
printed += function__tag_fprintf(pos, cu, function, indent + 1,
|
||||||
|
conf, fp);
|
||||||
printed += fprintf(fp, "%.*s}", indent, tabs);
|
printed += fprintf(fp, "%.*s}", indent, tabs);
|
||||||
|
|
||||||
if (function->lexblock.low_pc != self->low_pc)
|
if (function->lexblock.low_pc != self->low_pc)
|
||||||
|
@ -2037,7 +2043,8 @@ size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu,
|
||||||
|
|
||||||
size_t ftype__fprintf(const struct ftype *self, const struct cu *cu,
|
size_t ftype__fprintf(const struct ftype *self, const struct cu *cu,
|
||||||
const char *name, const int inlined,
|
const char *name, const int inlined,
|
||||||
const int is_pointer, int type_spacing, FILE *fp)
|
const int is_pointer, int type_spacing,
|
||||||
|
const struct conf_fprintf *conf, FILE *fp)
|
||||||
{
|
{
|
||||||
struct tag *type = cu__type(cu, self->tag.type);
|
struct tag *type = cu__type(cu, self->tag.type);
|
||||||
char sbf[128];
|
char sbf[128];
|
||||||
|
@ -2051,11 +2058,13 @@ size_t ftype__fprintf(const struct ftype *self, const struct cu *cu,
|
||||||
self->tag.tag == DW_TAG_subroutine_type ?
|
self->tag.tag == DW_TAG_subroutine_type ?
|
||||||
")" : "");
|
")" : "");
|
||||||
|
|
||||||
return printed + ftype__fprintf_parms(self, cu, 0, fp);
|
return printed + ftype__fprintf_parms(self, cu, 0, conf, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t function__fprintf(const struct tag *tag_self,
|
static size_t function__fprintf(const struct tag *tag_self,
|
||||||
const struct cu *cu, FILE *fp)
|
const struct cu *cu,
|
||||||
|
const struct conf_fprintf *conf,
|
||||||
|
FILE *fp)
|
||||||
{
|
{
|
||||||
struct function *self = tag__function(tag_self);
|
struct function *self = tag__function(tag_self);
|
||||||
size_t printed = 0;
|
size_t printed = 0;
|
||||||
|
@ -2065,7 +2074,8 @@ static size_t function__fprintf(const struct tag *tag_self,
|
||||||
printed += fprintf(fp, "virtual ");
|
printed += fprintf(fp, "virtual ");
|
||||||
|
|
||||||
printed += ftype__fprintf(&self->proto, cu, function__name(self, cu),
|
printed += ftype__fprintf(&self->proto, cu, function__name(self, cu),
|
||||||
function__declared_inline(self), 0, 0, fp);
|
function__declared_inline(self), 0, 0,
|
||||||
|
conf, fp);
|
||||||
|
|
||||||
if (self->virtuality == DW_VIRTUALITY_pure_virtual)
|
if (self->virtuality == DW_VIRTUALITY_pure_virtual)
|
||||||
printed += fprintf(fp, " = 0");
|
printed += fprintf(fp, " = 0");
|
||||||
|
@ -2074,10 +2084,12 @@ static size_t function__fprintf(const struct tag *tag_self,
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t function__fprintf_stats(const struct tag *tag_self,
|
size_t function__fprintf_stats(const struct tag *tag_self,
|
||||||
const struct cu *cu, FILE *fp)
|
const struct cu *cu,
|
||||||
|
const struct conf_fprintf *conf,
|
||||||
|
FILE *fp)
|
||||||
{
|
{
|
||||||
struct function *self = tag__function(tag_self);
|
struct function *self = tag__function(tag_self);
|
||||||
size_t printed = lexblock__fprintf(&self->lexblock, cu, self, 0, fp);
|
size_t printed = lexblock__fprintf(&self->lexblock, cu, self, 0, conf, fp);
|
||||||
|
|
||||||
printed += fprintf(fp, "/* size: %d", function__size(self));
|
printed += fprintf(fp, "/* size: %d", function__size(self));
|
||||||
if (self->lexblock.nr_variables > 0)
|
if (self->lexblock.nr_variables > 0)
|
||||||
|
@ -2581,7 +2593,7 @@ size_t tag__fprintf(struct tag *self, const struct cu *cu,
|
||||||
printed += namespace__fprintf(self, cu, pconf, fp);
|
printed += namespace__fprintf(self, cu, pconf, fp);
|
||||||
break;
|
break;
|
||||||
case DW_TAG_subprogram:
|
case DW_TAG_subprogram:
|
||||||
printed += function__fprintf(self, cu, fp);
|
printed += function__fprintf(self, cu, pconf, fp);
|
||||||
break;
|
break;
|
||||||
case DW_TAG_union_type:
|
case DW_TAG_union_type:
|
||||||
printed += union__fprintf(tag__type(self), cu, pconf, fp);
|
printed += union__fprintf(tag__type(self), cu, pconf, fp);
|
||||||
|
|
11
dwarves.h
11
dwarves.h
|
@ -65,6 +65,7 @@ struct conf_fprintf {
|
||||||
uint8_t no_semicolon:1;
|
uint8_t no_semicolon:1;
|
||||||
uint8_t show_first_biggest_size_base_type_member:1;
|
uint8_t show_first_biggest_size_base_type_member:1;
|
||||||
uint8_t flat_arrays:1;
|
uint8_t flat_arrays:1;
|
||||||
|
uint8_t no_parm_names:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cus {
|
struct cus {
|
||||||
|
@ -485,7 +486,8 @@ void lexblock__add_lexblock(struct lexblock *self, struct lexblock *child);
|
||||||
void lexblock__add_tag(struct lexblock *self, struct tag *tag);
|
void lexblock__add_tag(struct lexblock *self, struct tag *tag);
|
||||||
void lexblock__add_variable(struct lexblock *self, struct variable *var);
|
void lexblock__add_variable(struct lexblock *self, struct variable *var);
|
||||||
size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu,
|
size_t lexblock__fprintf(const struct lexblock *self, const struct cu *cu,
|
||||||
struct function *function, uint16_t indent, FILE *fp);
|
struct function *function, uint16_t indent,
|
||||||
|
const struct conf_fprintf *conf, FILE *fp);
|
||||||
|
|
||||||
struct parameter {
|
struct parameter {
|
||||||
struct tag tag;
|
struct tag tag;
|
||||||
|
@ -539,7 +541,8 @@ void ftype__delete(struct ftype *self);
|
||||||
void ftype__add_parameter(struct ftype *self, struct parameter *parm);
|
void ftype__add_parameter(struct ftype *self, struct parameter *parm);
|
||||||
size_t ftype__fprintf(const struct ftype *self, const struct cu *cu,
|
size_t ftype__fprintf(const struct ftype *self, const struct cu *cu,
|
||||||
const char *name, const int inlined,
|
const char *name, const int inlined,
|
||||||
const int is_pointer, const int type_spacing, FILE *fp);
|
const int is_pointer, const int type_spacing,
|
||||||
|
const struct conf_fprintf *conf, FILE *fp);
|
||||||
int ftype__has_parm_of_type(const struct ftype *self, const uint16_t target,
|
int ftype__has_parm_of_type(const struct ftype *self, const uint16_t target,
|
||||||
const struct cu *cu);
|
const struct cu *cu);
|
||||||
|
|
||||||
|
@ -590,7 +593,9 @@ static __pure inline int tag__is_function(const struct tag *self)
|
||||||
|
|
||||||
const char *function__name(struct function *self, const struct cu *cu);
|
const char *function__name(struct function *self, const struct cu *cu);
|
||||||
size_t function__fprintf_stats(const struct tag *tag_self,
|
size_t function__fprintf_stats(const struct tag *tag_self,
|
||||||
const struct cu *cu, FILE *fp);
|
const struct cu *cu,
|
||||||
|
const struct conf_fprintf *conf,
|
||||||
|
FILE *fp);
|
||||||
const char *function__prototype(const struct function *self,
|
const char *function__prototype(const struct function *self,
|
||||||
const struct cu *cu, char *bf, size_t len);
|
const struct cu *cu, char *bf, size_t len);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ static void emit_tag(struct tag *self, uint32_t tag_id, struct cu *cu)
|
||||||
if (tag__is_function(self)) {
|
if (tag__is_function(self)) {
|
||||||
struct function *fn = tag__function(self);
|
struct function *fn = tag__function(self);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
lexblock__fprintf(&fn->lexblock, cu, fn, 0, stdout);
|
lexblock__fprintf(&fn->lexblock, cu, fn, 0, &conf, stdout);
|
||||||
}
|
}
|
||||||
printf(" size: %zd\n\n", tag__size(self, cu));
|
printf(" size: %zd\n\n", tag__size(self, cu));
|
||||||
}
|
}
|
||||||
|
|
13
pfunct.c
13
pfunct.c
|
@ -152,7 +152,7 @@ static void fn_stats_fmtr(const struct fn_stats *self)
|
||||||
tag__fprintf(self->tag, self->cu, &conf, stdout);
|
tag__fprintf(self->tag, self->cu, &conf, stdout);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if (show_variables || show_inline_expansions)
|
if (show_variables || show_inline_expansions)
|
||||||
function__fprintf_stats(self->tag, self->cu, stdout);
|
function__fprintf_stats(self->tag, self->cu, &conf, stdout);
|
||||||
printf("/* definitions: %u */\n", self->nr_files);
|
printf("/* definitions: %u */\n", self->nr_files);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
} else {
|
} else {
|
||||||
|
@ -368,7 +368,7 @@ static int function_iterator(struct tag *tag, struct cu *cu, void *cookie)
|
||||||
tag__fprintf(tag, cu, &conf, stdout);
|
tag__fprintf(tag, cu, &conf, stdout);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if (show_variables || show_inline_expansions)
|
if (show_variables || show_inline_expansions)
|
||||||
function__fprintf_stats(tag, cu, stdout);
|
function__fprintf_stats(tag, cu, &conf, stdout);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -463,7 +463,8 @@ int elf_symtabs__show(char *filenames[])
|
||||||
/* Name and version of program. */
|
/* Name and version of program. */
|
||||||
ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
|
ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
|
||||||
|
|
||||||
#define ARGP_symtab 300
|
#define ARGP_symtab 300
|
||||||
|
#define ARGP_no_parm_names 301
|
||||||
|
|
||||||
static const struct argp_option pfunct__options[] = {
|
static const struct argp_option pfunct__options[] = {
|
||||||
{
|
{
|
||||||
|
@ -566,6 +567,11 @@ static const struct argp_option pfunct__options[] = {
|
||||||
.flags = OPTION_ARG_OPTIONAL,
|
.flags = OPTION_ARG_OPTIONAL,
|
||||||
.doc = "show symbol table NAME (Default .symtab)",
|
.doc = "show symbol table NAME (Default .symtab)",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "no_parm_names",
|
||||||
|
.key = ARGP_no_parm_names,
|
||||||
|
.doc = "Don't show parameter names",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = NULL,
|
.name = NULL,
|
||||||
}
|
}
|
||||||
|
@ -607,6 +613,7 @@ static error_t pfunct__options_parser(int key, char *arg,
|
||||||
case 'V': verbose = 1;
|
case 'V': verbose = 1;
|
||||||
conf_load.extra_dbg_info = 1; break;
|
conf_load.extra_dbg_info = 1; break;
|
||||||
case ARGP_symtab: symtab_name = arg ?: ".symtab"; break;
|
case ARGP_symtab: symtab_name = arg ?: ".symtab"; break;
|
||||||
|
case ARGP_no_parm_names: conf.no_parm_names = 1; break;
|
||||||
default: return ARGP_ERR_UNKNOWN;
|
default: return ARGP_ERR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue