diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-11-12 14:09:49 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-11-14 23:34:33 +0200 |
commit | 614eabb225a9f62d1dbfe50fe44e7b9db9c0467d (patch) | |
tree | ed0ae264afb6e4dc4b7bc3f3f908281ebd50f220 /src | |
parent | b92047ed10c4da784c296dfcf09da250b7b637c7 (diff) | |
download | cflow-614eabb225a9f62d1dbfe50fe44e7b9db9c0467d.tar.gz cflow-614eabb225a9f62d1dbfe50fe44e7b9db9c0467d.tar.bz2 |
Include static symbols as root points in inverted graphs.
* src/cflow.h (linked_list_size): New function.
* src/linked-list.c (linked_list_size): New function.
* src/symbol.c (collect_symbols): Include static symbols,
if allowed by sel.
* src/main.c (parse_opt): Exclude static symbols for --xref
Diffstat (limited to 'src')
-rw-r--r-- | src/cflow.h | 1 | ||||
-rw-r--r-- | src/linked-list.c | 13 | ||||
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/symbol.c | 31 |
4 files changed, 36 insertions, 10 deletions
diff --git a/src/cflow.h b/src/cflow.h index 5867a18..0e3ee44 100644 --- a/src/cflow.h +++ b/src/cflow.h @@ -200,2 +200,3 @@ void linked_list_unlink(struct linked_list *list, struct linked_list_entry *ent); +size_t linked_list_size(struct linked_list *list); diff --git a/src/linked-list.c b/src/linked-list.c index 095b63e..3c57bf0 100644 --- a/src/linked-list.c +++ b/src/linked-list.c @@ -146 +146,14 @@ data_in_list(void *data, struct linked_list *list) } + +size_t +linked_list_size(struct linked_list *list) +{ + size_t size = 0; + if (list) { + struct linked_list_entry *p; + for (p = linked_list_head(list); p; p = p->next) + size++; + } + return size; +} + @@ -649,2 +649,3 @@ parse_opt (int key, char *arg, struct argp_state *state) print_option = PRINT_XREF; + SYMBOL_EXCLUDE('s'); /* Exclude static symbols by default */ break; diff --git a/src/symbol.c b/src/symbol.c index 460f954..5f7dec2 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -299,2 +299,14 @@ collect_processor(void *data, void *proc_data) +static int +collect_list_entry(void *item, void *proc_data) +{ + Symbol *s = item; + struct collect_data *cd = proc_data; + if (cd->sel(s)) { + cd->sym[cd->index] = s; + cd->index++; + } + return 0; +} + size_t @@ -304,4 +316,7 @@ collect_symbols(Symbol ***return_sym, int (*sel)(Symbol *p), struct collect_data cdata; + size_t size; - cdata.sym = NULL; + size = hash_get_n_entries(symbol_table) + + linked_list_size(static_func_list); + cdata.sym = xcalloc(size + reserved_slots, sizeof(*cdata.sym)); cdata.index = 0; @@ -309,7 +324,6 @@ collect_symbols(Symbol ***return_sym, int (*sel)(Symbol *p), hash_do_for_each(symbol_table, collect_processor, &cdata); - cdata.sym = calloc(cdata.index + reserved_slots, sizeof(*cdata.sym)); - if (!cdata.sym) - xalloc_die(); - cdata.index = 0; - hash_do_for_each (symbol_table, collect_processor, &cdata); + linked_list_iterate(&static_func_list, collect_list_entry, &cdata); + + cdata.sym = xrealloc(cdata.sym, + (cdata.index + reserved_slots) * sizeof(*cdata.sym)); *return_sym = cdata.sym; @@ -326,6 +340,3 @@ collect_functions(Symbol ***return_sym) /* Count static functions */ - snum = 0; - if (static_func_list) - for (p = linked_list_head(static_func_list); p; p = p->next) - snum++; + snum = linked_list_size(static_func_list); |