Commit | Line | Data |
---|---|---|
2585dbeb YK |
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 | ||
4dbc3ccd | 27 | printf("log = []\n"); |
2585dbeb YK |
28 | for (i = 0; i < DSS_NR_CPUS; i++) { |
29 | for (j = 0; j < DSS_LOG_MAX_NUM; j++) { | |
b96f09b4 YK |
30 | if (p->task[i][j].time == 0) |
31 | break; | |
4dbc3ccd | 32 | printf("log.append({'time':%.9f, 'type' : 'sched', 'cpu' : %d, 'comm' : '%s', 'pid' : %d})\n", |
f601fa86 YK |
33 | p->task[i][j].time/1.0e9, |
34 | i, | |
35 | p->task[i][j].task_comm, | |
36 | p->task[i][j].pid); | |
2585dbeb YK |
37 | } |
38 | } | |
39 | ||
d02a8563 | 40 | #ifdef CONFIG_DEBUG_SNAPSHOT_FREQ |
2585dbeb | 41 | for (i = 0; i < DSS_LOG_MAX_NUM; i++) { |
b96f09b4 YK |
42 | if (p->freq[i].time == 0) |
43 | break; | |
4dbc3ccd | 44 | printf("log.append({'time':%.9f, 'type' : 'freq', 'cpu' : %d, 'cluster' : %d, 'freq' : %lu })\n", |
f601fa86 | 45 | p->freq[i].time/1.0e9, |
9c741bd7 | 46 | p->freq[i].cpu, |
f601fa86 YK |
47 | p->freq[i].type, |
48 | p->freq[i].target_freq); | |
2585dbeb | 49 | } |
d02a8563 | 50 | #endif |
2585dbeb YK |
51 | |
52 | for (i = 0; i < DSS_NR_CPUS; i++) { | |
53 | for (j = 0; j < DSS_LOG_MAX_NUM; j++) { | |
b96f09b4 YK |
54 | if (p->irq[i][j].time == 0) |
55 | break; | |
4dbc3ccd YK |
56 | printf("log.append({'time':%.9f, 'type' : 'irq', 'cpu' : %d, 'num' : %d," |
57 | "'en' : %d, 'func' : '%p'})\n", | |
f601fa86 YK |
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); | |
2585dbeb YK |
63 | } |
64 | } | |
65 | ||
66 | for (i = 0; i < DSS_NR_CPUS; i++) { | |
67 | for (j = 0; j < DSS_LOG_MAX_NUM; j++) { | |
b96f09b4 YK |
68 | if (p->cpuidle[i][j].time == 0) |
69 | break; | |
4dbc3ccd | 70 | printf("log.append({'time':%.9f, 'type' : 'cpuidle', 'cpu' : %d, 'state' : %d})\n", |
f601fa86 YK |
71 | p->cpuidle[i][j].time/1.0e9, |
72 | i, | |
73 | p->cpuidle[i][j].state); | |
2585dbeb YK |
74 | } |
75 | } | |
f3e93f19 | 76 | #ifdef CONFIG_DEBUG_SNAPSHOT_BINDER |
8c02497e | 77 | for (i = 0; i < DSS_API_MAX_NUM << 2; i++) { |
b96f09b4 YK |
78 | if (p->binder[i].time == 0) |
79 | break; | |
4dbc3ccd | 80 | printf("log.append({'time':%.9f, 'type' : 'binder', 'cpu' : %d, 'trace_type' : %d, 'transaction_id' : %d," |
8c02497e YK |
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," | |
4dbc3ccd | 85 | " 'return_error' : %d, 'return_error_param' : %d, 'return_error_line' : %d})\n", |
f3e93f19 | 86 | p->binder[i].time/1.0e9, |
8c02497e YK |
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, | |
f3e93f19 YK |
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, | |
8c02497e YK |
94 | p->binder[i].error.return_error, p->binder[i].error.return_error_param, |
95 | p->binder[i].error.return_error_line); | |
f3e93f19 | 96 | } |
59c77fd4 YK |
97 | #endif |
98 | #ifdef CONFIG_DEBUG_SNAPSHOT_ACPM | |
8c02497e | 99 | for (i = 0; i < DSS_LOG_MAX_NUM; i++) { |
b96f09b4 YK |
100 | if (p->acpm[i].time == 0) |
101 | break; | |
7dc8c7ac YK |
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, | |
59c77fd4 YK |
108 | p->acpm[i].acpm_time/1.0e9, |
109 | p->acpm[i].log, | |
110 | p->acpm[i].data); | |
59c77fd4 | 111 | } |
f3e93f19 | 112 | #endif |
2585dbeb YK |
113 | return 0; |
114 | } | |
115 |