[CLASSES]: Add optional prefix and suffix parameters to class__print
That will be used when typedefs are being emitted, etc. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
79206c3a22
commit
66ef6a39ba
14
classes.c
14
classes.c
|
@ -1132,7 +1132,8 @@ static int class__print_cacheline_boundary(uint32_t last_cacheline,
|
|||
return cacheline;
|
||||
}
|
||||
|
||||
static void class__print_struct(const struct class *self)
|
||||
static void class__print_struct(const struct class *self,
|
||||
const char *prefix, const char *suffix)
|
||||
{
|
||||
unsigned long sum = 0;
|
||||
unsigned long sum_holes = 0;
|
||||
|
@ -1145,7 +1146,8 @@ static void class__print_struct(const struct class *self)
|
|||
uint8_t newline = 0;
|
||||
unsigned int sum_bit_holes = 0;
|
||||
|
||||
printf("%s {\n", class__name(self, name, sizeof(name)));
|
||||
printf("%s%s {\n", prefix ? : "",
|
||||
class__name(self, name, sizeof(name)));
|
||||
list_for_each_entry(pos, &self->members, tag.node) {
|
||||
const int cc_last_size = pos->offset - last_offset;
|
||||
|
||||
|
@ -1234,7 +1236,8 @@ static void class__print_struct(const struct class *self)
|
|||
class__print_cacheline_boundary(last_cacheline, sum, sum_holes,
|
||||
&newline);
|
||||
|
||||
printf("}; /* size: %llu, cachelines: %llu */\n", self->size,
|
||||
printf("}%s; /* size: %llu, cachelines: %llu */\n",
|
||||
suffix ?: "", self->size,
|
||||
(self->size + cacheline_size - 1) / cacheline_size);
|
||||
if (sum_holes > 0)
|
||||
printf(" /* sum members: %lu, holes: %d, sum holes: %lu */\n",
|
||||
|
@ -1257,13 +1260,14 @@ static void class__print_struct(const struct class *self)
|
|||
self->size - (sum + sum_holes));
|
||||
}
|
||||
|
||||
void class__print(const struct class *self)
|
||||
void class__print(const struct class *self,
|
||||
const char *prefix, const char *suffix)
|
||||
{
|
||||
printf("/* %s:%u */\n", self->tag.decl_file, self->tag.decl_line);
|
||||
|
||||
switch (self->tag.tag) {
|
||||
case DW_TAG_structure_type:
|
||||
class__print_struct(self);
|
||||
class__print_struct(self, prefix, suffix);
|
||||
break;
|
||||
default:
|
||||
printf("%s%s;\n", tag_name(self->cu, self->tag.tag),
|
||||
|
|
|
@ -141,7 +141,8 @@ struct label {
|
|||
#define DEFAULT_CACHELINE_SIZE 32
|
||||
|
||||
extern void class__find_holes(struct class *self);
|
||||
extern void class__print(const struct class *self);
|
||||
extern void class__print(const struct class *self,
|
||||
const char *prefix, const char *suffix);
|
||||
extern void function__print(const struct function *self, int show_stats,
|
||||
const int show_variables,
|
||||
const int show_inline_expansions);
|
||||
|
|
4
pahole.c
4
pahole.c
|
@ -90,7 +90,7 @@ static void class_name_len_formatter(const struct structure *self)
|
|||
|
||||
static void class_formatter(const struct structure *self)
|
||||
{
|
||||
class__print(self->class);
|
||||
class__print(self->class, NULL, NULL);
|
||||
printf(" /* definitions: %u */\n", self->nr_files);
|
||||
putchar('\n');
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ int main(int argc, char *argv[])
|
|||
printf("struct %s not found!\n", class_name);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
class__print(s->class);
|
||||
class__print(s->class, NULL, NULL);
|
||||
} else
|
||||
print_classes(formatter);
|
||||
|
||||
|
|
Loading…
Reference in New Issue