History

tracing: Change synthetic event string format to limit printed length

Change the format for printing synthetic field strings to limit the length of the string printed even if it's not correctly terminated. Link: https://lore.kernel.org/r/20201002210036.0200371b@oasis.local.home Link: https://lkml.kernel.org/r/b6bdb34e70d970e8026daa3503db6b8e5cdad524.1601848695.git.zanussi@kernel.org

Steven Rostedt (VMware) committed 6 years ago

Commit 8db4d6b1 parent cbcd9c81 file · +3 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_events_synth.c+3−1
@@ -234,7 +234,7 @@ static const char *synth_field_fmt(char *type) · 233 unmodified lines
234 else if (strcmp(type, "gfp_t") == 0)234 else if (strcmp(type, "gfp_t") == 0)
235 fmt = "%x";235 fmt = "%x";
236 else if (synth_field_is_string(type))236 else if (synth_field_is_string(type))
237 fmt = "%s";237 fmt = "%.*s";
238 238
239 return fmt;239 return fmt;
240}240}
@@ -303,11 +303,13 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter, · 62 unmodified lines
303 str_field = (char *)entry + data_offset;303 str_field = (char *)entry + data_offset;
304 304
305 trace_seq_printf(s, print_fmt, se->fields[i]->name,305 trace_seq_printf(s, print_fmt, se->fields[i]->name,
306 STR_VAR_LEN_MAX,
306 str_field,307 str_field,
307 i == se->n_fields - 1 ? "" : " ");308 i == se->n_fields - 1 ? "" : " ");
308 n_u64++;309 n_u64++;
309 } else {310 } else {
310 trace_seq_printf(s, print_fmt, se->fields[i]->name,311 trace_seq_printf(s, print_fmt, se->fields[i]->name,
312 STR_VAR_LEN_MAX,
311 (char *)&entry->fields[n_u64],313 (char *)&entry->fields[n_u64],
312 i == se->n_fields - 1 ? "" : " ");314 i == se->n_fields - 1 ? "" : " ");
313 n_u64 += STR_VAR_LEN_MAX / sizeof(u64);315 n_u64 += STR_VAR_LEN_MAX / sizeof(u64);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t