PERFORCE change 52521 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sat May 8 20:25:12 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=52521
Change 52521 by marcel at marcel_nfs on 2004/05/08 20:24:54
IFC @52520
Affected files ...
.. //depot/projects/gdb/sbin/ipfw/ipfw2.c#5 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src.diff#1 branch
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx.h#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_context.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_env.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_env.h#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_scoreboard.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_self-new.c#1 branch
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_self.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_self.h#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_self_context.s#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_step.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_step.h#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_str.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_ttrace.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_ttrace.h#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_uinfo.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_utable.c#2 integrate
.. //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_utable.h#2 integrate
.. //depot/projects/gdb/sys/sparc64/sparc64/pmap.c#5 integrate
.. //depot/projects/gdb/sys/vm/vm_page.c#7 integrate
.. //depot/projects/gdb/usr.sbin/pkg_install/add/main.c#3 integrate
Differences ...
==== //depot/projects/gdb/sbin/ipfw/ipfw2.c#5 (text+ko) ====
@@ -17,7 +17,7 @@
*
* NEW command line interface for IP firewall facility
*
- * $FreeBSD: src/sbin/ipfw/ipfw2.c,v 1.47 2004/04/23 14:28:38 andre Exp $
+ * $FreeBSD: src/sbin/ipfw/ipfw2.c,v 1.48 2004/05/09 01:53:31 csjp Exp $
*/
#include <sys/param.h>
@@ -3388,8 +3388,6 @@
break;
case TOK_MAC:
- if (ac < 2)
- errx(EX_USAGE, "MAC dst-mac src-mac");
if (add_mac(cmd, ac, av)) {
ac -= 2; av += 2;
}
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx.h#2 (text+ko) ====
@@ -22,6 +22,9 @@
OTHER DEALINGS IN THE SOFTWARE.
*/
+#ifndef __UWX_INCLUDED
+#define __UWX_INCLUDED 1
+
#ifndef _KERNEL
#include <stdlib.h>
#include <inttypes.h>
@@ -30,22 +33,30 @@
#include <sys/systm.h>
#endif
+#if defined(__cplusplus)
+#define __EXTERN_C extern "C"
+#else
+#define __EXTERN_C extern
+#endif
+
+#define UWX_VERSION 1 /* Version id for callback interfaces */
+
/* Unwind environment structure (opaque) */
struct uwx_env;
/* Allocate and free callbacks */
typedef void *(*alloc_cb)(size_t size);
typedef void (*free_cb)(void *ptr);
-extern int uwx_register_alloc_cb(alloc_cb alloc, free_cb free);
+__EXTERN_C int uwx_register_alloc_cb(alloc_cb alloc, free_cb free);
/* Allocate and initialize an unwind environment */
-extern struct uwx_env *uwx_init(void);
+__EXTERN_C struct uwx_env *uwx_init(void);
/* Free an unwind environment */
-extern int uwx_free(struct uwx_env *env);
+__EXTERN_C int uwx_free(struct uwx_env *env);
/* Put unwind express into cross-process mode */
-extern int uwx_set_remote(struct uwx_env *env, int is_big_endian_target);
+__EXTERN_C int uwx_set_remote(struct uwx_env *env, int is_big_endian_target);
/* Copy-in callback */
typedef int (*copyin_cb)(
@@ -63,14 +74,14 @@
uint64_t **vecp); /* parameter vector (in/out) */
/* Register copy-in and lookup IP callbacks */
-extern int uwx_register_callbacks(
+__EXTERN_C int uwx_register_callbacks(
struct uwx_env *env, /* unwind environment */
intptr_t tok, /* callback token */
copyin_cb copyin, /* copy-in callback */
lookupip_cb lookupip); /* lookup IP callback */
/* Initialize a context with the basic info needed to start an unwind */
-extern int uwx_init_context(
+__EXTERN_C int uwx_init_context(
struct uwx_env *env, /* unwind environment */
uint64_t ip, /* IP (instruction pointer) */
uint64_t sp, /* SP (stack pointer) */
@@ -78,51 +89,51 @@
uint64_t cfm); /* CFM (current frame marker) */
/* Set the value of a specific register in the current context (non fp) */
-extern int uwx_set_reg(
+__EXTERN_C int uwx_set_reg(
struct uwx_env *env, /* unwind environment */
int regid, /* register id (see below) */
uint64_t val); /* register value */
/* Set the value of a floating-point register in the current context */
-extern int uwx_set_fr(
+__EXTERN_C int uwx_set_fr(
struct uwx_env *env, /* unwind environment */
int regid, /* register id (see below) */
uint64_t *val); /* register value (ptr to 16 bytes) */
/* (memory spill format) */
/* Initialize the unwind history */
-extern int uwx_init_history(struct uwx_env *env);
+__EXTERN_C int uwx_init_history(struct uwx_env *env);
/* Step one frame */
-extern int uwx_step(struct uwx_env *env);
+__EXTERN_C int uwx_step(struct uwx_env *env);
/* Get symbol information, if available, for current frame */
-extern int uwx_get_sym_info(
+__EXTERN_C int uwx_get_sym_info(
struct uwx_env *env, /* unwind environment */
char **modp, /* load module name (out) */
char **symp, /* function name (out) */
uint64_t *offsetp); /* offset from start of function (out) */
/* Get the value of a register from the current context */
-extern int uwx_get_reg(
+__EXTERN_C int uwx_get_reg(
struct uwx_env *env, /* unwind environment */
int regid, /* register id (see below) */
uint64_t *valp); /* register value (out) */
/* Get the NaT bit of a GR from the current context */
-extern int uwx_get_nat(
+__EXTERN_C int uwx_get_nat(
struct uwx_env *env, /* unwind environment */
int regid, /* register id (see below) */
int *natp); /* NaT value (out: 0 or 1) */
/* Get the spill location for a register in the current context */
-extern int uwx_get_spill_loc(
+__EXTERN_C int uwx_get_spill_loc(
struct uwx_env *env, /* unwind environment */
int regid, /* register id (see below) */
uint64_t *dispp); /* disposition code (see below) (out) */
/* Get the ABI context code (if uwx_step returned UWX_ABI_FRAME) */
-extern int uwx_get_abi_context_code(struct uwx_env *env);
+__EXTERN_C int uwx_get_abi_context_code(struct uwx_env *env);
/* Return status codes for uwx_ APIs */
#define UWX_OK 0
@@ -165,6 +176,8 @@
#define UWX_LKUP_UTABLE 2 /* Returned ref to unwind table */
#define UWX_LKUP_FDESC 3 /* Returned frame description */
#define UWX_LKUP_SYMINFO 4 /* Returned symbolic information */
+#define UWX_LKUP_REMAP 5 /* Returned remapped IP */
+#define UWX_LKUP_UINFO 6 /* Returned unw info block ptr */
/* The lookup IP callback receives a parameter vector, and returns */
/* one on success. This vector is a series of key/value pairs; each */
@@ -175,26 +188,40 @@
/* Keys passed to lookup IP callback */
#define UWX_KEY_PREDS 1 /* Predicate registers */
+#define UWX_KEY_VERSION 2 /* Version id of unwind engine */
+/* UWX_KEY_FUNCSTART (below) may also be passed with the UWX_LKUP_SYMINFO */
+/* request. */
/* Keys returned with UWX_LKUP_UTABLE */
/* These key/value pairs describe the unwind table corresponding */
/* to the load module in which the current IP resides. */
#define UWX_KEY_TBASE 1 /* Base address of text seg */
-#define UWX_KEY_UFLAGS 2 /* Unwind flags */
+#define UWX_KEY_UFLAGS 2 /* Unwind flags (optional) */
#define UWX_KEY_USTART 3 /* Base of unwind tbl */
#define UWX_KEY_UEND 4 /* End of unwind tbl */
/* Keys returned with UWX_LKUP_FDESC */
/* These key/value pairs describe the state of the frame at the */
/* given IP. They are typically used for dynamically-generated code. */
+/* If UWX_KEY_CONTEXT is returned, it must be the only key returned. */
#define UWX_KEY_FSIZE 1 /* Frame size */
#define UWX_KEY_SPILL(reg_id) (2 | ((reg_id) << 4)) /* Reg spilled */
#define UWX_KEY_CONTEXT 3 /* ABI-dep. context */
-/* Keys returned with UWX_LKUP_FDESC or UWX_LKUP_SYMINFO */
-#define UWX_KEY_MODULE 5 /* Name of load module */
-#define UWX_KEY_FUNC 6 /* Name of function */
-#define UWX_KEY_FUNCSTART 7 /* Address of start of function */
+/* Keys returned with UWX_LKUP_REMAP */
+#define UWX_KEY_NEWIP 5 /* Remapped IP */
+
+/* Keys returned with UWX_LKUP_UINFO */
+/* Use UWX_KEY_FUNCSTART for the start address of the function */
+/* Use UWX_KEY_UFLAGS for the unwind flags (optional) */
+#define UWX_KEY_UINFO 6 /* Address of unwind info block */
+
+/* Keys returned with UWX_LKUP_SYMINFO */
+/* These keys may be returned with UWX_LKUP_FDESC or UWX_LKUP_UINFO, */
+/* if the information is cheap to obtain. */
+#define UWX_KEY_MODULE 17 /* Name of load module */
+#define UWX_KEY_FUNC 18 /* Name of function */
+#define UWX_KEY_FUNCSTART 19 /* Address of start of function */
/* Register identifiers */
/* For use in UWX_LKUP_FDESC result vectors and context access APIs. */
@@ -255,3 +282,75 @@
#define UWX_GET_DISP_OFFSET(disp) ((disp) & ~(uint64_t)0x07)
#define UWX_GET_DISP_ADDR(disp) ((disp) & ~(uint64_t)0x07)
#define UWX_GET_DISP_REGID(disp) ((int)(disp) >> 4)
+
+#undef __EXTERN_C
+
+#if defined(__cplusplus)
+
+class UnwindExpress {
+
+public:
+
+ UnwindExpress() {
+ env = uwx_init();
+ }
+
+ ~UnwindExpress() {
+ if (env != 0)
+ uwx_free(env);
+ env = 0;
+ }
+
+ int init_context(uint64_t ip, uint64_t sp, uint64_t bsp, uint64_t cfm) {
+ return uwx_init_context(env, ip, sp, bsp, cfm);
+ }
+
+ int init_history() {
+ return uwx_init_history(env);
+ }
+
+ int set_reg(int regid, uint64_t val) {
+ return uwx_set_reg(env, regid, val);
+ }
+
+ int set_fr(int regid, uint64_t *valp) {
+ return uwx_set_fr(env, regid, valp);
+ }
+
+ int step() {
+ return uwx_step(env);
+ }
+
+ int get_sym_info(char **modp, char **symp, uint64_t *offsetp) {
+ return uwx_get_sym_info(env, modp, symp, offsetp);
+ }
+
+ int get_reg(int regid, uint64_t *valp) {
+ return uwx_get_reg(env, regid, valp);
+ }
+
+ int get_nat(int regid, int *natp) {
+ return uwx_get_nat(env, regid, natp);
+ }
+
+ int get_spill_loc(int regid, uint64_t *dispp) {
+ return uwx_get_spill_loc(env, regid, dispp);
+ }
+
+ int get_abi_context_code() {
+ return uwx_get_abi_context_code(env);
+ }
+
+ struct uwx_env *get_env() {
+ return env;
+ }
+
+protected:
+
+ struct uwx_env *env;
+
+};
+
+#endif /* __cplusplus */
+
+#endif /* __UWX_INCLUDED */
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_context.c#2 (text+ko) ====
@@ -181,11 +181,7 @@
}
bsp = uwx_add_to_bsp(bsp, regid);
natcollp = bsp | 0x01f8;
- if (natcollp >= bsp)
- n = (*env->copyin)(UWX_COPYIN_REG, (char *)&natcoll,
- (uint64_t)UWX_REG_AR_RNAT, DWORDSZ, env->cb_token);
- else
- n = (*env->copyin)(UWX_COPYIN_RSTACK, (char *)&natcoll,
+ n = (*env->copyin)(UWX_COPYIN_RSTACK, (char *)&natcoll,
bsp, DWORDSZ, env->cb_token);
if (n != DWORDSZ)
return UWX_ERR_COPYIN_RSTK;
@@ -319,28 +315,86 @@
* bsp
* <------- adjusted (nslots + bias) ------->
- * When subtracting from bsp, we bias the bsp in the opposite
- * direction so that it is at the next NaT collection.
+ * When subtracting from bsp, we avoid depending on the sign of
+ * the quotient by adding 63*8 before division and subtracting 8
+ * after division. (Assumes that we will never be called upon
+ * to subtract more than 504 slots from bsp.)
*
* 0 1f8 3f8
* +---------------------------------------------------------------+
* | X X|
* +---------------------------------------------------------------+
- * <------- bias ------->
- * <--- nslots --->
- * ^
- * |
- * bsp
- * <------ adjusted (nslots + bias) ------>
+ * <-- bias -->
+ * <--- |nslots| --->
+ * ^
+ * |
+ * bsp
+ * <----------------->
+ * adjusted |nslots + bias|
*/
- if (nslots > 0) {
- bias = ((unsigned int)bsp & 0x1f8) / DWORDSZ;
- nslots += (nslots + bias) / 63;
+ bias = ((unsigned int)bsp & 0x1f8) / DWORDSZ;
+ nslots += (nslots + bias + 63*8) / 63 - 8;
+ return bsp + nslots * DWORDSZ;
+}
+
+#if 0
+int uwx_selftest_bsp_arithmetic()
+{
+ int i;
+ int j;
+ int r;
+ uint64_t bstore[161];
+ uint64_t *bsp;
+ uint64_t *p;
+ int failed = 0;
+
+ printf("uwx_selftest_bsp_arithmetic: bsp at %08lx\n", (unsigned int)bstore);
+ r = 0;
+ bsp = bstore;
+ for (i = 0; i < 161; i++) {
+ if (((unsigned int)bsp & 0x1f8) == 0x1f8)
+ *bsp++ = 1000 + r;
+ else
+ *bsp++ = r++;
+ }
+
+ printf("uwx_selftest_bsp_arithmetic: plus tests...\n");
+ bsp = bstore;
+ for (i = 0; i < 64; i++) {
+ r = (int)*bsp;
+ if (r >= 1000)
+ r -= 1000;
+ for (j = 0; j < 96; j++) {
+ p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, j);
+ if (*p != (r + j)) {
+ failed++;
+ printf("%d [%08lx] + %d -> %08lx ",
+ i, (unsigned int)bsp, j, (unsigned int)p);
+ printf("(read %d instead of %d)\n", (int)*p, r + j);
+ }
+ }
+ bsp++;
}
- else if (nslots < 0) {
- bias = (0x1f8 - ((unsigned int)bsp & 0x1f8)) / DWORDSZ;
- nslots -= (-nslots + bias) / 63;
+
+ printf("uwx_selftest_bsp_arithmetic: minus tests...\n");
+ bsp = &bstore[161];
+ for (i = 63; i >= 0; i--) {
+ bsp--;
+ r = (int)*bsp;
+ if (r >= 1000)
+ r -= 1000;
+ for (j = 0; j < 96; j++) {
+ p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, -j);
+ if (*p != (r - j)) {
+ failed++;
+ printf("%d [%08lx] - %d -> %08lx ",
+ i, (unsigned int)bsp, j, (unsigned int)p);
+ printf("(read %d instead of %d)\n", (int)*p, r - j);
+ }
+ }
}
- return bsp + nslots * DWORDSZ;
+
+ return failed;
}
+#endif
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_env.c#2 (text+ko) ====
@@ -24,9 +24,6 @@
#ifndef _KERNEL
#include <stdlib.h>
-#else
-#define free(p) /* nullified */
-#define malloc(sz) NULL
#endif
#include "uwx_env.h"
@@ -34,6 +31,12 @@
#include "uwx_str.h"
#include "uwx_trace.h"
+#ifdef _KERNEL
+static struct uwx_env uwx_env;
+#define free(p) /* nullified */
+#define malloc(sz) ((sz == sizeof(uwx_env)) ? &uwx_env : NULL)
+#endif
+
alloc_cb uwx_allocate_cb = 0;
free_cb uwx_free_cb = 0;
@@ -88,6 +91,7 @@
env->context.fr[i].part1 = 0;
}
env->rstate = 0;
+ env->remapped_ip = 0;
env->function_offset = 0;
(void)uwx_init_history(env);
env->allocate_cb = uwx_allocate_cb;
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_env.h#2 (text+ko) ====
@@ -78,6 +78,7 @@
struct uwx_env {
struct uwx_context context;
uint64_t *rstate;
+ uint64_t remapped_ip;
int64_t function_offset;
struct uwx_history history;
alloc_cb allocate_cb;
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_scoreboard.c#2 (text+ko) ====
@@ -24,15 +24,39 @@
#ifndef _KERNEL
#include <stdlib.h>
-#else
-#define free(p) /* nullified */
-#define malloc(sz) NULL
#endif
#include "uwx_env.h"
#include "uwx_scoreboard.h"
#include "uwx_trace.h"
+#ifdef _KERNEL
+static unsigned short uwx_allocated;
+static struct uwx_scoreboard uwx_scoreboard[sizeof(uwx_allocated) << 3];
+
+static void
+free(struct uwx_scoreboard *p)
+{
+ int idx = p - uwx_scoreboard;
+ uwx_allocated &= ~(1 << idx);
+}
+
+static struct uwx_scoreboard *
+malloc(size_t sz)
+{
+ int idx;
+ if (sz != sizeof(struct uwx_scoreboard))
+ return (NULL);
+ for (idx = 0; idx < (sizeof(uwx_allocated) << 3); idx++) {
+ if ((uwx_allocated & (1 << idx)) == 0) {
+ uwx_allocated |= 1 << idx;
+ return (uwx_scoreboard + idx);
+ }
+ }
+ return (NULL);
+}
+#endif
+
struct uwx_scoreboard *uwx_alloc_scoreboard(struct uwx_env *env)
{
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_self.c#2 (text+ko) ====
@@ -22,12 +22,10 @@
OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef _KERNEL
#include <stdlib.h>
#include <crt0.h>
#include <dlfcn.h>
#include <sys/uc_access.h>
-#endif
#include "uwx_env.h"
#include "uwx_context.h"
@@ -37,6 +35,7 @@
#define UWX_ABI_HPUX_SIGCONTEXT 0x0101 /* abi = HP-UX, context = 1 */
struct uwx_self_info {
+ struct uwx_env *env;
ucontext_t *ucontext;
uint64_t bspstore;
uint64_t rvec[10];
@@ -60,6 +59,7 @@
if (info == 0)
return 0;
+ info->env = env;
info->ucontext = 0;
info->bspstore = 0;
info->sendsig_start = __load_info->li_sendsig_txt;
@@ -155,72 +155,78 @@
unsigned long *wp;
uint64_t *dp;
+ status = -1;
+
dp = (uint64_t *) loc;
- if (request == UWX_COPYIN_UINFO ||
- request == UWX_COPYIN_MSTACK) {
- if (len == 4) {
- wp = (unsigned long *) loc;
- *wp = *(unsigned long *)rem;
- TRACE_SELF_COPYIN4(rem, len, wp)
- }
- else if (len == 8) {
- *dp = *(uint64_t *)rem;
- TRACE_SELF_COPYIN4(rem, len, dp)
- }
- else
- return 0;
- }
- else if (request == UWX_COPYIN_RSTACK && len == 8) {
- if (info->ucontext == 0 || rem < info->bspstore) {
- *dp = *(uint64_t *)rem;
- TRACE_SELF_COPYIN4(rem, len, dp)
- }
- else {
- status = __uc_get_rsebs(info->ucontext, (uint64_t *)rem, 1, dp);
- if (status != 0)
- return 0;
- }
- }
- else if (request == UWX_COPYIN_REG && len == 8) {
- if (info->ucontext == 0)
- return 0;
- regid = (int)rem;
- if (rem < UWX_REG_GR(0)) {
- switch (regid) {
- case UWX_REG_PREDS:
- status = __uc_get_prs(info->ucontext, dp);
- break;
- case UWX_REG_AR_PFS:
- status = __uc_get_ar(info->ucontext, 64, dp);
- break;
- case UWX_REG_AR_RNAT:
- status = __uc_get_ar(info->ucontext, 19, dp);
- break;
- case UWX_REG_AR_UNAT:
- status = __uc_get_ar(info->ucontext, 36, dp);
- break;
- case UWX_REG_AR_FPSR:
- status = __uc_get_ar(info->ucontext, 40, dp);
- break;
- case UWX_REG_AR_LC:
- status = __uc_get_ar(info->ucontext, 65, dp);
- break;
- default:
- return 0;
+ switch (request) {
+ case UWX_COPYIN_UINFO:
+ case UWX_COPYIN_MSTACK:
+ if (len == 4) {
+ wp = (unsigned long *) loc;
+ *wp = *(unsigned long *)rem;
+ TRACE_SELF_COPYIN4(rem, len, wp)
+ status = 0;
+ }
+ else if (len == 8) {
+ *dp = *(uint64_t *)rem;
+ TRACE_SELF_COPYIN8(rem, len, dp)
+ status = 0;
+ }
+ break;
+ case UWX_COPYIN_RSTACK:
+ if (len == 8) {
+ if (info->ucontext == 0 && rem == (info->bspstore | 0x1f8)) {
+ *dp = info->env->context.special[UWX_REG_AR_RNAT];
+ status = 0;
+ }
+ else if (info->ucontext == 0 || rem < info->bspstore) {
+ *dp = *(uint64_t *)rem;
+ TRACE_SELF_COPYIN8(rem, len, dp)
+ status = 0;
+ }
+ else {
+ status = __uc_get_rsebs(info->ucontext,
+ (uint64_t *)rem, 1, dp);
+ }
+ }
+ break;
+ case UWX_COPYIN_REG:
+ regid = (int)rem;
+ if (info->ucontext != 0) {
+ if (len == 8) {
+ if (rem == UWX_REG_PREDS)
+ status = __uc_get_prs(info->ucontext, dp);
+ else if (rem == UWX_REG_AR_PFS)
+ status = __uc_get_ar(info->ucontext, 64, dp);
+ else if (rem == UWX_REG_AR_RNAT)
+ status = __uc_get_ar(info->ucontext, 19, dp);
+ else if (rem == UWX_REG_AR_UNAT)
+ status = __uc_get_ar(info->ucontext, 36, dp);
+ else if (rem == UWX_REG_AR_FPSR)
+ status = __uc_get_ar(info->ucontext, 40, dp);
+ else if (rem == UWX_REG_AR_LC)
+ status = __uc_get_ar(info->ucontext, 65, dp);
+ else if (regid >= UWX_REG_GR(1) &&
+ regid <= UWX_REG_GR(31))
+ status = __uc_get_grs(info->ucontext,
+ regid - UWX_REG_GR(0), 1, dp, &nat);
+ else if (regid >= UWX_REG_BR(0) &&
+ regid <= UWX_REG_BR(7))
+ status = __uc_get_brs(info->ucontext,
+ regid - UWX_REG_BR(0), 1, dp);
+ }
+ else if (len == 16) {
+ if (regid >= UWX_REG_FR(2) && regid <= UWX_REG_FR(127)) {
+ status = __uc_get_frs(info->ucontext,
+ regid - UWX_REG_FR(0), 1, (fp_regval_t *)dp);
+ }
+ }
}
- }
- else if (regid >= UWX_REG_GR(1) && regid <= UWX_REG_GR(31)) {
- status = __uc_get_grs(info->ucontext,
- regid - UWX_REG_GR(0), 1, dp, &nat);
- }
- else if (regid >= UWX_REG_BR(0) && regid <= UWX_REG_BR(7)) {
- status = __uc_get_brs(info->ucontext,
- regid - UWX_REG_BR(0), 1, dp);
- }
- if (status != 0)
- return 0;
+ break;
}
+ if (status != 0)
+ return 0;
return len;
}
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_self.h#2 (text+ko) ====
@@ -22,38 +22,91 @@
OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef _KERNEL
+#ifndef __UWX_SELF_INCLUDED
+#define __UWX_SELF_INCLUDED 1
+
#include <signal.h>
+
+#ifndef __UWX_INCLUDED
+#include "uwx.h"
+#endif /* __UWX_INCLUDED */
+
+#if defined(__cplusplus)
+#define __EXTERN_C extern "C"
+#else
+#define __EXTERN_C extern
#endif
struct uwx_self_info;
-extern struct uwx_self_info *uwx_self_init_info(struct uwx_env *env);
+__EXTERN_C struct uwx_self_info *uwx_self_init_info(struct uwx_env *env);
-extern int uwx_self_free_info(struct uwx_self_info *info);
+__EXTERN_C int uwx_self_free_info(struct uwx_self_info *info);
-extern int uwx_self_init_context(struct uwx_env *env);
+__EXTERN_C int uwx_self_init_context(struct uwx_env *env);
-extern int uwx_self_init_from_sigcontext(
+__EXTERN_C int uwx_self_init_from_sigcontext(
struct uwx_env *env,
struct uwx_self_info *info,
ucontext_t *ucontext);
-extern int uwx_self_do_context_frame(
+__EXTERN_C int uwx_self_do_context_frame(
struct uwx_env *env,
struct uwx_self_info *info);
-extern int uwx_self_copyin(
+__EXTERN_C int uwx_self_copyin(
int request,
char *loc,
uint64_t rem,
int len,
intptr_t tok);
-extern int uwx_self_lookupip(
+__EXTERN_C int uwx_self_lookupip(
int request,
uint64_t ip,
intptr_t tok,
uint64_t **resultp);
#define UWX_SELF_ERR_BADABICONTEXT (-101)
+
+#undef __EXTERN_C
+
+#if defined(__cplusplus)
+
+class UnwindExpressSelf : public UnwindExpress {
+
+public:
+
+ UnwindExpressSelf() {
+ info = uwx_self_init_info(env);
+ (void)uwx_register_callbacks(env, (intptr_t)info,
+ uwx_self_copyin, uwx_self_lookupip);
+ }
+
+ ~UnwindExpressSelf() {
+ if (info != 0)
+ uwx_self_free_info(info);
+ info = 0;
+ }
+
+ int init_context() {
+ return uwx_self_init_context(env);
+ }
+
+ int init_context(ucontext_t *ucontext) {
+ return uwx_self_init_from_sigcontext(env, info, ucontext);
+ }
+
+ int do_context_frame() {
+ return uwx_self_do_context_frame(env, info);
+ }
+
+protected:
+
+ struct uwx_self_info *info;
+
+};
+
+#endif /* __cplusplus */
+
+#endif /* __UWX_SELF_INCLUDED */
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_self_context.s#2 (text+ko) ====
@@ -1,24 +1,24 @@
-/*
- * Copyright (c) 2002,2003 Hewlett-Packard Company
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
+// Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
#ifdef _LP64
#define SWIZZLE add
@@ -48,6 +48,21 @@
rTMP4 = r31
rTMP5 = r8
+VALID_IP = 1
+VALID_SP = 1 << 1
+VALID_BSP = 1 << 2
+VALID_CFM = 1 << 3
+VALID_PREDS = 1 << 7
+VALID_RNAT = 1 << 10
+VALID_UNAT = 1 << 11
+VALID_FPSR = 1 << 12
+VALID_LC = 1 << 13
+VALID_GRS = 0xf << 16
+VALID_BRS = 0x1f << 20
+VALID_BASIC4 = VALID_IP | VALID_SP | VALID_BSP | VALID_CFM
+VALID_SPEC = VALID_PREDS | VALID_RNAT | VALID_UNAT | VALID_FPSR | VALID_LC
+VALID_BITS = (VALID_BASIC4 | VALID_SPEC | VALID_GRS | VALID_BRS) << 32
+
.text
.proc uwx_self_init_context
.global uwx_self_init_context
@@ -63,40 +78,42 @@
mov rRP = b0
;;
mov rRSC = ar.rsc
- add rENV1 = 120, rENV0 // rENV1 = &env->context.gr[0]
- add rENV2 = 128, rENV0 // rENV2 = &env->context.gr[1]
+ add rENV1 = 136, rENV0 // rENV1 = &env->context.gr[0]
+ add rENV2 = 144, rENV0 // rENV2 = &env->context.gr[1]
;;
and rRSC0 = -4, rRSC // clear ar.rsc.mode
adds rNATP = 0x1f8, r0
mov rTMP1 = b1
;;
- st8.spill [rENV1] = r4, 16 // env+120: r4
- st8.spill [rENV2] = r5, 16 // env+128: r5
+ st8.spill [rENV1] = r4, 16 // env+136: r4
+ st8.spill [rENV2] = r5, 16 // env+144: r5
mov rTMP2 = b2
;;
- st8.spill [rENV1] = r6, 16 // env+136: r6
- st8.spill [rENV2] = r7, 16 // env+144: r7
+ st8.spill [rENV1] = r6, 16 // env+152: r6
+ st8.spill [rENV2] = r7, 16 // env+160: r7
mov rTMP3 = b3
;;
- st8 [rENV1] = rTMP1, 16 // env+152: b1
- st8 [rENV2] = rTMP2, 16 // env+160: b2
+ st8 [rENV1] = rTMP1, 16 // env+168: b1
+ st8 [rENV2] = rTMP2, 16 // env+176: b2
mov rTMP1 = b4
;;
- st8 [rENV1] = rTMP3, 16 // env+168: b3
- st8 [rENV2] = rTMP1, 16 // env+176: b4
+ st8 [rENV1] = rTMP3, 16 // env+184: b3
+ st8 [rENV2] = rTMP1, 16 // env+192: b4
mov rTMP2 = b5
;;
- st8 [rENV1] = rTMP2 // env+184: b5
+ st8 [rENV1] = rTMP2 // env+200: b5
mov ar.rsc = rRSC0 // enforced lazy mode
add rENV1 = 8, rENV0
;;
mov rRNAT = ar.rnat // get copy of ar.rnat
- movl rTMP1 = 0x7fec8f00000000 // valid_regs: ip, sp, bsp, cfm,
- // preds, rnat, unat, lc, grs, brs
+ movl rTMP1 = VALID_BITS // valid_regs: ip, sp, bsp, cfm,
+ // preds, rnat, unat, fpsr,
+ // lc, grs, brs
+ // = 0x1ff3c8f00000000
;;
mov ar.rsc = rRSC // restore ar.rsc
mov rBSP = ar.bsp
- add rTMP3 = 120, rENV0 // spill_loc = &env->context.gr[0]
+ add rTMP3 = 136, rENV0 // spill_loc = &env->context.gr[0]
;;
mov rTMP2 = ar.unat
nop
@@ -143,7 +160,7 @@
add rENV2 = 320, rENV2 // rENV2 = &env->context.rstate
;;
st8 [rENV1] = rTMP1 // env+112: lc
- STPTR [rENV2] = r0 // env+512: env->rstate = 0
+ STPTR [rENV2] = r0 // env+528: env->rstate = 0
nop
;;
mov ar.unat = rUNAT
==== //depot/projects/gdb/sys/contrib/ia64/libuwx/src/uwx_step.c#2 (text+ko) ====
@@ -52,6 +52,19 @@
int uwx_restore_nat(struct uwx_env *env, uint64_t rstate, int unat);
+/* uwx_lookupip_hook: Hook routine so dynamic instrumentation */
+/* tools can intercept Lookup IP events. When not */
+/* intercepted, it just returns "Not found", so that */
+/* the callback routine is invoked. */
+
+/*ARGSUSED*/
+int uwx_lookupip_hook(int request, uint64_t ip, intptr_t tok, uint64_t **vecp,
+ size_t uvecsize)
+{
+ return UWX_LKUP_NOTFOUND;
+}
+
+
/* uwx_get_frame_info: Gets unwind info for current frame */
static
int uwx_get_frame_info(struct uwx_env *env)
@@ -59,10 +72,12 @@
int i;
int status;
int cbstatus;
+ int cbcalled = 0;
+ uint64_t ip;
uint64_t *uvec;
uint64_t *rstate;
struct uwx_utable_entry uentry;
- uint64_t uvecout[4];
+ uint64_t uvecout[UVECSIZE];
if (env->copyin == 0 || env->lookupip == 0)
return UWX_ERR_NOCALLBACKS;
@@ -76,7 +91,14 @@
/* current IP. If the predicate registers are valid, pass them */
/* in the uvec. */
+ /* When self-unwinding, we call a hook routine before the */
+ /* callback. If the application is running under control of */
+ /* a dynamic instrumentation tool, that tool will have an */
+ /* opportunity to intercept lookup IP requests. */
+
i = 0;
+ uvecout[i++] = UWX_KEY_VERSION;
+ uvecout[i++] = UWX_VERSION;
if (env->context.valid_regs & (1 << UWX_REG_PREDS)) {
uvecout[i++] = UWX_KEY_PREDS;
uvecout[i++] = env->context.special[UWX_REG_PREDS];
@@ -84,8 +106,52 @@
uvecout[i++] = UWX_KEY_END;
uvecout[i++] = 0;
uvec = uvecout;
- cbstatus = (*env->lookupip)(UWX_LKUP_LOOKUP,
- env->context.special[UWX_REG_IP], env->cb_token, &uvec);
+ cbstatus = UWX_LKUP_NOTFOUND;
+ ip = env->context.special[UWX_REG_IP];
+ env->remapped_ip = ip;
+
+ /* Call the hook routine. */
+
+ if (env->remote == 0)
+ cbstatus = uwx_lookupip_hook(UWX_LKUP_LOOKUP, ip, env->cb_token, &uvec,
+ sizeof(uvecout));
+
+ /* If the hook routine remapped the IP, use the new IP for */
+ /* the callback instead of the original IP. */
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list