dtrace_isa.c (278529) | dtrace_isa.c (278997) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 * | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 * |
22 * $FreeBSD: head/sys/cddl/dev/dtrace/arm/dtrace_isa.c 278529 2015-02-10 19:41:30Z gnn $ | 22 * $FreeBSD: head/sys/cddl/dev/dtrace/arm/dtrace_isa.c 278997 2015-02-19 12:20:21Z andrew $ |
23 */ 24/* 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28#include <sys/cdefs.h> 29 30#include <sys/param.h> --- 33 unchanged lines hidden (view full) --- 64uint16_t dtrace_fuword16_nocheck(void *); 65uint32_t dtrace_fuword32_nocheck(void *); 66uint64_t dtrace_fuword64_nocheck(void *); 67 68void 69dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, 70 uint32_t *intrpc) 71{ | 23 */ 24/* 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28#include <sys/cdefs.h> 29 30#include <sys/param.h> --- 33 unchanged lines hidden (view full) --- 64uint16_t dtrace_fuword16_nocheck(void *); 65uint32_t dtrace_fuword32_nocheck(void *); 66uint64_t dtrace_fuword64_nocheck(void *); 67 68void 69dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, 70 uint32_t *intrpc) 71{ |
72 u_int32_t *frame, *lastframe; 73 int scp_offset; 74 int depth = 0; | 72 struct unwind_state state; 73 register_t sp; 74 int scp_offset; 75 int depth = 0; |
75 pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller; 76 77 if (intrpc != 0) 78 pcstack[depth++] = (pc_t) intrpc; 79 80 aframes++; 81 | 76 pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller; 77 78 if (intrpc != 0) 79 pcstack[depth++] = (pc_t) intrpc; 80 81 aframes++; 82 |
82 frame = (u_int32_t *)__builtin_frame_address(0);; 83 lastframe = NULL; 84 scp_offset = -(get_pc_str_offset() >> 2); | 83 __asm __volatile("mov %0, sp" : "=&r" (sp)); |
85 | 84 |
86 while ((frame != NULL) && (depth < pcstack_limit)) { 87 db_addr_t scp; 88#if 0 89 u_int32_t savecode; 90 int r; 91 u_int32_t *rp; 92#endif | 85 state.registers[FP] = (uint32_t)__builtin_frame_address(0); 86 state.registers[SP] = sp; 87 state.registers[LR] = (uint32_t)__builtin_return_address(0); 88 state.registers[PC] = (uint32_t)dtrace_getpcstack; |
93 | 89 |
94 /* 95 * In theory, the SCP isn't guaranteed to be in the function 96 * that generated the stack frame. We hope for the best. 97 */ 98 scp = frame[FR_SCP]; | 90 while (depth < pcstack_limit) { 91 int done; |
99 | 92 |
93 done = unwind_stack_one(&state, 1); 94 |
|
100 if (aframes > 0) { 101 aframes--; 102 if ((aframes == 0) && (caller != 0)) { 103 pcstack[depth++] = caller; 104 } 105 } 106 else { | 95 if (aframes > 0) { 96 aframes--; 97 if ((aframes == 0) && (caller != 0)) { 98 pcstack[depth++] = caller; 99 } 100 } 101 else { |
107 pcstack[depth++] = scp; | 102 pcstack[depth++] = state.registers[PC]; |
108 } 109 | 103 } 104 |
110#if 0 111 savecode = ((u_int32_t *)scp)[scp_offset]; 112 if ((savecode & 0x0e100000) == 0x08000000) { 113 /* Looks like an STM */ 114 rp = frame - 4; 115 for (r = 10; r >= 0; r--) { 116 if (savecode & (1 << r)) { 117 /* register r == *rp-- */ 118 } 119 } 120 } 121#endif 122 123 /* 124 * Switch to next frame up 125 */ 126 if (frame[FR_RFP] == 0) 127 break; /* Top of stack */ 128 129 lastframe = frame; 130 frame = (u_int32_t *)(frame[FR_RFP]); 131 132 if (INKERNEL((int)frame)) { 133 /* staying in kernel */ 134 if (frame <= lastframe) { 135 /* bad frame pointer */ 136 break; 137 } 138 } 139 else | 105 if (done) |
140 break; 141 } 142 143 for (; depth < pcstack_limit; depth++) { 144 pcstack[depth] = 0; 145 } 146} 147 --- 23 unchanged lines hidden (view full) --- 171/* struct arm_frame *fp = (struct arm_frame *)dtrace_getfp();*/ 172 173 return (0); 174} 175 176int 177dtrace_getstackdepth(int aframes) 178{ | 106 break; 107 } 108 109 for (; depth < pcstack_limit; depth++) { 110 pcstack[depth] = 0; 111 } 112} 113 --- 23 unchanged lines hidden (view full) --- 137/* struct arm_frame *fp = (struct arm_frame *)dtrace_getfp();*/ 138 139 return (0); 140} 141 142int 143dtrace_getstackdepth(int aframes) 144{ |
179 u_int32_t *frame, *lastframe; 180 int scp_offset; 181 int depth = 1; | 145 struct unwind_state state; 146 register_t sp; 147 int scp_offset; 148 int done = 0; 149 int depth = 1; |
182 | 150 |
183 frame = (u_int32_t *)__builtin_frame_address(0);; 184 lastframe = NULL; 185 scp_offset = -(get_pc_str_offset() >> 2); | 151 __asm __volatile("mov %0, sp" : "=&r" (sp)); |
186 | 152 |
187 while (frame != NULL) { 188 db_addr_t scp; 189#if 0 190 u_int32_t savecode; 191 int r; 192 u_int32_t *rp; 193#endif | 153 state.registers[FP] = (uint32_t)__builtin_frame_address(0); 154 state.registers[SP] = sp; 155 state.registers[LR] = (uint32_t)__builtin_return_address(0); 156 state.registers[PC] = (uint32_t)dtrace_getstackdepth; |
194 | 157 |
195 /* 196 * In theory, the SCP isn't guaranteed to be in the function 197 * that generated the stack frame. We hope for the best. 198 */ 199 scp = frame[FR_SCP]; 200 | 158 do { 159 done = unwind_stack_one(&state, 1); |
201 depth++; | 160 depth++; |
161 } while (!done); |
|
202 | 162 |
203 /* 204 * Switch to next frame up 205 */ 206 if (frame[FR_RFP] == 0) 207 break; /* Top of stack */ 208 209 lastframe = frame; 210 frame = (u_int32_t *)(frame[FR_RFP]); 211 212 if (INKERNEL((int)frame)) { 213 /* staying in kernel */ 214 if (frame <= lastframe) { 215 /* bad frame pointer */ 216 break; 217 } 218 } 219 else 220 break; 221 } 222 | |
223 if (depth < aframes) 224 return 0; 225 else 226 return depth - aframes; | 163 if (depth < aframes) 164 return 0; 165 else 166 return depth - aframes; |
227 | |
228} 229 230ulong_t 231dtrace_getreg(struct trapframe *rp, uint_t reg) 232{ 233 printf("IMPLEMENT ME: %s\n", __func__); 234 235 return (0); --- 121 unchanged lines hidden --- | 167} 168 169ulong_t 170dtrace_getreg(struct trapframe *rp, uint_t reg) 171{ 172 printf("IMPLEMENT ME: %s\n", __func__); 173 174 return (0); --- 121 unchanged lines hidden --- |