emit: Search for data structures using its type in addition to its name
As we may have, say, both a typedef and a struct with the same name and sometimes we need to emit both to reflect some types found in the Linux kernel that use: typedef struct foo { ... } foo; So we need both 'struct foo' and 'typedef foo'. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
32cc148172
commit
742f04f89d
|
@ -612,7 +612,7 @@ static void emit_list_of_types(struct list_head *list)
|
||||||
* Lets look at the other CUs, perhaps we have already
|
* Lets look at the other CUs, perhaps we have already
|
||||||
* emmited this one
|
* emmited this one
|
||||||
*/
|
*/
|
||||||
if (type_emissions__find_definition(&emissions, structure__name(pos))) {
|
if (type_emissions__find_definition(&emissions, type__tag(type)->tag, structure__name(pos))) {
|
||||||
type->definition_emitted = 1;
|
type->definition_emitted = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ static void type_emissions__add_fwd_decl(struct type_emissions *emissions,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct type *type_emissions__find_definition(const struct type_emissions *emissions,
|
struct type *type_emissions__find_definition(const struct type_emissions *emissions,
|
||||||
const char *name)
|
uint16_t tag, const char *name)
|
||||||
{
|
{
|
||||||
struct type *pos;
|
struct type *pos;
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ struct type *type_emissions__find_definition(const struct type_emissions *emissi
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
list_for_each_entry(pos, &emissions->definitions, node)
|
list_for_each_entry(pos, &emissions->definitions, node)
|
||||||
if (type__name(pos) != NULL &&
|
if (type__tag(pos)->tag == tag &&
|
||||||
|
type__name(pos) != NULL &&
|
||||||
strcmp(type__name(pos), name) == 0)
|
strcmp(type__name(pos), name) == 0)
|
||||||
return pos;
|
return pos;
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ static int enumeration__emit_definitions(struct tag *tag,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Ok, lets look at the previous CUs: */
|
/* Ok, lets look at the previous CUs: */
|
||||||
if (type_emissions__find_definition(emissions, type__name(etype)) != NULL) {
|
if (type_emissions__find_definition(emissions, DW_TAG_enumeration_type, type__name(etype)) != NULL) {
|
||||||
/*
|
/*
|
||||||
* Yes, so lets mark it visited on this CU too,
|
* Yes, so lets mark it visited on this CU too,
|
||||||
* to speed up the lookup.
|
* to speed up the lookup.
|
||||||
|
@ -111,7 +112,7 @@ static int typedef__emit_definitions(struct tag *tdef, struct cu *cu,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Ok, lets look at the previous CUs: */
|
/* Ok, lets look at the previous CUs: */
|
||||||
if (type_emissions__find_definition(emissions, type__name(def)) != NULL) {
|
if (type_emissions__find_definition(emissions, DW_TAG_typedef, type__name(def)) != NULL) {
|
||||||
/*
|
/*
|
||||||
* Yes, so lets mark it visited on this CU too,
|
* Yes, so lets mark it visited on this CU too,
|
||||||
* to speed up the lookup.
|
* to speed up the lookup.
|
||||||
|
@ -298,7 +299,7 @@ int type__emit_definitions(struct tag *tag, struct cu *cu,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Ok, lets look at the previous CUs: */
|
/* Ok, lets look at the previous CUs: */
|
||||||
if (type_emissions__find_definition(emissions, type__name(ctype)) != NULL) {
|
if (type_emissions__find_definition(emissions, tag->tag, type__name(ctype)) != NULL) {
|
||||||
ctype->definition_emitted = 1;
|
ctype->definition_emitted = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
struct cu;
|
struct cu;
|
||||||
|
@ -30,6 +31,6 @@ int type__emit_definitions(struct tag *tag, struct cu *cu,
|
||||||
void type__emit(struct tag *tag_type, struct cu *cu,
|
void type__emit(struct tag *tag_type, struct cu *cu,
|
||||||
const char *prefix, const char *suffix, FILE *fp);
|
const char *prefix, const char *suffix, FILE *fp);
|
||||||
struct type *type_emissions__find_definition(const struct type_emissions *temissions,
|
struct type *type_emissions__find_definition(const struct type_emissions *temissions,
|
||||||
const char *name);
|
uint16_t tag, const char *name);
|
||||||
|
|
||||||
#endif /* _DWARVES_EMIT_H_ */
|
#endif /* _DWARVES_EMIT_H_ */
|
||||||
|
|
Loading…
Reference in New Issue