00001 /* 00002 * Copyright (C) 2008 by Duane Ellis 00003 * 00004 * All rights reserved. 00005 * 00006 * The original code had been released as part of the LoastARM Project 00007 * under GPL Version 2 and is published here under the following license 00008 * with kind permission from the author: 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright 00017 * notice, this list of conditions and the following disclaimer in the 00018 * documentation and/or other materials provided with the distribution. 00019 * 3. Neither the name of the copyright holders nor the names of 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00030 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00031 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00033 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00034 * SUCH DAMAGE. 00035 * 00036 * For additional information see http://lostarm.sourceforge.net/ 00037 */ 00038 00047 #include <stdio.h> 00048 #include <sys/ptrace.h> 00049 #include <arch/arm/ptrace.h> 00050 00051 /* 00052 * For Nut/OS we can use DEV_DEBUG with stdio. 00053 */ 00054 00055 void 00056 ptrace_dump_regs( struct pt_regs *p ) 00057 { 00058 int x; 00059 char *mode; 00060 00061 for (x = PTRACE_R0_idx; x <= PTRACE_R7_idx; x++) { 00062 printf("R%d : 0x%08lx ", x, p->uregs[x]); 00063 x += PTRACE_R8_idx; 00064 printf("R%d%s: 0x%08lx\n", x, x < 10 ? " " : "", p->uregs[x]); 00065 x -= PTRACE_R8_idx; 00066 } 00067 printf("PSW: 0x%08lx ", p->uregs[ PTRACE_CPSR_idx ] ); 00068 /* now decode the flags */ 00069 x = p->uregs[ PTRACE_CPSR_idx ]; 00070 putchar( ( x & ARM_CPSR_N_BIT ) ? 'N' : 'n' ); 00071 putchar( ( x & ARM_CPSR_Z_BIT ) ? 'Z' : 'z' ); 00072 putchar( ( x & ARM_CPSR_C_BIT ) ? 'C' : 'c' ); 00073 putchar( ( x & ARM_CPSR_V_BIT ) ? 'V' : 'v' ); 00074 printf("..."); 00075 putchar( ( x & ARM_CPSR_F_BIT ) ? 'F' : 'f' ); 00076 putchar( ( x & ARM_CPSR_I_BIT ) ? 'I' : 'i' ); 00077 putchar( ( x & ARM_CPSR_T_BIT ) ? 'T' : 't' ); 00078 putchar(' '); 00079 switch( ARM_MODE_MASK & x ){ 00080 case ARM_USR_MODE: 00081 mode = "user"; 00082 break; 00083 case ARM_FIQ_MODE: 00084 mode = "fiq"; 00085 break; 00086 case ARM_IRQ_MODE: 00087 mode = "irq"; 00088 break; 00089 case ARM_SVC_MODE: 00090 mode = "svc"; 00091 break; 00092 case ARM_ABT_MODE: 00093 if( p->uregs[ PTRACE_FRAMETYPE_idx ] == PTRACE_FRAMETYPE_pfa ){ 00094 mode = "pfa"; 00095 } else if( p->uregs[ PTRACE_FRAMETYPE_idx ] == PTRACE_FRAMETYPE_da ){ 00096 mode = "da"; 00097 } else { 00098 mode = "unknown-abort"; 00099 } 00100 break; 00101 case ARM_UND_MODE: 00102 mode = "und"; 00103 break; 00104 case ARM_SYS_MODE: 00105 mode = "sys"; 00106 break; 00107 default: 00108 mode = NULL; 00109 break; 00110 } 00111 if (mode) 00112 printf("%s-mode\n", mode); 00113 }