source: rtems/c/src/lib/libcpu/powerpc/shared/src/stack.c @ 1d367a49

4.11
Last change on this file since 1d367a49 was 1d367a49, checked in by Sebastian Huber <sebastian.huber@…>, on Aug 24, 2011 at 9:45:20 AM

2011-08-24 Sebastian Huber <sebastian.huber@…>

  • mpc6xx/clock/c_clock.c, mpc6xx/mmu/mmuAsm.S, new-exceptions/bspsupport/ppc_exc_global_handler.c, shared/include/cpuIdent.c, shared/src/stack.c: Update due to API changes.
  • Property mode set to 100644
File size: 913 bytes
Line 
1#include "stackTrace.h"
2#include <rtems/bspIo.h>
3#include <libcpu/spr.h>
4
5SPR_RO(PPC_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_PPC_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.