Deleted Added
full compact
uwx_self.c (121642) uwx_self.c (129059)
1/*
2Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the

--- 8 unchanged lines hidden (view full) ---

17OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
23*/
24
1/*
2Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the

--- 8 unchanged lines hidden (view full) ---

17OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
23*/
24
25#ifndef _KERNEL
26#include <stdlib.h>
27#include <crt0.h>
28#include <dlfcn.h>
29#include <sys/uc_access.h>
25#include <stdlib.h>
26#include <crt0.h>
27#include <dlfcn.h>
28#include <sys/uc_access.h>
30#endif
31
32#include "uwx_env.h"
33#include "uwx_context.h"
34#include "uwx_trace.h"
35#include "uwx_self.h"
36
37#define UWX_ABI_HPUX_SIGCONTEXT 0x0101 /* abi = HP-UX, context = 1 */
38
39struct uwx_self_info {
29
30#include "uwx_env.h"
31#include "uwx_context.h"
32#include "uwx_trace.h"
33#include "uwx_self.h"
34
35#define UWX_ABI_HPUX_SIGCONTEXT 0x0101 /* abi = HP-UX, context = 1 */
36
37struct uwx_self_info {
38 struct uwx_env *env;
40 ucontext_t *ucontext;
41 uint64_t bspstore;
42 uint64_t rvec[10];
43 uint64_t sendsig_start;
44 uint64_t sendsig_end;
45 alloc_cb allocate_cb;
46 free_cb free_cb;
47 int trace;

--- 7 unchanged lines hidden (view full) ---

55 info = (struct uwx_self_info *)
56 malloc(sizeof(struct uwx_self_info));
57 else
58 info = (struct uwx_self_info *)
59 (*env->allocate_cb)(sizeof(struct uwx_self_info));
60 if (info == 0)
61 return 0;
62
39 ucontext_t *ucontext;
40 uint64_t bspstore;
41 uint64_t rvec[10];
42 uint64_t sendsig_start;
43 uint64_t sendsig_end;
44 alloc_cb allocate_cb;
45 free_cb free_cb;
46 int trace;

--- 7 unchanged lines hidden (view full) ---

54 info = (struct uwx_self_info *)
55 malloc(sizeof(struct uwx_self_info));
56 else
57 info = (struct uwx_self_info *)
58 (*env->allocate_cb)(sizeof(struct uwx_self_info));
59 if (info == 0)
60 return 0;
61
62 info->env = env;
63 info->ucontext = 0;
64 info->bspstore = 0;
65 info->sendsig_start = __load_info->li_sendsig_txt;
66 info->sendsig_end = __load_info->li_sendsig_txt +
67 __load_info->li_sendsig_tsz;
68 info->allocate_cb = env->allocate_cb;
69 info->free_cb = env->free_cb;
70 info->trace = env->trace;

--- 79 unchanged lines hidden (view full) ---

150{
151 int status;
152 int regid;
153 unsigned int nat;
154 struct uwx_self_info *info = (struct uwx_self_info *) tok;
155 unsigned long *wp;
156 uint64_t *dp;
157
63 info->ucontext = 0;
64 info->bspstore = 0;
65 info->sendsig_start = __load_info->li_sendsig_txt;
66 info->sendsig_end = __load_info->li_sendsig_txt +
67 __load_info->li_sendsig_tsz;
68 info->allocate_cb = env->allocate_cb;
69 info->free_cb = env->free_cb;
70 info->trace = env->trace;

--- 79 unchanged lines hidden (view full) ---

150{
151 int status;
152 int regid;
153 unsigned int nat;
154 struct uwx_self_info *info = (struct uwx_self_info *) tok;
155 unsigned long *wp;
156 uint64_t *dp;
157
158 status = -1;
159
158 dp = (uint64_t *) loc;
159
160 dp = (uint64_t *) loc;
161
160 if (request == UWX_COPYIN_UINFO ||
161 request == UWX_COPYIN_MSTACK) {
162 if (len == 4) {
163 wp = (unsigned long *) loc;
164 *wp = *(unsigned long *)rem;
165 TRACE_SELF_COPYIN4(rem, len, wp)
166 }
167 else if (len == 8) {
168 *dp = *(uint64_t *)rem;
169 TRACE_SELF_COPYIN4(rem, len, dp)
170 }
171 else
172 return 0;
173 }
174 else if (request == UWX_COPYIN_RSTACK && len == 8) {
175 if (info->ucontext == 0 || rem < info->bspstore) {
176 *dp = *(uint64_t *)rem;
177 TRACE_SELF_COPYIN4(rem, len, dp)
178 }
179 else {
180 status = __uc_get_rsebs(info->ucontext, (uint64_t *)rem, 1, dp);
181 if (status != 0)
182 return 0;
183 }
184 }
185 else if (request == UWX_COPYIN_REG && len == 8) {
186 if (info->ucontext == 0)
187 return 0;
188 regid = (int)rem;
189 if (rem < UWX_REG_GR(0)) {
190 switch (regid) {
191 case UWX_REG_PREDS:
192 status = __uc_get_prs(info->ucontext, dp);
193 break;
194 case UWX_REG_AR_PFS:
195 status = __uc_get_ar(info->ucontext, 64, dp);
196 break;
197 case UWX_REG_AR_RNAT:
198 status = __uc_get_ar(info->ucontext, 19, dp);
199 break;
200 case UWX_REG_AR_UNAT:
201 status = __uc_get_ar(info->ucontext, 36, dp);
202 break;
203 case UWX_REG_AR_FPSR:
204 status = __uc_get_ar(info->ucontext, 40, dp);
205 break;
206 case UWX_REG_AR_LC:
207 status = __uc_get_ar(info->ucontext, 65, dp);
208 break;
209 default:
210 return 0;
162 switch (request) {
163 case UWX_COPYIN_UINFO:
164 case UWX_COPYIN_MSTACK:
165 if (len == 4) {
166 wp = (unsigned long *) loc;
167 *wp = *(unsigned long *)rem;
168 TRACE_SELF_COPYIN4(rem, len, wp)
169 status = 0;
211 }
170 }
212 }
213 else if (regid >= UWX_REG_GR(1) && regid <= UWX_REG_GR(31)) {
214 status = __uc_get_grs(info->ucontext,
215 regid - UWX_REG_GR(0), 1, dp, &nat);
216 }
217 else if (regid >= UWX_REG_BR(0) && regid <= UWX_REG_BR(7)) {
218 status = __uc_get_brs(info->ucontext,
219 regid - UWX_REG_BR(0), 1, dp);
220 }
221 if (status != 0)
222 return 0;
171 else if (len == 8) {
172 *dp = *(uint64_t *)rem;
173 TRACE_SELF_COPYIN8(rem, len, dp)
174 status = 0;
175 }
176 break;
177 case UWX_COPYIN_RSTACK:
178 if (len == 8) {
179 if (info->ucontext == 0 && rem == (info->bspstore | 0x1f8)) {
180 *dp = info->env->context.special[UWX_REG_AR_RNAT];
181 status = 0;
182 }
183 else if (info->ucontext == 0 || rem < info->bspstore) {
184 *dp = *(uint64_t *)rem;
185 TRACE_SELF_COPYIN8(rem, len, dp)
186 status = 0;
187 }
188 else {
189 status = __uc_get_rsebs(info->ucontext,
190 (uint64_t *)rem, 1, dp);
191 }
192 }
193 break;
194 case UWX_COPYIN_REG:
195 regid = (int)rem;
196 if (info->ucontext != 0) {
197 if (len == 8) {
198 if (rem == UWX_REG_PREDS)
199 status = __uc_get_prs(info->ucontext, dp);
200 else if (rem == UWX_REG_AR_PFS)
201 status = __uc_get_ar(info->ucontext, 64, dp);
202 else if (rem == UWX_REG_AR_RNAT)
203 status = __uc_get_ar(info->ucontext, 19, dp);
204 else if (rem == UWX_REG_AR_UNAT)
205 status = __uc_get_ar(info->ucontext, 36, dp);
206 else if (rem == UWX_REG_AR_FPSR)
207 status = __uc_get_ar(info->ucontext, 40, dp);
208 else if (rem == UWX_REG_AR_LC)
209 status = __uc_get_ar(info->ucontext, 65, dp);
210 else if (regid >= UWX_REG_GR(1) &&
211 regid <= UWX_REG_GR(31))
212 status = __uc_get_grs(info->ucontext,
213 regid - UWX_REG_GR(0), 1, dp, &nat);
214 else if (regid >= UWX_REG_BR(0) &&
215 regid <= UWX_REG_BR(7))
216 status = __uc_get_brs(info->ucontext,
217 regid - UWX_REG_BR(0), 1, dp);
218 }
219 else if (len == 16) {
220 if (regid >= UWX_REG_FR(2) && regid <= UWX_REG_FR(127)) {
221 status = __uc_get_frs(info->ucontext,
222 regid - UWX_REG_FR(0), 1, (fp_regval_t *)dp);
223 }
224 }
225 }
226 break;
223 }
227 }
228 if (status != 0)
229 return 0;
224 return len;
225}
226
227
228int uwx_self_lookupip(
229 int request,
230 uint64_t ip,
231 intptr_t tok,

--- 47 unchanged lines hidden ---
230 return len;
231}
232
233
234int uwx_self_lookupip(
235 int request,
236 uint64_t ip,
237 intptr_t tok,

--- 47 unchanged lines hidden ---