X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-trace.c;h=7d4c81e31e9716a01e9105951c63483f85b05c8e;hb=refs%2Ftags%2Fflounder_5.99.2;hp=a603951ce170251212534924f9272541519b42e0;hpb=4521c1e7ae5371ab9d639adc617d17fb4e8ded0c;p=src%2Fapp-framework-binder.git diff --git a/src/afb-trace.c b/src/afb-trace.c index a603951c..7d4c81e3 100644 --- a/src/afb-trace.c +++ b/src/afb-trace.c @@ -169,6 +169,7 @@ static int get_flag(const char *name, struct flag flags[], int count) /* timestamp */ static struct json_object *timestamp(const struct afb_hookid *hookid) { +#if JSON_C_MAJOR_VERSION > 0 || JSON_C_MINOR_VERSION >= 12 char ts[50]; snprintf(ts, sizeof ts, "%llu.%06lu", @@ -176,9 +177,9 @@ static struct json_object *timestamp(const struct afb_hookid *hookid) (long unsigned)((hookid->time.tv_nsec + 500) / 1000)); return json_object_new_double_s(0.0f, ts); /* the real value isn't used */ -#if 0 - return json_object_new_string(ts); - return json_object_new_double_s(0f, ts); /* the real value isn't used */ +#else + return json_object_new_double((double)hookid->time.tv_sec + + (double)hookid->time.tv_nsec * .000000001); #endif } @@ -489,7 +490,7 @@ static void hook_xreq_get_uid(void *closure, const struct afb_hookid *hookid, co static void hook_xreq_get_client_info(void *closure, const struct afb_hookid *hookid, const struct afb_xreq *xreq, struct json_object *result) { - hook_xreq(closure, hookid, xreq, "get_client_info", "{so}", + hook_xreq(closure, hookid, xreq, "get_client_info", "{sO}", "result", result); } @@ -685,33 +686,46 @@ static void hook_api_event_make(void *closure, const struct afb_hookid *hookid, static void hook_api_rootdir_get_fd(void *closure, const struct afb_hookid *hookid, const struct afb_export *export, int result) { - char path[PATH_MAX]; + char path[PATH_MAX], proc[100]; + const char *key, *val; + ssize_t s; if (result >= 0) { - sprintf(path, "/proc/self/fd/%d", result); - readlink(path, path, sizeof path); + snprintf(proc, sizeof proc, "/proc/self/fd/%d", result); + s = readlink(proc, path, sizeof path); + path[s < 0 ? 0 : s >= sizeof path ? sizeof path - 1 : s] = 0; + key = "path"; + val = path; + } else { + key = "error"; + val = strerror(errno); } - hook_api(closure, hookid, export, "rootdir_get_fd", "{ss}", - result < 0 ? "path" : "error", - result < 0 ? strerror(errno) : path); + hook_api(closure, hookid, export, "rootdir_get_fd", "{ss}", key, val); } static void hook_api_rootdir_open_locale(void *closure, const struct afb_hookid *hookid, const struct afb_export *export, const char *filename, int flags, const char *locale, int result) { - char path[PATH_MAX]; + char path[PATH_MAX], proc[100]; + const char *key, *val; + ssize_t s; if (result >= 0) { - sprintf(path, "/proc/self/fd/%d", result); - readlink(path, path, sizeof path); + snprintf(proc, sizeof proc, "/proc/self/fd/%d", result); + s = readlink(proc, path, sizeof path); + path[s < 0 ? 0 : s >= sizeof path ? sizeof path - 1 : s] = 0; + key = "path"; + val = path; + } else { + key = "error"; + val = strerror(errno); } hook_api(closure, hookid, export, "rootdir_open_locale", "{ss si ss* ss}", "file", filename, "flags", flags, "locale", locale, - result < 0 ? "path" : "error", - result < 0 ? strerror(errno) : path); + key, val); } static void hook_api_queue_job(void *closure, const struct afb_hookid *hookid, const struct afb_export *export, void (*callback)(int signum, void *arg), void *argument, void *group, int timeout, int result) @@ -1012,7 +1026,7 @@ static void hook_session(void *closure, const struct afb_hookid *hookid, struct va_start(ap, format); emit(closure, hookid, "session", "{ss ss}", format, ap, - "uuid", session, + "uuid", afb_session_uuid(session), "action", action); va_end(ap); } @@ -1586,7 +1600,7 @@ static void add(void *closure, struct json_object *object) wrap_json_optarray_for_all(event, add_evt_flags, &desc); if (session) - wrap_json_optarray_for_all(event, add_session_flags, &desc); + wrap_json_optarray_for_all(session, add_session_flags, &desc); if (global) wrap_json_optarray_for_all(global, add_global_flags, &desc); @@ -1730,7 +1744,7 @@ int afb_trace_add(afb_req_t req, struct json_object *args, struct afb_trace *tra } /* drop traces */ -extern int afb_trace_drop(afb_req_t req, struct json_object *args, struct afb_trace *trace) +int afb_trace_drop(afb_req_t req, struct json_object *args, struct afb_trace *trace) { int rc; struct context context;