1 | /*
|
---|
2 | * TOPPERS/JSP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Just Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
8 | *
|
---|
9 | * ä¸è¨è使¨©è
|
---|
10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
11 | * ã«ãã£ã¦å
|
---|
12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
14 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
15 | å¸ï¼ä»¥ä¸ï¼
|
---|
16 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
21 | * ç¨ã§ããå½¢ã§åé
|
---|
22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
24 | * è
|
---|
25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è使¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
30 | * ã¨ï¼
|
---|
31 | * (a) åé
|
---|
32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
34 | * 使¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
35 | * (b) åé
|
---|
36 | å¸ã®å½¢æ
|
---|
37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
38 | * å ±åãããã¨ï¼
|
---|
39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
40 | * 害ãããï¼ä¸è¨è使¨©è
|
---|
41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
42 | 責ãããã¨ï¼
|
---|
43 | *
|
---|
44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨è使¨©è
|
---|
45 | ã
|
---|
46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
49 | *
|
---|
50 | * @(#) $Id: debugout.c,v 1.10 2003/12/15 07:19:22 takayuki Exp $
|
---|
51 | */
|
---|
52 |
|
---|
53 | #include <debugout.h>
|
---|
54 | #include <hal_msg.h>
|
---|
55 | #include <resource.h>
|
---|
56 |
|
---|
57 | #ifdef DEBUG_ENABLE
|
---|
58 |
|
---|
59 | #define DBG_SIZE_STRINGBUFFER 512
|
---|
60 |
|
---|
61 | static HANDLE DebugConsole; //ãããã°æååã表示ããããã¹ãããã¯ã¹
|
---|
62 | static HWND DialogHandle; //ãããã°åºåãã¤ã¢ãã°
|
---|
63 |
|
---|
64 | extern void FatalAssertion(int exp, LPCSTR format, ... );
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * ãããã°ç¨ãã¤ã¢ãã°ã®ã¡ãã»ã¼ã¸ãã³ãã©
|
---|
68 | */
|
---|
69 | static LRESULT CALLBACK DebugOutDialogProc(HWND hDlg,UINT Msg,WPARAM wParam,LPARAM lParam)
|
---|
70 | {
|
---|
71 | switch(Msg)
|
---|
72 | {
|
---|
73 | case WM_INITDIALOG:
|
---|
74 | DebugConsole = GetDlgItem(hDlg,IDC_DEBUGOUT); //åºåå
|
---|
75 | ããã¹ãããã¯ã¹
|
---|
76 | ShowWindow(hDlg,SW_SHOW);
|
---|
77 |
|
---|
78 | case WM_SIZE:
|
---|
79 | {
|
---|
80 | RECT client;
|
---|
81 | GetClientRect(hDlg,&client);
|
---|
82 | MoveWindow(DebugConsole,0,0,client.right,client.bottom,TRUE);
|
---|
83 | break;
|
---|
84 | }
|
---|
85 |
|
---|
86 | case WM_CLOSE:
|
---|
87 | /* Never let this dialog close by pressing of the close button. */
|
---|
88 | break;
|
---|
89 |
|
---|
90 | case WM_DESTROY:
|
---|
91 | DialogHandle = 0;
|
---|
92 | break;
|
---|
93 |
|
---|
94 | case WM_QUIT:
|
---|
95 | DestroyWindow(hDlg);
|
---|
96 | break;
|
---|
97 |
|
---|
98 | default:
|
---|
99 | return FALSE;
|
---|
100 | }
|
---|
101 | return TRUE;
|
---|
102 | }
|
---|
103 |
|
---|
104 | /* ä¸ã®2颿°ãæ
|
---|
105 | å ±ãããåãããããã®æ§é ä½ */
|
---|
106 | struct tagInitializeDebugServicesParam {
|
---|
107 | HINSTANCE hInstance;
|
---|
108 | HWND hDlg;
|
---|
109 | };
|
---|
110 |
|
---|
111 | /* ãããã°ã«ã¼ãã³ãã¨ãã */
|
---|
112 | void FinalizeDebugServices(void)
|
---|
113 | {
|
---|
114 | if(DialogHandle != 0l) {
|
---|
115 | DestroyWindow(DialogHandle);
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | /* 管çã¹ã¬ãããå®è¡ããã¦ã£ã³ãã¦ä½æã«ã¼ãã³ */
|
---|
120 | static void _initializeDebugServices(void * _param)
|
---|
121 | {
|
---|
122 | struct tagInitializeDebugServicesParam * param = (struct tagInitializeDebugServicesParam *)_param;
|
---|
123 | DialogHandle = CreateDialog(param->hInstance, MAKEINTRESOURCE(DEBUGOUTDIALOG), param->hDlg, DebugOutDialogProc);
|
---|
124 | FatalAssertion(DialogHandle != NULL, "DebugService could not create its own dialog.");
|
---|
125 | }
|
---|
126 |
|
---|
127 | /* ãããã°ã«ã¼ãã³ã®åæå ï¼ç®¡çã¹ã¬ããã«ãã¤ã¢ãã°ãä½ã£ã¦ããã) */
|
---|
128 | void InitializeDebugServices(HINSTANCE hinst,HWND dlg)
|
---|
129 | {
|
---|
130 | struct tagInitializeDebugServicesParam param;
|
---|
131 | param.hInstance = hinst;
|
---|
132 | param.hDlg = dlg;
|
---|
133 |
|
---|
134 | HALExecuteProcedure(_initializeDebugServices, (void *)¶m); //çæä¾é ¼
|
---|
135 | HALAddDestructionProcedure(FinalizeDebugServices, 0); //ç ´æ£ã«ã¼ãã³ã®ç»é²
|
---|
136 | }
|
---|
137 |
|
---|
138 | /* ãããã°æç¨printf */
|
---|
139 | int _debugOut(const char * format, ... )
|
---|
140 | {
|
---|
141 | int result;
|
---|
142 | int i;
|
---|
143 | char buffer[DBG_SIZE_STRINGBUFFER*2];
|
---|
144 | char * scope;
|
---|
145 | const char * work;
|
---|
146 | va_list vl;
|
---|
147 |
|
---|
148 | if(format == 0l)
|
---|
149 | return 0;
|
---|
150 |
|
---|
151 | va_start(vl, format);
|
---|
152 |
|
---|
153 | /* formatã«å«ã¾ãã '\n' ã '\r\n' ã«ç½®æãã */
|
---|
154 | scope = buffer;
|
---|
155 | work = format;
|
---|
156 |
|
---|
157 | while(*format != '\0')
|
---|
158 | {
|
---|
159 | if(*format == '\n')
|
---|
160 | {
|
---|
161 | i = format - work;
|
---|
162 | lstrcpyn(scope, work, i);
|
---|
163 |
|
---|
164 | scope += i;
|
---|
165 | work = format;
|
---|
166 |
|
---|
167 | *(scope++) = '\r';
|
---|
168 | }
|
---|
169 | format ++;
|
---|
170 | }
|
---|
171 |
|
---|
172 | i = format - work + 1;
|
---|
173 | lstrcpyn(scope, work, i); //+1ãã¦'\x0'ãã³ãã¼
|
---|
174 | scope += i;
|
---|
175 |
|
---|
176 | if((result = wvsprintf(scope, buffer, vl)) > 0)
|
---|
177 | {
|
---|
178 | //åºåãããããå°ãã«ãã
|
---|
179 | i = GetWindowTextLength(DebugConsole);
|
---|
180 | if(i > DEBUG_LIMITTERUPPERBOUND)
|
---|
181 | {
|
---|
182 | SendMessage(DebugConsole, EM_SETSEL, 0, i - DEBUG_LIMITTERUPPERBOUND);
|
---|
183 | SendMessage(DebugConsole, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)"");
|
---|
184 | }
|
---|
185 |
|
---|
186 | SendMessage(DebugConsole,EM_SETSEL,i,i);
|
---|
187 | SendMessage(DebugConsole,EM_REPLACESEL,(WPARAM)FALSE,(LPARAM)scope);
|
---|
188 | }
|
---|
189 |
|
---|
190 | return result;
|
---|
191 | }
|
---|
192 |
|
---|
193 | #endif
|
---|
194 |
|
---|
195 |
|
---|