#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
+extern gboolean lttv_profile_memory;
+
#endif // LTTV_H
LttvHooks *check;
LttvHooks *before;
LttvHooks *after;
- LttvTracefileContext **control_tracefiles;
- LttvTracefileContext **per_cpu_tracefiles;
+ LttvTracefileContext **tracefiles;
LttvAttribute *a;
LttvAttribute *t_a;
};
LttvTraceContext *t_context;
gboolean control;
- guint index; /* in ts_context->control/per_cpu_tracefiles */
+ guint index; /* in ts_context->tracefiles */
LttTracefile *tf;
LttvHooks *check;
LttvHooks *before;
#include <glib.h>
#include <lttv/processTrace.h>
+#include <stdio.h>
/* The operating system state, kept during the trace analysis,
contains a subset of the real operating system state,
lttv_state_create_process(LttvTracefileState *tfs, LttvProcessState *parent,
guint pid);
+void lttv_state_write(LttvTraceState *self, LttTime t, FILE *fp);
/* The LttvTracesetState, LttvTraceState and LttvTracefileState types
inherit from the corresponding Context objects defined in processTrace. */
#include <lttv/traceset.h>
#include <ltt/trace.h>
#include <stdio.h>
+#include <mcheck.h>
void lttv_option_init(int argc, char **argv);
a_verbose,
a_debug;
+gboolean lttv_profile_memory;
+
static int a_argc;
static char **a_argv;
int main(int argc, char **argv) {
+ int i;
+
+ char
+ *profile_memory_short_option = "-M",
+ *profile_memory_long_option = "--memory";
+
+ gboolean profile_memory = FALSE;
+
LttvAttributeValue value;
-#ifdef MEMDEBUG
- g_mem_set_vtable(glib_mem_profiler_table);
- g_message("Memory summary before main");
- g_mem_profile();
-#endif
- g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
- g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
+ /* Before anything else, check if memory profiling is requested */
+
+ for(i = 1 ; i < argc ; i++) {
+ if(*(argv[i]) != '-') break;
+ if(strcmp(argv[i], profile_memory_short_option) == 0 ||
+ strcmp(argv[i], profile_memory_long_option) == 0) {
+ mcheck(0);
+ g_mem_set_vtable(glib_mem_profiler_table);
+ g_message("Memory summary before main");
+ g_mem_profile();
+ profile_memory = TRUE;
+ break;
+ }
+ }
+
+
+ /* Initialize glib and by default ignore info and debug messages */
g_type_init();
//g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS);
+ g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
+ g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
+
+
+ /* Have an attributes subtree to store hooks to be registered by modules. */
attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
before_main = lttv_hooks_new();
after_main = lttv_hooks_new();
+
+ /* Create a number of hooks lists */
+
g_assert(lttv_iattribute_find_by_path(attributes, "hooks/options/before",
LTTV_POINTER, &value));
*(value.v_pointer) = before_options;
lttv_state_init(argc,argv);
lttv_stats_init(argc,argv);
+
/* Initialize the module loading */
lttv_module_path_add(PACKAGE_PLUGIN_DIR);
+
/* Add some built-in options */
lttv_option_add("module",'m', "load a module", "name of module to load",
lttv_option_add("debug",'d', "print debugging messages", "none",
LTTV_OPT_NONE, NULL, lttv_debug, NULL);
+ lttv_profile_memory = FALSE;
+ lttv_option_add(profile_memory_long_option + 2,
+ profile_memory_short_option[1], "print memory information", "none",
+ LTTV_OPT_NONE, <tv_profile_memory, NULL, NULL);
+
+
+ /* Process the options */
lttv_hooks_call(before_options, NULL);
lttv_option_parse(argc, argv);
lttv_hooks_call(after_options, NULL);
+
+ /* Memory profiling to be useful must be activated as early as possible */
+
+ if(profile_memory != lttv_profile_memory)
+ g_error("Memory profiling options must appear before other options");
+
+
+ /* Do the main work */
+
lttv_hooks_call(before_main, NULL);
lttv_hooks_call(after_main, NULL);
+
+ /* Clean up everything */
+
lttv_stats_destroy();
lttv_state_destroy();
lttv_module_destroy();
lttv_hooks_destroy(after_main);
g_object_unref(attributes);
-#ifdef MEMDEBUG
+ if(profile_memory) {
g_message("Memory summary after main");
g_mem_profile();
-#endif
+ }
}
"Load module %s, as %s is a dependent requiring it", name,
g_module_name(m->module));
module = module_load(name, argc, argv);
- if(module != NULL) g_ptr_array_add(module->dependents, m);
+ if(module != NULL) g_ptr_array_add(m->dependents, module);
return module;
}
"Module usage count decremented to %d", m->ref_count);
return;
}
- /* We really have to unload the module, first unload its dependents */
+
+ /* We really have to unload the module. First destroy it. */
+
+ g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
+ "Call the destroy function and unload the module");
+ if(!g_module_symbol(m->module, "destroy", (gpointer)&destroy_function)) {
+ g_warning("module (%s) has no destroy function", pathname);
+ }
+ else destroy_function();
+
+ /* Then release the modules required by this module */
len = m->dependents->len;
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Unload dependent modules");
if(len != m->dependents->len) g_error("dependents list modified");
- /* Unload the module itself */
-
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
- "Call the destroy function and unload the module");
- if(!g_module_symbol(m->module, "destroy", (gpointer)&destroy_function)) {
- g_warning("module (%s) has no destroy function", pathname);
- }
- else destroy_function();
+ /* Finally remove any trace of this module */
g_hash_table_remove(modules, g_module_name(m->module));
g_ptr_array_free(m->dependents, TRUE);
LttvModule *m;
- GPtrArray *independent_modules = g_ptr_array_new();
+ GPtrArray *independent_modules;
- g_hash_table_foreach(modules, list_independent, independent_modules);
+ while(g_hash_table_size(modules) != 0) {
+ independent_modules = g_ptr_array_new();
+ g_hash_table_foreach(modules, list_independent, independent_modules);
- for(i = 0 ; i < independent_modules->len ; i++) {
- m = (LttvModule *)independent_modules->pdata[i];
- while(m->load_count > 0) lttv_module_unload(m);
+ for(i = 0 ; i < independent_modules->len ; i++) {
+ m = (LttvModule *)independent_modules->pdata[i];
+ lttv_module_unload(m);
+ }
+ g_ptr_array_free(independent_modules, TRUE);
}
-
- g_ptr_array_free(independent_modules, TRUE);
- if(g_hash_table_size(modules) != 0) g_warning("cannot unload all modules");
}
nb_control = ltt_trace_control_tracefile_number(tc->t);
nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
nb_tracefile = nb_control + nb_per_cpu;
- tc->control_tracefiles = g_new(LttvTracefileContext *, nb_control);
- tc->per_cpu_tracefiles = g_new(LttvTracefileContext *, nb_per_cpu);
+ tc->tracefiles = g_new(LttvTracefileContext *, nb_tracefile);
for(j = 0 ; j < nb_tracefile ; j++) {
tfc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_tracefile_context(self);
+ tc->tracefiles[j] = tfc;
+ tfc->index = j;
+
if(j < nb_control) {
- tc->control_tracefiles[j] = tfc;
tfc->control = TRUE;
- tfc->index = j;
tfc->tf = ltt_trace_control_tracefile_get(tc->t, j);
}
else {
- tc->per_cpu_tracefiles[j - nb_control] = tfc;
tfc->control = FALSE;
- tfc->index = j - nb_control;
tfc->tf = ltt_trace_per_cpu_tracefile_get(tc->t, j - nb_control);
}
tfc->t_context = tc;
void fini(LttvTracesetContext *self)
{
- guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile;
LttvTraceContext *tc;
lttv_hooks_destroy(tc->after);
g_object_unref(tc->a);
- nb_control = ltt_trace_control_tracefile_number(tc->t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) tfc = tc->control_tracefiles[j];
- else tfc = tc->per_cpu_tracefiles[j - nb_control];
-
+ tfc = tc->tracefiles[j];
lttv_hooks_destroy(tfc->check);
lttv_hooks_destroy(tfc->before);
lttv_hooks_destroy(tfc->after);
g_object_unref(tfc->a);
g_object_unref(tfc);
}
- g_free(tc->control_tracefiles);
- g_free(tc->per_cpu_tracefiles);
+ g_free(tc->tracefiles);
g_object_unref(tc);
}
g_free(self->traces);
{
LttvTraceset *ts = self->ts;
- guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile;
LttvTraceContext *tc;
lttv_hooks_add_list(tc->check, check_trace);
lttv_hooks_add_list(tc->before, before_trace);
lttv_hooks_add_list(tc->after, after_trace);
- nb_control = ltt_trace_control_tracefile_number(tc->t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfc = tc->control_tracefiles[j];
- }
- else {
- tfc = tc->per_cpu_tracefiles[j-nb_control];
- }
+ tfc = tc->tracefiles[j];
lttv_hooks_add_list(tfc->check, check_tracefile);
lttv_hooks_add_list(tfc->before, before_tracefile);
lttv_hooks_add_list(tfc->after, after_tracefile);
{
LttvTraceset *ts = self->ts;
- guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile;
LttvTraceContext *tc;
lttv_hooks_remove_list(tc->check, check_trace);
lttv_hooks_remove_list(tc->before, before_trace);
lttv_hooks_remove_list(tc->after, after_trace);
- nb_control = ltt_trace_control_tracefile_number(tc->t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfc = tc->control_tracefiles[j];
- }
- else {
- tfc = tc->per_cpu_tracefiles[j-nb_control];
- }
+ tfc = tc->tracefiles[j];
lttv_hooks_remove_list(tfc->check, check_tracefile);
lttv_hooks_remove_list(tfc->before, before_tracefile);
lttv_hooks_remove_list(tfc->after, after_tracefile);
void lttv_process_traceset_begin(LttvTracesetContext *self, LttTime end)
{
- guint i, j, nbi, nbj, nb_control, nb_cpu;
+ guint i, j, nbi, nb_tracefile;
LttvTraceContext *tc;
if(!lttv_hooks_call_check(tc->check, tc)) {
lttv_hooks_call(tc->before, tc);
- nb_control = ltt_trace_control_tracefile_number(tc->t);
- nb_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
- nbj = nb_control + nb_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
- for(j = 0 ; j < nbj ; j++) {
- if(j < nb_control) {
- tfc = tc->control_tracefiles[j];
- }
- else {
- tfc = tc->per_cpu_tracefiles[j - nb_control];
- }
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tfc = tc->tracefiles[j];
if(!lttv_hooks_call_check(tfc->check, tfc)) {
lttv_hooks_call(tfc->before, tfc);
if(tfc->e != NULL) {
if(tfc->timestamp.tv_sec < end.tv_sec ||
- (tfc->timestamp.tv_sec == end.tv_sec && tfc->timestamp.tv_nsec <= end.tv_nsec)){
+ (tfc->timestamp.tv_sec == end.tv_sec &&
+ tfc->timestamp.tv_nsec <= end.tv_nsec)) {
g_tree_insert(self->pqueue, &(tfc->timestamp), tfc);
}
}
void lttv_process_traceset_end(LttvTracesetContext *self)
{
- guint i, j, nbi, nbj, nb_control, nb_cpu;
+ guint i, j, nbi, nb_tracefile;
LttvTraceContext *tc;
obtained at the beginning. CHECK if it poses a problem */
if(!lttv_hooks_call_check(tc->check, tc)) {
- nb_control = ltt_trace_control_tracefile_number(tc->t);
- nb_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
- nbj = nb_control + nb_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
- for(j = 0 ; j < nbj ; j++) {
- if(j < nb_control) {
- tfc = tc->control_tracefiles[j];
- }
- else {
- tfc = tc->per_cpu_tracefiles[j - nb_control];
- }
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tfc = tc->tracefiles[j];
if(!lttv_hooks_call_check(tfc->check, tfc)) {
lttv_hooks_call(tfc->after, tfc);
void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start)
{
- guint i, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, nb_tracefile;
LttvTracefileContext *tfc;
LttEvent *event;
- nb_control = ltt_trace_control_tracefile_number(self->t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(i = 0 ; i < nb_tracefile ; i++) {
- if(i < nb_control) tfc = self->control_tracefiles[i];
- else tfc = self->per_cpu_tracefiles[i - nb_control];
+ nb_tracefile = ltt_trace_control_tracefile_number(self->t) +
+ ltt_trace_per_cpu_tracefile_number(self->t);
+ for(i = 0 ; i < nb_tracefile ; i++) {
+ tfc = self->tracefiles[i];
ltt_tracefile_seek_time(tfc->tf, start);
event = ltt_tracefile_read(tfc->tf);
tfc->e = event;
LTTV_STATE_PROCESS,
LTTV_STATE_EVENT,
LTTV_STATE_SAVED_STATES,
+ LTTV_STATE_SAVED_STATES_TIME,
LTTV_STATE_TIME,
LTTV_STATE_HOOKS;
static void
restore_init_state(LttvTraceState *self)
{
- guint i, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, nb_tracefile;
LttvTracefileState *tfcs;
self->processes = g_hash_table_new(process_hash, process_equal);
self->nb_event = 0;
- nb_control = ltt_trace_control_tracefile_number(self->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(i = 0 ; i < nb_tracefile ; i++) {
- if(i < nb_control) {
- tfcs = LTTV_TRACEFILE_STATE(self->parent.control_tracefiles[i]);
- }
- else {
- tfcs = LTTV_TRACEFILE_STATE(self->parent.per_cpu_tracefiles[i - nb_control]);
- }
+ nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(self->parent.t);
+ for(i = 0 ; i < nb_tracefile ; i++) {
+ tfcs = LTTV_TRACEFILE_STATE(self->parent.tracefiles[i]);
tfcs->parent.timestamp = null_time;
tfcs->saved_position = 0;
tfcs->process = lttv_state_create_process(tfcs, NULL,0);
static void
init(LttvTracesetState *self, LttvTraceset *ts)
{
- guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile;
LttvTraceContext *tc;
LttvTracefileState *tfcs;
+ LttvAttributeValue v;
+
LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_CONTEXT_TYPE))->
init((LttvTracesetContext *)self, ts);
for(i = 0 ; i < nb_trace ; i++) {
tc = self->parent.traces[i];
tcs = (LttvTraceState *)tc;
- tcs->save_interval = 100000;
- tcs->max_time_state_recomputed_in_seek = &time_zero;
+ tcs->save_interval = 50000;
+ lttv_attribute_find(tcs->parent.t_a, LTTV_STATE_SAVED_STATES_TIME,
+ LTTV_POINTER, &v);
+ if(*(v.v_pointer) == NULL) *(v.v_pointer) = g_new(LttTime,1);
+ tcs->max_time_state_recomputed_in_seek = (LttTime *)*(v.v_pointer);
+
fill_name_tables(tcs);
- nb_control = ltt_trace_control_tracefile_number(tc->t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
+
for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfcs = LTTV_TRACEFILE_STATE(tc->control_tracefiles[j]);
- }
- else {
- tfcs = LTTV_TRACEFILE_STATE(tc->per_cpu_tracefiles[j - nb_control]);
- }
+ tfcs = LTTV_TRACEFILE_STATE(tc->tracefiles[j]);
tfcs->cpu_name= g_quark_from_string(ltt_tracefile_name(tfcs->parent.tf));
}
tcs->processes = NULL;
static void
fini(LttvTracesetState *self)
{
- guint i, j, nb_trace, nb_tracefile;
+ guint i, j, nb_trace;
LttvTraceState *tcs;
}
+/* Write the process state of the trace */
+
+static void write_process_state(gpointer key, gpointer value,
+ gpointer user_data)
+{
+ LttvProcessState *process;
+
+ LttvExecutionState *es;
+
+ FILE *fp = (FILE *)user_data;
+
+ guint i;
+
+ process = (LttvProcessState *)value;
+ fprintf(fp,
+" <PROCESS PID=%u PPID=%u CTIME_S=%lu CTIME_NS=%lu NAME=\"%s\" CPU=\"%s\">\n",
+ process->pid, process->ppid, process->creation_time.tv_sec,
+ process->creation_time.tv_nsec, g_quark_to_string(process->name),
+ g_quark_to_string(process->last_cpu));
+
+ for(i = 0 ; i < process->execution_stack->len; i++) {
+ es = &g_array_index(process->execution_stack, LttvExecutionState, i);
+ fprintf(fp, " <ES MODE=\"%s\" SUBMODE=\"%s\" ENTRY_S=%lu ENTRY_NS=%lu",
+ g_quark_to_string(es->t), g_quark_to_string(es->n),
+ es->entry.tv_sec, es->entry.tv_nsec);
+ fprintf(fp, " CHANGE_S=%lu CHANGE_NS=%lu STATUS=\"%s\"/>\n",
+ es->change.tv_sec, es->change.tv_nsec, g_quark_to_string(es->s));
+ }
+ fprintf(fp, " </PROCESS>\n");
+}
+
+
+void lttv_state_write(LttvTraceState *self, LttTime t, FILE *fp)
+{
+ guint i, nb_tracefile, nb_block, nb_event;
+
+ LttvTracefileState *tfcs;
+
+ LttTracefile *tf;
+
+ LttEventPosition *ep;
+
+ ep = ltt_event_position_new();
+
+ fprintf(fp,"<PROCESS_STATE TIME_S=%lu TIME_NS=%lu>\n", t.tv_sec, t.tv_nsec);
+
+ g_hash_table_foreach(self->processes, write_process_state, fp);
+
+ nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(self->parent.t);
+
+ for(i = 0 ; i < nb_tracefile ; i++) {
+ tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
+ fprintf(fp, " <TRACEFILE PID=%u", tfcs->process->pid);
+ if(tfcs->parent.e == NULL) fprintf(fp,"/>\n");
+ else {
+ ltt_event_position(tfcs->parent.e, ep);
+ ltt_event_position_get(ep, &nb_block, &nb_event, &tf);
+ fprintf(fp, " BLOCK=%u EVENT=%u/>\n", nb_block, nb_event);
+ }
+ }
+ g_free(ep);
+ fprintf(fp,"</PROCESS_STATE>");
+}
+
+
+/* Copy each process from an existing hash table to a new one */
+
static void copy_process_state(gpointer key, gpointer value,gpointer user_data)
{
LttvProcessState *process, *new_process;
static void state_save(LttvTraceState *self, LttvAttribute *container)
{
- guint i, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, nb_tracefile;
LttvTracefileState *tfcs;
LTTV_POINTER);
*(value.v_pointer) = lttv_state_copy_process_table(self->processes);
- nb_control = ltt_trace_control_tracefile_number(self->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(self->parent.t);
for(i = 0 ; i < nb_tracefile ; i++) {
- if(i < nb_control)
- tfcs = (LttvTracefileState *)self->parent.control_tracefiles[i];
- else tfcs = (LttvTracefileState *)
- self->parent.per_cpu_tracefiles[i - nb_control];
-
+ tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
tracefile_tree = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
value = lttv_attribute_add(tracefiles_tree, i,
LTTV_GOBJECT);
static void state_restore(LttvTraceState *self, LttvAttribute *container)
{
- guint i, nb_control, nb_per_cpu, nb_tracefile, pid;
+ guint i, nb_tracefile, pid;
LttvTracefileState *tfcs;
lttv_state_free_process_table(self->processes);
self->processes = lttv_state_copy_process_table(*(value.v_pointer));
- nb_control = ltt_trace_control_tracefile_number(self->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(self->parent.t);
for(i = 0 ; i < nb_tracefile ; i++) {
- if(i < nb_control) tfcs = (LttvTracefileState *)
- self->parent.control_tracefiles[i];
- else tfcs = (LttvTracefileState *)
- self->parent.per_cpu_tracefiles[i - nb_control];
-
+ tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
g_assert(type == LTTV_GOBJECT);
tracefile_tree = *((LttvAttribute **)(value.v_gobject));
static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
{
- guint i, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, nb_tracefile;
LttvTracefileState *tfcs;
*(value.v_pointer) = NULL;
lttv_attribute_remove_by_name(container, LTTV_STATE_PROCESSES);
- nb_control = ltt_trace_control_tracefile_number(self->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(self->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(self->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(self->parent.t);
for(i = 0 ; i < nb_tracefile ; i++) {
- if(i < nb_control) tfcs = (LttvTracefileState *)
- self->parent.control_tracefiles[i];
- else tfcs = (LttvTracefileState *)
- self->parent.per_cpu_tracefiles[i - nb_control];
-
+ tfcs = (LttvTracefileState *)self->parent.tracefiles[i];
type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
g_assert(type == LTTV_GOBJECT);
tracefile_tree = *((LttvAttribute **)(value.v_gobject));
{
LttvTraceset *traceset = self->parent.ts;
- guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, k, nb_trace, nb_tracefile;
LttvTraceState *ts;
/* Add these hooks to each before_event_by_id hooks list */
- nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(ts->parent.t);
+
for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
- }
- else {
- tfs = LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
- }
+ tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
for(k = 0 ; k < hooks->len ; k++) {
hook = g_array_index(hooks, LttvTraceHook, k);
{
LttvTraceset *traceset = self->parent.ts;
- guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, k, nb_trace, nb_tracefile;
LttvTraceState *ts;
/* Add these hooks to each before_event_by_id hooks list */
- nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(ts->parent.t);
+
for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
- }
- else {
- tfs = LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
- }
+ tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
for(k = 0 ; k < hooks->len ; k++) {
hook = g_array_index(hooks, LttvTraceHook, k);
static gboolean block_end(void *hook_data, void *call_data)
{
- LttvTracefileState *tfcs = (LttvTracefileState *)call_data;
+ LttvTracefileState *self = (LttvTracefileState *)call_data;
- LttvTraceState *tcs = (LttvTraceState *)(tfcs->parent.t_context);
+ LttvTracefileState *tfcs;
- LttEventPosition *ep = ltt_event_position_new();
+ LttvTraceState *tcs = (LttvTraceState *)(self->parent.t_context);
+
+ LttEventPosition *ep;
- guint nb_block, nb_event;
+ guint i, nb_block, nb_event, nb_tracefile;
LttTracefile *tf;
LttvAttributeValue value;
- ltt_event_position(tfcs->parent.e, ep);
+ ep = ltt_event_position_new();
+ nb_tracefile = ltt_trace_control_tracefile_number(tcs->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(tcs->parent.t);
+
+ /* Count the number of events added since the last block end in any
+ tracefile. */
+
+ for(i = 0 ; i < nb_tracefile ; i++) {
+ tfcs = (LttvTracefileState *)tcs->parent.tracefiles[i];
+ ltt_event_position(tfcs->parent.e, ep);
+ ltt_event_position_get(ep, &nb_block, &nb_event, &tf);
+ tcs->nb_event += nb_event - tfcs->saved_position;
+ tfcs->saved_position = nb_event;
+ }
+ g_free(ep);
- ltt_event_position_get(ep, &nb_block, &nb_event, &tf);
- tcs->nb_event += nb_event - tfcs->saved_position;
- tfcs->saved_position = 0;
if(tcs->nb_event >= tcs->save_interval) {
saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a,
LTTV_STATE_SAVED_STATES);
lttv_attribute_get_number(saved_states_tree), LTTV_GOBJECT);
*(value.v_gobject) = (GObject *)saved_state_tree;
value = lttv_attribute_add(saved_state_tree, LTTV_STATE_TIME, LTTV_TIME);
- *(value.v_time) = tfcs->parent.timestamp;
+ *(value.v_time) = self->parent.timestamp;
lttv_state_save(tcs, saved_state_tree);
tcs->nb_event = 0;
}
+ *(tcs->max_time_state_recomputed_in_seek) = self->parent.timestamp;
return FALSE;
}
{
LttvTraceset *traceset = self->parent.ts;
- guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, k, nb_trace, nb_tracefile;
LttvTraceState *ts;
lttv_trace_find_hook(ts->parent.t, "core","block_end",NULL,
NULL, NULL, block_end, &hook);
- nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
- }
- else {
- tfs =LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
- }
+ nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(ts->parent.t);
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
lttv_hooks_add(lttv_hooks_by_id_find(tfs->parent.after_event_by_id,
hook.id), hook.h, NULL);
}
{
LttvTraceset *traceset = self->parent.ts;
- guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, k, nb_trace, nb_tracefile;
LttvTraceState *ts;
lttv_trace_find_hook(ts->parent.t, "core","block_end",NULL,
NULL, NULL, block_end, &hook);
- nb_control = ltt_trace_control_tracefile_number(ts->parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfs = LTTV_TRACEFILE_STATE(ts->parent.control_tracefiles[j]);
- }
- else {
- tfs =LTTV_TRACEFILE_STATE(ts->parent.per_cpu_tracefiles[j-nb_control]);
- }
+ nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.t) +
+ ltt_trace_per_cpu_tracefile_number(ts->parent.t);
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tfs = LTTV_TRACEFILE_STATE(ts->parent.tracefiles[j]);
lttv_hooks_remove_data(lttv_hooks_by_id_find(
tfs->parent.after_event_by_id, hook.id), hook.h, NULL);
}
(GClassInitFunc) traceset_state_class_init, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof (LttvTracesetContext),
+ sizeof (LttvTracesetState),
0, /* n_preallocs */
(GInstanceInitFunc) traceset_state_instance_init /* instance_init */
};
LTTV_STATE_PROCESS = g_quark_from_string("process");
LTTV_STATE_EVENT = g_quark_from_string("event");
LTTV_STATE_SAVED_STATES = g_quark_from_string("saved states");
+ LTTV_STATE_SAVED_STATES_TIME = g_quark_from_string("saved states time");
LTTV_STATE_TIME = g_quark_from_string("time");
LTTV_STATE_HOOKS = g_quark_from_string("saved state hooks");
}
static void
init(LttvTracesetStats *self, LttvTraceset *ts)
{
- guint i, j, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile;
LttvTraceContext *tc;
tcs = (LttvTraceStats *)tc = (LTTV_TRACESET_CONTEXT(self)->traces[i]);
tcs->stats = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
- nb_control = ltt_trace_control_tracefile_number(tc->t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfcs = LTTV_TRACEFILE_STATS(tc->control_tracefiles[j]);
- }
- else {
- tfcs = LTTV_TRACEFILE_STATS(tc->per_cpu_tracefiles[j - nb_control]);
- }
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tfcs = LTTV_TRACEFILE_STATS(tc->tracefiles[j]);
tfcs->stats = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
find_event_tree(tfcs, LTTV_STATS_PROCESS_UNKNOWN,
tfcs->parent.cpu_name, LTTV_STATE_MODE_UNKNOWN,
tcs = (LttvTraceStats *)tc = (LTTV_TRACESET_CONTEXT(self)->traces[i]);
lttv_attribute_recursive_free(tcs->stats);
- nb_tracefile = ltt_trace_control_tracefile_number(tc->t);
- for(j = 0 ; j < nb_tracefile ; j++) {
- tfcs = (LttvTracefileStats *)tfc = tc->control_tracefiles[j];
- lttv_attribute_recursive_free(tfcs->stats);
- tfcs->current_events_tree = NULL;
- tfcs->current_event_types_tree = NULL;
- }
+ nb_tracefile = ltt_trace_control_tracefile_number(tc->t) +
+ ltt_trace_per_cpu_tracefile_number(tc->t);
- nb_tracefile = ltt_trace_per_cpu_tracefile_number(tc->t);
for(j = 0 ; j < nb_tracefile ; j++) {
- tfcs = (LttvTracefileStats *)tfc = tc->per_cpu_tracefiles[j];
+ tfcs = (LttvTracefileStats *)tfc = tc->tracefiles[j];
lttv_attribute_recursive_free(tfcs->stats);
tfcs->current_events_tree = NULL;
tfcs->current_event_types_tree = NULL;
(GClassInitFunc) traceset_stats_class_init, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof (LttvTracesetContext),
+ sizeof (LttvTracesetStats),
0, /* n_preallocs */
(GInstanceInitFunc) traceset_stats_instance_init /* instance_init */
};
{
LttvTraceset *traceset = self->parent.parent.ts;
- guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, k, nb_trace, nb_tracefile;
LttFacility *f;
/* Add these hooks to each before_event_by_id hooks list */
- nb_control = ltt_trace_control_tracefile_number(ts->parent.parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.control_tracefiles[j]);
- }
- else {
- tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.per_cpu_tracefiles[
- j-nb_control]);
- }
+ nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.parent.t) +
+ ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.tracefiles[j]);
lttv_hooks_add(tfs->parent.parent.after_event, every_event, NULL);
for(k = 0 ; k < before_hooks->len ; k++) {
{
LttvTraceset *traceset = self->parent.parent.ts;
- guint i, j, k, nb_trace, nb_control, nb_per_cpu, nb_tracefile;
+ guint i, j, k, nb_trace, nb_tracefile;
LttvTraceStats *ts;
/* Add these hooks to each before_event_by_id hooks list */
- nb_control = ltt_trace_control_tracefile_number(ts->parent.parent.t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control) {
- tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.control_tracefiles[j]);
- }
- else {
- tfs =LTTV_TRACEFILE_STATS(ts->parent.parent.per_cpu_tracefiles[
- j-nb_control]);
- }
+ nb_tracefile = ltt_trace_control_tracefile_number(ts->parent.parent.t) +
+ ltt_trace_per_cpu_tracefile_number(ts->parent.parent.t);
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ tfs = LTTV_TRACEFILE_STATS(ts->parent.parent.tracefiles[j]);
lttv_hooks_remove_data(tfs->parent.parent.after_event, every_event,
NULL);
LttvTracesetContext * tsc)
{
gint i, j, k, m,n, nbi, id;
- gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
+ gint nb_tracefile, nb_facility, nb_event;
LttTrace *trace;
LttvTraceContext *tc;
LttvTracefileContext *tfc;
trace = tc->t;
//if there are hooks for trace, add them here
- nb_control = ltt_trace_control_tracefile_number(trace);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+ ltt_trace_per_cpu_tracefile_number(trace);
for(j = 0 ; j < nb_tracefile ; j++) {
tf_s = lttv_trace_selector_tracefile_get(t_s,j);
selected = lttv_tracefile_selector_get_selected(tf_s);
if(!selected) continue;
-
- if(j < nb_control)
- tfc = tc->control_tracefiles[j];
- else
- tfc = tc->per_cpu_tracefiles[j - nb_control];
+ tfc = tc->tracefiles[j];
//if there are hooks for tracefile, add them here
// lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
LttvTracesetContext * tsc)
{
gint i, j, k, m, nbi, n, id;
- gint nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
+ gint nb_tracefile, nb_facility, nb_event;
LttTrace *trace;
LttvTraceContext *tc;
LttvTracefileContext *tfc;
trace = tc->t;
//if there are hooks for trace, remove them here
- nb_control = ltt_trace_control_tracefile_number(trace);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+ ltt_trace_per_cpu_tracefile_number(trace);
for(j = 0 ; j < nb_tracefile ; j++) {
tf_s = lttv_trace_selector_tracefile_get(t_s,j);
selected = lttv_tracefile_selector_get_selected(tf_s);
if(!selected) continue;
-
- if(j < nb_control)
- tfc = tc->control_tracefiles[j];
- else
- tfc = tc->per_cpu_tracefiles[j - nb_control];
+ tfc = tc->tracefiles[j];
//if there are hooks for tracefile, remove them here
// lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
#include "../icons/hGuiStatisticInsert.xpm"
-#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
-#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
-
-#define PATH_LENGTH 256
+#define PATH_LENGTH 256 /* CHECK */
static LttvModule *statistic_main_win_module;
static GPtrArray * statistic_traceset;
void statistic_add_context_hooks(StatisticViewerData * statistic_viewer_data,
LttvTracesetContext * tsc)
{
- gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+ gint i, j, nbi, nb_tracefile;
LttTrace *trace;
LttvTraceContext *tc;
LttvTracefileContext *tfc;
trace = tc->t;
//if there are hooks for trace, add them here
- nb_control = ltt_trace_control_tracefile_number(trace);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+ ltt_trace_per_cpu_tracefile_number(trace);
for(j = 0 ; j < nb_tracefile ; j++) {
tf_s = lttv_trace_selector_tracefile_get(t_s,j);
selected = lttv_tracefile_selector_get_selected(tf_s);
if(!selected) continue;
-
- if(j < nb_control)
- tfc = tc->control_tracefiles[j];
- else
- tfc = tc->per_cpu_tracefiles[j - nb_control];
+ tfc = tc->tracefiles[j];
//if there are hooks for tracefile, add them here
// lttv_tracefile_context_add_hooks(tfc, NULL,NULL,NULL,NULL,
void statistic_remove_context_hooks(StatisticViewerData * statistic_viewer_data,
LttvTracesetContext * tsc)
{
- gint i, j, nbi, nb_tracefile, nb_control, nb_per_cpu;
+ gint i, j, nbi, nb_tracefile;
LttTrace *trace;
LttvTraceContext *tc;
LttvTracefileContext *tfc;
trace = tc->t;
//if there are hooks for trace, remove them here
- nb_control = ltt_trace_control_tracefile_number(trace);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(trace);
- nb_tracefile = nb_control + nb_per_cpu;
+ nb_tracefile = ltt_trace_control_tracefile_number(trace) +
+ ltt_trace_per_cpu_tracefile_number(trace);
for(j = 0 ; j < nb_tracefile ; j++) {
tf_s = lttv_trace_selector_tracefile_get(t_s,j);
selected = lttv_tracefile_selector_get_selected(tf_s);
if(!selected) continue;
-
- if(j < nb_control)
- tfc = tc->control_tracefiles[j];
- else
- tfc = tc->per_cpu_tracefiles[j - nb_control];
+ tfc = tc->tracefiles[j];
//if there are hooks for tracefile, remove them here
// lttv_tracefile_context_remove_hooks(tfc, NULL,NULL,NULL,NULL,
libdir = ${lttvplugindir}
-lib_LTLIBRARIES = libtextDump.la libbatchAnalysis.la
+lib_LTLIBRARIES = libtextDump.la libbatchAnalysis.la libbatchtest.la
libtextDump_la_LDFLAGS = -module
libtextDump_la_SOURCES = textDump.c
libbatchAnalysis_la_LDFLAGS = -module
libbatchAnalysis_la_SOURCES = batchAnalysis.c
+libbatchtest_la_LDFLAGS = -module
+libbatchtest_la_SOURCES = batchtest.c