-
Notifications
You must be signed in to change notification settings - Fork 5
/
ev_signal.c
81 lines (71 loc) · 1.61 KB
/
ev_signal.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* LTTng to GTKwave trace conversion
*
* Authors:
* Ivan Djelic <[email protected]>
* Matthieu Castet <[email protected]>
*
* Copyright (C) 2013 Parrot S.A.
*/
#include "lttng2lxt.h"
/* This is not valid for alpha, sparc and mips */
static const char * const signal_name[] = {
[1] = "HUP",
[2] = "INT",
[3] = "QUIT",
[4] = "ILL",
[5] = "TRAP",
[6] = "ABRT",
[7] = "BUS",
[8] = "FPE",
[9] = "KILL",
[10] = "USR1",
[11] = "SEGV",
[12] = "USR2",
[13] = "PIPE",
[14] = "ALRM",
[15] = "TERM",
[17] = "CHLD",
[18] = "CONT",
[19] = "STOP",
[20] = "TSTP",
};
static void emit_signal(struct task *task, int sig, int cpu)
{
const char *name = "NAL";
if ((sig < (int)ARRAY_SIZE(signal_name)) && (signal_name[sig]))
name = signal_name[sig];
emit_trace(task->info_trace, (union ltt_value)"%d: SIG%s(%d)", cpu,
name, sig);
}
static void signal_generate_process(const char *modname, int pass,
double clock, int cpu, void *args)
{
int sig, pid;
const char *comm;
struct task *task;
comm = get_arg_str(args, "comm");
pid = (int)get_arg_u64(args, "pid");
if (pass == 1)
(void)find_or_add_task(comm, pid);
if (pass == 2) {
sig = (int)get_arg_u64(args, "sig");
task = find_or_add_task(NULL, pid);
if (task)
emit_signal(task, sig, cpu);
}
}
MODULE(signal_generate);
static void signal_deliver_process(const char *modname, int pass,
double clock, int cpu, void *args)
{
int sig;
struct task *task;
if (pass == 2) {
sig = (int)get_arg_u64(args, "sig");
task = get_current_task(cpu);
if (task)
emit_signal(task, sig, cpu);
}
}
MODULE(signal_deliver);