@@ -129,37 +129,20 @@ error:
return NULL;
}
-static int insert_kprobe(const char *type, const char *system,
- const char *event, const char *addr,
- const char *format)
+static int kprobe_raw(enum tracefs_dynevent_type type, const char *system,
+ const char *event, const char *addr, const char *format)
{
- char *str;
+ static struct tracefs_dynevent *kp;
int ret;
- if (!tracefs_file_exists(NULL, KPROBE_EVENTS))
- return -1;
-
- errno = EBADMSG;
- if (!addr || !format)
- return -1;
-
- if (!event)
- event = addr;
-
- if (system)
- ret = asprintf(&str, "%s:%s/%s %s %s\n",
- type, system, event, addr, format);
- else
- ret = asprintf(&str, "%s:%s %s %s\n",
- type, event, addr, format);
-
- if (ret < 0)
+ kp = kprobe_alloc(type, system, event, addr, format);
+ if (!kp)
return -1;
- ret = tracefs_instance_file_append(NULL, KPROBE_EVENTS, str);
- free(str);
+ ret = tracefs_dynevent_create(kp);
+ tracefs_dynevent_free(kp);
- return ret < 0 ? ret : 0;
+ return ret;
}
/**
@@ -185,7 +168,7 @@ static int insert_kprobe(const char *type, const char *system,
int tracefs_kprobe_raw(const char *system, const char *event,
const char *addr, const char *format)
{
- return insert_kprobe("p", system, event, addr, format);
+ return kprobe_raw(TRACEFS_DYNEVENT_KPROBE, system, event, addr, format);
}
/**
@@ -211,5 +194,5 @@ int tracefs_kprobe_raw(const char *system, const char *event,
int tracefs_kretprobe_raw(const char *system, const char *event,
const char *addr, const char *format)
{
- return insert_kprobe("r", system, event, addr, format);
+ return kprobe_raw(TRACEFS_DYNEVENT_KRETPROBE, system, event, addr, format);
}
In order to unify the code and use the new dynamic event helpers, these kprobe APIs are rewritten: kracefs_kprobe_raw() kracefs_kretprobe_raw() The definition and logic of the APIs remain the same. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- src/tracefs-kprobes.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-)