aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2021-08-19 09:49:30 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-08-20 16:40:27 -0300
commitf035871495435e584b5248f0f7d908b7d17190f0 (patch)
treec9b6bbac9884f646562394fa1ea63a7e6cad2aba
parentc59e996c97eb55698fe34b1a0aa0e540456f672d (diff)
downloadpahole-f035871495435e584b5248f0f7d908b7d17190f0.tar.gz
core: Add CU stats printer
To help sizing some tables, etc. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarves.c15
-rw-r--r--dwarves.h4
2 files changed, 19 insertions, 0 deletions
diff --git a/dwarves.c b/dwarves.c
index e8be9c38..9484e572 100644
--- a/dwarves.c
+++ b/dwarves.c
@@ -605,6 +605,21 @@ int cu__add_tag_with_id(struct cu *cu, struct tag *tag, uint32_t id)
return err;
}
+int cus__fprintf_ptr_table_stats_csv_header(FILE *fp)
+{
+ return fprintf(fp, "# cu,tags,allocated_tags,types,allocated_types,functions,allocated_functions\n");
+}
+
+int cu__fprintf_ptr_table_stats_csv(struct cu *cu, FILE *fp)
+{
+ int printed = fprintf(fp, "%s,%u,%u,%u,%u,%u,%u\n", cu->name,
+ cu->tags_table.nr_entries, cu->tags_table.allocated_entries,
+ cu->types_table.nr_entries, cu->types_table.allocated_entries,
+ cu->functions_table.nr_entries, cu->functions_table.allocated_entries);
+
+ return printed;
+}
+
struct cu *cu__new(const char *name, uint8_t addr_size,
const unsigned char *build_id, int build_id_len,
const char *filename, bool use_obstack)
diff --git a/dwarves.h b/dwarves.h
index 0b6252e1..72535364 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -262,6 +262,10 @@ void *cu__malloc(struct cu *cu, size_t size);
void *cu__zalloc(struct cu *cu, size_t size);
void cu__free(struct cu *cu, void *ptr);
+int cu__fprintf_ptr_table_stats_csv(struct cu *cu, FILE *fp);
+
+int cus__fprintf_ptr_table_stats_csv_header(FILE *fp);
+
static inline int cu__cache_symtab(struct cu *cu)
{
int err = dwfl_module_getsymtab(cu->dwfl);