| 1 |
786 |
skrzyp |
//==========================================================================
|
| 2 |
|
|
//
|
| 3 |
|
|
// simple.cxx
|
| 4 |
|
|
//
|
| 5 |
|
|
// Simple, non formatting trace and assert functions
|
| 6 |
|
|
//
|
| 7 |
|
|
//==========================================================================
|
| 8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
| 9 |
|
|
// -------------------------------------------
|
| 10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
| 11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
| 12 |
|
|
//
|
| 13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
| 14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
| 15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
| 16 |
|
|
// version.
|
| 17 |
|
|
//
|
| 18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
| 19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 21 |
|
|
// for more details.
|
| 22 |
|
|
//
|
| 23 |
|
|
// You should have received a copy of the GNU General Public License
|
| 24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
| 25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 26 |
|
|
//
|
| 27 |
|
|
// As a special exception, if other files instantiate templates or use
|
| 28 |
|
|
// macros or inline functions from this file, or you compile this file
|
| 29 |
|
|
// and link it with other works to produce a work based on this file,
|
| 30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
| 31 |
|
|
// the GNU General Public License. However the source code for this file
|
| 32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
| 33 |
|
|
// General Public License v2.
|
| 34 |
|
|
//
|
| 35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
| 36 |
|
|
// on this file might be covered by the GNU General Public License.
|
| 37 |
|
|
// -------------------------------------------
|
| 38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
| 39 |
|
|
//==========================================================================
|
| 40 |
|
|
//#####DESCRIPTIONBEGIN####
|
| 41 |
|
|
//
|
| 42 |
|
|
// Author(s): nickg
|
| 43 |
|
|
// Contributors: nickg
|
| 44 |
|
|
// Date: 1997-12-04
|
| 45 |
|
|
// Purpose: Simple Trace and assert functions
|
| 46 |
|
|
// Description: The functions in this file are simple implementations
|
| 47 |
|
|
// of the standard trace and assert functions. These do not
|
| 48 |
|
|
// do any printf style formatting, simply printing the string
|
| 49 |
|
|
// and arguments directly.
|
| 50 |
|
|
//
|
| 51 |
|
|
//####DESCRIPTIONEND####
|
| 52 |
|
|
//
|
| 53 |
|
|
//==========================================================================
|
| 54 |
|
|
|
| 55 |
|
|
#include <pkgconf/system.h>
|
| 56 |
|
|
#include <pkgconf/infra.h>
|
| 57 |
|
|
|
| 58 |
|
|
#ifdef CYGDBG_INFRA_DEBUG_TRACE_ASSERT_SIMPLE
|
| 59 |
|
|
|
| 60 |
|
|
#include <cyg/infra/cyg_type.h> // base types
|
| 61 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
| 62 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
| 63 |
|
|
|
| 64 |
|
|
#include <pkgconf/hal.h> // HAL configury
|
| 65 |
|
|
#include <cyg/infra/diag.h> // HAL polled output
|
| 66 |
|
|
#include <cyg/hal/hal_arch.h> // architectural stuff for...
|
| 67 |
|
|
#include <cyg/hal/hal_intr.h> // interrupt control
|
| 68 |
|
|
|
| 69 |
|
|
#ifdef CYGPKG_KERNEL
|
| 70 |
|
|
#include <pkgconf/kernel.h> // kernel configury
|
| 71 |
|
|
#include <cyg/kernel/thread.hxx> // thread id to print
|
| 72 |
|
|
#include <cyg/kernel/sched.hxx> // ancillaries for above
|
| 73 |
|
|
#include <cyg/kernel/thread.inl> // ancillaries for above
|
| 74 |
|
|
#endif
|
| 75 |
|
|
|
| 76 |
|
|
// -------------------------------------------------------------------------
|
| 77 |
|
|
// Local Configuration: hack me!
|
| 78 |
|
|
|
| 79 |
|
|
#define CYG_NO_FILENAME 1
|
| 80 |
|
|
#define CYG_NO_THREADID 0
|
| 81 |
|
|
#define CYG_NO_LINENUM 0
|
| 82 |
|
|
#define CYG_NO_FUNCNAME 0
|
| 83 |
|
|
#define CYG_DIAG_PRINTF 1
|
| 84 |
|
|
|
| 85 |
|
|
#ifndef CYGPKG_KERNEL
|
| 86 |
|
|
# undef CYG_NO_THREADID
|
| 87 |
|
|
# define CYG_NO_THREADID 1
|
| 88 |
|
|
#endif
|
| 89 |
|
|
// -------------------------------------------------------------------------
|
| 90 |
|
|
// Functions to trim file names and function names down to printable lengths
|
| 91 |
|
|
// (these are shared between trace and assert functions)
|
| 92 |
|
|
|
| 93 |
|
|
static const char *trim_file(const char *file)
|
| 94 |
|
|
{
|
| 95 |
|
|
#if !CYG_NO_FILENAME
|
| 96 |
|
|
if ( NULL == file )
|
| 97 |
|
|
file = "<nofile>";
|
| 98 |
|
|
|
| 99 |
|
|
const char *f = file;
|
| 100 |
|
|
|
| 101 |
|
|
while( *f ) f++;
|
| 102 |
|
|
|
| 103 |
|
|
while( *f != '/' && f != file ) f--;
|
| 104 |
|
|
|
| 105 |
|
|
return f==file?f:(f+1);
|
| 106 |
|
|
#else
|
| 107 |
|
|
return "";
|
| 108 |
|
|
#endif
|
| 109 |
|
|
}
|
| 110 |
|
|
|
| 111 |
|
|
static const char *trim_func(const char *func)
|
| 112 |
|
|
{
|
| 113 |
|
|
#if !CYG_NO_FUNCNAME
|
| 114 |
|
|
|
| 115 |
|
|
static char fbuf[100];
|
| 116 |
|
|
int i;
|
| 117 |
|
|
|
| 118 |
|
|
if ( NULL == func )
|
| 119 |
|
|
func = "<nofunc>";
|
| 120 |
|
|
|
| 121 |
|
|
for( i = 0; func[i] && func[i] != '(' ; i++ )
|
| 122 |
|
|
fbuf[i] = func[i];
|
| 123 |
|
|
|
| 124 |
|
|
fbuf[i++] = '(';
|
| 125 |
|
|
fbuf[i++] = ')';
|
| 126 |
|
|
fbuf[i ] = 0;
|
| 127 |
|
|
|
| 128 |
|
|
return &fbuf[0];
|
| 129 |
|
|
#else
|
| 130 |
|
|
return "";
|
| 131 |
|
|
#endif
|
| 132 |
|
|
}
|
| 133 |
|
|
|
| 134 |
|
|
void write_lnum( cyg_uint32 lnum)
|
| 135 |
|
|
{
|
| 136 |
|
|
#if !CYG_NO_LINENUM
|
| 137 |
|
|
diag_write_char('[');
|
| 138 |
|
|
diag_write_dec(lnum);
|
| 139 |
|
|
diag_write_char(']');
|
| 140 |
|
|
#endif
|
| 141 |
|
|
}
|
| 142 |
|
|
|
| 143 |
|
|
void write_thread_id()
|
| 144 |
|
|
{
|
| 145 |
|
|
#if !CYG_NO_THREADID
|
| 146 |
|
|
Cyg_Thread *t = Cyg_Thread::self();
|
| 147 |
|
|
cyg_uint16 tid = 0xFFFF;
|
| 148 |
|
|
|
| 149 |
|
|
if( t != NULL ) tid = t->get_unique_id();
|
| 150 |
|
|
|
| 151 |
|
|
diag_write_char('<');
|
| 152 |
|
|
diag_write_hex(tid);
|
| 153 |
|
|
diag_write_char('>');
|
| 154 |
|
|
#endif
|
| 155 |
|
|
}
|
| 156 |
|
|
|
| 157 |
|
|
|
| 158 |
|
|
// -------------------------------------------------------------------------
|
| 159 |
|
|
// Trace functions:
|
| 160 |
|
|
|
| 161 |
|
|
#ifdef CYGDBG_USE_TRACING
|
| 162 |
|
|
|
| 163 |
|
|
externC void
|
| 164 |
|
|
cyg_tracenomsg( const char *psz_func, const char *psz_file, cyg_uint32 linenum )
|
| 165 |
|
|
{
|
| 166 |
|
|
cyg_uint32 old_ints;
|
| 167 |
|
|
|
| 168 |
|
|
HAL_DISABLE_INTERRUPTS(old_ints);
|
| 169 |
|
|
DIAG_DEVICE_START_SYNC();
|
| 170 |
|
|
|
| 171 |
|
|
diag_write_string("TRACE: ");
|
| 172 |
|
|
write_thread_id();
|
| 173 |
|
|
diag_write_string(trim_file(psz_file));
|
| 174 |
|
|
write_lnum(linenum);
|
| 175 |
|
|
diag_write_string(trim_func(psz_func));
|
| 176 |
|
|
diag_write_char('\n');
|
| 177 |
|
|
|
| 178 |
|
|
DIAG_DEVICE_END_SYNC();
|
| 179 |
|
|
HAL_RESTORE_INTERRUPTS(old_ints);
|
| 180 |
|
|
|
| 181 |
|
|
};
|
| 182 |
|
|
|
| 183 |
|
|
// provide every other one of these as a space/caller bloat compromise.
|
| 184 |
|
|
|
| 185 |
|
|
externC void
|
| 186 |
|
|
cyg_tracemsg( cyg_uint32 what,
|
| 187 |
|
|
const char *psz_func, const char *psz_file, cyg_uint32 linenum,
|
| 188 |
|
|
const char *psz_msg )
|
| 189 |
|
|
{
|
| 190 |
|
|
cyg_uint32 old_ints;
|
| 191 |
|
|
|
| 192 |
|
|
HAL_DISABLE_INTERRUPTS(old_ints);
|
| 193 |
|
|
DIAG_DEVICE_START_SYNC();
|
| 194 |
|
|
|
| 195 |
|
|
if ( NULL == psz_msg )
|
| 196 |
|
|
psz_msg = "<nomsg>";
|
| 197 |
|
|
|
| 198 |
|
|
diag_write_string("TRACE: ");
|
| 199 |
|
|
write_thread_id();
|
| 200 |
|
|
diag_write_string(trim_file(psz_file));
|
| 201 |
|
|
write_lnum(linenum);
|
| 202 |
|
|
diag_write_string(trim_func(psz_func));
|
| 203 |
|
|
diag_write_char(' ');
|
| 204 |
|
|
diag_write_string(psz_msg);
|
| 205 |
|
|
diag_write_char('\n');
|
| 206 |
|
|
|
| 207 |
|
|
DIAG_DEVICE_END_SYNC();
|
| 208 |
|
|
HAL_RESTORE_INTERRUPTS(old_ints);
|
| 209 |
|
|
|
| 210 |
|
|
};
|
| 211 |
|
|
|
| 212 |
|
|
externC void
|
| 213 |
|
|
cyg_tracemsg2( cyg_uint32 what,
|
| 214 |
|
|
const char *psz_func, const char *psz_file, cyg_uint32 linenum,
|
| 215 |
|
|
const char *psz_msg,
|
| 216 |
|
|
CYG_ADDRWORD arg0, CYG_ADDRWORD arg1 )
|
| 217 |
|
|
{
|
| 218 |
|
|
cyg_uint32 old_ints;
|
| 219 |
|
|
|
| 220 |
|
|
HAL_DISABLE_INTERRUPTS(old_ints);
|
| 221 |
|
|
DIAG_DEVICE_START_SYNC();
|
| 222 |
|
|
|
| 223 |
|
|
if ( NULL == psz_msg )
|
| 224 |
|
|
psz_msg = "<nomsg>";
|
| 225 |
|
|
|
| 226 |
|
|
diag_write_string("TRACE: ");
|
| 227 |
|
|
write_thread_id();
|
| 228 |
|
|
diag_write_string(trim_file(psz_file));
|
| 229 |
|
|
write_lnum(linenum);
|
| 230 |
|
|
diag_write_string(trim_func(psz_func));
|
| 231 |
|
|
diag_write_char(' ');
|
| 232 |
|
|
#if CYG_DIAG_PRINTF
|
| 233 |
|
|
diag_printf( psz_msg, arg0, arg1 );
|
| 234 |
|
|
#else
|
| 235 |
|
|
diag_write_string(psz_msg);
|
| 236 |
|
|
diag_write_char(' ');
|
| 237 |
|
|
diag_write_hex(arg0);
|
| 238 |
|
|
diag_write_char(' ');
|
| 239 |
|
|
diag_write_hex(arg1);
|
| 240 |
|
|
#endif
|
| 241 |
|
|
diag_write_char('\n');
|
| 242 |
|
|
DIAG_DEVICE_END_SYNC();
|
| 243 |
|
|
HAL_RESTORE_INTERRUPTS(old_ints);
|
| 244 |
|
|
};
|
| 245 |
|
|
|
| 246 |
|
|
externC void
|
| 247 |
|
|
cyg_tracemsg4( cyg_uint32 what,
|
| 248 |
|
|
const char *psz_func, const char *psz_file, cyg_uint32 linenum,
|
| 249 |
|
|
const char *psz_msg,
|
| 250 |
|
|
CYG_ADDRWORD arg0, CYG_ADDRWORD arg1,
|
| 251 |
|
|
CYG_ADDRWORD arg2, CYG_ADDRWORD arg3 )
|
| 252 |
|
|
{
|
| 253 |
|
|
cyg_uint32 old_ints;
|
| 254 |
|
|
|
| 255 |
|
|
HAL_DISABLE_INTERRUPTS(old_ints);
|
| 256 |
|
|
DIAG_DEVICE_START_SYNC();
|
| 257 |
|
|
|
| 258 |
|
|
if ( NULL == psz_msg )
|
| 259 |
|
|
psz_msg = "<nomsg>";
|
| 260 |
|
|
|
| 261 |
|
|
diag_write_string("TRACE: ");
|
| 262 |
|
|
write_thread_id();
|
| 263 |
|
|
diag_write_string(trim_file(psz_file));
|
| 264 |
|
|
write_lnum(linenum);
|
| 265 |
|
|
diag_write_string(trim_func(psz_func));
|
| 266 |
|
|
diag_write_char(' ');
|
| 267 |
|
|
#if CYG_DIAG_PRINTF
|
| 268 |
|
|
diag_printf( psz_msg, arg0, arg1, arg2, arg3 );
|
| 269 |
|
|
#else
|
| 270 |
|
|
diag_write_string(psz_msg);
|
| 271 |
|
|
diag_write_char(' ');
|
| 272 |
|
|
diag_write_hex(arg0);
|
| 273 |
|
|
diag_write_char(' ');
|
| 274 |
|
|
diag_write_hex(arg1);
|
| 275 |
|
|
diag_write_char(' ');
|
| 276 |
|
|
diag_write_hex(arg2);
|
| 277 |
|
|
diag_write_char(' ');
|
| 278 |
|
|
diag_write_hex(arg3);
|
| 279 |
|
|
#endif
|
| 280 |
|
|
diag_write_char('\n');
|
| 281 |
|
|
|
| 282 |
|
|
DIAG_DEVICE_END_SYNC();
|
| 283 |
|
|
HAL_RESTORE_INTERRUPTS(old_ints);
|
| 284 |
|
|
};
|
| 285 |
|
|
|
| 286 |
|
|
externC void
|
| 287 |
|
|
cyg_tracemsg6( cyg_uint32 what,
|
| 288 |
|
|
const char *psz_func, const char *psz_file, cyg_uint32 linenum,
|
| 289 |
|
|
const char *psz_msg,
|
| 290 |
|
|
CYG_ADDRWORD arg0, CYG_ADDRWORD arg1,
|
| 291 |
|
|
CYG_ADDRWORD arg2, CYG_ADDRWORD arg3,
|
| 292 |
|
|
CYG_ADDRWORD arg4, CYG_ADDRWORD arg5 )
|
| 293 |
|
|
{
|
| 294 |
|
|
cyg_uint32 old_ints;
|
| 295 |
|
|
|
| 296 |
|
|
HAL_DISABLE_INTERRUPTS(old_ints);
|
| 297 |
|
|
DIAG_DEVICE_START_SYNC();
|
| 298 |
|
|
|
| 299 |
|
|
if ( NULL == psz_msg )
|
| 300 |
|
|
psz_msg = "<nomsg>";
|
| 301 |
|
|
|
| 302 |
|
|
diag_write_string("TRACE: ");
|
| 303 |
|
|
write_thread_id();
|
| 304 |
|
|
diag_write_string(trim_file(psz_file));
|
| 305 |
|
|
write_lnum(linenum);
|
| 306 |
|
|
diag_write_string(trim_func(psz_func));
|
| 307 |
|
|
diag_write_char(' ');
|
| 308 |
|
|
#if CYG_DIAG_PRINTF
|
| 309 |
|
|
diag_printf( psz_msg, arg0, arg1, arg2, arg3, arg4, arg5 );
|
| 310 |
|
|
#else
|
| 311 |
|
|
diag_write_string(psz_msg);
|
| 312 |
|
|
diag_write_char(' ');
|
| 313 |
|
|
diag_write_hex(arg0);
|
| 314 |
|
|
diag_write_char(' ');
|
| 315 |
|
|
diag_write_hex(arg1);
|
| 316 |
|
|
diag_write_char(' ');
|
| 317 |
|
|
diag_write_hex(arg2);
|
| 318 |
|
|
diag_write_char(' ');
|
| 319 |
|
|
diag_write_hex(arg3);
|
| 320 |
|
|
diag_write_char(' ');
|
| 321 |
|
|
diag_write_hex(arg4);
|
| 322 |
|
|
diag_write_char(' ');
|
| 323 |
|
|
diag_write_hex(arg5);
|
| 324 |
|
|
#endif
|
| 325 |
|
|
diag_write_char('\n');
|
| 326 |
|
|
|
| 327 |
|
|
DIAG_DEVICE_END_SYNC();
|
| 328 |
|
|
HAL_RESTORE_INTERRUPTS(old_ints);
|
| 329 |
|
|
};
|
| 330 |
|
|
|
| 331 |
|
|
externC void
|
| 332 |
|
|
cyg_tracemsg8( cyg_uint32 what,
|
| 333 |
|
|
const char *psz_func, const char *psz_file, cyg_uint32 linenum,
|
| 334 |
|
|
const char *psz_msg,
|
| 335 |
|
|
CYG_ADDRWORD arg0, CYG_ADDRWORD arg1,
|
| 336 |
|
|
CYG_ADDRWORD arg2, CYG_ADDRWORD arg3,
|
| 337 |
|
|
CYG_ADDRWORD arg4, CYG_ADDRWORD arg5,
|
| 338 |
|
|
CYG_ADDRWORD arg6, CYG_ADDRWORD arg7 )
|
| 339 |
|
|
{
|
| 340 |
|
|
cyg_uint32 old_ints;
|
| 341 |
|
|
|
| 342 |
|
|
HAL_DISABLE_INTERRUPTS(old_ints);
|
| 343 |
|
|
DIAG_DEVICE_START_SYNC();
|
| 344 |
|
|
|
| 345 |
|
|
if ( NULL == psz_msg )
|
| 346 |
|
|
psz_msg = "<nomsg>";
|
| 347 |
|
|
|
| 348 |
|
|
diag_write_string("TRACE: ");
|
| 349 |
|
|
write_thread_id();
|
| 350 |
|
|
diag_write_string(trim_file(psz_file));
|
| 351 |
|
|
write_lnum(linenum);
|
| 352 |
|
|
diag_write_string(trim_func(psz_func));
|
| 353 |
|
|
diag_write_char(' ');
|
| 354 |
|
|
#if CYG_DIAG_PRINTF
|
| 355 |
|
|
diag_printf( psz_msg, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 );
|
| 356 |
|
|
#else
|
| 357 |
|
|
diag_write_string(psz_msg);
|
| 358 |
|
|
diag_write_char(' ');
|
| 359 |
|
|
diag_write_hex(arg0);
|
| 360 |
|
|
diag_write_char(' ');
|
| 361 |
|
|
diag_write_hex(arg1);
|
| 362 |
|
|
diag_write_char(' ');
|
| 363 |
|
|
diag_write_hex(arg2);
|
| 364 |
|
|
diag_write_char(' ');
|
| 365 |
|
|
diag_write_hex(arg3);
|
| 366 |
|
|
diag_write_char(' ');
|
| 367 |
|
|
diag_write_hex(arg4);
|
| 368 |
|
|
diag_write_char(' ');
|
| 369 |
|
|
diag_write_hex(arg5);
|
| 370 |
|
|
diag_write_char(' ');
|
| 371 |
|
|
diag_write_hex(arg6);
|
| 372 |
|
|
diag_write_char(' ');
|
| 373 |
|
|
diag_write_hex(arg7);
|
| 374 |
|
|
#endif
|
| 375 |
|
|
diag_write_char('\n');
|
| 376 |
|
|
|
| 377 |
|
|
DIAG_DEVICE_END_SYNC();
|
| 378 |
|
|
HAL_RESTORE_INTERRUPTS(old_ints);
|
| 379 |
|
|
};
|
| 380 |
|
|
|
| 381 |
|
|
// -------------------------------------------------------------------------
|
| 382 |
|
|
|
| 383 |
|
|
externC void
|
| 384 |
|
|
cyg_trace_dump(void)
|
| 385 |
|
|
{
|
| 386 |
|
|
#if defined(CYGPKG_KERNEL) && defined(CYG_DIAG_PRINTF)
|
| 387 |
|
|
|
| 388 |
|
|
{
|
| 389 |
|
|
diag_printf("\nScheduler:\n\n");
|
| 390 |
|
|
|
| 391 |
|
|
Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
|
| 392 |
|
|
|
| 393 |
|
|
diag_printf("Lock: %d\n",sched->get_sched_lock() );
|
| 394 |
|
|
|
| 395 |
|
|
# ifdef CYGVAR_KERNEL_THREADS_NAME
|
| 396 |
|
|
|
| 397 |
|
|
diag_printf("Current Thread: %s\n",sched->get_current_thread()->get_name());
|
| 398 |
|
|
|
| 399 |
|
|
# else
|
| 400 |
|
|
|
| 401 |
|
|
diag_printf("Current Thread: %d\n",sched->get_current_thread()->get_unique_id());
|
| 402 |
|
|
|
| 403 |
|
|
# endif
|
| 404 |
|
|
|
| 405 |
|
|
}
|
| 406 |
|
|
|
| 407 |
|
|
# ifdef CYGVAR_KERNEL_THREADS_LIST
|
| 408 |
|
|
|
| 409 |
|
|
{
|
| 410 |
|
|
Cyg_Thread *t = Cyg_Thread::get_list_head();
|
| 411 |
|
|
|
| 412 |
|
|
diag_printf("\nThreads:\n\n");
|
| 413 |
|
|
|
| 414 |
|
|
while( NULL != t )
|
| 415 |
|
|
{
|
| 416 |
|
|
cyg_uint32 state = t->get_state();
|
| 417 |
|
|
char tstate[7];
|
| 418 |
|
|
char *tstate1 = "SCUKX";
|
| 419 |
|
|
static char *(reasons[8]) =
|
| 420 |
|
|
{
|
| 421 |
|
|
"NONE", // No recorded reason
|
| 422 |
|
|
"WAIT", // Wait with no timeout
|
| 423 |
|
|
"DELAY", // Simple time delay
|
| 424 |
|
|
"TIMEOUT", // Wait with timeout/timeout expired
|
| 425 |
|
|
"BREAK", // forced break out of sleep
|
| 426 |
|
|
"DESTRUCT", // wait object destroyed[note]
|
| 427 |
|
|
"EXIT", // forced termination
|
| 428 |
|
|
"DONE" // Wait/delay complete
|
| 429 |
|
|
};
|
| 430 |
|
|
|
| 431 |
|
|
if( 0 != state )
|
| 432 |
|
|
{
|
| 433 |
|
|
// Knock out chars that do not correspond to set bits.
|
| 434 |
|
|
for( int i = 0; i < 6 ; i++ )
|
| 435 |
|
|
if( 0 == (state & (1<<i)) )
|
| 436 |
|
|
tstate[i] = ' ';
|
| 437 |
|
|
else tstate[i] = tstate1[i];
|
| 438 |
|
|
tstate[6] = 0;
|
| 439 |
|
|
}
|
| 440 |
|
|
else tstate[0] = 'R', tstate[1] = 0;
|
| 441 |
|
|
|
| 442 |
|
|
# ifdef CYGVAR_KERNEL_THREADS_NAME
|
| 443 |
|
|
|
| 444 |
|
|
diag_printf( "%20s pri = %3d state = %6s id = %3d\n",
|
| 445 |
|
|
t->get_name(),
|
| 446 |
|
|
t->get_priority(),
|
| 447 |
|
|
tstate,
|
| 448 |
|
|
t->get_unique_id()
|
| 449 |
|
|
);
|
| 450 |
|
|
# else
|
| 451 |
|
|
|
| 452 |
|
|
diag_printf( "Thread %3d pri = %3d state = %6s\n",
|
| 453 |
|
|
t->get_unique_id(),
|
| 454 |
|
|
t->get_priority(),
|
| 455 |
|
|
tstate
|
| 456 |
|
|
);
|
| 457 |
|
|
|
| 458 |
|
|
# endif
|
| 459 |
|
|
diag_printf( "%20s stack base = %08x ptr = %08x size = %08x\n",
|
| 460 |
|
|
"",
|
| 461 |
|
|
t->get_stack_base(),
|
| 462 |
|
|
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
|
| 463 |
|
|
t->get_saved_context(),
|
| 464 |
|
|
#else
|
| 465 |
|
|
0,
|
| 466 |
|
|
#endif
|
| 467 |
|
|
t->get_stack_size()
|
| 468 |
|
|
);
|
| 469 |
|
|
|
| 470 |
|
|
diag_printf( "%20s sleep reason %8s wake reason %8s\n",
|
| 471 |
|
|
"",
|
| 472 |
|
|
reasons[t->get_sleep_reason()],
|
| 473 |
|
|
reasons[t->get_wake_reason()]
|
| 474 |
|
|
);
|
| 475 |
|
|
|
| 476 |
|
|
diag_printf( "%20s queue = %08x wait info = %08x\n",
|
| 477 |
|
|
"",
|
| 478 |
|
|
t->get_current_queue(),
|
| 479 |
|
|
t->get_wait_info()
|
| 480 |
|
|
);
|
| 481 |
|
|
|
| 482 |
|
|
diag_printf("\n");
|
| 483 |
|
|
t = t->get_list_next();
|
| 484 |
|
|
}
|
| 485 |
|
|
|
| 486 |
|
|
}
|
| 487 |
|
|
# endif // CYGVAR_KERNEL_THREADS_LIST
|
| 488 |
|
|
|
| 489 |
|
|
#endif // CYG_DIAG_PRINTF
|
| 490 |
|
|
}
|
| 491 |
|
|
|
| 492 |
|
|
#endif // CYGDBG_USE_TRACING
|
| 493 |
|
|
|
| 494 |
|
|
// -------------------------------------------------------------------------
|
| 495 |
|
|
// Assert functions:
|
| 496 |
|
|
|
| 497 |
|
|
#ifdef CYGDBG_USE_ASSERTS
|
| 498 |
|
|
|
| 499 |
|
|
externC void
|
| 500 |
|
|
cyg_assert_fail( const char *psz_func, const char *psz_file,
|
| 501 |
|
|
cyg_uint32 linenum, const char *psz_msg ) __THROW
|
| 502 |
|
|
{
|
| 503 |
|
|
cyg_uint32 old_ints;
|
| 504 |
|
|
|
| 505 |
|
|
HAL_DISABLE_INTERRUPTS(old_ints);
|
| 506 |
|
|
DIAG_DEVICE_START_SYNC();
|
| 507 |
|
|
|
| 508 |
|
|
diag_write_string("ASSERT FAIL: ");
|
| 509 |
|
|
write_thread_id();
|
| 510 |
|
|
diag_write_string(trim_file(psz_file));
|
| 511 |
|
|
write_lnum(linenum);
|
| 512 |
|
|
diag_write_string(trim_func(psz_func));
|
| 513 |
|
|
diag_write_char(' ');
|
| 514 |
|
|
diag_write_string(psz_msg);
|
| 515 |
|
|
diag_write_char('\n');
|
| 516 |
|
|
|
| 517 |
|
|
#ifdef CYGHWR_TEST_PROGRAM_EXIT
|
| 518 |
|
|
CYGHWR_TEST_PROGRAM_EXIT();
|
| 519 |
|
|
#endif
|
| 520 |
|
|
for(;;);
|
| 521 |
|
|
|
| 522 |
|
|
// DIAG_DEVICE_END_SYNC();
|
| 523 |
|
|
// HAL_RESTORE_INTERRUPTS(old_ints);
|
| 524 |
|
|
};
|
| 525 |
|
|
|
| 526 |
|
|
extern "C"
|
| 527 |
|
|
{
|
| 528 |
|
|
extern unsigned long _stext;
|
| 529 |
|
|
extern unsigned long _etext;
|
| 530 |
|
|
|
| 531 |
|
|
unsigned long stext_addr = (unsigned long)&_stext;
|
| 532 |
|
|
unsigned long etext_addr = (unsigned long)&_etext;
|
| 533 |
|
|
};
|
| 534 |
|
|
|
| 535 |
|
|
externC cyg_bool cyg_check_data_ptr(const void *ptr)
|
| 536 |
|
|
{
|
| 537 |
|
|
unsigned long p = (unsigned long)ptr;
|
| 538 |
|
|
|
| 539 |
|
|
if( p == 0 ) return false;
|
| 540 |
|
|
|
| 541 |
|
|
if( p > stext_addr && p < etext_addr ) return false;
|
| 542 |
|
|
|
| 543 |
|
|
return true;
|
| 544 |
|
|
}
|
| 545 |
|
|
|
| 546 |
|
|
externC cyg_bool cyg_check_func_ptr(void (*ptr)(void))
|
| 547 |
|
|
{
|
| 548 |
|
|
unsigned long p = (unsigned long)ptr;
|
| 549 |
|
|
|
| 550 |
|
|
if( p == 0 ) return false;
|
| 551 |
|
|
|
| 552 |
|
|
if( p < stext_addr && p > etext_addr ) return false;
|
| 553 |
|
|
|
| 554 |
|
|
return true;
|
| 555 |
|
|
}
|
| 556 |
|
|
|
| 557 |
|
|
#endif // CYGDBG_USE_ASSERTS
|
| 558 |
|
|
|
| 559 |
|
|
#endif // CYGDBG_INFRA_DEBUG_TRACE_ASSERT_SIMPLE
|
| 560 |
|
|
|
| 561 |
|
|
// -------------------------------------------------------------------------
|
| 562 |
|
|
// EOF simple.cxx
|