* MA 02111-1307, USA.
*/
+#include <string.h>
#include <lttv/attribute.h>
#include <ltt/ltt.h>
case LTTV_POINTER: va.v_pointer = &v->dv_pointer; break;
case LTTV_STRING: va.v_string = &v->dv_string; break;
case LTTV_GOBJECT: va.v_gobject = &v->dv_gobject; break;
+ case LTTV_NONE: break;
}
return va;
}
case LTTV_POINTER: v.dv_pointer = NULL; break;
case LTTV_STRING: v.dv_string = NULL; break;
case LTTV_GOBJECT: v.dv_gobject = NULL; break;
+ case LTTV_NONE: break;
}
return v;
}
fprintf(fp, "TYPE=DOUBLE VALUE=%f/>\n", a->value.dv_double);
break;
case LTTV_TIME:
- fprintf(fp, "TYPE=TIME SEC=%u NSEC=%u/>\n", a->value.dv_time.tv_sec,
+ fprintf(fp, "TYPE=TIME SEC=%lu NSEC=%lu/>\n", a->value.dv_time.tv_sec,
a->value.dv_time.tv_nsec);
break;
case LTTV_POINTER:
void
lttv_attribute_read_xml(LttvAttribute *self, FILE *fp)
{
- int i, nb, res;
-
- Attribute *a;
+ int res;
char buffer[256], type[10];
}
else if(strcmp(type, "DOUBLE") == 0) {
value = lttv_attribute_add(self, name, LTTV_DOUBLE);
- res = fscanf(fp, " VALUE=%f/>", value.v_double);
+ res = fscanf(fp, " VALUE=%lf/>", value.v_double);
g_assert(res == 1);
}
else if(strcmp(type, "TIME") == 0) {
value = lttv_attribute_add(self, name, LTTV_TIME);
- res = fscanf(fp, " SEC=%u NSEC=%u/>", &(value.v_time->tv_sec),
+ res = fscanf(fp, " SEC=%lu NSEC=%lu/>", &(value.v_time->tv_sec),
&(value.v_time->tv_nsec));
g_assert(res == 2);
}
NULL, /* class_data */
sizeof (LttvAttribute),
0, /* n_preallocs */
- (GInstanceInitFunc) attribute_instance_init /* instance_init */
+ (GInstanceInitFunc) attribute_instance_init, /* instance_init */
+ NULL /* value handling */
};
static const GInterfaceInfo iattribute_info = {
/* This module inserts a hook in the program main loop. This hook processes
all the events in the main tracefile while testing the speed and
functionality of the state and stats computations. */
-
+#include <string.h>
#include <lttv/lttv.h>
#include <lttv/attribute.h>
#include <ltt/trace.h>
#include <ltt/event.h>
#include <ltt/type.h>
+#include <ltt/facility.h>
+
+#define __UNUSED__ __attribute__((__unused__))
static LttvTraceset *traceset;
} SaveState;
-static void lttv_trace_option(void *hook_data)
+static void lttv_trace_option(void __UNUSED__ *hook_data)
{
LttTrace *trace;
{
double t0, t1;
- int i;
+ unsigned int i;
//lttv_traceset_context_add_hooks(&ts->parent,
//before_traceset, after_traceset, NULL, before_trace, after_trace,
}
-gboolean trace_event(void *hook_data, void *call_data)
+gboolean trace_event(void __UNUSED__ *hook_data, void *call_data)
{
LttvTracefileState *tfs = (LttvTracefileState *)call_data;
ltt_event_position(tfs->parent.e, a_event_position);
ltt_event_position_get(a_event_position, &nb_block, &nb_event, &tf);
- fprintf(stderr,"Event %s %lu.%09lu [%lu %lu]\n",
+ fprintf(stderr,"Event %s %lu.%09lu [%u %u]\n",
ltt_eventtype_name(ltt_event_eventtype(tfs->parent.e)),
tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec,
nb_block, nb_event);
}
-gboolean count_event(void *hook_data, void *call_data)
+gboolean count_event(void *hook_data, void __UNUSED__ *call_data)
{
guint *pcount = (guint *)hook_data;
gboolean save_state_copy_event(void *hook_data, void *call_data)
{
- SaveState *save_state = (SaveState *)hook_data;
+ SaveState __UNUSED__ *save_state = (SaveState *)hook_data;
LttvTracefileState *tfs = (LttvTracefileState *)call_data;
}
-static gboolean process_traceset(void *hook_data, void *call_data)
+static gboolean process_traceset(void __UNUSED__ *hook_data,
+ void __UNUSED__ *call_data)
{
LttvTracesetStats *tscs;
LttFacility *facility;
- LttType *type;
-
LttEventType *event_type;
LttTime time, previous_time;
- long long unsigned cycle_count, start_count, delta_cycle;
+ /* start_count is always initialized in this function _if_ there is always
+ * a block_start before a block_end.
+ */
+ long long unsigned cycle_count, start_count=0, delta_cycle;
long long unsigned start_nsec, end_nsec, delta_nsec, added_nsec, added_nsec2;
/* Seek a few times to each saved position */
if((a_test7 && a_test3) || a_test_all) {
- int i, j;
-
- for(i = 0 ; i < a_seek_number ; i++) {
- for(j = save_state.position - 1 ; j >= 0 ; j--) {
+ g_assert(a_seek_number >= 0);
+ for(i = 0 ; i < (guint)a_seek_number ; i++) {
+ gint reverse_j; /* just to make sure j is unsigned */
+ for(reverse_j = save_state.position - 1 ; reverse_j >= 0 ; reverse_j--) {
+ j = (guint)reverse_j;
lttv_state_add_event_hooks(ts);
t = run_one_test(ts, save_state.write_time[j],
save_state.write_time[j]);
}
g_info("BatchTest end process traceset");
+ return 0;
}
#include <lttv/traceset.h>
#include <ltt/trace.h>
#include <stdio.h>
+#include <string.h>
/* The main program maintains a few central data structures and relies
GError *error = NULL;
LttvModule *module_module = lttv_module_require("module", &error);
- if(error != NULL) g_error(error->message);
+ if(error != NULL) g_error("%s", error->message);
LttvModule *module_option = lttv_module_require("option", &error);
- if(error != NULL) g_error(error->message);
+ if(error != NULL) g_error("%s", error->message);
/* Initialize the module loading */
GError *error = NULL;
lttv_module_require(a_module, &error);
- if(error != NULL) g_error(error->message);
+ if(error != NULL) g_error("%s", error->message);
}
static void init();
-static finish_destroy();
+static void finish_destroy();
static void module_release(LttvModule *m);
LttvModule *m;
GPtrArray *modules;
-
+ GPtrArray **modules_ptr = &modules; /* for strict aliasing */
guint i;
char *key;
+ char **key_ptr = &key; /* for strict aliasing */
for(i = 0 ; i < l->modules->len ; i++) {
m = (LttvModule *)(l->modules->pdata[i]);
g_hash_table_lookup_extended(modules_by_name, m->info.name,
- (gpointer *)&key, (gpointer *)&modules);
+ (gpointer *)key_ptr, (gpointer *)modules_ptr);
g_assert(modules != NULL);
g_ptr_array_remove(modules, m);
if(modules->len == 0) {
static LttvLibrary *library_load(char *name, GError **error)
{
- GModule *gm;
+ GModule *gm = NULL;
int i, nb;
- char *path, *pathname;
+ /* path is always initialized, checked */
+ char *path = NULL, *pathname;
LttvLibrary *l;
static void library_unload(LttvLibrary *l)
{
- guint i, len;
+ guint i;
GModule *gm;
}
-static finish_destroy()
+static void finish_destroy()
{
guint i;
POPT_ARG_NONE, POPT_ARG_STRING, POPT_ARG_INT, POPT_ARG_LONG
};
-static struct poptOption endOption = { NULL, '\0', 0, NULL, 0};
+static struct poptOption endOption = { NULL, '\0', 0, NULL, 0, NULL, NULL };
static void
/* add the options in the reverse order, so last additions are parsed first */
for(i = 0 ; i < list->len ; i++) {
- guint index = list->len-1-i;
+ guint reverse_i = list->len-1-i;
option = (LttvOption *)list->pdata[i];
- popts[index].longName = option->long_name;
- popts[index].shortName = option->char_name;
- popts[index].descrip = option->description;
- popts[index].argDescrip = option->arg_description;
- popts[index].argInfo = poptToLTT[option->t];
- popts[index].arg = option->p;
- popts[index].val = option->val;
+ popts[reverse_i].longName = option->long_name;
+ popts[reverse_i].shortName = option->char_name;
+ popts[reverse_i].descrip = option->description;
+ popts[reverse_i].argDescrip = option->arg_description;
+ popts[reverse_i].argInfo = poptToLTT[option->t];
+ popts[reverse_i].arg = option->p;
+ popts[reverse_i].val = option->val;
}
/* Terminate the array for popt and create the context */
void lttv_option_show_help(void)
{
- LttvOption option;
-
GPtrArray *list = g_ptr_array_new();
- int i;
+ guint i;
g_hash_table_foreach(options, list_options, list);
show_help((LttvOption *)list->pdata[i]);
}
g_ptr_array_free(list, TRUE);
-
-
}
static void init()
static void destroy()
{
- LttvOption option;
-
GPtrArray *list = g_ptr_array_new();
- int i;
+ guint i;
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Destroy option.c");
g_hash_table_foreach(options, list_options, list);
guint process_hash(gconstpointer key)
{
- return ((LttvProcessState *)key)->pid;
+ return ((const LttvProcessState *)key)->pid;
}
gboolean process_equal(gconstpointer a, gconstpointer b)
{
- LttvProcessState *process_a, *process_b;
+ const LttvProcessState *process_a, *process_b;
- process_a = (LttvProcessState *)a;
- process_b = (LttvProcessState *)b;
+ process_a = (const LttvProcessState *)a;
+ process_b = (const LttvProcessState *)b;
if(process_a->pid != process_b->pid) return FALSE;
if(process_a->pid == 0 &&
static void
fini(LttvTracesetState *self)
{
- guint i, j, nb_trace;
+ guint i, nb_trace;
LttvTraceState *tcs;
tcs = (LttvTraceState *)(LTTV_TRACESET_CONTEXT(self)->traces[i]);
lttv_attribute_find(tcs->parent.t_a, LTTV_STATE_TRACE_STATE_USE_COUNT,
LTTV_UINT, &v);
+
+ g_assert(*(v.v_uint) != 0);
(*v.v_uint)--;
- g_assert(*(v.v_uint) >= 0);
if(*(v.v_uint) == 0) {
free_name_tables(tcs);
free_max_time(tcs);
guint depth = process->execution_stack->len;
if(process->state->t != t){
- g_info("Different execution mode type (%d.%09d): ignore it\n",
+ g_info("Different execution mode type (%lu.%09lu): ignore it\n",
tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
g_info("process state has %s when pop_int is %s\n",
g_quark_to_string(process->state->t),
}
if(depth == 1){
- g_info("Trying to pop last state on stack (%d.%09d): ignore it\n",
+ g_info("Trying to pop last state on stack (%lu.%09lu): ignore it\n",
tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
return;
}
self->saved_position = 0;
*(tcs->max_time_state_recomputed_in_seek) = self->parent.timestamp;
g_free(ep);
+
+ return FALSE;
}
{
LttvTraceset *traceset = self->parent.ts;
- guint i, j, k, nb_trace, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile;
LttvTraceState *ts;
{
LttvTraceset *traceset = self->parent.ts;
- guint i, j, k, nb_trace, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile;
LttvTraceState *ts;
{
LttvTraceset *traceset = self->parent.ts;
- guint i, j, nb_trace, nb_saved_state;
+ guint i, nb_trace;
int min_pos, mid_pos, max_pos;
NULL, /* class_data */
sizeof (LttvTracesetState),
0, /* n_preallocs */
- (GInstanceInitFunc) traceset_state_instance_init /* instance_init */
+ (GInstanceInitFunc) traceset_state_instance_init, /* instance_init */
+ NULL /* value handling */
};
type = g_type_register_static (LTTV_TRACESET_CONTEXT_TYPE, "LttvTracesetStateType",
NULL, /* class_data */
sizeof (LttvTraceState),
0, /* n_preallocs */
- (GInstanceInitFunc) trace_state_instance_init /* instance_init */
+ (GInstanceInitFunc) trace_state_instance_init, /* instance_init */
+ NULL /* value handling */
};
type = g_type_register_static (LTTV_TRACE_CONTEXT_TYPE,
NULL, /* class_data */
sizeof (LttvTracefileState),
0, /* n_preallocs */
- (GInstanceInitFunc) tracefile_state_instance_init /* instance_init */
+ (GInstanceInitFunc) tracefile_state_instance_init, /* instance_init */
+ NULL /* value handling */
};
type = g_type_register_static (LTTV_TRACEFILE_CONTEXT_TYPE,
struct _LttvTraceState {
LttvTraceContext parent;
- GHashTable *processes; /* LttvProcessState objects indexed by pid */
+ GHashTable *processes; /* LttvProcessState objects indexed by pid and
+ last_cpu */
guint nb_event, save_interval;
/* Block/char devices, locks, memory pages... */
GQuark *eventtype_names;
LTTV_STATS_BEFORE_HOOKS,
LTTV_STATS_AFTER_HOOKS;
-static void remove_all_processes(GHashTable *processes);
-
static void
-find_event_tree(LttvTracefileStats *tfcs, GQuark process, GQuark cpu,
+find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, GQuark cpu,
GQuark mode, GQuark sub_mode, LttvAttribute **events_tree,
LttvAttribute **event_types_tree);
NULL, /* class_data */
sizeof (LttvTracesetStats),
0, /* n_preallocs */
- (GInstanceInitFunc) traceset_stats_instance_init /* instance_init */
+ (GInstanceInitFunc) traceset_stats_instance_init, /* instance_init */
+ NULL /* Value handling */
};
- type = g_type_register_static (LTTV_TRACESET_STATE_TYPE, "LttvTracesetStatsType",
- &info, 0);
+ type = g_type_register_static (LTTV_TRACESET_STATE_TYPE,
+ "LttvTracesetStatsType",
+ &info, 0);
}
return type;
}
NULL, /* class_data */
sizeof (LttvTraceStats),
0, /* n_preallocs */
- (GInstanceInitFunc) trace_stats_instance_init /* instance_init */
+ (GInstanceInitFunc) trace_stats_instance_init, /* instance_init */
+ NULL /* Value handling */
};
type = g_type_register_static (LTTV_TRACE_STATE_TYPE,
NULL, /* class_data */
sizeof (LttvTracefileStats),
0, /* n_preallocs */
- (GInstanceInitFunc) tracefile_stats_instance_init /* instance_init */
+ (GInstanceInitFunc) tracefile_stats_instance_init, /* instance_init */
+ NULL /* Value handling */
};
type = g_type_register_static (LTTV_TRACEFILE_STATE_TYPE,
static void
-find_event_tree(LttvTracefileStats *tfcs, GQuark process, GQuark cpu,
- GQuark mode, GQuark sub_mode, LttvAttribute **events_tree,
- LttvAttribute **event_types_tree)
+find_event_tree(LttvTracefileStats *tfcs,
+ GQuark pid_time,
+ GQuark cpu,
+ GQuark mode,
+ GQuark sub_mode,
+ LttvAttribute **events_tree,
+ LttvAttribute **event_types_tree)
{
LttvAttribute *a;
LttvTraceStats *tcs = LTTV_TRACE_STATS(tfcs->parent.parent.t_context);
a = lttv_attribute_find_subdir(tcs->stats, LTTV_STATS_PROCESSES);
- a = lttv_attribute_find_subdir(a, tfcs->parent.process->pid_time);
+ a = lttv_attribute_find_subdir(a, pid_time);
a = lttv_attribute_find_subdir(a, LTTV_STATS_CPU);
- a = lttv_attribute_find_subdir(a, tfcs->parent.cpu_name);
+ a = lttv_attribute_find_subdir(a, cpu);
a = lttv_attribute_find_subdir(a, LTTV_STATS_MODE_TYPES);
- a = lttv_attribute_find_subdir(a, tfcs->parent.process->state->t);
+ a = lttv_attribute_find_subdir(a, mode);
a = lttv_attribute_find_subdir(a, LTTV_STATS_SUBMODES);
- a = lttv_attribute_find_subdir(a, tfcs->parent.process->state->n);
+ a = lttv_attribute_find_subdir(a, sub_mode);
*events_tree = a;
a = lttv_attribute_find_subdir(a, LTTV_STATS_EVENT_TYPES);
*event_types_tree = a;
{
LttvExecutionState *es = tfcs->parent.process->state;
- find_event_tree(tfcs, tfcs->parent.process->pid_time, tfcs->parent.cpu_name,
+ find_event_tree(tfcs, tfcs->parent.process->pid_time,
+ tfcs->parent.cpu_name,
es->t, es->n, &(tfcs->current_events_tree),
&(tfcs->current_event_types_tree));
}
// Hook wrapper. call_data is a traceset context.
-gint lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data)
+gboolean lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data)
{
LttvTracesetStats *tss = (LttvTracesetStats*)call_data;
return 0;
}
-lttv_stats_add_event_hooks(LttvTracesetStats *self)
+void lttv_stats_add_event_hooks(LttvTracesetStats *self)
{
LttvTraceset *traceset = self->parent.parent.ts;
}
// Hook wrapper. call_data is a traceset context.
-gint lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data)
+gboolean lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data)
{
LttvTracesetStats *tss = (LttvTracesetStats*)call_data;
return 0;
}
-lttv_stats_remove_event_hooks(LttvTracesetStats *self)
+void lttv_stats_remove_event_hooks(LttvTracesetStats *self)
{
LttvTraceset *traceset = self->parent.parent.ts;
// Hook wrapper. call_data is a trace context.
-gint lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data);
-gboolean lttv_stats_add_event_hooks(LttvTracesetStats *self);
+gboolean lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data);
+void lttv_stats_add_event_hooks(LttvTracesetStats *self);
// Hook wrapper. call_data is a trace context.
-gint lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data);
-gboolean lttv_stats_remove_event_hooks(LttvTracesetStats *self);
+gboolean lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data);
+void lttv_stats_remove_event_hooks(LttvTracesetStats *self);
gboolean lttv_stats_sum_traceset_hook(void *hook_data, void *call_data);
void lttv_stats_sum_traceset(LttvTracesetStats *self);
* MA 02111-1307, USA.
*/
-
+#include <string.h>
#include <lttv/tracecontext.h>
#include <ltt/event.h>
#include <ltt/facility.h>
{
gint comparison;
- LttvTracefileContext *trace_a = (LttvTracefileContext *)a;
+ const LttvTracefileContext *trace_a = (const LttvTracefileContext *)a;
- LttvTracefileContext *trace_b = (LttvTracefileContext *)b;
+ const LttvTracefileContext *trace_b = (const LttvTracefileContext *)b;
if(trace_a == trace_b) return 0;
comparison = ltt_time_compare(trace_a->timestamp, trace_b->timestamp);
else if(trace_a->index > trace_b->index) return 1;
if(trace_a->t_context->index < trace_b->t_context->index) return -1;
else if(trace_a->t_context->index > trace_b->t_context->index) return 1;
+
g_assert(FALSE);
+ return 0; /* This should never happen */
}
struct _LttvTraceContextPosition {
NULL, /* class_data */
sizeof (LttvTracesetContext),
0, /* n_preallocs */
- (GInstanceInitFunc) traceset_context_instance_init /* instance_init */
+ (GInstanceInitFunc) traceset_context_instance_init, /* instance_init */
+ NULL /* Value handling */
};
type = g_type_register_static (G_TYPE_OBJECT, "LttvTracesetContextType",
NULL, /* class_data */
sizeof (LttvTraceContext),
0, /* n_preallocs */
- (GInstanceInitFunc) trace_context_instance_init /* instance_init */
+ (GInstanceInitFunc) trace_context_instance_init, /* instance_init */
+ NULL /* Value handling */
};
type = g_type_register_static (G_TYPE_OBJECT, "LttvTraceContextType",
NULL, /* class_data */
sizeof (LttvTracefileContext),
0, /* n_preallocs */
- (GInstanceInitFunc) tracefile_context_instance_init /* instance_init */
+ (GInstanceInitFunc) tracefile_context_instance_init, /* instance_init */
+ NULL /* Value handling */
};
type = g_type_register_static (G_TYPE_OBJECT, "LttvTracefileContextType",
LttvTraceContext *tc;
- LttvTracefileContext *tfc;
-
nb_trace = lttv_traceset_number(self->ts);
for(i = 0 ; i < nb_trace ; i++) {
tc = self->traces[i];
{
LttvTracefileContext *tfc = self;
- LttEvent *event;
-
GTree *pqueue = self->t_context->ts_context->pqueue;
ltt_tracefile_seek_position(tfc->tf, pos);
g_tree_insert(pqueue, tfc, tfc);
}
-
+ return TRUE;
}
gboolean lttv_process_trace_seek_position(LttvTraceContext *self,
LttvTracefileContext *tfc;
- LttEvent *event;
-
nb_tracefile = ltt_trace_control_tracefile_number(self->t) +
ltt_trace_per_cpu_tracefile_number(self->t);
LttvTraceContext *tc;
- LttvTracefileContext *tfc;
-
nb_trace = lttv_traceset_number(self->ts);
if(nb_trace != pos->nb_trace)
LttEventType *et;
- guint nb, pos, i;
-
- char *name;
+ guint nb, pos;
nb = ltt_trace_facility_find(t, facility, &pos);
if(nb < 1) g_error("No %s facility", facility);
void lttv_traceset_context_position_destroy(LttvTracesetContextPosition *pos)
{
- guint nb_trace, nb_tracefile;
+ guint nb_trace;
guint iter_trace, iter_tracefile;
nb_trace = pos->nb_trace;
for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) {
tfc = tc->tracefiles[iter_tracefile];
event = tfc->e;
- if(
- ret =
- ltt_event_event_position_compare(event,
- pos->t_pos[iter_trace].tf_pos[iter_tracefile])
- != 0)
+ ret = ltt_event_event_position_compare(event,
+ pos->t_pos[iter_trace].tf_pos[iter_tracefile]);
+ if(ret != 0)
return ret;
}
}
g_error("lttv_traceset_context_ctx_pos_compare : nb_tracefile does not match.");
for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) {
- if(ret =
- ltt_event_position_compare(
+ ret = ltt_event_position_compare(
pos1->t_pos[iter_trace].tf_pos[iter_tracefile],
- pos2->t_pos[iter_trace].tf_pos[iter_tracefile])
- != 0)
+ pos2->t_pos[iter_trace].tf_pos[iter_tracefile]);
+ if(ret != 0)
return ret;
}
}
LttTime lttv_traceset_context_position_get_time(
const LttvTracesetContextPosition *pos);
+gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self,
+ const LttEventPosition *pos);
+
#endif // PROCESSTRACE_H
LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig)
{
- int i;
+ guint i;
LttvTraceset *s;
LttvTrace * trace;