-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathshiva_callsite.c
More file actions
29 lines (26 loc) · 737 Bytes
/
shiva_callsite.c
File metadata and controls
29 lines (26 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "shiva.h"
void
shiva_callsite_iterator_init(struct shiva_ctx *ctx, struct shiva_callsite_iterator *iter)
{
iter->current = TAILQ_FIRST(&ctx->tailq.branch_tqlist);
iter->ctx = ctx;
return;
}
shiva_iterator_res_t
shiva_callsite_iterator_next(struct shiva_callsite_iterator *iter, struct shiva_branch_site *e)
{
if (iter->current == NULL)
return SHIVA_ITER_DONE;
check_branch:
if (iter->current->branch_type == SHIVA_BRANCH_CALL) {
memcpy(e, iter->current, sizeof(*e));
iter->current = TAILQ_NEXT(iter->current, _linkage);
return SHIVA_ITER_OK;
} else {
iter->current = TAILQ_NEXT(iter->current, _linkage);
if (iter->current == NULL)
return SHIVA_ITER_DONE;
goto check_branch;
}
return ELF_ITER_DONE;
}