Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of example plugin for library call detection and counting. #79

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/plugin_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <assert.h>
#include <sys/mman.h>
#include <stdarg.h>
#include <string.h>

#include "../dbm.h"
#include "../common.h"
Expand Down Expand Up @@ -171,6 +172,14 @@ void *mambo_alloc(mambo_context *ctx, size_t size) {
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
}

void *mambo_calloc(mambo_context *ctx, size_t nitems, size_t size) {
void* ret = mmap(NULL, nitems*size, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if(ret) {
memset(ret, 0, nitems*size);
}
return ret;
}

void mambo_free(mambo_context *ctx, void *ptr) {
}

Expand Down
1 change: 1 addition & 0 deletions api/plugin_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ int mambo_register_function_cb(mambo_context *ctx, char *fn_name,

/* Memory management */
void *mambo_alloc(mambo_context *ctx, size_t size);
void *mambo_calloc(mambo_context *ctx, size_t nitems, size_t size);
void mambo_free(mambo_context *ctx, void *ptr);

/* Access plugin data */
Expand Down
1 change: 1 addition & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#PLUGINS+=plugins/symbol_example.c
#PLUGINS+=plugins/memcheck/memcheck.S plugins/memcheck/memcheck.c plugins/memcheck/naive_stdlib.c
#PLUGINS+=plugins/follow_exec.c
#PLUGINS+=plugins/library_call_trace.c

OPTS= -DDBM_LINK_UNCOND_IMM
OPTS+=-DDBM_INLINE_UNCOND_IMM
Expand Down
Loading