Fix: add "has_build_id" and "has_debug_link" fields to debuginfo events
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 16 May 2016 14:40:32 +0000 (10:40 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 16 May 2016 14:42:33 +0000 (10:42 -0400)
This allows trace analyzers to know whether they should expect the build
id or debug link events following the bin_info event.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-dl/lttng-ust-dl.c
liblttng-ust-dl/ust_dl.h
liblttng-ust/lttng-ust-statedump-provider.h
liblttng-ust/lttng-ust-statedump.c

index ac3c951fc85cd9ee80f096fd033d9852630bc31f..e4cb42068ed1548ab10eaa4a1b850b2a19d45eb8 100644 (file)
@@ -104,7 +104,8 @@ void lttng_ust_dl_dlopen(void *so_base, const char *so_name, void *ip)
        }
 
        tracepoint(lttng_ust_dl, dlopen,
-               ip, so_base, resolved_path, memsz);
+               ip, so_base, resolved_path, memsz,
+               has_build_id, has_debug_link);
 
        if (has_build_id) {
                tracepoint(lttng_ust_dl, build_id,
index 72b23ac58eea522f6f8466e1c80c34608a600c68..24c9b70fa1e7ef7fb1bf532c7459504a9897972c 100644 (file)
@@ -39,11 +39,14 @@ extern "C" {
 
 TRACEPOINT_EVENT(lttng_ust_dl, dlopen,
        TP_ARGS(void *, ip, void *, baddr, const char*, path,
-               uint64_t, memsz),
+               uint64_t, memsz, uint8_t, has_build_id,
+               uint8_t, has_debug_link),
        TP_FIELDS(
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint64_t, memsz, memsz)
                ctf_string(path, path)
+               ctf_integer(uint8_t, has_build_id, has_build_id)
+               ctf_integer(uint8_t, has_debug_link, has_debug_link)
        )
 )
 
index 9f1f74c572b3217f065965ca433dca9546572924..b6a6f7e5970da8f8e789593f537debcf414fd643 100644 (file)
@@ -49,13 +49,17 @@ TRACEPOINT_EVENT(lttng_ust_statedump, bin_info,
                void *, baddr,
                const char*, path,
                uint64_t, memsz,
-               uint8_t, is_pic
+               uint8_t, is_pic,
+               uint8_t, has_build_id,
+               uint8_t, has_debug_link
        ),
        TP_FIELDS(
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint64_t, memsz, memsz)
                ctf_string(path, path)
                ctf_integer(uint8_t, is_pic, is_pic)
+               ctf_integer(uint8_t, has_build_id, has_build_id)
+               ctf_integer(uint8_t, has_debug_link, has_debug_link)
        )
 )
 
index 10854d9f1d268a5637a81144e97eb113ac2c1e9b..e64b4f2538f79251da1f6627d2f1ab5569b30a95 100644 (file)
@@ -53,6 +53,8 @@ struct bin_info_data {
        int vdso;
        uint32_t crc;
        uint8_t is_pic;
+       uint8_t has_build_id;
+       uint8_t has_debug_link;
 };
 
 typedef void (*tracepoint_cb)(struct lttng_session *session, void *priv);
@@ -85,7 +87,9 @@ void trace_bin_info_cb(struct lttng_session *session, void *priv)
 
        tracepoint(lttng_ust_statedump, bin_info,
                session, bin_data->base_addr_ptr,
-               bin_data->resolved_path, bin_data->memsz, bin_data->is_pic);
+               bin_data->resolved_path, bin_data->memsz,
+               bin_data->is_pic, bin_data->has_build_id,
+               bin_data->has_debug_link);
 }
 
 static
@@ -121,10 +125,10 @@ void trace_end_cb(struct lttng_session *session, void *priv)
 }
 
 static
-int get_elf_info(struct bin_info_data *bin_data, int *has_build_id,
-               int *has_debug_link) {
+int get_elf_info(struct bin_info_data *bin_data)
+{
        struct lttng_ust_elf *elf;
-       int ret = 0;
+       int ret = 0, found;
 
        elf = lttng_ust_elf_create(bin_data->resolved_path);
        if (!elf) {
@@ -137,16 +141,22 @@ int get_elf_info(struct bin_info_data *bin_data, int *has_build_id,
                goto end;
        }
 
+       found = 0;
        ret = lttng_ust_elf_get_build_id(elf, &bin_data->build_id,
-                                       &bin_data->build_id_len, has_build_id);
+                                       &bin_data->build_id_len,
+                                       &found);
        if (ret) {
                goto end;
        }
+       bin_data->has_build_id = !!found;
+       found = 0;
        ret = lttng_ust_elf_get_debug_link(elf, &bin_data->dbg_file,
-                                       &bin_data->crc, has_debug_link);
+                                       &bin_data->crc,
+                                       &found);
        if (ret) {
                goto end;
        }
+       bin_data->has_debug_link = !!found;
 
        bin_data->is_pic = lttng_ust_elf_is_pic(elf);
 
@@ -158,10 +168,10 @@ end:
 static
 int trace_baddr(struct bin_info_data *bin_data)
 {
-       int ret = 0, has_build_id = 0, has_debug_link = 0;
+       int ret = 0;
 
        if (!bin_data->vdso) {
-               ret = get_elf_info(bin_data, &has_build_id, &has_debug_link);
+               ret = get_elf_info(bin_data);
                if (ret) {
                        goto end;
                }
@@ -175,7 +185,7 @@ int trace_baddr(struct bin_info_data *bin_data)
                goto end;
        }
 
-       if (has_build_id) {
+       if (bin_data->has_build_id) {
                ret = trace_statedump_event(
                        trace_build_id_cb, bin_data->owner, bin_data);
                free(bin_data->build_id);
@@ -184,7 +194,7 @@ int trace_baddr(struct bin_info_data *bin_data)
                }
        }
 
-       if (has_debug_link) {
+       if (bin_data->has_debug_link) {
                ret = trace_statedump_event(
                        trace_debug_link_cb, bin_data->owner, bin_data);
                free(bin_data->dbg_file);
This page took 0.028393 seconds and 4 git commands to generate.