mm: mm_event supports vmstat
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] / lib / libdss.c
1 #include "debug-snapshot-log.h"
2
3 struct dbg_snapshot_log *p;
4
5 int main(int argc, char *argv[])
6 {
7 FILE *f;
8 int ch;
9 long fsize;
10 char *string;
11 int i, j;
12
13 f = fopen(argv[1], "rb");
14 if (f == NULL) {
15 fputs("file read error!", stderr);
16 exit(1);
17 }
18 fseek(f, 0, SEEK_END);
19 fsize = ftell(f);
20 fseek(f, 0, SEEK_SET); //same as rewind(f);
21
22 string = malloc(fsize + 1);
23 fread(string, fsize, 1, f);
24 fclose(f);
25 p = (struct dbg_snapshot_log *)string;
26
27 printf("log = []\n");
28 for (i = 0; i < DSS_NR_CPUS; i++) {
29 for (j = 0; j < DSS_LOG_MAX_NUM; j++) {
30 if (p->task[i][j].time == 0)
31 break;
32 printf("log.append({'time':%.9f, 'type' : 'sched', 'cpu' : %d, 'comm' : '%s', 'pid' : %d})\n",
33 p->task[i][j].time/1.0e9,
34 i,
35 p->task[i][j].task_comm,
36 p->task[i][j].pid);
37 }
38 }
39
40 #ifdef CONFIG_DEBUG_SNAPSHOT_FREQ
41 for (i = 0; i < DSS_LOG_MAX_NUM; i++) {
42 if (p->freq[i].time == 0)
43 break;
44 printf("log.append({'time':%.9f, 'type' : 'freq', 'cpu' : %d, 'cluster' : %d, 'freq' : %lu })\n",
45 p->freq[i].time/1.0e9,
46 p->freq[i].cpu,
47 p->freq[i].type,
48 p->freq[i].target_freq);
49 }
50 #endif
51
52 for (i = 0; i < DSS_NR_CPUS; i++) {
53 for (j = 0; j < DSS_LOG_MAX_NUM; j++) {
54 if (p->irq[i][j].time == 0)
55 break;
56 printf("log.append({'time':%.9f, 'type' : 'irq', 'cpu' : %d, 'num' : %d,"
57 "'en' : %d, 'func' : '%p'})\n",
58 p->irq[i][j].time/1.0e9,
59 i,
60 p->irq[i][j].irq,
61 p->irq[i][j].en,
62 p->irq[i][j].fn);
63 }
64 }
65
66 for (i = 0; i < DSS_NR_CPUS; i++) {
67 for (j = 0; j < DSS_LOG_MAX_NUM; j++) {
68 if (p->cpuidle[i][j].time == 0)
69 break;
70 printf("log.append({'time':%.9f, 'type' : 'cpuidle', 'cpu' : %d, 'state' : %d})\n",
71 p->cpuidle[i][j].time/1.0e9,
72 i,
73 p->cpuidle[i][j].state);
74 }
75 }
76 #ifdef CONFIG_DEBUG_SNAPSHOT_BINDER
77 for (i = 0; i < DSS_API_MAX_NUM << 2; i++) {
78 if (p->binder[i].time == 0)
79 break;
80 printf("log.append({'time':%.9f, 'type' : 'binder', 'cpu' : %d, 'trace_type' : %d, 'transaction_id' : %d,"
81 " 'from_pid' : %d, 'from_tid' : %d, 'to_pid' : %d, 'to_tid' : %d,"
82 " 'from_pid_comm' : '%s', 'from_tid_comm' : '%s',"
83 " 'to_pid_comm' : '%s', 'to_tid_comm' : '%s', 'to_node_id' : %d,"
84 " 'reply' : %d, 'flags' : 0x%x, 'code' : 0x%x,"
85 " 'return_error' : %d, 'return_error_param' : %d, 'return_error_line' : %d})\n",
86 p->binder[i].time/1.0e9,
87 p->binder[i].cpu, p->binder[i].base.trace_type, p->binder[i].base.transaction_id,
88 p->binder[i].base.from_pid, p->binder[i].base.from_tid,
89 p->binder[i].base.to_pid, p->binder[i].base.to_tid,
90 p->binder[i].base.from_pid_comm, p->binder[i].base.from_tid_comm,
91 p->binder[i].base.to_pid_comm, p->binder[i].base.to_tid_comm,
92 p->binder[i].transaction.to_node_id, p->binder[i].transaction.reply,
93 p->binder[i].transaction.flags, p->binder[i].transaction.code,
94 p->binder[i].error.return_error, p->binder[i].error.return_error_param,
95 p->binder[i].error.return_error_line);
96 }
97 #endif
98 #ifdef CONFIG_DEBUG_SNAPSHOT_ACPM
99 for (i = 0; i < DSS_LOG_MAX_NUM; i++) {
100 if (p->acpm[i].time == 0)
101 break;
102 for (j = 0; j < 8; j++) {
103 if (!((p->acpm[i].log[j] >= 'a' && p->acpm[i].log[j] <= 'z') || p->acpm[i].log[j] == '_'))
104 p->acpm[i].log[j] = 0;
105 }
106 printf("log.append({'time':%.9f, 'acpm_time':%.9f, 'type' : 'acpmlog', 'log' : '%s', 'value' : %d })\n",
107 p->acpm[i].time/1.0e9,
108 p->acpm[i].acpm_time/1.0e9,
109 p->acpm[i].log,
110 p->acpm[i].data);
111 }
112 #endif
113 return 0;
114 }
115