Commit | Line | Data |
---|---|---|
4f45f9bb JD |
1 | #ifndef BABELTRACE_PLUGIN_DEBUG_INFO_H |
2 | #define BABELTRACE_PLUGIN_DEBUG_INFO_H | |
3 | ||
4 | /* | |
5 | * Babeltrace - Debug information Plug-in | |
6 | * | |
7 | * Copyright (c) 2015 EfficiOS Inc. | |
8 | * Copyright (c) 2015 Antoine Busque <abusque@efficios.com> | |
9 | * | |
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
11 | * of this software and associated documentation files (the "Software"), to deal | |
12 | * in the Software without restriction, including without limitation the rights | |
13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
14 | * copies of the Software, and to permit persons to whom the Software is | |
15 | * furnished to do so, subject to the following conditions: | |
16 | * | |
17 | * The above copyright notice and this permission notice shall be included in | |
18 | * all copies or substantial portions of the Software. | |
19 | * | |
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
26 | * SOFTWARE. | |
27 | */ | |
28 | ||
29 | #include <stdbool.h> | |
30 | #include <stdint.h> | |
31 | #include <stddef.h> | |
32 | #include <babeltrace/babeltrace-internal.h> | |
33 | #include <babeltrace/ctf-ir/event.h> | |
34 | #include <babeltrace/ctf-ir/trace.h> | |
35 | #include <babeltrace/ctf-ir/fields.h> | |
36 | #include <babeltrace/ctf-ir/event-class.h> | |
37 | ||
1c78e839 JD |
38 | enum debug_info_stream_state { |
39 | /* | |
40 | * We know the stream exists but we have never received a | |
41 | * stream_begin notification for it. | |
42 | */ | |
43 | DEBUG_INFO_UNKNOWN_STREAM, | |
44 | /* We know this stream is active (between stream_begin and _end). */ | |
45 | DEBUG_INFO_ACTIVE_STREAM, | |
46 | /* We have received a stream_end for this stream. */ | |
47 | DEBUG_INFO_COMPLETED_STREAM, | |
48 | }; | |
49 | ||
4f45f9bb JD |
50 | struct debug_info_component { |
51 | FILE *err; | |
52 | char *arg_debug_info_field_name; | |
53 | const char *arg_debug_dir; | |
54 | bool arg_full_path; | |
55 | const char *arg_target_prefix; | |
56 | }; | |
57 | ||
58 | struct debug_info_iterator { | |
59 | struct debug_info_component *debug_info_component; | |
60 | /* Map between struct bt_ctf_trace and struct bt_ctf_writer. */ | |
61 | GHashTable *trace_map; | |
504db471 JD |
62 | /* Input iterators associated with this output iterator. */ |
63 | GPtrArray *input_iterator_group; | |
64 | struct bt_notification *current_notification; | |
65 | struct bt_notification_iterator *input_iterator; | |
66 | FILE *err; | |
67 | }; | |
68 | ||
69 | struct debug_info_trace { | |
70 | struct bt_ctf_trace *trace; | |
71 | struct bt_ctf_trace *writer_trace; | |
72 | struct debug_info_component *debug_info_component; | |
1c78e839 | 73 | struct debug_info_iterator *debug_it; |
504db471 JD |
74 | int static_listener_id; |
75 | int trace_static; | |
4f45f9bb JD |
76 | /* Map between reader and writer stream. */ |
77 | GHashTable *stream_map; | |
78 | /* Map between reader and writer stream class. */ | |
79 | GHashTable *stream_class_map; | |
80 | /* Map between reader and writer stream class. */ | |
81 | GHashTable *packet_map; | |
82 | /* Map between a trace_class and its corresponding debug_info. */ | |
83 | GHashTable *trace_debug_map; | |
1c78e839 JD |
84 | /* Map between a stream and enum debug_info_stream_state. */ |
85 | GHashTable *stream_states; | |
4f45f9bb JD |
86 | }; |
87 | ||
88 | struct debug_info_source { | |
89 | /* Strings are owned by debug_info_source. */ | |
90 | char *func; | |
91 | uint64_t line_no; | |
92 | char *src_path; | |
93 | /* short_src_path points inside src_path, no need to free. */ | |
94 | const char *short_src_path; | |
95 | char *bin_path; | |
96 | /* short_bin_path points inside bin_path, no need to free. */ | |
97 | const char *short_bin_path; | |
98 | /* | |
99 | * Location within the binary. Either absolute (@0x1234) or | |
100 | * relative (+0x4321). | |
101 | */ | |
102 | char *bin_loc; | |
103 | }; | |
104 | ||
105 | BT_HIDDEN | |
9d325e17 | 106 | struct debug_info *debug_info_create(struct debug_info_component *comp); |
4f45f9bb JD |
107 | |
108 | BT_HIDDEN | |
109 | void debug_info_destroy(struct debug_info *debug_info); | |
110 | ||
111 | BT_HIDDEN | |
112 | struct debug_info_source *debug_info_query(struct debug_info *debug_info, | |
113 | int64_t vpid, uint64_t ip); | |
114 | ||
115 | BT_HIDDEN | |
116 | void debug_info_handle_event(FILE *err, struct bt_ctf_event *event, | |
117 | struct debug_info *debug_info); | |
118 | ||
1c78e839 JD |
119 | BT_HIDDEN |
120 | void debug_info_close_trace(struct debug_info_iterator *debug_it, | |
121 | struct debug_info_trace *di_trace); | |
122 | ||
4f45f9bb | 123 | #endif /* BABELTRACE_PLUGIN_DEBUG_INFO_H */ |