OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [infra/] [current/] [src/] [buffer.cxx] - Blame information for rev 838

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      buffer.cxx
4
//
5
//      Memory buffered 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:        1998-10-16
45
// Purpose:     Buffered Trace and assert functions
46
// Description: The functions in this file are a buffered implementation
47
//              of the standard trace and assert functions. These store
48
//              trace messages in a memory buffer and emit them when an
49
//              assert is hit, or when requested to.
50
//
51
//####DESCRIPTIONEND####
52
//
53
//==========================================================================
54
 
55
#include <pkgconf/system.h>
56
#include <pkgconf/infra.h>
57
 
58
#ifdef CYGDBG_INFRA_DEBUG_TRACE_ASSERT_BUFFER
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
// these are generally:
80
//      if 0, feature is disabled
81
//      if 1, feature is enabled, printing is default width
82
//      if >1, field is padded up to that width if necessary
83
//              (not truncated ever)
84
 
85
#define CYG_FILENAME    20
86
#define CYG_THREADID    1
87
#define CYG_LINENUM     4
88
#define CYG_FUNCNAME    100
89
#define CYG_DIAG_PRINTF 1
90
#define CYG_FUNC_INDENT 2
91
 
92
#ifndef CYGPKG_KERNEL
93
# undef  CYG_THREADID
94
# define CYG_THREADID 0
95
#endif
96
 
97
#if CYG_FUNCNAME == 1
98
#define CYG_FBUF_SIZE   100
99
#else
100
#define CYG_FBUF_SIZE   (CYG_FUNCNAME+20)
101
#endif
102
 
103
// -------------------------------------------------------------------------
104
// Trace buffer
105
 
106
#ifdef CYGDBG_USE_TRACING
107
 
108
struct Cyg_TraceRecord
109
{
110
    cyg_uint32          what;
111
    cyg_uint32          tid;
112
    const char          *function;
113
    const char          *file;
114
    const char          *message;
115
    cyg_uint32          line;
116
    cyg_uint32          narg;
117
    CYG_ADDRWORD        arg[8];
118
};
119
 
120
Cyg_TraceRecord cyg_infra_trace_buffer[CYGDBG_INFRA_DEBUG_TRACE_BUFFER_SIZE];
121
 
122
static cyg_uint32 cyg_infra_trace_buffer_pos = 0;
123
 
124
static cyg_bool cyg_infra_trace_buffer_enable = true;
125
 
126
static cyg_bool cyg_infra_trace_buffer_wrap = false;
127
 
128
// -------------------------------------------------------------------------
129
// Functions to trim file names and function names down to printable lengths
130
// (these are shared between trace and assert functions)
131
 
132
#if 0
133
static char * tracepremsgs[] = {
134
    "  INFO:",
135
    "ENTER :",
136
    "ARGS  :",
137
    "RETURN:",
138
    "bad code"
139
};
140
#endif
141
 
142
static char * tracepremsgs[] = {
143
    "'",
144
    "{{",
145
    "((",
146
    "}}",
147
    "bad code"
148
};
149
 
150
static char * tracepostmsgs[] = {
151
    "'",
152
    "",
153
    "))",
154
    "",
155
    "bad code"
156
};
157
 
158
static void
159
write_whattrace( cyg_uint32 what )
160
{
161
#if CYG_FUNC_INDENT
162
    static cyg_int32 cyg_indent = 0;
163
    if ( 3 == what )
164
        cyg_indent -= CYG_FUNC_INDENT;
165
    cyg_int32 i = cyg_indent;
166
    for ( ; i > 0; i-- )
167
        diag_write_string( " " );
168
#endif // CYG_FUNC_INDENT
169
    diag_write_string( tracepremsgs[ what > 4 ? 4 : what ] );
170
#if CYG_FUNC_INDENT
171
    if ( 1 == what )
172
        cyg_indent += CYG_FUNC_INDENT;
173
#endif // CYG_FUNC_INDENT
174
}
175
 
176
static void
177
write_whattracepost( cyg_uint32 what )
178
{
179
    diag_write_string( tracepostmsgs[ what > 4 ? 4 : what ] );
180
}
181
 
182
 
183
#endif // CYGDBG_USE_TRACING
184
 
185
// -------------------------------------------------------------------------
186
 
187
#if defined(CYGDBG_USE_TRACING) || defined(CYGDBG_USE_ASSERTS)
188
 
189
static const char *trim_file(const char *file)
190
{
191
#if CYG_FILENAME
192
    if ( NULL == file )
193
        file = "<nofile>";
194
 
195
#if 1 == CYG_FILENAME
196
    const char *f = file;
197
    while( *f ) f++;
198
    while( *f != '/' && f != file ) f--;
199
    return f==file?f:(f+1);
200
#else
201
    static char fbuf2[100];
202
    const char *f = file;
203
    char *g = fbuf2;
204
    while( *f ) f++;
205
    while( *f != '/' && f != file ) f--;
206
    if ( f > file ) f++;
207
    while( *f ) *g++ = *f++;
208
    while( CYG_FILENAME > (g - fbuf2) ) *g++ = ' ';
209
    *g = 0;
210
    return fbuf2;
211
#endif
212
#else
213
    return "";
214
#endif
215
}
216
 
217
static const char *trim_func(const char *func)
218
{
219
#if CYG_FUNCNAME
220
    static char fbuf[CYG_FBUF_SIZE];
221
    cyg_count32 i;
222
 
223
    if ( NULL == func )
224
        func = "<nofunc>";
225
 
226
    for( i = 0; func[i] && func[i] != '(' && i < CYG_FBUF_SIZE-4 ; i++ )
227
        fbuf[i] = func[i];
228
 
229
    fbuf[i++] = '(';
230
    fbuf[i++] = ')';
231
    fbuf[i  ] = 0;
232
    i=0;
233
#if 1 == CYG_FUNCNAME
234
    return &fbuf[i];
235
#else
236
    char *p = &fbuf[i];
237
    while ( *p ) p++;
238
    while ( CYG_FUNCNAME > (p - (&fbuf[i])) ) *p++ = ' ';
239
    *p = 0;
240
    return &fbuf[i];
241
#endif
242
#else
243
    return "";
244
#endif
245
}
246
 
247
static void write_lnum( cyg_uint32 lnum)
248
{
249
#if CYG_LINENUM
250
    diag_write_char('[');
251
#if 1 < CYG_LINENUM
252
    cyg_uint32 i, j;
253
    for ( i = 2, j = 100; i < CYG_LINENUM ; i++, j *= 10 )
254
        if ( lnum < j )
255
            diag_write_char(' ');
256
#endif    
257
    diag_write_dec(lnum);
258
    diag_write_char(']');
259
    diag_write_char(' ');
260
#endif
261
}
262
 
263
#endif // defined(CYGDBG_USE_TRACING) || defined(CYGDBG_USE_ASSERTS)
264
 
265
// -------------------------------------------------------------------------
266
 
267
#if defined(CYGDBG_USE_TRACING) || defined(CYGDBG_USE_ASSERTS)
268
 
269
#if CYG_THREADID
270
static cyg_uint32 get_tid(void)
271
{
272
 
273
    Cyg_Thread *t = Cyg_Thread::self();
274
    cyg_uint16 tid = 0xFFFF;
275
 
276
    if( t != NULL ) tid = t->get_unique_id();
277
 
278
    return tid;
279
}
280
#else
281
# define get_tid() (0xFFFF)
282
#endif
283
 
284
#endif // defined(CYGDBG_USE_TRACING) || defined(CYGDBG_USE_ASSERTS)
285
 
286
#ifdef CYGDBG_USE_ASSERTS
287
static void write_thread_id()
288
{
289
#if CYG_THREADID    
290
    cyg_uint16 tid = get_tid();
291
 
292
    diag_write_char('<');
293
    diag_write_hex(tid);
294
    diag_write_char('>');
295
#endif
296
}
297
#endif
298
 
299
// -------------------------------------------------------------------------
300
// Trace functions:
301
 
302
#ifdef CYGDBG_USE_TRACING
303
 
304
static void print_trace_buffer(void)
305
{
306
    cyg_count32 start = cyg_infra_trace_buffer_pos;
307
    cyg_count32 end = start;
308
    cyg_count32 i;
309
 
310
    // If the buffer has wrapped we want to display the records from
311
    // the current pos and around back to the same place. If the buffer
312
    // has not wrapped, we want to display from the start to pos.
313
 
314
    if( !cyg_infra_trace_buffer_wrap )
315
        start = 0;
316
 
317
    i = start;
318
    do
319
    {
320
        Cyg_TraceRecord *rec = &cyg_infra_trace_buffer[i];
321
        cyg_uint32 old_ints;
322
 
323
        const char *psz_msg = rec->message;
324
 
325
 
326
        HAL_DISABLE_INTERRUPTS(old_ints);
327
        DIAG_DEVICE_START_SYNC();
328
 
329
        if ( NULL == psz_msg )
330
            psz_msg = "<nomsg>";
331
 
332
        diag_write_string( "TRACE: " );
333
#if CYG_THREADID
334
        diag_write_char('<');
335
        diag_write_hex(rec->tid);
336
        diag_write_char('>');
337
#endif        
338
        diag_write_string(trim_file(rec->file));
339
        write_lnum(rec->line);
340
        diag_write_string(trim_func(rec->function));
341
        diag_write_char(' ');
342
        write_whattrace( rec->what );
343
#if CYG_DIAG_PRINTF
344
        diag_printf( psz_msg,
345
                     rec->arg[0], rec->arg[1],
346
                     rec->arg[2], rec->arg[3],
347
                     rec->arg[4], rec->arg[5],
348
                     rec->arg[6], rec->arg[7] );
349
#else
350
        diag_write_string(psz_msg);
351
        diag_write_char(' ');
352
 
353
        for( cyg_count8 j = 0; j < rec->narg ; j++ )
354
        {
355
            diag_write_hex(rec->arg[j]);
356
            diag_write_char(' ');
357
        }
358
#endif    
359
        write_whattracepost( rec->what );
360
        diag_write_char('\n');
361
 
362
        DIAG_DEVICE_END_SYNC();
363
        HAL_RESTORE_INTERRUPTS(old_ints);
364
 
365
        i++;
366
        if( i == CYGDBG_INFRA_DEBUG_TRACE_BUFFER_SIZE )
367
            i = 0;
368
 
369
    } while( i != end );
370
 
371
}
372
 
373
static void increment_buffer_pos()
374
{
375
    cyg_infra_trace_buffer_pos++;
376
 
377
    if( cyg_infra_trace_buffer_pos == CYGDBG_INFRA_DEBUG_TRACE_BUFFER_SIZE )
378
    {
379
#if defined(CYGDBG_INFRA_DEBUG_TRACE_BUFFER_WRAP)
380
        cyg_infra_trace_buffer_pos = 0;
381
        cyg_infra_trace_buffer_wrap = true;
382
#elif defined(CYGDBG_INFRA_DEBUG_TRACE_BUFFER_HALT)
383
        cyg_infra_trace_buffer_enable = false;
384
#elif defined(CYGDBG_INFRA_DEBUG_TRACE_BUFFER_PRINT)
385
        cyg_infra_trace_buffer_pos = 0;
386
        print_trace_buffer();
387
#else
388
#error No trace buffer full mode set
389
#endif
390
    }
391
 
392
}
393
 
394
// -------------------------------------------------------------------------
395
 
396
externC void
397
cyg_tracenomsg( const char *psz_func, const char *psz_file, cyg_uint32 linenum )
398
{
399
    cyg_uint32 old_ints;
400
 
401
    if( !cyg_infra_trace_buffer_enable ) return;
402
 
403
    HAL_DISABLE_INTERRUPTS(old_ints);
404
 
405
    Cyg_TraceRecord *rec = &cyg_infra_trace_buffer[cyg_infra_trace_buffer_pos];
406
 
407
    rec->what           = 0;
408
    rec->tid            = get_tid();
409
    rec->function       = psz_func;
410
    rec->file           = psz_file;
411
    rec->line           = linenum;
412
    rec->message        = 0;
413
    rec->narg           = 0;
414
 
415
    increment_buffer_pos();
416
 
417
    HAL_RESTORE_INTERRUPTS(old_ints);
418
 
419
};
420
 
421
// provide every other one of these as a space/caller bloat compromise.
422
 
423
externC void
424
cyg_tracemsg( cyg_uint32 what,
425
              const char *psz_func, const char *psz_file, cyg_uint32 linenum,
426
              const char *psz_msg )
427
{
428
    cyg_uint32 old_ints;
429
 
430
    if( !cyg_infra_trace_buffer_enable ) return;
431
 
432
    HAL_DISABLE_INTERRUPTS(old_ints);
433
 
434
    Cyg_TraceRecord *rec = &cyg_infra_trace_buffer[cyg_infra_trace_buffer_pos];
435
 
436
    rec->what           = what;
437
    rec->tid            = get_tid();
438
    rec->function       = psz_func;
439
    rec->file           = psz_file;
440
    rec->line           = linenum;
441
    rec->message        = psz_msg;
442
    rec->narg           = 0;
443
 
444
    increment_buffer_pos();
445
 
446
    HAL_RESTORE_INTERRUPTS(old_ints);
447
 
448
};
449
 
450
externC void
451
cyg_tracemsg2( cyg_uint32 what,
452
               const char *psz_func, const char *psz_file, cyg_uint32 linenum,
453
               const char *psz_msg,
454
               CYG_ADDRWORD arg0,  CYG_ADDRWORD arg1 )
455
{
456
    cyg_uint32 old_ints;
457
 
458
    if( !cyg_infra_trace_buffer_enable ) return;
459
 
460
    HAL_DISABLE_INTERRUPTS(old_ints);
461
 
462
    Cyg_TraceRecord *rec = &cyg_infra_trace_buffer[cyg_infra_trace_buffer_pos];
463
 
464
    rec->what           = what;
465
    rec->tid            = get_tid();
466
    rec->function       = psz_func;
467
    rec->file           = psz_file;
468
    rec->line           = linenum;
469
    rec->message        = psz_msg;
470
    rec->narg           = 2;
471
 
472
    rec->arg[0]         = arg0;
473
    rec->arg[1]         = arg1;
474
 
475
    increment_buffer_pos();
476
 
477
    HAL_RESTORE_INTERRUPTS(old_ints);
478
};
479
 
480
externC void
481
cyg_tracemsg4( cyg_uint32 what,
482
               const char *psz_func, const char *psz_file, cyg_uint32 linenum,
483
               const char *psz_msg,
484
               CYG_ADDRWORD arg0,  CYG_ADDRWORD arg1,
485
               CYG_ADDRWORD arg2,  CYG_ADDRWORD arg3 )
486
{
487
    cyg_uint32 old_ints;
488
 
489
    if( !cyg_infra_trace_buffer_enable ) return;
490
 
491
    HAL_DISABLE_INTERRUPTS(old_ints);
492
 
493
    Cyg_TraceRecord *rec = &cyg_infra_trace_buffer[cyg_infra_trace_buffer_pos];
494
 
495
    rec->what           = what;
496
    rec->tid            = get_tid();
497
    rec->function       = psz_func;
498
    rec->file           = psz_file;
499
    rec->line           = linenum;
500
    rec->message        = psz_msg;
501
    rec->narg           = 4;
502
 
503
    rec->arg[0]         = arg0;
504
    rec->arg[1]         = arg1;
505
    rec->arg[2]         = arg2;
506
    rec->arg[3]         = arg3;
507
 
508
    increment_buffer_pos();
509
 
510
    HAL_RESTORE_INTERRUPTS(old_ints);
511
};
512
 
513
externC void
514
cyg_tracemsg6( cyg_uint32 what,
515
               const char *psz_func, const char *psz_file, cyg_uint32 linenum,
516
               const char *psz_msg,
517
               CYG_ADDRWORD arg0,  CYG_ADDRWORD arg1,
518
               CYG_ADDRWORD arg2,  CYG_ADDRWORD arg3,
519
               CYG_ADDRWORD arg4,  CYG_ADDRWORD arg5 )
520
{
521
    cyg_uint32 old_ints;
522
 
523
    if( !cyg_infra_trace_buffer_enable ) return;
524
 
525
    HAL_DISABLE_INTERRUPTS(old_ints);
526
 
527
    Cyg_TraceRecord *rec = &cyg_infra_trace_buffer[cyg_infra_trace_buffer_pos];
528
 
529
    rec->what           = what;
530
    rec->tid            = get_tid();
531
    rec->function       = psz_func;
532
    rec->file           = psz_file;
533
    rec->line           = linenum;
534
    rec->message        = psz_msg;
535
    rec->narg           = 6;
536
 
537
    rec->arg[0]         = arg0;
538
    rec->arg[1]         = arg1;
539
    rec->arg[2]         = arg2;
540
    rec->arg[3]         = arg3;
541
    rec->arg[4]         = arg4;
542
    rec->arg[5]         = arg5;
543
 
544
    increment_buffer_pos();
545
 
546
    HAL_RESTORE_INTERRUPTS(old_ints);
547
};
548
 
549
externC void
550
cyg_tracemsg8( cyg_uint32 what,
551
               const char *psz_func, const char *psz_file, cyg_uint32 linenum,
552
               const char *psz_msg,
553
               CYG_ADDRWORD arg0,  CYG_ADDRWORD arg1,
554
               CYG_ADDRWORD arg2,  CYG_ADDRWORD arg3,
555
               CYG_ADDRWORD arg4,  CYG_ADDRWORD arg5,
556
               CYG_ADDRWORD arg6,  CYG_ADDRWORD arg7 )
557
{
558
    cyg_uint32 old_ints;
559
 
560
    if( !cyg_infra_trace_buffer_enable ) return;
561
 
562
    HAL_DISABLE_INTERRUPTS(old_ints);
563
 
564
    Cyg_TraceRecord *rec = &cyg_infra_trace_buffer[cyg_infra_trace_buffer_pos];
565
 
566
    rec->what           = what;
567
    rec->tid            = get_tid();
568
    rec->function       = psz_func;
569
    rec->file           = psz_file;
570
    rec->line           = linenum;
571
    rec->message        = psz_msg;
572
    rec->narg           = 6;
573
 
574
    rec->arg[0]         = arg0;
575
    rec->arg[1]         = arg1;
576
    rec->arg[2]         = arg2;
577
    rec->arg[3]         = arg3;
578
    rec->arg[4]         = arg4;
579
    rec->arg[5]         = arg5;
580
    rec->arg[6]         = arg6;
581
    rec->arg[7]         = arg7;
582
 
583
    increment_buffer_pos();
584
 
585
    HAL_RESTORE_INTERRUPTS(old_ints);
586
};
587
 
588
// -------------------------------------------------------------------------
589
 
590
externC void
591
cyg_trace_print(void)
592
{
593
    cyg_bool old_enable = cyg_infra_trace_buffer_enable;
594
    cyg_infra_trace_buffer_enable = false;
595
    print_trace_buffer();
596
    cyg_infra_trace_buffer_pos = 0;
597
    cyg_infra_trace_buffer_wrap = false;
598
    cyg_infra_trace_buffer_enable = old_enable;
599
}
600
 
601
 
602
// -------------------------------------------------------------------------
603
 
604
externC void
605
cyg_trace_dump(void)
606
{
607
#if defined(CYGPKG_KERNEL) && defined(CYG_DIAG_PRINTF)
608
 
609
    {
610
        diag_printf("\nScheduler:\n\n");
611
 
612
        Cyg_Scheduler *sched = &Cyg_Scheduler::scheduler;
613
 
614
        diag_printf("Lock:                %d\n",sched->get_sched_lock() );
615
 
616
# ifdef CYGVAR_KERNEL_THREADS_NAME
617
 
618
        diag_printf("Current Thread:      %s\n",sched->get_current_thread()->get_name());
619
 
620
# else
621
 
622
        diag_printf("Current Thread:    %d\n",sched->get_current_thread()->get_unique_id());
623
 
624
# endif
625
 
626
    }
627
 
628
# ifdef CYGVAR_KERNEL_THREADS_LIST
629
 
630
    {
631
        Cyg_Thread *t = Cyg_Thread::get_list_head();
632
 
633
        diag_printf("\nThreads:\n\n");
634
 
635
        while( NULL != t )
636
        {
637
            cyg_uint32 state = t->get_state();
638
            char tstate[7];
639
            char *tstate1 = "SCUKX";
640
            static char *(reasons[8]) =
641
            {
642
                "NONE",                           // No recorded reason
643
                "WAIT",                           // Wait with no timeout
644
                "DELAY",                          // Simple time delay
645
                "TIMEOUT",                        // Wait with timeout/timeout expired
646
                "BREAK",                          // forced break out of sleep
647
                "DESTRUCT",                       // wait object destroyed[note]
648
                "EXIT",                           // forced termination
649
                "DONE"                            // Wait/delay complete
650
            };
651
 
652
            if( 0 != state )
653
            {
654
                // Knock out chars that do not correspond to set bits.
655
                for( int i = 0; i < 6 ; i++ )
656
                    if( 0 == (state & (1<<i)) )
657
                        tstate[i] = ' ';
658
                    else tstate[i] = tstate1[i];
659
                tstate[6] = 0;
660
            }
661
            else tstate[0] = 'R', tstate[1] = 0;
662
 
663
#   ifdef CYGVAR_KERNEL_THREADS_NAME
664
 
665
            diag_printf( "%20s pri = %3d state = %6s id = %3d\n",
666
                         t->get_name(),
667
                         t->get_priority(),
668
                         tstate,
669
                         t->get_unique_id()
670
                );
671
#   else
672
 
673
            diag_printf( "Thread %3d        pri = %3d state = %6s\n",
674
                         t->get_unique_id(),
675
                         t->get_priority(),
676
                         tstate
677
                );
678
 
679
#   endif        
680
            diag_printf( "%20s stack base = %08x ptr = %08x size = %08x\n",
681
                         "",
682
                         t->get_stack_base(),
683
#ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT
684
                         (int) t->get_saved_context(),
685
#else
686
                         0,
687
#endif
688
                         t->get_stack_size()
689
                );
690
 
691
            diag_printf( "%20s sleep reason %8s wake reason %8s\n",
692
                         "",
693
                         reasons[t->get_sleep_reason()],
694
                         reasons[t->get_wake_reason()]
695
                );
696
 
697
            diag_printf( "%20s queue = %08x      wait info = %08x\n",
698
                         "",
699
                         (int) t->get_current_queue(),
700
                         t->get_wait_info()
701
                         );
702
 
703
            diag_printf("\n");
704
            t = t->get_list_next();
705
        }
706
 
707
    }
708
# endif // CYGVAR_KERNEL_THREADS_LIST
709
 
710
#endif // CYG_DIAG_PRINTF
711
}
712
 
713
#endif // CYGDBG_USE_TRACING
714
 
715
// -------------------------------------------------------------------------
716
// Assert functions:
717
 
718
#ifdef CYGDBG_USE_ASSERTS
719
 
720
externC void
721
cyg_assert_fail( const char *psz_func, const char *psz_file,
722
                 cyg_uint32 linenum, const char *psz_msg ) __THROW
723
{
724
    cyg_uint32 old_ints;
725
 
726
    HAL_DISABLE_INTERRUPTS(old_ints);
727
    DIAG_DEVICE_START_SYNC();
728
 
729
    diag_write_string("ASSERT FAIL: ");
730
    write_thread_id();
731
    diag_write_string(trim_file(psz_file));
732
    write_lnum(linenum);
733
    diag_write_string(trim_func(psz_func));
734
    diag_write_char(' ');
735
    diag_write_string(psz_msg);
736
    diag_write_char('\n');
737
 
738
#ifdef CYGDBG_INFRA_DEBUG_TRACE_BUFFER_PRINT_ON_ASSERT
739
 
740
    cyg_trace_print();
741
    cyg_trace_dump();
742
 
743
#endif
744
 
745
#ifdef CYGHWR_TEST_PROGRAM_EXIT
746
    CYGHWR_TEST_PROGRAM_EXIT();
747
#endif
748
    for(;;);
749
 
750
//    DIAG_DEVICE_END_SYNC();
751
//    HAL_RESTORE_INTERRUPTS(old_ints);
752
};
753
 
754
extern "C"
755
{
756
extern unsigned long _stext;
757
extern unsigned long _etext;
758
 
759
unsigned long stext_addr = (unsigned long)&_stext;
760
unsigned long etext_addr = (unsigned long)&_etext;
761
};
762
 
763
externC cyg_bool cyg_check_data_ptr(const void *ptr)
764
{
765
    unsigned long p = (unsigned long)ptr;
766
 
767
    if( p == 0 ) return false;
768
 
769
    if( p > stext_addr && p < etext_addr ) return false;
770
 
771
    return true;
772
}
773
 
774
externC cyg_bool cyg_check_func_ptr(void (*ptr)(void))
775
{
776
    unsigned long p = (unsigned long)ptr;
777
 
778
    if( p == 0 ) return false;
779
 
780
    if( p < stext_addr && p > etext_addr ) return false;
781
 
782
    return true;
783
}
784
 
785
#endif // CYGDBG_USE_ASSERTS
786
 
787
#endif // CYGDBG_INFRA_DEBUG_TRACE_ASSERT_BUFFER
788
 
789
// -------------------------------------------------------------------------
790
// EOF buffer.cxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.