diff options
-rw-r--r-- | kernel-shark.h | 2 | ||||
-rw-r--r-- | trace-capture.c | 30 |
2 files changed, 29 insertions, 3 deletions
diff --git a/kernel-shark.h b/kernel-shark.h index c3f7b13..981eb8b 100644 --- a/kernel-shark.h +++ b/kernel-shark.h | |||
@@ -60,6 +60,8 @@ struct shark_info { | |||
60 | gchar *cap_command; | 60 | gchar *cap_command; |
61 | gchar *cap_file; | 61 | gchar *cap_file; |
62 | gchar *cap_settings_name; | 62 | gchar *cap_settings_name; |
63 | int cap_max_buf_size; | ||
64 | gchar *cap_buffer_output; | ||
63 | }; | 65 | }; |
64 | 66 | ||
65 | #define offset_of(type, field) (long)(&((type *)0)->field) | 67 | #define offset_of(type, field) (long)(&((type *)0)->field) |
diff --git a/trace-capture.c b/trace-capture.c index 01436a9..f866b3e 100644 --- a/trace-capture.c +++ b/trace-capture.c | |||
@@ -71,7 +71,6 @@ struct trace_capture { | |||
71 | gboolean kill_thread; | 71 | gboolean kill_thread; |
72 | gboolean capture_done; | 72 | gboolean capture_done; |
73 | gboolean load_file; | 73 | gboolean load_file; |
74 | gint max_buffer_size; | ||
75 | int command_input_fd; | 74 | int command_input_fd; |
76 | int command_output_fd; | 75 | int command_output_fd; |
77 | int command_pid; | 76 | int command_pid; |
@@ -233,6 +232,9 @@ void kernel_shark_clear_capture(struct shark_info *info) | |||
233 | 232 | ||
234 | free(info->cap_file); | 233 | free(info->cap_file); |
235 | info->cap_file = NULL; | 234 | info->cap_file = NULL; |
235 | |||
236 | g_free(info->cap_buffer_output); | ||
237 | info->cap_buffer_output = NULL; | ||
236 | } | 238 | } |
237 | 239 | ||
238 | static gboolean end_capture(struct trace_capture *cap) | 240 | static gboolean end_capture(struct trace_capture *cap) |
@@ -1267,11 +1269,14 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
1267 | GtkWidget *textview; | 1269 | GtkWidget *textview; |
1268 | GtkWidget *hbox; | 1270 | GtkWidget *hbox; |
1269 | GtkTextBuffer *buffer; | 1271 | GtkTextBuffer *buffer; |
1272 | GtkTextIter start_iter; | ||
1273 | GtkTextIter end_iter; | ||
1270 | char **plugins; | 1274 | char **plugins; |
1271 | int nr_plugins; | 1275 | int nr_plugins; |
1272 | struct trace_capture cap; | 1276 | struct trace_capture cap; |
1273 | const gchar *file; | 1277 | const gchar *file; |
1274 | const char *command; | 1278 | const char *command; |
1279 | const char *val; | ||
1275 | GString *str; | 1280 | GString *str; |
1276 | gint result; | 1281 | gint result; |
1277 | 1282 | ||
@@ -1294,7 +1299,6 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
1294 | trace_dialog_register_alt_warning(NULL); | 1299 | trace_dialog_register_alt_warning(NULL); |
1295 | 1300 | ||
1296 | cap.pevent = pevent; | 1301 | cap.pevent = pevent; |
1297 | cap.max_buffer_size = DEFAULT_MAX_BUF_SIZE; | ||
1298 | 1302 | ||
1299 | if (!pevent && !nr_plugins) { | 1303 | if (!pevent && !nr_plugins) { |
1300 | warning("No events or plugins found"); | 1304 | warning("No events or plugins found"); |
@@ -1506,6 +1510,10 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
1506 | cap.output_text = textview; | 1510 | cap.output_text = textview; |
1507 | cap.output_buffer = buffer; | 1511 | cap.output_buffer = buffer; |
1508 | 1512 | ||
1513 | /* set the buffer from its previous setting */ | ||
1514 | if (info->cap_buffer_output) | ||
1515 | gtk_text_buffer_set_text(buffer, info->cap_buffer_output, | ||
1516 | strlen(info->cap_buffer_output)); | ||
1509 | 1517 | ||
1510 | hbox = gtk_hbox_new(FALSE, 0); | 1518 | hbox = gtk_hbox_new(FALSE, 0); |
1511 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 1519 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
@@ -1521,8 +1529,11 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
1521 | 1529 | ||
1522 | cap.max_num_entry = entry; | 1530 | cap.max_num_entry = entry; |
1523 | 1531 | ||
1532 | if (!info->cap_max_buf_size) | ||
1533 | info->cap_max_buf_size = DEFAULT_MAX_BUF_SIZE; | ||
1534 | |||
1524 | str = g_string_new(""); | 1535 | str = g_string_new(""); |
1525 | g_string_append_printf(str, "%d", cap.max_buffer_size); | 1536 | g_string_append_printf(str, "%d", info->cap_max_buf_size); |
1526 | gtk_entry_set_text(GTK_ENTRY(entry), str->str); | 1537 | gtk_entry_set_text(GTK_ENTRY(entry), str->str); |
1527 | g_string_free(str, TRUE); | 1538 | g_string_free(str, TRUE); |
1528 | 1539 | ||
@@ -1547,6 +1558,19 @@ static void tracing_dialog(struct shark_info *info, const char *tracing) | |||
1547 | /* Make sure no capture is running */ | 1558 | /* Make sure no capture is running */ |
1548 | end_capture(&cap); | 1559 | end_capture(&cap); |
1549 | 1560 | ||
1561 | /* Get the max buffer size */ | ||
1562 | val = gtk_entry_get_text(GTK_ENTRY(entry)); | ||
1563 | info->cap_max_buf_size = atoi(val); | ||
1564 | |||
1565 | gtk_text_buffer_get_start_iter(cap.output_buffer, &start_iter); | ||
1566 | gtk_text_buffer_get_end_iter(cap.output_buffer, &end_iter); | ||
1567 | |||
1568 | g_free(info->cap_buffer_output); | ||
1569 | info->cap_buffer_output = gtk_text_buffer_get_text(cap.output_buffer, | ||
1570 | &start_iter, | ||
1571 | &end_iter, | ||
1572 | FALSE); | ||
1573 | |||
1550 | /* save the plugin and file to reuse if we come back */ | 1574 | /* save the plugin and file to reuse if we come back */ |
1551 | update_plugin(&cap); | 1575 | update_plugin(&cap); |
1552 | 1576 | ||