summaryrefslogtreecommitdiffstats
path: root/task_manager/server/src/tskm_debug.cpp
blob: 5881f9afeceb95f20ecbcf474e7a12f21f418f3d (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "tskm_debug.h"

const char*
tskm_convState2Str(TSKM_STATE_t state) {
  const char* ret = "UNKNONW";
  switch (state) {    // LCOV_EXCL_BR_LINE 7:debug code
    case TSKM_ST_ACCOFF:
      ret = "ACCOFF";
      break;
    case TSKM_ST_ACCON:
      ret = "ACCON";
      break;
    case TSKM_ST_WAKEUP:
      ret = "WAKEUP";
      break;
    case TSKM_ST_RUNNING:
      ret = "RUNNING";
      break;
    case TSKM_ST_DOWN:
      ret = "DOWN";
      break;
  }
  return ret;
}

const char*
tskm_convEvent2Str(TSKM_EVENT_t event) {
  switch (event) {    // LCOV_EXCL_BR_LINE 7:debug code
    case TSKM_EV_NOP:
      return "NOP";
    case TSKM_EV_PRI_REQ_WAKEUP:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REQ_WAKEUP";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REQ_DOWN:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REQ_DOWN";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REQ_TOUCH:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REQ_TOUCH";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REQ_DEBUGDUMP:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REQ_DEBUGDUMP";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REP_LOWMEM:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REP_LOWMEM";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REP_WAKEUP_COMP:
      return "PRI_REP_WAKEUP_COMP";
    case TSKM_EV_PRI_REP_DOWN_COMP:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REP_DOWN_COMP";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REP_CONNECT:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REP_CONNECT";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REP_DISCONNECT:
      return "PRI_REP_DISCONNECT";
    case TSKM_EV_PRI_RES_WAKEUP:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_RES_WAKEUP";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_RES_DOWN:
      return "PRI_RES_DOWN";
    case TSKM_EV_PRI_RES_DEBUGDUMP:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_RES_DEBUGDUMP";
      // LCOV_EXCL_STOP
    case TSKM_EV_PRI_REQ_EXIT:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "PRI_REQ_EXIT";
      // LCOV_EXCL_STOP
    case TSKM_EV_SVC_REP_TERM:
      return "SVC_REP_TERM";
    case TSKM_EV_API_REQ_REBOOT:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "API_REQ_REBOOT";
      // LCOV_EXCL_STOP
    case TSKM_EV_API_REQ_SVC_CTL:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "API_REQ_SVC_CTL";
      // LCOV_EXCL_STOP
    case TSKM_EV_API_REQ_SVC_DISABLE:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "API_REQ_SVC_DISABLE";
      // LCOV_EXCL_STOP
    case TSKM_EV_LCL_REQ_STOP:
      return "API_REQ_STOP";
    case TSKM_EV_LCL_CHG_SVC_STATE:
      return "LCL_CHG_SVC_STATE";
    case TSKM_EV_LCL_REQ_SDUMP:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "LCL_REQ_SDUMP";
      // LCOV_EXCL_STOP
    case TSKM_EV_LCL_REP_TIMEOUT:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "LCL_REP_TIMEOUT";
      // LCOV_EXCL_STOP
    case TSKM_EV_LCL_REP_POLLING:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "LCL_REP_POLLING";
      // LCOV_EXCL_STOP
    case TSKM_EV_LCL_REP_LOWMEM:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "LCL_REP_LOWMEM";
      // LCOV_EXCL_STOP
    case TSKM_EV_LCL_REQ_TRANS_STEP:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "LCL_REQ_TRANS_STEP";
      // LCOV_EXCL_STOP
    default:
      break;
  }
  // LCOV_EXCL_START 7:debug code
  AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
  return "UNKNOWN";
  // LCOV_EXCL_STOP
}

const char*
tskm_convInitCompId2Str(uint64_t compId) {
  switch (compId) {    // LCOV_EXCL_BR_LINE 7:debug code
    case INI_INITCOMP_NONE:
      return "NONE";
    case INI_INITCOMP_ON_START:
      return "ONSTART";
    case INI_INITCOMP_NVM_ACCESS:
      return "NVM_ACCESS";
    case INI_INITCOMP_TEST0:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST0";
      // LCOV_EXCL_STOP
    case INI_INITCOMP_TEST1:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST1";
      // LCOV_EXCL_STOP
    case INI_INITCOMP_TEST2:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST2";
      // LCOV_EXCL_STOP
    case INI_INITCOMP_TEST3:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST3";
      // LCOV_EXCL_STOP
  }
  // LCOV_EXCL_START 7:debug code
  AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
  return "UNKNONW";
  // LCOV_EXCL_STOP
}

const char*
tskm_convTermCompId2Str(uint64_t compId) {
  switch (compId) {  // LCOV_EXCL_BR_LINE 7:debug code
    case INI_TERMCOMP_NONE:
      return "NONE";
    case INI_TERMCOMP_ACTIVITYMGR:
      return "ACTIVITYMGR";
    case INI_TERMCOMP_RESIDENT:
      return "RESIDENT";
    case INI_TERMCOMP_TRANSIENT:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TRANSIENT";
      // LCOV_EXCL_STOP
    case INI_TERMCOMP_TEST0:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST0";
      // LCOV_EXCL_STOP
    case INI_TERMCOMP_TEST1:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST1";
      // LCOV_EXCL_STOP
    case INI_TERMCOMP_TEST2:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST2";
      // LCOV_EXCL_STOP
    case INI_TERMCOMP_TEST3:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "TEST3";
      // LCOV_EXCL_STOP
  }
  return "UNKNONW";
}

const char*
tskm_convSvcState2Str(TSKM_SVC_STATE_t state) {
  switch (state) {  // LCOV_EXCL_BR_LINE 7:debug code
    case TSKM_SVC_DORMANT:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "DORMANT";
      // LCOV_EXCL_STOP
    case TSKM_SVC_WAITCONNECT:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "WAITCONNECT";
      // LCOV_EXCL_STOP
    case TSKM_SVC_WAKEUP:
      return "WAKEUP";
    case TSKM_SVC_RUNNING:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "RUNNING";
      // LCOV_EXCL_STOP
    case TSKM_SVC_DOWN:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "DOWN";
      // LCOV_EXCL_STOP
    case TSKM_SVC_FINDOWN:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "FINDOWN";
      // LCOV_EXCL_STOP
    case TSKM_SVC_DISABLE:
      // LCOV_EXCL_START 7:debug code
      AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
      return "DISABLE";
      // LCOV_EXCL_STOP
    default:
      break;
  }
  return "UNKNONW";
}

TSKM_STATIC void svcDump(TSKM_SVC_CTX_t* p_svc) {
  TSKM_PRINTF(TSKM_LOG_STATE, "<%s>", p_svc->attr->name);
  TSKM_PRINTF(TSKM_LOG_STATE, "  pid:%d svcId:%#x state:%s waitResCnt:%d",
              p_svc->pid, p_svc->attr->svcId,
              tskm_convSvcState2Str(p_svc->state), p_svc->waitResCnt);
}

void tskm_svcsDump(TSKM_SVCS_CTX_t* p_svcs) {
  uint32_t ii;
  for (ii = 0; ii < p_svcs->svcNum; ii++) {
    svcDump(&p_svcs->svcList[ii]);
  }
}