#include <ltt/marker-desc.h>
#include <stdio.h>
#include <string.h>
+#include <ltt/ltt-private.h>
/* Comment :
* Mathieu Desnoyers
LTT_FACILITY_LIST,
LTT_FACILITY_FS,
LTT_FACILITY_USER_GENERIC,
- LTT_FACILITY_BLOCK;
+ LTT_FACILITY_BLOCK,
+ LTT_FACILITY_STATEDUMP;
/* Events Quarks */
LTT_EVENT_THREAD_BRAND,
LTT_EVENT_REQUEST_ISSUE,
LTT_EVENT_REQUEST_COMPLETE,
- LTT_EVENT_LIST_INTERRUPT;
+ LTT_EVENT_LIST_INTERRUPT,
+ LTT_EVENT_SYS_CALL_TABLE,
+ LTT_EVENT_SOFTIRQ_VEC;
/* Fields Quarks */
LTT_FIELD_MINOR,
LTT_FIELD_MAJOR,
LTT_FIELD_OPERATION,
- LTT_FIELD_ACTION;
+ LTT_FIELD_ACTION,
+ LTT_FIELD_ID,
+ LTT_FIELD_ADDRESS,
+ LTT_FIELD_SYMBOL;
LttvExecutionMode
LTTV_STATE_MODE_UNKNOWN,
process = (LttvProcessState *)value;
fprintf(fp,
-" <PROCESS CORE=%p PID=%u TGID=%u PPID=%u TYPE=\"%s\" CTIME_S=%lu CTIME_NS=%lu ITIME_S=%lu ITIME_NS=%lu NAME=\"%s\" BRAND=\"%s\" CPU=\"%u\">\n",
+" <PROCESS CORE=%p PID=%u TGID=%u PPID=%u TYPE=\"%s\" CTIME_S=%lu CTIME_NS=%lu ITIME_S=%lu ITIME_NS=%lu NAME=\"%s\" BRAND=\"%s\" CPU=\"%u\" FREE_EVENTS=\"%u\">\n",
process, process->pid, process->tgid, process->ppid,
g_quark_to_string(process->type),
process->creation_time.tv_sec,
process->insertion_time.tv_nsec,
g_quark_to_string(process->name),
g_quark_to_string(process->brand),
- process->cpu);
+ process->cpu, process->free_events);
for(i = 0 ; i < process->execution_stack->len; i++) {
es = &g_array_index(process->execution_stack, LttvExecutionState, i);
//fputc('\0', fp);
fwrite(&process->brand, sizeof(process->brand), 1, fp);
fwrite(&process->pid, sizeof(process->pid), 1, fp);
+ fwrite(&process->free_events, sizeof(process->free_events), 1, fp);
fwrite(&process->tgid, sizeof(process->tgid), 1, fp);
fwrite(&process->ppid, sizeof(process->ppid), 1, fp);
fwrite(&process->cpu, sizeof(process->cpu), 1, fp);
fread(&tmp.name, sizeof(tmp.name), 1, fp);
fread(&tmp.brand, sizeof(tmp.brand), 1, fp);
fread(&tmp.pid, sizeof(tmp.pid), 1, fp);
+ fread(&tmp.free_events, sizeof(tmp.free_events), 1, fp);
fread(&tmp.tgid, sizeof(tmp.tgid), 1, fp);
fread(&tmp.ppid, sizeof(tmp.ppid), 1, fp);
fread(&tmp.cpu, sizeof(tmp.cpu), 1, fp);
(gchar*)g_ptr_array_index(quarktable, tmp.brand));
process->name =
g_quark_from_string((gchar*)g_ptr_array_index(quarktable, tmp.name));
-
+ process->free_events = tmp.free_events;
do {
if(feof(fp) || ferror(fp)) goto end_loop;
process->creation_time.tv_nsec);
process->pid_time = g_quark_from_string(buffer);
process->cpu = cpu;
+ process->free_events = 0;
//process->last_cpu = tfs->cpu_name;
//process->last_cpu_index = ltt_tracefile_num(((LttvTracefileContext*)tfs)->tf);
process->execution_stack = g_array_sized_new(FALSE, FALSE,
* has the flag SA_NOCLDWAIT. It can also happen when the child is part
* of a killed thread group, but isn't the leader.
*/
-static void exit_process(LttvTracefileState *tfs, LttvProcessState *process)
+static int exit_process(LttvTracefileState *tfs, LttvProcessState *process)
{
LttvTraceState *ts = LTTV_TRACE_STATE(tfs->parent.t_context);
LttvProcessState key;
+ /* Wait for both schedule with exit dead and process free to happen.
+ * They can happen in any order. */
+ if (++(process->free_events) < 2)
+ return 0;
+
key.pid = process->pid;
key.cpu = process->cpu;
g_hash_table_remove(ts->processes, &key);
g_array_free(process->execution_stack, TRUE);
g_array_free(process->user_stack, TRUE);
g_free(process);
+ return 1;
}
return FALSE;
}
+static gboolean dump_syscall(void *hook_data, void *call_data)
+{
+ LttvTracefileState *s = (LttvTracefileState *)call_data;
+ LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
+ LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
+ LttvTraceHook *th = (LttvTraceHook *)hook_data;
+ guint id;
+ guint64 address;
+ char *symbol;
+
+ id = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0));
+ address = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
+ symbol = ltt_event_get_string(e, lttv_trace_get_hook_field(th, 2));
+
+ if (ts->nb_syscalls < id) {
+ GQuark *old_names = ts->syscall_names;
+ guint new_nb_syscalls = max(id + 1, ts->nb_syscalls * 2);
+ guint i;
+ GString *fe_name = g_string_new("");
+ ts->syscall_names = g_new(GQuark, new_nb_syscalls);
+ memcpy(ts->syscall_names, old_names,
+ ts->nb_syscalls * sizeof(GQuark));
+ for(i = ts->nb_syscalls ; i < new_nb_syscalls ; i++) {
+ g_string_printf(fe_name, "syscall %d", i);
+ ts->syscall_names[i] = g_quark_from_string(fe_name->str);
+ }
+ g_string_free(fe_name, TRUE);
+ ts->nb_syscalls = new_nb_syscalls;
+ }
+ ts->syscall_names[id] = g_quark_from_string(symbol);
+
+ return FALSE;
+}
+
+static gboolean dump_softirq(void *hook_data, void *call_data)
+{
+ LttvTracefileState *s = (LttvTracefileState *)call_data;
+ LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
+ LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
+ LttvTraceHook *th = (LttvTraceHook *)hook_data;
+ guint id;
+ guint64 address;
+ char *symbol;
+
+ id = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0));
+ address = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
+ symbol = ltt_event_get_string(e, lttv_trace_get_hook_field(th, 2));
+ ts->soft_irq_names[id] = g_quark_from_string(symbol);
+
+ return FALSE;
+}
+
static gboolean schedchange(void *hook_data, void *call_data)
{
LttvTracefileState *s = (LttvTracefileState *)call_data;
process->state->change = s->parent.timestamp;
}
- if(state_out == 32 || state_out == 64)
- exit_process(s, process); /* EXIT_DEAD || TASK_DEAD */
- /* see sched.h for states */
+ if(state_out == 32 || state_out == 64) { /* EXIT_DEAD || TASK_DEAD */
+ /* see sched.h for states */
+ if (!exit_process(s, process)) {
+ process->state->s = LTTV_STATE_DEAD;
+ process->state->change = s->parent.timestamp;
+ }
+ }
}
}
process = ts->running_process[cpu] =
process = lttv_state_find_process_or_create(ts, ANY_CPU, pid,
<t_time_zero);
- process->execution_stack =
- g_array_set_size(process->execution_stack, 1);
- es = process->state =
- &g_array_index(process->execution_stack, LttvExecutionState, 0);
- es->t = LTTV_STATE_SYSCALL;
+ if (process->state->s != LTTV_STATE_DEAD) {
+ process->execution_stack =
+ g_array_set_size(process->execution_stack, 1);
+ es = process->state =
+ &g_array_index(process->execution_stack, LttvExecutionState, 0);
+ es->t = LTTV_STATE_SYSCALL;
+ }
process->type = LTTV_STATE_KERNEL_THREAD;
return FALSE;
g_assert(release_pid != 0);
process = lttv_state_find_process(ts, ANY_CPU, release_pid);
-
+ if(likely(process != NULL))
+ exit_process(s, process);
+ return FALSE;
+//DISABLED
if(likely(process != NULL)) {
/* release_task is happening at kernel level : we can now safely release
* the data structure of the process */
FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE),
function_exit, NULL, &hooks);
+ lttv_trace_find_hook(ts->parent.t,
+ LTT_FACILITY_STATEDUMP,
+ LTT_EVENT_SYS_CALL_TABLE,
+ FIELD_ARRAY(LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL),
+ dump_syscall, NULL, &hooks);
+
+ lttv_trace_find_hook(ts->parent.t,
+ LTT_FACILITY_STATEDUMP,
+ LTT_EVENT_SOFTIRQ_VEC,
+ FIELD_ARRAY(LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL),
+ dump_softirq, NULL, &hooks);
+
/* Add these hooks to each event_by_id hooks list */
nb_tracefile = ts->parent.tracefiles->len;
LTT_FACILITY_LIST = g_quark_from_string("list");
LTT_FACILITY_USER_GENERIC = g_quark_from_string("user_generic");
LTT_FACILITY_BLOCK = g_quark_from_string("block");
-
-
+ LTT_FACILITY_STATEDUMP = g_quark_from_string("statedump");
+
LTT_EVENT_SYSCALL_ENTRY = g_quark_from_string("syscall_entry");
LTT_EVENT_SYSCALL_EXIT = g_quark_from_string("syscall_exit");
LTT_EVENT_TRAP_ENTRY = g_quark_from_string("trap_entry");
LTT_EVENT_THREAD_BRAND = g_quark_from_string("thread_brand");
LTT_EVENT_REQUEST_ISSUE = g_quark_from_string("_blk_request_issue");
LTT_EVENT_REQUEST_COMPLETE = g_quark_from_string("_blk_request_complete");
- LTT_EVENT_LIST_INTERRUPT = g_quark_from_string("interrupt");;
-
+ LTT_EVENT_LIST_INTERRUPT = g_quark_from_string("interrupt");
+ LTT_EVENT_SYS_CALL_TABLE = g_quark_from_string("sys_call_table");
+ LTT_EVENT_SOFTIRQ_VEC = g_quark_from_string("softirq_vec");
LTT_FIELD_SYSCALL_ID = g_quark_from_string("syscall_id");
LTT_FIELD_TRAP_ID = g_quark_from_string("trap_id");
LTT_FIELD_MINOR = g_quark_from_string("minor");
LTT_FIELD_OPERATION = g_quark_from_string("direction");
LTT_FIELD_ACTION = g_quark_from_string("action");
+ LTT_FIELD_ID = g_quark_from_string("id");
+ LTT_FIELD_ADDRESS = g_quark_from_string("address");
+ LTT_FIELD_SYMBOL = g_quark_from_string("symbol");
LTTV_CPU_UNKNOWN = g_quark_from_string("unknown");
LTTV_CPU_IDLE = g_quark_from_string("idle");