Fix: callsite support: list multiple callsites
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 2 Oct 2012 21:33:11 +0000 (17:33 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 2 Oct 2012 21:33:11 +0000 (17:33 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf-text/ctf-text.c
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
include/babeltrace/ctf-ir/metadata.h

index 4f46427be5ec38bb5fce23e4a905267486fa12a4..67400f513c7fffad32ac89ea96050679e4df3fa0 100644 (file)
@@ -119,7 +119,7 @@ void __attribute__((constructor)) init_quarks(void)
 }
 
 static
-struct ctf_callsite *ctf_trace_callsite_lookup(struct ctf_trace *trace,
+struct ctf_callsite_dups *ctf_trace_callsite_lookup(struct ctf_trace *trace,
                        GQuark callsite_name)
 {
        return g_hash_table_lookup(trace->callsites,
@@ -409,20 +409,30 @@ int ctf_text_write_event(struct stream_pos *ppos, struct ctf_stream_definition *
                dom_print = 1;
        }
        if ((opt_callsite_field || opt_all_fields)) {
+               struct ctf_callsite_dups *cs_dups;
                struct ctf_callsite *callsite;
 
-               callsite = ctf_trace_callsite_lookup(stream_class->trace,
+               cs_dups = ctf_trace_callsite_lookup(stream_class->trace,
                                event_class->name);
-               if (callsite) {
+               if (cs_dups) {
+                       int i = 0;
+
                        set_field_names_print(pos, ITEM_HEADER);
                        if (pos->print_names) {
                                fprintf(pos->fp, "callsite = ");
                        } else if (dom_print) {
                                fprintf(pos->fp, ":");
                        }
-                       fprintf(pos->fp, "[%s@%s:%" PRIu64 "]",
-                               callsite->func, callsite->file,
-                               callsite->line);
+                       fprintf(pos->fp, "[");
+                       bt_list_for_each_entry(callsite, &cs_dups->head, node) {
+                               if (i != 0)
+                                       fprintf(pos->fp, ",");
+                               fprintf(pos->fp, "%s@%s:%" PRIu64 "",
+                                       callsite->func, callsite->file,
+                                       callsite->line);
+                               i++;
+                       }
+                       fprintf(pos->fp, "]");
                        if (pos->print_names)
                                fprintf(pos->fp, ", ");
                        dom_print = 1;
index 0e9fe7961845ca9b99c8d7d30d881eb1bb26fc58..9be7e161a237f27c0e57eb8bf6d4edab6d72a09d 100644 (file)
@@ -2529,6 +2529,7 @@ int ctf_callsite_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_tr
        int ret = 0;
        struct ctf_node *iter;
        struct ctf_callsite *callsite;
+       struct ctf_callsite_dups *cs_dups;
 
        callsite = g_new0(struct ctf_callsite, 1);
        bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
@@ -2557,7 +2558,15 @@ int ctf_callsite_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_tr
                goto error;
        }
 
-       g_hash_table_insert(trace->callsites, (gpointer) (unsigned long) callsite->name, callsite);
+       cs_dups = g_hash_table_lookup(trace->callsites,
+               (gpointer) (unsigned long) callsite->name);
+       if (!cs_dups) {
+               cs_dups = g_new0(struct ctf_callsite_dups, 1);
+               BT_INIT_LIST_HEAD(&cs_dups->head);
+               g_hash_table_insert(trace->callsites,
+                       (gpointer) (unsigned long) callsite->name, cs_dups);
+       }
+       bt_list_add_tail(&callsite->node, &cs_dups->head);
        return 0;
 
 error:
@@ -2570,11 +2579,14 @@ error:
 static
 void callsite_free(gpointer data)
 {
-       struct ctf_callsite *callsite = data;
+       struct ctf_callsite_dups *cs_dups = data;
+       struct ctf_callsite *callsite, *cs_n;
 
-       g_free(callsite->func);
-       g_free(callsite->file);
-       g_free(callsite);
+       bt_list_for_each_entry_safe(callsite, cs_n, &cs_dups->head, node) {
+               g_free(callsite->func);
+               g_free(callsite->file);
+               g_free(callsite);
+       }
 }
 
 static
index 137e3b58652075fcf26f48e48ded13bbd55fc12d..8e0eb0542fc49ac2a76e5965a259396e58a137a1 100644 (file)
@@ -121,6 +121,7 @@ struct ctf_callsite {
        char *func;
        char *file;
        uint64_t line;
+       struct bt_list_head node;
        enum {                                  /* Fields populated mask */
                CTF_CALLSITE_name       =       (1U << 0),
                CTF_CALLSITE_func       =       (1U << 1),
@@ -129,6 +130,10 @@ struct ctf_callsite {
        } field_mask;
 };
 
+struct ctf_callsite_dups {
+       struct bt_list_head head;
+};
+
 #define CTF_TRACE_SET_FIELD(ctf_trace, field)                          \
        do {                                                            \
                (ctf_trace)->field_mask |= CTF_TRACE_ ## field;         \
This page took 0.028476 seconds and 4 git commands to generate.