dwarves: Introduce cu__hash
So that we can then decide in what hashtable we will add it, and this also paves the way for a type array that will help us in reducing the size of struct tag by removing the id field. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
d2d07eab08
commit
e710cca6bf
|
@ -516,7 +516,7 @@ static unsigned long create_full_members(struct ctf_state *sp, void *ptr,
|
|||
member->offset = bit_offset / 8;
|
||||
member->bit_offset = bit_offset % 8;
|
||||
type__add_member(class, member);
|
||||
hashtags__hash(sp->cu->hash_tags, &member->tag);
|
||||
cu__hash(sp->cu, &member->tag);
|
||||
}
|
||||
|
||||
return sizeof(*mp);
|
||||
|
@ -543,7 +543,7 @@ static unsigned long create_short_members(struct ctf_state *sp, void *ptr,
|
|||
member->bit_offset = bit_offset % 8;
|
||||
|
||||
type__add_member(class, member);
|
||||
hashtags__hash(sp->cu->hash_tags, &member->tag);
|
||||
cu__hash(sp->cu, &member->tag);
|
||||
}
|
||||
|
||||
return sizeof(*mp);
|
||||
|
@ -624,7 +624,7 @@ static int create_new_enumeration(struct ctf_state *sp, void *ptr,
|
|||
oom("enumerator__new");
|
||||
|
||||
enumeration__add(enumeration, enumerator);
|
||||
hashtags__hash(sp->cu->hash_tags, &enumerator->tag);
|
||||
cu__hash(sp->cu, &enumerator->tag);
|
||||
}
|
||||
|
||||
cu__add_tag(sp->cu, &enumeration->namespace.tag);
|
||||
|
|
|
@ -788,7 +788,7 @@ static struct tag *die__create_new_enumeration(Dwarf_Die *die, struct cu *cu)
|
|||
oom("enumerator__new");
|
||||
|
||||
enumeration__add(enumeration, enumerator);
|
||||
hashtags__hash(cu->hash_tags, &enumerator->tag);
|
||||
cu__hash(cu, &enumerator->tag);
|
||||
} while (dwarf_siblingof(die, die) == 0);
|
||||
|
||||
return &enumeration->namespace.tag;
|
||||
|
@ -807,7 +807,7 @@ static void die__process_class(Dwarf_Die *die, struct type *class,
|
|||
oom("class_member__new");
|
||||
|
||||
type__add_member(class, member);
|
||||
hashtags__hash(cu->hash_tags, &member->tag);
|
||||
cu__hash(cu, &member->tag);
|
||||
}
|
||||
continue;
|
||||
default: {
|
||||
|
@ -815,7 +815,7 @@ static void die__process_class(Dwarf_Die *die, struct type *class,
|
|||
|
||||
if (tag != NULL) {
|
||||
namespace__add_tag(&class->namespace, tag);
|
||||
hashtags__hash(cu->hash_tags, tag);
|
||||
cu__hash(cu, tag);
|
||||
if (tag->tag == DW_TAG_subprogram) {
|
||||
struct function *fself = tag__function(tag);
|
||||
|
||||
|
@ -837,7 +837,7 @@ static void die__process_namespace(Dwarf_Die *die,
|
|||
|
||||
if (tag != NULL) {
|
||||
namespace__add_tag(namespace, tag);
|
||||
hashtags__hash(cu->hash_tags, tag);
|
||||
cu__hash(cu, tag);
|
||||
}
|
||||
} while (dwarf_siblingof(die, die) == 0);
|
||||
}
|
||||
|
|
12
dwarves.c
12
dwarves.c
|
@ -25,11 +25,14 @@
|
|||
#include "config.h"
|
||||
#include "ctf_loader.h"
|
||||
#include "dwarf_loader.h"
|
||||
#include "hash.h"
|
||||
#include "list.h"
|
||||
#include "dwarves.h"
|
||||
#include "dutil.h"
|
||||
#include "strings.h"
|
||||
|
||||
#define hashtags__fn(key) hash_64(key, HASHTAGS__BITS)
|
||||
|
||||
struct strings *strings;
|
||||
|
||||
static inline const char *s(strings_t i)
|
||||
|
@ -485,17 +488,22 @@ void cu__delete(struct cu *self)
|
|||
free(self);
|
||||
}
|
||||
|
||||
void hashtags__hash(struct list_head *hashtable, struct tag *tag)
|
||||
static void hashtags__hash(struct list_head *hashtable, struct tag *tag)
|
||||
{
|
||||
struct list_head *head = hashtable + hashtags__fn(tag->id);
|
||||
|
||||
list_add_tail(&tag->hash_node, head);
|
||||
}
|
||||
|
||||
void cu__hash(struct cu *self, struct tag *tag)
|
||||
{
|
||||
hashtags__hash(self->hash_tags, tag);
|
||||
}
|
||||
|
||||
void cu__add_tag(struct cu *self, struct tag *tag)
|
||||
{
|
||||
list_add_tail(&tag->node, &self->tags);
|
||||
hashtags__hash(self->hash_tags, tag);
|
||||
cu__hash(self, tag);
|
||||
}
|
||||
|
||||
bool cu__same_build_id(const struct cu *self, const struct cu *other)
|
||||
|
|
10
dwarves.h
10
dwarves.h
|
@ -16,7 +16,6 @@
|
|||
#include <elfutils/libdw.h>
|
||||
|
||||
#include "list.h"
|
||||
#include "hash.h"
|
||||
#include "strings.h"
|
||||
|
||||
extern struct strings *strings;
|
||||
|
@ -29,11 +28,6 @@ struct cus *cus__new(void);
|
|||
|
||||
#define HASHTAGS__BITS 8
|
||||
#define HASHTAGS__SIZE (1UL << HASHTAGS__BITS)
|
||||
#define hashtags__fn(key) hash_64(key, HASHTAGS__BITS)
|
||||
|
||||
struct tag;
|
||||
|
||||
void hashtags__hash(struct list_head *hashtable, struct tag *tag);
|
||||
|
||||
struct cu {
|
||||
struct list_head node;
|
||||
|
@ -54,6 +48,10 @@ struct cu {
|
|||
unsigned char build_id[0];
|
||||
};
|
||||
|
||||
struct tag;
|
||||
|
||||
void cu__hash(struct cu *cu, struct tag *tag);
|
||||
|
||||
struct tag {
|
||||
struct list_head node;
|
||||
struct list_head hash_node;
|
||||
|
|
Loading…
Reference in New Issue