aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dissect.c
diff options
context:
space:
mode:
Diffstat (limited to 'dissect.c')
-rw-r--r--dissect.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/dissect.c b/dissect.c
index 582e8fc3..300d5ca9 100644
--- a/dissect.c
+++ b/dissect.c
@@ -610,6 +610,16 @@ static struct symbol *do_initializer(struct symbol *type, struct expression *exp
return type;
}
+static inline bool is_macro(struct symbol *sym)
+{
+ return (sym->namespace == NS_MACRO || sym->namespace == NS_UNDEF);
+}
+
+static inline bool is_typedef(struct symbol *sym)
+{
+ return (sym->namespace == NS_TYPEDEF);
+}
+
static inline struct symbol *do_symbol(struct symbol *sym)
{
struct symbol *type = base_type(sym);
@@ -652,9 +662,58 @@ static void do_sym_list(struct symbol_list *list)
DO_LIST(list, sym, do_symbol(sym));
}
+static inline bool valid_namespace(enum namespace ns)
+{
+ return (ns == NS_TYPEDEF || ns == NS_MACRO || ns == NS_UNDEF || ns == NS_STRUCT || ns == NS_SYMBOL);
+}
+
+static void do_file(char *file)
+{
+ struct symbol_list *res = sparse_keep_tokens(file);
+
+ if (!dissect_show_all_symbols) {
+ do_sym_list(res);
+ goto end;
+ }
+
+ DO_LIST(file_scope->symbols, sym,
+ if (input_streams[sym->pos.stream].fd != -1 && valid_namespace(sym->namespace)) {
+ if (is_typedef(sym)) {
+ sym->kind = 't';
+ reporter->r_symdef(sym);
+ continue;
+ }
+
+ if (is_macro(sym)) {
+ sym->kind = 'd';
+ reporter->r_symdef(sym);
+ continue;
+ }
+
+ if (sym->type == SYM_STRUCT || sym->type == SYM_UNION) {
+ sym->ctype.base_type = sym;
+ examine_sym_node(sym, NULL);
+ continue;
+ }
+
+ do_symbol(sym);
+ }
+ );
+
+ DO_LIST(global_scope->symbols, sym,
+ if (input_streams[sym->pos.stream].fd != -1 && valid_namespace(sym->namespace)) {
+ do_symbol(sym);
+ }
+ );
+
+end:
+ /* Drop the tokens for this file after parsing */
+ clear_token_alloc();
+}
+
void dissect(struct reporter *rep, struct string_list *filelist)
{
reporter = rep;
- DO_LIST(filelist, file, do_sym_list(__sparse(file)));
+ DO_LIST(filelist, file, do_file(file));
}