Mercurial > ecos-v2_0-branch
annotate packages/infra/current/src/fancy.cxx @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children | c5536bad4c24 |
| rev | line source |
|---|---|
| 0 | 1 //========================================================================== |
| 2 // | |
| 2 | 3 // fancy.cxx |
| 0 | 4 // |
| 5 // Fancy formatting trace and assert functions | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
12 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // |
| 0 | 30 //####COPYRIGHTEND#### |
| 31 //========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 2 | 34 // Author(s): nickg |
| 35 // Contributors: nickg | |
| 36 // Date: 1997-12-04 | |
| 37 // Purpose: Fancy Trace and assert functions | |
| 38 // Description: The functions in this file are fancy implementations of the | |
| 0 | 39 // standard trace and assert functions. These do printf |
| 40 // style formatting, printing the string and arguments. | |
| 41 // | |
| 42 //####DESCRIPTIONEND#### | |
| 43 // | |
| 44 //========================================================================== | |
| 45 | |
| 46 #include <pkgconf/system.h> | |
| 47 #include <pkgconf/infra.h> | |
| 48 | |
| 49 #ifdef CYGDBG_INFRA_DEBUG_TRACE_ASSERT_FANCY | |
| 50 | |
| 51 #include <cyg/infra/cyg_type.h> // base types | |
| 52 #include <cyg/infra/cyg_trac.h> // tracing macros | |
| 53 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 54 | |
| 55 #include <pkgconf/hal.h> // HAL configury | |
| 56 #include <cyg/infra/diag.h> // HAL polled output | |
| 57 #include <cyg/hal/hal_arch.h> // architectural stuff for... | |
| 58 #include <cyg/hal/hal_intr.h> // interrupt control | |
| 59 | |
| 60 #ifdef CYGPKG_KERNEL | |
| 61 #include <pkgconf/kernel.h> // kernel configury | |
| 62 #include <cyg/kernel/thread.hxx> // thread id to print | |
| 63 #include <cyg/kernel/sched.hxx> // ancillaries for above | |
| 64 #include <cyg/kernel/thread.inl> // ancillaries for above | |
| 65 #endif | |
| 66 | |
| 67 // ------------------------------------------------------------------------- | |
| 68 // Local Configuration: hack me! | |
| 69 | |
| 70 // these are generally: | |
| 2 | 71 // if 0, feature is disabled |
| 72 // if 1, feature is enabled, printing is default width | |
| 73 // if >1, field is padded up to that width if necessary | |
| 74 // (not truncated ever) | |
| 0 | 75 |
| 2 | 76 #define CYG_FILENAME 20 |
| 77 #define CYG_THREADID 0 // DO NOT SET IF NO KERNEL | |
| 78 #define CYG_LINENUM 4 | |
| 79 #define CYG_FUNCNAME 100 | |
| 0 | 80 #define CYG_DIAG_PRINTF 1 |
| 81 #define CYG_FUNC_INDENT 2 | |
| 82 | |
| 83 #ifndef CYGPKG_KERNEL | |
| 84 # undef CYG_THREADID | |
| 85 # define CYG_THREADID 0 | |
| 86 #endif | |
| 87 | |
| 88 #if CYG_FUNCNAME == 1 | |
| 89 #define CYG_FBUF_SIZE 100 | |
| 90 #else | |
| 91 #define CYG_FBUF_SIZE (CYG_FUNCNAME+20) | |
| 92 #endif | |
| 93 | |
| 94 // ------------------------------------------------------------------------- | |
| 95 // Functions to trim file names and function names down to printable lengths | |
| 96 // (these are shared between trace and assert functions) | |
| 97 | |
| 98 #ifdef CYGDBG_USE_TRACING | |
| 99 | |
| 100 #if 0 | |
| 101 static char * tracepremsgs[] = { | |
| 102 " INFO:", | |
| 103 "ENTER :", | |
| 104 "ARGS :", | |
| 105 "RETURN:", | |
| 106 "bad code" | |
| 107 }; | |
| 108 #endif | |
| 109 | |
| 110 static char * tracepremsgs[] = { | |
| 111 "'", | |
| 112 "{{", | |
| 113 "((", | |
| 114 "}}", | |
| 115 "bad code" | |
| 116 }; | |
| 117 | |
| 118 static char * tracepostmsgs[] = { | |
| 119 "'", | |
| 120 "", | |
| 121 "))", | |
| 122 "", | |
| 123 "bad code" | |
| 124 }; | |
| 125 | |
| 126 static void | |
| 127 write_whattrace( cyg_uint32 what ) | |
| 128 { | |
| 129 #if CYG_FUNC_INDENT | |
| 130 static cyg_uint32 cyg_indent = 0; | |
| 131 if ( 3 == what ) | |
| 132 cyg_indent -= CYG_FUNC_INDENT; | |
| 133 cyg_uint32 i = cyg_indent; | |
| 134 for ( ; i > 0; i-- ) | |
| 135 diag_write_string( " " ); | |
| 136 #endif // CYG_FUNC_INDENT | |
| 137 diag_write_string( tracepremsgs[ what > 4 ? 4 : what ] ); | |
| 138 #if CYG_FUNC_INDENT | |
| 139 if ( 1 == what ) | |
| 140 cyg_indent += CYG_FUNC_INDENT; | |
| 141 #endif // CYG_FUNC_INDENT | |
| 142 } | |
| 143 | |
| 144 static void | |
| 145 write_whattracepost( cyg_uint32 what ) | |
| 146 { | |
| 147 diag_write_string( tracepostmsgs[ what > 4 ? 4 : what ] ); | |
| 148 } | |
| 149 #endif // CYGDBG_USE_TRACING | |
| 150 | |
| 2 | 151 static const char *trim_file(const char *file) |
| 0 | 152 { |
| 153 #if CYG_FILENAME | |
| 154 if ( NULL == file ) | |
| 155 file = "<nofile>"; | |
| 156 | |
| 157 #if 1 == CYG_FILENAME | |
| 2 | 158 const char *f = file; |
| 0 | 159 while( *f ) f++; |
| 160 while( *f != '/' && f != file ) f--; | |
| 161 return f==file?f:(f+1); | |
| 162 #else | |
| 163 static char fbuf2[100]; | |
| 2 | 164 const char *f = file; |
| 165 char *g = fbuf2; | |
| 0 | 166 while( *f ) f++; |
| 167 while( *f != '/' && f != file ) f--; | |
| 168 if ( f > file ) f++; | |
| 169 while( *f ) *g++ = *f++; | |
| 170 while( CYG_FILENAME > (g - fbuf2) ) *g++ = ' '; | |
| 171 *g = 0; | |
| 172 return fbuf2; | |
| 173 #endif | |
| 174 #else | |
| 175 return ""; | |
| 176 #endif | |
| 177 } | |
| 178 | |
| 2 | 179 static const char *trim_func(const char *func) |
| 0 | 180 { |
| 181 #if CYG_FUNCNAME | |
| 182 static char fbuf[CYG_FBUF_SIZE]; | |
| 183 int i; | |
| 184 | |
| 185 if ( NULL == func ) | |
| 186 func = "<nofunc>"; | |
| 187 | |
| 188 for( i = 0; func[i] && func[i] != '(' && i < CYG_FBUF_SIZE-4 ; i++ ) | |
| 189 fbuf[i] = func[i]; | |
| 190 | |
| 191 fbuf[i++] = '('; | |
| 192 fbuf[i++] = ')'; | |
| 193 fbuf[i ] = 0; | |
| 2 | 194 i=0; |
| 0 | 195 #if 1 == CYG_FUNCNAME |
| 196 return &fbuf[i]; | |
| 197 #else | |
| 198 char *p = &fbuf[i]; | |
| 199 while ( *p ) p++; | |
| 200 while ( CYG_FUNCNAME > (p - (&fbuf[i])) ) *p++ = ' '; | |
| 201 *p = 0; | |
| 202 return &fbuf[i]; | |
| 203 #endif | |
| 204 #else | |
| 205 return ""; | |
| 206 #endif | |
| 207 } | |
| 208 | |
| 209 void write_lnum( cyg_uint32 lnum) | |
| 210 { | |
| 211 #if CYG_LINENUM | |
| 212 diag_write_char('['); | |
| 213 #if 1 < CYG_LINENUM | |
| 214 cyg_uint32 i, j; | |
| 215 for ( i = 2, j = 100; i < CYG_LINENUM ; i++, j *= 10 ) | |
| 216 if ( lnum < j ) | |
| 217 diag_write_char(' '); | |
| 218 #endif | |
| 219 diag_write_dec(lnum); | |
| 220 diag_write_char(']'); | |
| 221 diag_write_char(' '); | |
| 222 #endif | |
| 223 } | |
| 224 | |
| 225 void write_thread_id() | |
| 226 { | |
| 227 #if CYG_THREADID | |
| 228 Cyg_Thread *t = Cyg_Thread::self(); | |
| 229 cyg_uint16 tid = 0xFFFF; | |
| 230 | |
| 231 if( t != NULL ) tid = t->get_unique_id(); | |
| 232 | |
| 233 diag_write_char('<'); | |
| 234 diag_write_hex(tid); | |
| 235 diag_write_char('>'); | |
| 236 #endif | |
| 237 } | |
| 238 | |
| 239 // ------------------------------------------------------------------------- | |
| 240 // Trace functions: | |
| 241 | |
| 242 #ifdef CYGDBG_USE_TRACING | |
| 243 | |
| 244 externC void | |
| 245 cyg_tracenomsg( char *psz_func, char *psz_file, cyg_uint32 linenum ) | |
| 246 { | |
| 247 cyg_uint32 old_ints; | |
| 248 | |
| 249 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 250 DIAG_DEVICE_START_SYNC(); | |
| 251 | |
| 252 diag_write_string("TRACE: "); | |
| 253 write_thread_id(); | |
| 254 diag_write_string(trim_file(psz_file)); | |
| 255 write_lnum(linenum); | |
| 256 diag_write_string(trim_func(psz_func)); | |
| 257 diag_write_char('\n'); | |
| 258 | |
| 259 DIAG_DEVICE_END_SYNC(); | |
| 260 HAL_RESTORE_INTERRUPTS(old_ints); | |
| 261 | |
| 262 }; | |
| 263 | |
| 264 // provide every other one of these as a space/caller bloat compromise. | |
| 265 | |
| 266 externC void | |
| 267 cyg_tracemsg( cyg_uint32 what, | |
| 268 char *psz_func, char *psz_file, cyg_uint32 linenum, | |
| 269 char *psz_msg ) | |
| 270 { | |
| 271 cyg_uint32 old_ints; | |
| 272 | |
| 273 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 274 DIAG_DEVICE_START_SYNC(); | |
| 275 | |
| 276 if ( NULL == psz_msg ) | |
| 277 psz_msg = "<nomsg>"; | |
| 278 | |
| 279 diag_write_string( "TRACE: " ); | |
| 280 write_thread_id(); | |
| 281 diag_write_string(trim_file(psz_file)); | |
| 282 write_lnum(linenum); | |
| 283 diag_write_string(trim_func(psz_func)); | |
| 284 diag_write_char(' '); | |
| 285 write_whattrace( what ); | |
| 286 diag_write_string(psz_msg); | |
| 287 write_whattracepost( what ); | |
| 288 diag_write_char('\n'); | |
| 289 | |
| 290 DIAG_DEVICE_END_SYNC(); | |
| 291 HAL_RESTORE_INTERRUPTS(old_ints); | |
| 292 | |
| 293 }; | |
| 294 | |
| 295 externC void | |
| 296 cyg_tracemsg2( cyg_uint32 what, | |
| 297 char *psz_func, char *psz_file, cyg_uint32 linenum, | |
| 298 char *psz_msg, | |
| 299 CYG_ADDRWORD arg0, CYG_ADDRWORD arg1 ) | |
| 300 { | |
| 301 cyg_uint32 old_ints; | |
| 302 | |
| 303 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 304 DIAG_DEVICE_START_SYNC(); | |
| 305 | |
| 306 if ( NULL == psz_msg ) | |
| 307 psz_msg = "<nomsg>"; | |
| 308 | |
| 309 diag_write_string( "TRACE: " ); | |
| 310 write_thread_id(); | |
| 311 diag_write_string(trim_file(psz_file)); | |
| 312 write_lnum(linenum); | |
| 313 diag_write_string(trim_func(psz_func)); | |
| 314 diag_write_char(' '); | |
| 315 write_whattrace( what ); | |
| 316 #if CYG_DIAG_PRINTF | |
| 317 diag_printf( psz_msg, arg0, arg1 ); | |
| 318 #else | |
| 319 diag_write_string(psz_msg); | |
| 320 diag_write_char(' '); | |
| 321 diag_write_hex(arg0); | |
| 322 diag_write_char(' '); | |
| 323 diag_write_hex(arg1); | |
| 324 #endif | |
| 325 write_whattracepost( what ); | |
| 326 diag_write_char('\n'); | |
| 327 DIAG_DEVICE_END_SYNC(); | |
| 328 HAL_RESTORE_INTERRUPTS(old_ints); | |
| 329 }; | |
| 330 | |
| 331 externC void | |
| 332 cyg_tracemsg4( cyg_uint32 what, | |
| 333 char *psz_func, char *psz_file, cyg_uint32 linenum, | |
| 334 char *psz_msg, | |
| 335 CYG_ADDRWORD arg0, CYG_ADDRWORD arg1, | |
| 336 CYG_ADDRWORD arg2, CYG_ADDRWORD arg3 ) | |
| 337 { | |
| 338 cyg_uint32 old_ints; | |
| 339 | |
| 340 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 341 DIAG_DEVICE_START_SYNC(); | |
| 342 | |
| 343 if ( NULL == psz_msg ) | |
| 344 psz_msg = "<nomsg>"; | |
| 345 | |
| 346 diag_write_string( "TRACE: " ); | |
| 347 write_thread_id(); | |
| 348 diag_write_string(trim_file(psz_file)); | |
| 349 write_lnum(linenum); | |
| 350 diag_write_string(trim_func(psz_func)); | |
| 351 diag_write_char(' '); | |
| 352 write_whattrace( what ); | |
| 353 #if CYG_DIAG_PRINTF | |
| 354 diag_printf( psz_msg, arg0, arg1, arg2, arg3 ); | |
| 355 #else | |
| 356 diag_write_string(psz_msg); | |
| 357 diag_write_char(' '); | |
| 358 diag_write_hex(arg0); | |
| 359 diag_write_char(' '); | |
| 360 diag_write_hex(arg1); | |
| 361 diag_write_char(' '); | |
| 362 diag_write_hex(arg2); | |
| 363 diag_write_char(' '); | |
| 364 diag_write_hex(arg3); | |
| 365 #endif | |
| 366 write_whattracepost( what ); | |
| 367 diag_write_char('\n'); | |
| 368 | |
| 369 DIAG_DEVICE_END_SYNC(); | |
| 370 HAL_RESTORE_INTERRUPTS(old_ints); | |
| 371 }; | |
| 372 | |
| 373 externC void | |
| 374 cyg_tracemsg6( cyg_uint32 what, | |
| 375 char *psz_func, char *psz_file, cyg_uint32 linenum, | |
| 376 char *psz_msg, | |
| 377 CYG_ADDRWORD arg0, CYG_ADDRWORD arg1, | |
| 378 CYG_ADDRWORD arg2, CYG_ADDRWORD arg3, | |
| 379 CYG_ADDRWORD arg4, CYG_ADDRWORD arg5 ) | |
| 380 { | |
| 381 cyg_uint32 old_ints; | |
| 382 | |
| 383 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 384 DIAG_DEVICE_START_SYNC(); | |
| 385 | |
| 386 if ( NULL == psz_msg ) | |
| 387 psz_msg = "<nomsg>"; | |
| 388 | |
| 389 diag_write_string( "TRACE: " ); | |
| 390 write_thread_id(); | |
| 391 diag_write_string(trim_file(psz_file)); | |
| 392 write_lnum(linenum); | |
| 393 diag_write_string(trim_func(psz_func)); | |
| 394 diag_write_char(' '); | |
| 395 write_whattrace( what ); | |
| 396 #if CYG_DIAG_PRINTF | |
| 397 diag_printf( psz_msg, arg0, arg1, arg2, arg3, arg4, arg5 ); | |
| 398 #else | |
| 399 diag_write_string(psz_msg); | |
| 400 diag_write_char(' '); | |
| 401 diag_write_hex(arg0); | |
| 402 diag_write_char(' '); | |
| 403 diag_write_hex(arg1); | |
| 404 diag_write_char(' '); | |
| 405 diag_write_hex(arg2); | |
| 406 diag_write_char(' '); | |
| 407 diag_write_hex(arg3); | |
| 408 diag_write_char(' '); | |
| 409 diag_write_hex(arg4); | |
| 410 diag_write_char(' '); | |
| 411 diag_write_hex(arg5); | |
| 412 #endif | |
| 413 write_whattracepost( what ); | |
| 414 diag_write_char('\n'); | |
| 415 | |
| 416 DIAG_DEVICE_END_SYNC(); | |
| 417 HAL_RESTORE_INTERRUPTS(old_ints); | |
| 418 }; | |
| 419 | |
| 420 externC void | |
| 421 cyg_tracemsg8( cyg_uint32 what, | |
| 422 char *psz_func, char *psz_file, cyg_uint32 linenum, | |
| 423 char *psz_msg, | |
| 424 CYG_ADDRWORD arg0, CYG_ADDRWORD arg1, | |
| 425 CYG_ADDRWORD arg2, CYG_ADDRWORD arg3, | |
| 426 CYG_ADDRWORD arg4, CYG_ADDRWORD arg5, | |
| 427 CYG_ADDRWORD arg6, CYG_ADDRWORD arg7 ) | |
| 428 { | |
| 429 cyg_uint32 old_ints; | |
| 430 | |
| 431 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 432 DIAG_DEVICE_START_SYNC(); | |
| 433 | |
| 434 if ( NULL == psz_msg ) | |
| 435 psz_msg = "<nomsg>"; | |
| 436 | |
| 437 diag_write_string( "TRACE: " ); | |
| 438 write_thread_id(); | |
| 439 diag_write_string(trim_file(psz_file)); | |
| 440 write_lnum(linenum); | |
| 441 diag_write_string(trim_func(psz_func)); | |
| 442 diag_write_char(' '); | |
| 443 write_whattrace( what ); | |
| 444 #if CYG_DIAG_PRINTF | |
| 445 diag_printf( psz_msg, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 ); | |
| 446 #else | |
| 447 diag_write_string(psz_msg); | |
| 448 diag_write_char(' '); | |
| 449 diag_write_hex(arg0); | |
| 450 diag_write_char(' '); | |
| 451 diag_write_hex(arg1); | |
| 452 diag_write_char(' '); | |
| 453 diag_write_hex(arg2); | |
| 454 diag_write_char(' '); | |
| 455 diag_write_hex(arg3); | |
| 456 diag_write_char(' '); | |
| 457 diag_write_hex(arg4); | |
| 458 diag_write_char(' '); | |
| 459 diag_write_hex(arg5); | |
| 460 diag_write_char(' '); | |
| 461 diag_write_hex(arg6); | |
| 462 diag_write_char(' '); | |
| 463 diag_write_hex(arg7); | |
| 464 #endif | |
| 465 write_whattracepost( what ); | |
| 466 diag_write_char('\n'); | |
| 467 | |
| 468 DIAG_DEVICE_END_SYNC(); | |
| 469 HAL_RESTORE_INTERRUPTS(old_ints); | |
| 470 }; | |
| 471 | |
| 472 #endif // CYGDBG_USE_TRACING | |
| 473 | |
| 474 // ------------------------------------------------------------------------- | |
| 475 // Assert functions: | |
| 476 | |
| 477 #ifdef CYGDBG_USE_ASSERTS | |
| 478 | |
| 479 externC void | |
| 2 | 480 cyg_assert_fail( const char *psz_func, const char *psz_file, |
| 481 cyg_uint32 linenum, const char *psz_msg ) | |
| 0 | 482 { |
| 483 cyg_uint32 old_ints; | |
| 484 | |
| 485 HAL_DISABLE_INTERRUPTS(old_ints); | |
| 486 DIAG_DEVICE_START_SYNC(); | |
| 487 | |
| 488 diag_write_string("ASSERT FAIL: "); | |
| 489 write_thread_id(); | |
| 490 diag_write_string(trim_file(psz_file)); | |
| 491 write_lnum(linenum); | |
| 492 diag_write_string(trim_func(psz_func)); | |
| 493 diag_write_char(' '); | |
| 494 diag_write_string(psz_msg); | |
| 495 diag_write_char('\n'); | |
| 496 | |
| 497 for(;;); | |
| 498 | |
| 499 // DIAG_DEVICE_END_SYNC(); | |
| 500 // HAL_RESTORE_INTERRUPTS(old_ints); | |
| 501 }; | |
| 502 | |
| 503 extern "C" | |
| 504 { | |
| 505 extern unsigned long CYG_LABEL_NAME(stext); | |
| 506 extern unsigned long CYG_LABEL_NAME(etext); | |
| 507 | |
| 508 unsigned long stext_addr = (unsigned long)&CYG_LABEL_NAME(stext); | |
| 509 unsigned long etext_addr = (unsigned long)&CYG_LABEL_NAME(etext); | |
| 510 }; | |
| 511 | |
| 512 externC cyg_bool cyg_check_data_ptr(void *ptr) | |
| 513 { | |
| 514 unsigned long p = (unsigned long)ptr; | |
| 515 | |
| 516 if( p == 0 ) return false; | |
| 517 | |
| 518 if( p > stext_addr && p < etext_addr ) return false; | |
| 519 | |
| 520 return true; | |
| 521 } | |
| 522 | |
| 523 externC cyg_bool cyg_check_func_ptr(void (*ptr)(void)) | |
| 524 { | |
| 525 unsigned long p = (unsigned long)ptr; | |
| 526 | |
| 527 if( p == 0 ) return false; | |
| 528 | |
| 529 if( p < stext_addr && p > etext_addr ) return false; | |
| 530 | |
| 531 return true; | |
| 532 } | |
| 533 | |
| 534 #endif // CYGDBG_USE_ASSERTS | |
| 535 | |
| 536 #endif // CYGDBG_INFRA_DEBUG_TRACE_ASSERT_FANCY | |
| 537 | |
| 538 // ------------------------------------------------------------------------- | |
| 539 // EOF fancy.cxx |
