Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset fd608dc in mainline


Ignore:
Timestamp:
2010-01-13T17:52:13Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
65737d4, 990c70e
Parents:
439ba77 (diff), 15817089 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge the stacktrace branch.

This merge introduces support for kernel stack traces on arm32.

Location:
kernel/arch/arm32
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/Makefile.inc

    r439ba77 rfd608dc  
    3838ATSIGN = %
    3939
    40 GCC_CFLAGS += -fno-zero-initialized-in-bss
     40GCC_CFLAGS += -fno-zero-initialized-in-bss -mapcs-frame
    4141
    4242BITS = 32
  • kernel/arch/arm32/include/context.h

    r439ba77 rfd608dc  
    4343#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4444
     45#define context_set(c, _pc, stack, size) \
     46        do { \
     47                (c)->pc = (uintptr_t) (_pc); \
     48                (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
     49                (c)->fp = 0; \
     50        } while (0)
     51
    4552#ifndef __ASM__
    4653
     
    6269        uint32_t r9;
    6370        uint32_t r10;
    64         uint32_t r11;
     71        uint32_t fp;    /* r11 */
    6572       
    6673        ipl_t ipl;
  • kernel/arch/arm32/include/exception.h

    r439ba77 rfd608dc  
    102102        uint32_t r9;
    103103        uint32_t r10;
    104         uint32_t r11;
     104        uint32_t fp;
    105105        uint32_t r12;
    106106
     
    135135static inline unative_t istate_get_fp(istate_t *istate)
    136136{
    137         return istate->r11;
     137        return istate->fp;
    138138}
    139139
  • kernel/arch/arm32/src/debug/stacktrace.c

    r439ba77 rfd608dc  
    3838#include <typedefs.h>
    3939
     40#define FRAME_OFFSET_FP_PREV    -3
     41#define FRAME_OFFSET_RA         -1
     42
    4043bool kernel_frame_pointer_validate(uintptr_t fp)
    4144{
    42         return false;
     45        return fp != 0;
    4346}
    4447
    4548bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
    4649{
    47         return false;
     50        uint32_t *stack = (void *) fp;
     51
     52        *prev = stack[FRAME_OFFSET_FP_PREV];
     53        return true;
    4854}
    4955
    5056bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
    5157{
    52         return false;
     58        uint32_t *stack = (void *) fp;
     59
     60        *ra = stack[FRAME_OFFSET_RA];
     61        return true;
    5362}
    5463
    5564bool uspace_frame_pointer_validate(uintptr_t fp)
    5665{
    57         return false;
     66        return fp != 0;
    5867}
    5968
    6069bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
    6170{
    62         return false;
     71        return !copy_from_uspace((void *) prev,
     72            (uint32_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));
    6373}
    6474
    6575bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
    6676{
    67         return false;
     77        return !copy_from_uspace((void *) ra, (uint32_t *) fp + FRAME_OFFSET_RA,
     78            sizeof(*ra));
    6879}
    6980
  • kernel/arch/arm32/src/debug/stacktrace_asm.S

    r439ba77 rfd608dc  
    3333
    3434frame_pointer_get:
     35        mov r0, fp
    3536        mov pc, lr
    3637
    3738program_counter_get:
     39        mov r0, lr
    3840        mov pc, lr
  • kernel/arch/arm32/src/exc_handler.S

    r439ba77 rfd608dc  
    123123        stmfd r13!, {r2}
    1241242:
     125        # Stop stack traces here
     126        mov fp, #0
    125127.endm
    126128
  • kernel/arch/arm32/src/exception.c

    r439ba77 rfd608dc  
    4242#include <print.h>
    4343#include <syscall/syscall.h>
     44#include <stacktrace.h>
    4445
    4546#ifdef MACHINE_testarm
     
    183184        printf(" r4: %x    r5: %x    r6: %x    r7: %x\n",
    184185            istate->r4, istate->r5, istate->r6, istate->r7);
    185         printf(" r8: %x    r8: %x   r10: %x   r11: %x\n",
    186             istate->r8, istate->r9, istate->r10, istate->r11);
     186        printf(" r8: %x    r8: %x   r10: %x    fp: %x\n",
     187            istate->r8, istate->r9, istate->r10, istate->fp);
    187188        printf(" r12: %x    sp: %x    lr: %x  spsr: %x\n",
    188189            istate->r12, istate->sp, istate->lr, istate->spsr);
    189190       
    190191        printf(" pc: %x\n", istate->pc);
     192
     193        stack_trace_istate(istate);
    191194}
    192195
  • kernel/arch/arm32/src/mm/page_fault.c

    r439ba77 rfd608dc  
    181181
    182182        if (ret == AS_PF_FAULT) {
     183                fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr);
    183184                print_istate(istate);
    184185                printf("page fault - pc: %x, va: %x, status: %x(%x), "
     
    186187                    access);
    187188               
    188                 fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr);
    189189                panic("Page fault.");
    190190        }
  • kernel/arch/arm32/src/start.S

    r439ba77 rfd608dc  
    6969        bl arch_pre_main
    7070       
     71        #
     72        # Create the first stack frame.
     73        #
     74        mov fp, #0
     75        mov ip, sp
     76        push {fp, ip, lr, pc}
     77        sub fp, ip, #4
     78
    7179        bl main_bsp
    7280
Note: See TracChangeset for help on using the changeset viewer.