diff options
Diffstat (limited to 'tools/lib/traceevent')
-rw-r--r-- | tools/lib/traceevent/event-parse-api.c | 4 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse-local.h | 4 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 129 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 17 | ||||
-rw-r--r-- | tools/lib/traceevent/plugin_kvm.c | 2 | ||||
-rw-r--r-- | tools/lib/traceevent/trace-seq.c | 17 |
6 files changed, 110 insertions, 63 deletions
diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c index 8b31c0e00ba3..d463761a58f4 100644 --- a/tools/lib/traceevent/event-parse-api.c +++ b/tools/lib/traceevent/event-parse-api.c | |||
@@ -194,13 +194,13 @@ void tep_set_page_size(struct tep_handle *pevent, int _page_size) | |||
194 | } | 194 | } |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * tep_is_file_bigendian - get if the file is in big endian order | 197 | * tep_file_bigendian - get if the file is in big endian order |
198 | * @pevent: a handle to the tep_handle | 198 | * @pevent: a handle to the tep_handle |
199 | * | 199 | * |
200 | * This returns if the file is in big endian order | 200 | * This returns if the file is in big endian order |
201 | * If @pevent is NULL, 0 is returned. | 201 | * If @pevent is NULL, 0 is returned. |
202 | */ | 202 | */ |
203 | int tep_is_file_bigendian(struct tep_handle *pevent) | 203 | int tep_file_bigendian(struct tep_handle *pevent) |
204 | { | 204 | { |
205 | if(pevent) | 205 | if(pevent) |
206 | return pevent->file_bigendian; | 206 | return pevent->file_bigendian; |
diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h index 9a092dd4a86d..35833ee32d6c 100644 --- a/tools/lib/traceevent/event-parse-local.h +++ b/tools/lib/traceevent/event-parse-local.h | |||
@@ -7,7 +7,7 @@ | |||
7 | #ifndef _PARSE_EVENTS_INT_H | 7 | #ifndef _PARSE_EVENTS_INT_H |
8 | #define _PARSE_EVENTS_INT_H | 8 | #define _PARSE_EVENTS_INT_H |
9 | 9 | ||
10 | struct cmdline; | 10 | struct tep_cmdline; |
11 | struct cmdline_list; | 11 | struct cmdline_list; |
12 | struct func_map; | 12 | struct func_map; |
13 | struct func_list; | 13 | struct func_list; |
@@ -36,7 +36,7 @@ struct tep_handle { | |||
36 | int long_size; | 36 | int long_size; |
37 | int page_size; | 37 | int page_size; |
38 | 38 | ||
39 | struct cmdline *cmdlines; | 39 | struct tep_cmdline *cmdlines; |
40 | struct cmdline_list *cmdlist; | 40 | struct cmdline_list *cmdlist; |
41 | int cmdline_count; | 41 | int cmdline_count; |
42 | 42 | ||
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 69a96e39f0ab..abd4fa5d3088 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -124,15 +124,15 @@ struct tep_print_arg *alloc_arg(void) | |||
124 | return calloc(1, sizeof(struct tep_print_arg)); | 124 | return calloc(1, sizeof(struct tep_print_arg)); |
125 | } | 125 | } |
126 | 126 | ||
127 | struct cmdline { | 127 | struct tep_cmdline { |
128 | char *comm; | 128 | char *comm; |
129 | int pid; | 129 | int pid; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | static int cmdline_cmp(const void *a, const void *b) | 132 | static int cmdline_cmp(const void *a, const void *b) |
133 | { | 133 | { |
134 | const struct cmdline *ca = a; | 134 | const struct tep_cmdline *ca = a; |
135 | const struct cmdline *cb = b; | 135 | const struct tep_cmdline *cb = b; |
136 | 136 | ||
137 | if (ca->pid < cb->pid) | 137 | if (ca->pid < cb->pid) |
138 | return -1; | 138 | return -1; |
@@ -152,7 +152,7 @@ static int cmdline_init(struct tep_handle *pevent) | |||
152 | { | 152 | { |
153 | struct cmdline_list *cmdlist = pevent->cmdlist; | 153 | struct cmdline_list *cmdlist = pevent->cmdlist; |
154 | struct cmdline_list *item; | 154 | struct cmdline_list *item; |
155 | struct cmdline *cmdlines; | 155 | struct tep_cmdline *cmdlines; |
156 | int i; | 156 | int i; |
157 | 157 | ||
158 | cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count); | 158 | cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count); |
@@ -179,8 +179,8 @@ static int cmdline_init(struct tep_handle *pevent) | |||
179 | 179 | ||
180 | static const char *find_cmdline(struct tep_handle *pevent, int pid) | 180 | static const char *find_cmdline(struct tep_handle *pevent, int pid) |
181 | { | 181 | { |
182 | const struct cmdline *comm; | 182 | const struct tep_cmdline *comm; |
183 | struct cmdline key; | 183 | struct tep_cmdline key; |
184 | 184 | ||
185 | if (!pid) | 185 | if (!pid) |
186 | return "<idle>"; | 186 | return "<idle>"; |
@@ -208,8 +208,8 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid) | |||
208 | */ | 208 | */ |
209 | int tep_pid_is_registered(struct tep_handle *pevent, int pid) | 209 | int tep_pid_is_registered(struct tep_handle *pevent, int pid) |
210 | { | 210 | { |
211 | const struct cmdline *comm; | 211 | const struct tep_cmdline *comm; |
212 | struct cmdline key; | 212 | struct tep_cmdline key; |
213 | 213 | ||
214 | if (!pid) | 214 | if (!pid) |
215 | return 1; | 215 | return 1; |
@@ -232,11 +232,13 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid) | |||
232 | * we must add this pid. This is much slower than when cmdlines | 232 | * we must add this pid. This is much slower than when cmdlines |
233 | * are added before the array is initialized. | 233 | * are added before the array is initialized. |
234 | */ | 234 | */ |
235 | static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) | 235 | static int add_new_comm(struct tep_handle *pevent, |
236 | const char *comm, int pid, bool override) | ||
236 | { | 237 | { |
237 | struct cmdline *cmdlines = pevent->cmdlines; | 238 | struct tep_cmdline *cmdlines = pevent->cmdlines; |
238 | const struct cmdline *cmdline; | 239 | struct tep_cmdline *cmdline; |
239 | struct cmdline key; | 240 | struct tep_cmdline key; |
241 | char *new_comm; | ||
240 | 242 | ||
241 | if (!pid) | 243 | if (!pid) |
242 | return 0; | 244 | return 0; |
@@ -247,8 +249,19 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) | |||
247 | cmdline = bsearch(&key, pevent->cmdlines, pevent->cmdline_count, | 249 | cmdline = bsearch(&key, pevent->cmdlines, pevent->cmdline_count, |
248 | sizeof(*pevent->cmdlines), cmdline_cmp); | 250 | sizeof(*pevent->cmdlines), cmdline_cmp); |
249 | if (cmdline) { | 251 | if (cmdline) { |
250 | errno = EEXIST; | 252 | if (!override) { |
251 | return -1; | 253 | errno = EEXIST; |
254 | return -1; | ||
255 | } | ||
256 | new_comm = strdup(comm); | ||
257 | if (!new_comm) { | ||
258 | errno = ENOMEM; | ||
259 | return -1; | ||
260 | } | ||
261 | free(cmdline->comm); | ||
262 | cmdline->comm = new_comm; | ||
263 | |||
264 | return 0; | ||
252 | } | 265 | } |
253 | 266 | ||
254 | cmdlines = realloc(cmdlines, sizeof(*cmdlines) * (pevent->cmdline_count + 1)); | 267 | cmdlines = realloc(cmdlines, sizeof(*cmdlines) * (pevent->cmdline_count + 1)); |
@@ -275,21 +288,13 @@ static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid) | |||
275 | return 0; | 288 | return 0; |
276 | } | 289 | } |
277 | 290 | ||
278 | /** | 291 | static int _tep_register_comm(struct tep_handle *pevent, |
279 | * tep_register_comm - register a pid / comm mapping | 292 | const char *comm, int pid, bool override) |
280 | * @pevent: handle for the pevent | ||
281 | * @comm: the command line to register | ||
282 | * @pid: the pid to map the command line to | ||
283 | * | ||
284 | * This adds a mapping to search for command line names with | ||
285 | * a given pid. The comm is duplicated. | ||
286 | */ | ||
287 | int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid) | ||
288 | { | 293 | { |
289 | struct cmdline_list *item; | 294 | struct cmdline_list *item; |
290 | 295 | ||
291 | if (pevent->cmdlines) | 296 | if (pevent->cmdlines) |
292 | return add_new_comm(pevent, comm, pid); | 297 | return add_new_comm(pevent, comm, pid, override); |
293 | 298 | ||
294 | item = malloc(sizeof(*item)); | 299 | item = malloc(sizeof(*item)); |
295 | if (!item) | 300 | if (!item) |
@@ -312,6 +317,40 @@ int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid) | |||
312 | return 0; | 317 | return 0; |
313 | } | 318 | } |
314 | 319 | ||
320 | /** | ||
321 | * tep_register_comm - register a pid / comm mapping | ||
322 | * @pevent: handle for the pevent | ||
323 | * @comm: the command line to register | ||
324 | * @pid: the pid to map the command line to | ||
325 | * | ||
326 | * This adds a mapping to search for command line names with | ||
327 | * a given pid. The comm is duplicated. If a command with the same pid | ||
328 | * already exist, -1 is returned and errno is set to EEXIST | ||
329 | */ | ||
330 | int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid) | ||
331 | { | ||
332 | return _tep_register_comm(pevent, comm, pid, false); | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * tep_override_comm - register a pid / comm mapping | ||
337 | * @pevent: handle for the pevent | ||
338 | * @comm: the command line to register | ||
339 | * @pid: the pid to map the command line to | ||
340 | * | ||
341 | * This adds a mapping to search for command line names with | ||
342 | * a given pid. The comm is duplicated. If a command with the same pid | ||
343 | * already exist, the command string is udapted with the new one | ||
344 | */ | ||
345 | int tep_override_comm(struct tep_handle *pevent, const char *comm, int pid) | ||
346 | { | ||
347 | if (!pevent->cmdlines && cmdline_init(pevent)) { | ||
348 | errno = ENOMEM; | ||
349 | return -1; | ||
350 | } | ||
351 | return _tep_register_comm(pevent, comm, pid, true); | ||
352 | } | ||
353 | |||
315 | int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock) | 354 | int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock) |
316 | { | 355 | { |
317 | pevent->trace_clock = strdup(trace_clock); | 356 | pevent->trace_clock = strdup(trace_clock); |
@@ -5227,18 +5266,6 @@ int tep_data_type(struct tep_handle *pevent, struct tep_record *rec) | |||
5227 | } | 5266 | } |
5228 | 5267 | ||
5229 | /** | 5268 | /** |
5230 | * tep_data_event_from_type - find the event by a given type | ||
5231 | * @pevent: a handle to the pevent | ||
5232 | * @type: the type of the event. | ||
5233 | * | ||
5234 | * This returns the event form a given @type; | ||
5235 | */ | ||
5236 | struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type) | ||
5237 | { | ||
5238 | return tep_find_event(pevent, type); | ||
5239 | } | ||
5240 | |||
5241 | /** | ||
5242 | * tep_data_pid - parse the PID from record | 5269 | * tep_data_pid - parse the PID from record |
5243 | * @pevent: a handle to the pevent | 5270 | * @pevent: a handle to the pevent |
5244 | * @rec: the record to parse | 5271 | * @rec: the record to parse |
@@ -5292,8 +5319,8 @@ const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid) | |||
5292 | return comm; | 5319 | return comm; |
5293 | } | 5320 | } |
5294 | 5321 | ||
5295 | static struct cmdline * | 5322 | static struct tep_cmdline * |
5296 | pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next) | 5323 | pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct tep_cmdline *next) |
5297 | { | 5324 | { |
5298 | struct cmdline_list *cmdlist = (struct cmdline_list *)next; | 5325 | struct cmdline_list *cmdlist = (struct cmdline_list *)next; |
5299 | 5326 | ||
@@ -5305,7 +5332,7 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne | |||
5305 | while (cmdlist && strcmp(cmdlist->comm, comm) != 0) | 5332 | while (cmdlist && strcmp(cmdlist->comm, comm) != 0) |
5306 | cmdlist = cmdlist->next; | 5333 | cmdlist = cmdlist->next; |
5307 | 5334 | ||
5308 | return (struct cmdline *)cmdlist; | 5335 | return (struct tep_cmdline *)cmdlist; |
5309 | } | 5336 | } |
5310 | 5337 | ||
5311 | /** | 5338 | /** |
@@ -5321,10 +5348,10 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne | |||
5321 | * next pid. | 5348 | * next pid. |
5322 | * Also, it does a linear search, so it may be slow. | 5349 | * Also, it does a linear search, so it may be slow. |
5323 | */ | 5350 | */ |
5324 | struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, | 5351 | struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, |
5325 | struct cmdline *next) | 5352 | struct tep_cmdline *next) |
5326 | { | 5353 | { |
5327 | struct cmdline *cmdline; | 5354 | struct tep_cmdline *cmdline; |
5328 | 5355 | ||
5329 | /* | 5356 | /* |
5330 | * If the cmdlines have not been converted yet, then use | 5357 | * If the cmdlines have not been converted yet, then use |
@@ -5363,7 +5390,7 @@ struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *co | |||
5363 | * Returns the pid for a give cmdline. If @cmdline is NULL, then | 5390 | * Returns the pid for a give cmdline. If @cmdline is NULL, then |
5364 | * -1 is returned. | 5391 | * -1 is returned. |
5365 | */ | 5392 | */ |
5366 | int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) | 5393 | int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline) |
5367 | { | 5394 | { |
5368 | struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline; | 5395 | struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline; |
5369 | 5396 | ||
@@ -6593,6 +6620,12 @@ static struct tep_event *search_event(struct tep_handle *pevent, int id, | |||
6593 | * | 6620 | * |
6594 | * If @id is >= 0, then it is used to find the event. | 6621 | * If @id is >= 0, then it is used to find the event. |
6595 | * else @sys_name and @event_name are used. | 6622 | * else @sys_name and @event_name are used. |
6623 | * | ||
6624 | * Returns: | ||
6625 | * TEP_REGISTER_SUCCESS_OVERWRITE if an existing handler is overwritten | ||
6626 | * TEP_REGISTER_SUCCESS if a new handler is registered successfully | ||
6627 | * negative TEP_ERRNO_... in case of an error | ||
6628 | * | ||
6596 | */ | 6629 | */ |
6597 | int tep_register_event_handler(struct tep_handle *pevent, int id, | 6630 | int tep_register_event_handler(struct tep_handle *pevent, int id, |
6598 | const char *sys_name, const char *event_name, | 6631 | const char *sys_name, const char *event_name, |
@@ -6610,7 +6643,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id, | |||
6610 | 6643 | ||
6611 | event->handler = func; | 6644 | event->handler = func; |
6612 | event->context = context; | 6645 | event->context = context; |
6613 | return 0; | 6646 | return TEP_REGISTER_SUCCESS_OVERWRITE; |
6614 | 6647 | ||
6615 | not_found: | 6648 | not_found: |
6616 | /* Save for later use. */ | 6649 | /* Save for later use. */ |
@@ -6640,7 +6673,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id, | |||
6640 | pevent->handlers = handle; | 6673 | pevent->handlers = handle; |
6641 | handle->context = context; | 6674 | handle->context = context; |
6642 | 6675 | ||
6643 | return -1; | 6676 | return TEP_REGISTER_SUCCESS; |
6644 | } | 6677 | } |
6645 | 6678 | ||
6646 | static int handle_matches(struct event_handler *handler, int id, | 6679 | static int handle_matches(struct event_handler *handler, int id, |
@@ -6723,8 +6756,10 @@ struct tep_handle *tep_alloc(void) | |||
6723 | { | 6756 | { |
6724 | struct tep_handle *pevent = calloc(1, sizeof(*pevent)); | 6757 | struct tep_handle *pevent = calloc(1, sizeof(*pevent)); |
6725 | 6758 | ||
6726 | if (pevent) | 6759 | if (pevent) { |
6727 | pevent->ref_count = 1; | 6760 | pevent->ref_count = 1; |
6761 | pevent->host_bigendian = tep_host_bigendian(); | ||
6762 | } | ||
6728 | 6763 | ||
6729 | return pevent; | 6764 | return pevent; |
6730 | } | 6765 | } |
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 35d37087d3c5..aec48f2aea8a 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
@@ -432,6 +432,7 @@ int tep_set_function_resolver(struct tep_handle *pevent, | |||
432 | tep_func_resolver_t *func, void *priv); | 432 | tep_func_resolver_t *func, void *priv); |
433 | void tep_reset_function_resolver(struct tep_handle *pevent); | 433 | void tep_reset_function_resolver(struct tep_handle *pevent); |
434 | int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid); | 434 | int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid); |
435 | int tep_override_comm(struct tep_handle *pevent, const char *comm, int pid); | ||
435 | int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); | 436 | int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock); |
436 | int tep_register_function(struct tep_handle *pevent, char *name, | 437 | int tep_register_function(struct tep_handle *pevent, char *name, |
437 | unsigned long long addr, char *mod); | 438 | unsigned long long addr, char *mod); |
@@ -484,6 +485,11 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt, | |||
484 | struct tep_event *event, const char *name, | 485 | struct tep_event *event, const char *name, |
485 | struct tep_record *record, int err); | 486 | struct tep_record *record, int err); |
486 | 487 | ||
488 | enum tep_reg_handler { | ||
489 | TEP_REGISTER_SUCCESS = 0, | ||
490 | TEP_REGISTER_SUCCESS_OVERWRITE, | ||
491 | }; | ||
492 | |||
487 | int tep_register_event_handler(struct tep_handle *pevent, int id, | 493 | int tep_register_event_handler(struct tep_handle *pevent, int id, |
488 | const char *sys_name, const char *event_name, | 494 | const char *sys_name, const char *event_name, |
489 | tep_event_handler_func func, void *context); | 495 | tep_event_handler_func func, void *context); |
@@ -520,15 +526,14 @@ tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record); | |||
520 | void tep_data_lat_fmt(struct tep_handle *pevent, | 526 | void tep_data_lat_fmt(struct tep_handle *pevent, |
521 | struct trace_seq *s, struct tep_record *record); | 527 | struct trace_seq *s, struct tep_record *record); |
522 | int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); | 528 | int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); |
523 | struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type); | ||
524 | int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); | 529 | int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); |
525 | int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); | 530 | int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); |
526 | int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); | 531 | int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); |
527 | const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid); | 532 | const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid); |
528 | struct cmdline; | 533 | struct tep_cmdline; |
529 | struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, | 534 | struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, |
530 | struct cmdline *next); | 535 | struct tep_cmdline *next); |
531 | int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); | 536 | int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline); |
532 | 537 | ||
533 | void tep_print_field(struct trace_seq *s, void *data, | 538 | void tep_print_field(struct trace_seq *s, void *data, |
534 | struct tep_format_field *field); | 539 | struct tep_format_field *field); |
@@ -553,7 +558,7 @@ int tep_get_long_size(struct tep_handle *pevent); | |||
553 | void tep_set_long_size(struct tep_handle *pevent, int long_size); | 558 | void tep_set_long_size(struct tep_handle *pevent, int long_size); |
554 | int tep_get_page_size(struct tep_handle *pevent); | 559 | int tep_get_page_size(struct tep_handle *pevent); |
555 | void tep_set_page_size(struct tep_handle *pevent, int _page_size); | 560 | void tep_set_page_size(struct tep_handle *pevent, int _page_size); |
556 | int tep_is_file_bigendian(struct tep_handle *pevent); | 561 | int tep_file_bigendian(struct tep_handle *pevent); |
557 | void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian); | 562 | void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian); |
558 | int tep_is_host_bigendian(struct tep_handle *pevent); | 563 | int tep_is_host_bigendian(struct tep_handle *pevent); |
559 | void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian); | 564 | void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian); |
diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 754050eea467..64b9c25a1fd3 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c | |||
@@ -389,7 +389,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, | |||
389 | * We can only use the structure if file is of the same | 389 | * We can only use the structure if file is of the same |
390 | * endianness. | 390 | * endianness. |
391 | */ | 391 | */ |
392 | if (tep_is_file_bigendian(event->pevent) == | 392 | if (tep_file_bigendian(event->pevent) == |
393 | tep_is_host_bigendian(event->pevent)) { | 393 | tep_is_host_bigendian(event->pevent)) { |
394 | 394 | ||
395 | trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s", | 395 | trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s", |
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c index 8ff1d55954d1..8d5ecd2bf877 100644 --- a/tools/lib/traceevent/trace-seq.c +++ b/tools/lib/traceevent/trace-seq.c | |||
@@ -100,7 +100,8 @@ static void expand_buffer(struct trace_seq *s) | |||
100 | * @fmt: printf format string | 100 | * @fmt: printf format string |
101 | * | 101 | * |
102 | * It returns 0 if the trace oversizes the buffer's free | 102 | * It returns 0 if the trace oversizes the buffer's free |
103 | * space, 1 otherwise. | 103 | * space, the number of characters printed, or a negative |
104 | * value in case of an error. | ||
104 | * | 105 | * |
105 | * The tracer may use either sequence operations or its own | 106 | * The tracer may use either sequence operations or its own |
106 | * copy to user routines. To simplify formating of a trace | 107 | * copy to user routines. To simplify formating of a trace |
@@ -129,9 +130,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
129 | goto try_again; | 130 | goto try_again; |
130 | } | 131 | } |
131 | 132 | ||
132 | s->len += ret; | 133 | if (ret > 0) |
134 | s->len += ret; | ||
133 | 135 | ||
134 | return 1; | 136 | return ret; |
135 | } | 137 | } |
136 | 138 | ||
137 | /** | 139 | /** |
@@ -139,6 +141,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
139 | * @s: trace sequence descriptor | 141 | * @s: trace sequence descriptor |
140 | * @fmt: printf format string | 142 | * @fmt: printf format string |
141 | * | 143 | * |
144 | * It returns 0 if the trace oversizes the buffer's free | ||
145 | * space, the number of characters printed, or a negative | ||
146 | * value in case of an error. | ||
147 | * * | ||
142 | * The tracer may use either sequence operations or its own | 148 | * The tracer may use either sequence operations or its own |
143 | * copy to user routines. To simplify formating of a trace | 149 | * copy to user routines. To simplify formating of a trace |
144 | * trace_seq_printf is used to store strings into a special | 150 | * trace_seq_printf is used to store strings into a special |
@@ -163,9 +169,10 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | |||
163 | goto try_again; | 169 | goto try_again; |
164 | } | 170 | } |
165 | 171 | ||
166 | s->len += ret; | 172 | if (ret > 0) |
173 | s->len += ret; | ||
167 | 174 | ||
168 | return len; | 175 | return ret; |
169 | } | 176 | } |
170 | 177 | ||
171 | /** | 178 | /** |