source: UsbWattMeter/trunk/asp_dcre/arch/logtrace/trace_dump.c@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 4.0 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2007-2011 by Embedded and Real-Time Systems Laboratory
6 * Graduate School of Information Science, Nagoya Univ., JAPAN
7 *
8 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
9 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
10 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
11 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
12 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
13 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
14 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
15 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
16ƒƒ“ƒgi—˜—p
17 * ŽÒƒ}ƒjƒ…
18ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
19 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
20 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
21 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
22 * ‚ƁD
23 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
24ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
25ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
26 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
27 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
28 * •ñ‚·‚邱‚ƁD
29 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
30 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
31 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
32 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
33 * –Ɛӂ·‚邱‚ƁD
34 *
35 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
36 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
37 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
38 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
39 * ‚̐ӔC‚𕉂í‚È‚¢D
40 *
41 * $Id: trace_dump.c 164 2016-03-07 11:33:50Z coas-nagasima $
42 */
43
44/*
45 * ƒgƒŒ[ƒXƒƒO‚̃_ƒ“ƒv
46 */
47
48#include "kernel_impl.h"
49#include "task.h"
50#include <log_output.h>
51
52/*
53 * ƒJ[ƒlƒ‹î•ñ‚ÌŽæo‚µ
54 */
55static intptr_t
56get_tskid(intptr_t info)
57{
58 TCB *p_tcb;
59 ID tskid;
60
61 p_tcb = (TCB *) info;
62 if (p_tcb == NULL) {
63 tskid = 0;
64 }
65 else {
66 tskid = TSKID(p_tcb);
67 }
68 return((intptr_t) tskid);
69}
70
71static intptr_t
72get_tskstat(intptr_t info)
73{
74 uint_t tstat;
75 const char *tstatstr;
76
77 tstat = (uint_t) info;
78 switch (tstat & (TS_RUNNABLE|TS_WAITING|TS_SUSPENDED)) {
79 case TS_DORMANT:
80 tstatstr = "DORMANT";
81 break;
82 case TS_RUNNABLE:
83 tstatstr = "RUNNABLE";
84 break;
85 case TS_WAITING:
86 tstatstr = "WAITING";
87 break;
88 case TS_SUSPENDED:
89 tstatstr = "SUSPENDED";
90 break;
91 case TS_WAITING|TS_SUSPENDED:
92 tstatstr = "WAITING-SUSPENDED";
93 break;
94 default:
95 tstatstr = "unknown state";
96 break;
97 }
98 return((intptr_t) tstatstr);
99}
100
101/*
102 * ƒgƒŒ[ƒXƒƒO‚Ì•\Ž¦
103 */
104static void
105trace_print(TRACE *p_trace, void (*putc)(char))
106{
107 intptr_t traceinfo[TMAX_LOGINFO + 1];
108 const char *tracemsg;
109 int_t i;
110
111 traceinfo[0] = (intptr_t)(p_trace->logtim);
112 syslog_printf("[%d] ", traceinfo, putc);
113
114 switch (p_trace->logtype) {
115 case LOG_TYPE_TSKSTAT:
116 traceinfo[0] = get_tskid(p_trace->loginfo[0]);
117 traceinfo[1] = get_tskstat(p_trace->loginfo[1]);
118 tracemsg = "task %d becomes %s.";
119 break;
120 case LOG_TYPE_DSP|LOG_LEAVE:
121 traceinfo[0] = get_tskid(p_trace->loginfo[0]);
122 tracemsg = "dispatch to task %d.";
123 break;
124 case LOG_TYPE_COMMENT:
125 for (i = 1; i < TMAX_LOGINFO; i++) {
126 traceinfo[i-1] = p_trace->loginfo[i];
127 }
128 tracemsg = (const char *)(p_trace->loginfo[0]);
129 break;
130 case LOG_TYPE_ASSERT:
131 traceinfo[0] = p_trace->loginfo[0];
132 traceinfo[1] = p_trace->loginfo[1];
133 traceinfo[2] = p_trace->loginfo[2];
134 tracemsg = "%s:%u: Assertion `%s' failed.";
135 break;
136 default:
137 traceinfo[0] = p_trace->logtype;
138 tracemsg = "unknown trace log type: %d.";
139 break;
140 }
141 syslog_printf(tracemsg, traceinfo, putc);
142 (*putc)('\n');
143}
144
145/*
146 * ƒgƒŒ[ƒXƒƒO‚̃_ƒ“ƒv
147 */
148void
149trace_dump(intptr_t exinf)
150{
151 TRACE trace;
152 void (*putc)(char);
153
154 putc = (void (*)(char)) exinf;
155 while (trace_rea_log(&trace) >= 0) {
156 trace_print(&trace, putc);
157 }
158}
Note: See TracBrowser for help on using the repository browser.