source: rtems/c/src/lib/libcpu/powerpc/shared/src/stack.c @ 73b5bd5d

4.104.114.84.95
Last change on this file since 73b5bd5d was d49389a, checked in by Joel Sherrill <joel.sherrill@…>, on 02/20/03 at 22:07:22

2003-02-20 Till Straumann <strauman@…>

PR 349/bsps

  • mpc6xx/exceptions/raw_exception.c, mpc6xx/mmu/bat.c, mpc6xx/mmu/pte121.c, shared/include/cpuIdent.c, shared/include/cpuIdent.h, shared/src/Makefile.am, shared/src/stack.c, shared/src/stackTrace.h, powerpc/registers.h:
    • undo improper 'fix' who broke mpc604r identification
    • fix: 7400 identification PVR value was wrong
    • enhance 'setdbat()' to switch OFF a given BAT if called with 0 size
    • fix: page table support bugfix
    • enhancement: provide routines to take and print stack trace snapshots
    • add definitions for HID1 and DABR SPRs
  • Property mode set to 100644
File size: 905 bytes
Line 
1#include "stackTrace.h"
2#include <rtems/bspIo.h>
3#include <libcpu/spr.h>
4
5SPR_RO(LR)
6
7typedef struct FrameRec_ {
8        struct FrameRec_ *up;
9        void             *lr;
10} FrameRec, *Frame;
11
12#define CPU_STACK_TRACE_DEPTH 40
13
14void CPU_stack_take_snapshot(void **stack, int size, void *pc, void *lr, void *r1)
15{
16register Frame  p = (Frame)lr;
17register int    i=0;
18        if (pc) stack[i++]=pc;
19        if (!p)
20                p = (Frame)_read_LR();
21        stack[i++]=p;
22        p = r1;
23        if (!p) /* no macro for reading user regs */
24                __asm__ __volatile__("mr %0, %%r1":"=r"(p));
25        for (; i<size-1 && p->up; p=p->up, i++) {
26                stack[i]=p->up->lr;
27        }
28        stack[i]=0;
29}
30
31void CPU_print_stack(void)
32{
33        void *stck[CPU_STACK_TRACE_DEPTH];
34        int i;
35        CPU_stack_take_snapshot(stck,CPU_STACK_TRACE_DEPTH,0,0,0);
36        for (i=0; stck[i]; i++) {
37                if (i%5) printk("--> ");
38                else     printk("\n");
39                printk("0x%08x",stck[i]);
40        }
41        printk("\n");
42}
Note: See TracBrowser for help on using the repository browser.