dwarves_emit: Introduce type_emissions
We may want to work on just one object file, not on a multi cu. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
993bcbde35
commit
c3f6f8b79f
4
codiff.c
4
codiff.c
|
@ -695,8 +695,8 @@ failure:
|
|||
dwarves__init(0);
|
||||
|
||||
structs_printed = strlist__new(false);
|
||||
old_cus = cus__new(NULL, NULL);
|
||||
new_cus = cus__new(NULL, NULL);
|
||||
old_cus = cus__new(NULL);
|
||||
new_cus = cus__new(NULL);
|
||||
if (old_cus == NULL || new_cus == NULL || structs_printed == NULL) {
|
||||
fputs("codiff: insufficient memory\n", stderr);
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -61,8 +61,7 @@ static FILE *fp_classes;
|
|||
* List of definitions and forward declarations already emitted for
|
||||
* methods_cus, to avoid duplication.
|
||||
*/
|
||||
static LIST_HEAD(cus__definitions);
|
||||
static LIST_HEAD(cus__fwd_decls);
|
||||
static struct type_emissions cus__emissions;
|
||||
|
||||
/*
|
||||
* CU blacklist: if a "blacklist.cu" file is present, don't consider the
|
||||
|
@ -910,13 +909,15 @@ failure:
|
|||
*/
|
||||
dwarves__init(0);
|
||||
|
||||
type_emissions__init(&cus__emissions);
|
||||
|
||||
/*
|
||||
* Create the methods_cus (Compilation Units) object where we will
|
||||
* load the objects where we'll look for functions pointers to the
|
||||
* specified class, i.e. to find its "methods", where we'll insert
|
||||
* the entry and exit hooks.
|
||||
*/
|
||||
methods_cus = cus__new(&cus__definitions, &cus__fwd_decls);
|
||||
methods_cus = cus__new(&cus__emissions);
|
||||
if (methods_cus == NULL) {
|
||||
fputs("ctracer: insufficient memory\n", stderr);
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -42,7 +42,7 @@ static void cus__dump_class_tag_names(struct cus *self)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
struct cus *cus = cus__new(NULL, NULL);
|
||||
struct cus *cus = cus__new(NULL);
|
||||
|
||||
if (cus == NULL) {
|
||||
fputs("dtagnames: insufficient memory\n", stderr);
|
||||
|
|
21
dwarves.c
21
dwarves.c
|
@ -2489,6 +2489,12 @@ size_t tag__fprintf(struct tag *self, const struct cu *cu,
|
|||
return printed;
|
||||
}
|
||||
|
||||
void type_emissions__init(struct type_emissions *self)
|
||||
{
|
||||
INIT_LIST_HEAD(&self->definitions);
|
||||
INIT_LIST_HEAD(&self->fwd_decls);
|
||||
}
|
||||
|
||||
int cu__for_each_tag(struct cu *self,
|
||||
int (*iterator)(struct tag *tag, struct cu *cu,
|
||||
void *cookie),
|
||||
|
@ -2615,17 +2621,18 @@ void cus__print_error_msg(const char *progname, const struct cus *cus,
|
|||
fprintf(stderr, "%s: %s\n", progname, strerror(err));
|
||||
}
|
||||
|
||||
struct cus *cus__new(struct list_head *definitions,
|
||||
struct list_head *fwd_decls)
|
||||
struct cus *cus__new(struct type_emissions *emissions)
|
||||
{
|
||||
struct cus *self = malloc(sizeof(*self));
|
||||
struct cus *self = malloc(sizeof(*self) + (emissions ? 0 : sizeof(*emissions)));
|
||||
|
||||
if (self != NULL) {
|
||||
INIT_LIST_HEAD(&self->cus);
|
||||
INIT_LIST_HEAD(&self->priv_definitions);
|
||||
INIT_LIST_HEAD(&self->priv_fwd_decls);
|
||||
self->definitions = definitions ?: &self->priv_definitions;
|
||||
self->fwd_decls = fwd_decls ?: &self->priv_fwd_decls;
|
||||
if (emissions != NULL)
|
||||
self->emissions = emissions;
|
||||
else {
|
||||
self->emissions = (struct type_emissions *)(self + 1);
|
||||
type_emissions__init(self->emissions);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
20
dwarves.h
20
dwarves.h
|
@ -20,14 +20,20 @@
|
|||
|
||||
struct argp;
|
||||
|
||||
struct cus {
|
||||
struct list_head cus;
|
||||
struct list_head priv_definitions; /* struct type entries */
|
||||
struct list_head priv_fwd_decls; /* struct class entries */
|
||||
struct list_head *definitions;
|
||||
struct list_head *fwd_decls;
|
||||
struct type_emissions {
|
||||
struct list_head definitions; /* struct type entries */
|
||||
struct list_head fwd_decls; /* struct class entries */
|
||||
};
|
||||
|
||||
void type_emissions__init(struct type_emissions *self);
|
||||
|
||||
struct cus {
|
||||
struct list_head cus;
|
||||
struct type_emissions *emissions;
|
||||
};
|
||||
|
||||
struct cus *cus__new(struct type_emissions *emissions);
|
||||
|
||||
#define HASHTAGS__BITS 8
|
||||
#define HASHTAGS__SIZE (1UL << HASHTAGS__BITS)
|
||||
#define hashtags__fn(key) hash_64(key, HASHTAGS__BITS)
|
||||
|
@ -522,8 +528,6 @@ extern size_t lexblock__fprintf(const struct lexblock *self,
|
|||
const struct cu *cu, struct function *function,
|
||||
uint16_t indent, FILE *fp);
|
||||
|
||||
extern struct cus *cus__new(struct list_head *definitions,
|
||||
struct list_head *fwd_decls);
|
||||
extern int cus__loadfl(struct cus *self, struct argp *argp,
|
||||
int argc, char *argv[]);
|
||||
extern int cus__load(struct cus *self, const char *filename);
|
||||
|
|
|
@ -20,14 +20,14 @@ static void cus__add_definition(struct cus *self, struct type *type)
|
|||
type->definition_emitted = 1;
|
||||
if (!list_empty(&type->node))
|
||||
list_del(&type->node);
|
||||
list_add_tail(&type->node, self->definitions);
|
||||
list_add_tail(&type->node, &self->emissions->definitions);
|
||||
}
|
||||
|
||||
static void cus__add_fwd_decl(struct cus *self, struct type *type)
|
||||
{
|
||||
type->fwd_decl_emitted = 1;
|
||||
if (list_empty(&type->node))
|
||||
list_add_tail(&type->node, self->fwd_decls);
|
||||
list_add_tail(&type->node, &self->emissions->fwd_decls);
|
||||
}
|
||||
|
||||
struct type *cus__find_definition(const struct cus *self, const char *name)
|
||||
|
@ -37,7 +37,7 @@ struct type *cus__find_definition(const struct cus *self, const char *name)
|
|||
if (name == NULL)
|
||||
return NULL;
|
||||
|
||||
list_for_each_entry(pos, self->definitions, node)
|
||||
list_for_each_entry(pos, &self->emissions->definitions, node)
|
||||
if (type__name(pos, NULL) != NULL &&
|
||||
strcmp(type__name(pos, NULL), name) == 0)
|
||||
return pos;
|
||||
|
@ -50,7 +50,7 @@ static struct type *cus__find_fwd_decl(const struct cus *self,
|
|||
{
|
||||
struct type *pos;
|
||||
|
||||
list_for_each_entry(pos, self->fwd_decls, node)
|
||||
list_for_each_entry(pos, &self->emissions->fwd_decls, node)
|
||||
if (strcmp(type__name(pos, NULL), name) == 0)
|
||||
return pos;
|
||||
|
||||
|
|
2
pahole.c
2
pahole.c
|
@ -959,7 +959,7 @@ int main(int argc, char *argv[])
|
|||
struct cus *cus;
|
||||
int err;
|
||||
|
||||
cus = cus__new(NULL, NULL);
|
||||
cus = cus__new(NULL);
|
||||
if (cus == NULL) {
|
||||
fputs("pahole: insufficient memory\n", stderr);
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -89,7 +89,7 @@ static struct argp pdwtags__argp = {
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
struct cus *cus = cus__new(NULL, NULL);
|
||||
struct cus *cus = cus__new(NULL);
|
||||
|
||||
if (cus == NULL) {
|
||||
fputs("pwdtags: insufficient memory\n", stderr);
|
||||
|
|
2
pfunct.c
2
pfunct.c
|
@ -492,7 +492,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
int err;
|
||||
|
||||
cus = cus__new(NULL, NULL);
|
||||
cus = cus__new(NULL);
|
||||
if (cus == NULL) {
|
||||
fputs("pfunct: insufficient memory\n", stderr);
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -310,7 +310,7 @@ static struct argp pglobal__argp = {
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
struct cus *cus = cus__new(NULL, NULL);
|
||||
struct cus *cus = cus__new(NULL);
|
||||
|
||||
if (cus == NULL) {
|
||||
fputs("pglobal: insufficient memory\n", stderr);
|
||||
|
|
|
@ -150,7 +150,7 @@ static int cu_lost_iterator(struct cu *cu, void *cookie)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
struct cus *cus = cus__new(NULL, NULL);
|
||||
struct cus *cus = cus__new(NULL);
|
||||
|
||||
if (cus == NULL) {
|
||||
fputs("prefcnt: insufficient memory\n", stderr);
|
||||
|
|
Loading…
Reference in New Issue