[ltt-dev] [PATCH] Correctly process missing tracefile (fix bug #173)
Francis Giraldeau
francis.giraldeau at usherbrooke.ca
Thu Dec 16 14:51:22 EST 2010
In case of missing file, the JniTrace was crashing with segfault. The file
can be missing when CPU is offline during the trace capture.
---
ltt/jni_interface.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/ltt/jni_interface.c b/ltt/jni_interface.c
index d1bd993..0d46a1f 100644
--- a/ltt/jni_interface.c
+++ b/ltt/jni_interface.c
@@ -285,8 +285,11 @@ void g_datalist_foreach_addTracefilesOfTrace(GQuark name, gpointer data, gpointe
tracefile = &g_array_index(tracefile_array, LttTracefile, i);
newPtr = CONVERT_PTR_TO_JLONG(tracefile);
-
- (*args->env)->CallVoidMethod(args->env, args->jobj, accessFunction, (*args->env)->NewStringUTF(args->env, g_quark_to_string(tracefile->name) ), newPtr );
+
+ /* Only process online CPUs with backing tracefile */
+ if (tracefile->cpu_online) {
+ (*args->env)->CallVoidMethod(args->env, args->jobj, accessFunction, (*args->env)->NewStringUTF(args->env, g_quark_to_string(tracefile->name) ), newPtr );
+ }
}
}
@@ -315,13 +318,15 @@ void g_datalist_foreach_saveTracefilesTime(GQuark name, gpointer data, gpointer
for (i=0; i<tracefile_array->len; i++) {
tracefile = &g_array_index(tracefile_array, LttTracefile, i);
- /* Allocate a new LttTime for each tracefile (so it won't change if the tracefile seek somewhere else) */
- savedData = (struct saveTimeAndTracefile*)malloc( sizeof(struct saveTimeAndTracefile) );
- savedData->time.tv_sec = tracefile->event.event_time.tv_sec;
- savedData->time.tv_nsec = tracefile->event.event_time.tv_nsec;
- savedData->tracefile = tracefile;
- /* Append the saved data to the array */
- g_array_append_val(save_array, savedData);
+ if (tracefile->cpu_online) {
+ /* Allocate a new LttTime for each tracefile (so it won't change if the tracefile seek somewhere else) */
+ savedData = (struct saveTimeAndTracefile*)malloc( sizeof(struct saveTimeAndTracefile) );
+ savedData->time.tv_sec = tracefile->event.event_time.tv_sec;
+ savedData->time.tv_nsec = tracefile->event.event_time.tv_nsec;
+ savedData->tracefile = tracefile;
+ /* Append the saved data to the array */
+ g_array_append_val(save_array, savedData);
+ }
}
}
--
1.7.1
More information about the lttng-dev
mailing list