@@ -147,38 +147,20 @@ void tracefs_kprobe_free(struct tracefs_dynevent *kprobe)
dynevent_free(kprobe);
}
-
-static int insert_kprobe(const char *type, const char *system,
- const char *event, const char *addr,
- const char *format)
+static int kprobe_raw(enum trace_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 = dynevent_create(kp);
+ dynevent_free(kp);
- return ret < 0 ? ret : 0;
+ return ret;
}
/**
@@ -204,7 +186,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(TRACE_DYNEVENT_KPROBE, system, event, addr, format);
}
/**
@@ -230,7 +212,7 @@ 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(TRACE_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 | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-)