2006-12-28 17:03:42 +01:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Mandriva Conectiva S.A.
|
|
|
|
Copyright (C) 2006 Arnaldo Carvalho de Melo <acme@mandriva.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of version 2 of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
|
2007-01-11 19:07:05 +01:00
|
|
|
#include "dwarves.h"
|
2006-12-28 17:03:42 +01:00
|
|
|
|
|
|
|
static void print_malloc_stats(void)
|
|
|
|
{
|
|
|
|
struct mallinfo m = mallinfo();
|
|
|
|
|
|
|
|
fprintf(stderr, "size: %u\n", m.uordblks);
|
|
|
|
}
|
|
|
|
|
2007-01-29 13:42:03 +01:00
|
|
|
static int class__tag_name(struct tag *self, struct cu *cu __unused,
|
|
|
|
void *cookie __unused)
|
2006-12-28 17:03:42 +01:00
|
|
|
{
|
2006-12-29 18:28:58 +01:00
|
|
|
puts(dwarf_tag_name(self->tag));
|
2006-12-28 17:03:42 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-29 13:42:03 +01:00
|
|
|
static int cu__dump_class_tag_names(struct cu *self, void *cookie __unused)
|
2006-12-28 17:03:42 +01:00
|
|
|
{
|
2006-12-29 18:28:58 +01:00
|
|
|
cu__for_each_tag(self, class__tag_name, NULL, NULL);
|
2006-12-28 17:03:42 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cus__dump_class_tag_names(struct cus *self)
|
|
|
|
{
|
|
|
|
cus__for_each_cu(self, cu__dump_class_tag_names, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usage(void)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "usage: dtagnames <filename>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct cus *cus;
|
|
|
|
char *filename = argv[1];
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
usage();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2007-01-19 00:41:25 +01:00
|
|
|
dwarves__init(0);
|
|
|
|
|
2007-01-07 15:30:58 +01:00
|
|
|
cus = cus__new(NULL, NULL);
|
2006-12-28 17:03:42 +01:00
|
|
|
if (cus == NULL) {
|
|
|
|
fputs("dtagnames: insufficient memory\n", stderr);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cus__load(cus, filename) != 0) {
|
|
|
|
fprintf(stderr, "dtagnames: couldn't load DWARF info from %s\n",
|
|
|
|
filename);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
cus__dump_class_tag_names(cus);
|
|
|
|
print_malloc_stats();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|