From owner-p4-projects@FreeBSD.ORG Sat Jul 8 20:38:29 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 633FD16A4E0; Sat, 8 Jul 2006 20:38:29 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3AC6116A4DA for ; Sat, 8 Jul 2006 20:38:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD7B443D4C for ; Sat, 8 Jul 2006 20:38:28 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k68KcSVW092569 for ; Sat, 8 Jul 2006 20:38:28 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k68KcRbO092566 for perforce@freebsd.org; Sat, 8 Jul 2006 20:38:27 GMT (envelope-from jhb@freebsd.org) Date: Sat, 8 Jul 2006 20:38:27 GMT Message-Id: <200607082038.k68KcRbO092566@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 101055 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jul 2006 20:38:29 -0000 http://perforce.freebsd.org/chv.cgi?CH=101055 Change 101055 by jhb@jhb_mutex on 2006/07/08 20:38:19 IFC @101054 - loopback. Affected files ... .. //depot/projects/smpng/sys/compat/linux/linux_ipc.c#27 integrate .. //depot/projects/smpng/sys/compat/linux/linux_socket.c#32 integrate .. //depot/projects/smpng/sys/compat/svr4/svr4_ipc.c#19 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src.diff#2 delete .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/Makefile#4 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx.h#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_bstream.c#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_bstream.h#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_context.c#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_context.h#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_env.c#4 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_env.h#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_scoreboard.c#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_scoreboard.h#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_self-new.c#2 delete .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_self.c#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_self.h#4 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_self_context.s#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_self_info.h#1 branch .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_step.c#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_step.h#4 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_str.c#4 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_str.h#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_swap.c#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_swap.h#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_symbols.c#1 branch .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_symbols.h#1 branch .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_trace.c#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_trace.h#5 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_ttrace.c#5 delete .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_ttrace.h#4 delete .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_uinfo.c#6 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_uinfo.h#3 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_utable.c#4 integrate .. //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_utable.h#4 integrate .. //depot/projects/smpng/sys/contrib/pf/net/if_pfsync.c#21 integrate .. //depot/projects/smpng/sys/doc/Doxyfile#2 delete .. //depot/projects/smpng/sys/doc/Makefile#2 delete .. //depot/projects/smpng/sys/doc/subsys/Dependencies#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-cam#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-crypto#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-dev_pci#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-dev_sound#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-dev_usb#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-geom#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-i4b#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-kern#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-libkern#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-linux#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-net80211#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-netgraph#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-netinet#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-netinet6#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-netipsec#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-opencrypto#2 delete .. //depot/projects/smpng/sys/doc/subsys/Doxyfile-vm#2 delete .. //depot/projects/smpng/sys/doc/subsys/Makefile#2 delete .. //depot/projects/smpng/sys/doc/subsys/README#2 delete .. //depot/projects/smpng/sys/doc/subsys/common-Doxyfile#2 delete .. //depot/projects/smpng/sys/doc/subsys/notreviewed.dox#2 delete .. //depot/projects/smpng/sys/fs/portalfs/portal_vnops.c#25 integrate .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_ipc.c#13 integrate .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_ipc.h#5 integrate .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_other.c#10 integrate .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_xenix.c#17 integrate .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_xenix.h#10 integrate .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_xenix_syscall.h#9 integrate .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_xenix_sysent.c#10 integrate .. //depot/projects/smpng/sys/i386/ibcs2/syscalls.xenix#8 integrate .. //depot/projects/smpng/sys/isa/isahint.c#6 integrate .. //depot/projects/smpng/sys/kern/bus_if.m#12 integrate .. //depot/projects/smpng/sys/kern/kern_descrip.c#94 integrate .. //depot/projects/smpng/sys/kern/subr_bus.c#61 integrate .. //depot/projects/smpng/sys/kern/sys_generic.c#45 integrate .. //depot/projects/smpng/sys/kern/sysv_sem.c#41 integrate .. //depot/projects/smpng/sys/netinet/ip_carp.c#18 integrate .. //depot/projects/smpng/sys/nfsclient/nfs_socket.c#44 integrate .. //depot/projects/smpng/sys/nfsclient/nfs_vnops.c#60 integrate .. //depot/projects/smpng/sys/sys/bus.h#27 integrate .. //depot/projects/smpng/sys/sys/syscallsubr.h#46 integrate Differences ... ==== //depot/projects/smpng/sys/compat/linux/linux_ipc.c#27 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/linux/linux_ipc.c,v 1.47 2006/06/27 18:28:49 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/linux/linux_ipc.c,v 1.48 2006/07/08 19:51:37 jhb Exp $"); #include #include ==== //depot/projects/smpng/sys/compat/linux/linux_socket.c#32 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.68 2006/05/10 20:38:16 netchild Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.69 2006/07/08 20:03:38 jhb Exp $"); /* XXX we use functions that might not exist. */ #include "opt_compat.h" ==== //depot/projects/smpng/sys/compat/svr4/svr4_ipc.c#19 (text+ko) ==== @@ -71,7 +71,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_ipc.c,v 1.22 2006/07/06 21:38:24 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_ipc.c,v 1.23 2006/07/08 19:51:37 jhb Exp $"); #include "opt_sysvipc.h" ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/Makefile#4 (text+ko) ==== @@ -15,11 +15,12 @@ CFLAGS = -O $(OTHERCFLAGS) OBJS = uwx_bstream.o uwx_context.o uwx_env.o uwx_scoreboard.o \ - uwx_step.o uwx_str.o uwx_swap.o uwx_trace.o uwx_uinfo.o \ - uwx_utable.o + uwx_step.o uwx_str.o uwx_swap.o uwx_symbols.o \ + uwx_trace.o uwx_uinfo.o uwx_utable.o # SELFOBJS = # For cross-unwind library -SELFOBJS = uwx_self.o uwx_self_context.o uwx_ttrace.o +# SELFOBJS = uwx_self.o uwx_self_context.o uwx_ttrace.o +SELFOBJS = uwx_self.o uwx_self_context.o # SELFLIBS = # For cross-unwind library SELFLIBS = -luca @@ -34,6 +35,9 @@ libuwx.sl: $(OBJS) $(SELFOBJS) ld -b -o libuwx.sl $(OBJS) $(SELFOBJS) $(SELFLIBS) +clean: + rm -f $(OBJS) $(SELFOBJS) libuwx.a libuwx.so libuwx.sl + uwx_bstream.o: uwx.h uwx_env.h uwx_bstream.h uwx_context.o: uwx.h uwx_env.h uwx_scoreboard.h uwx_step.h uwx_trace.h @@ -49,6 +53,8 @@ uwx_swap.o: uwx.h uwx_env.h uwx_swap.h +uwx_symbols.o: uwx.h uwx_env.h uwx_symbols.h + uwx_trace.o: uwx.h uwx_env.h uwx_uinfo.h uwx_scoreboard.h uwx_trace.h uwx_uinfo.o: uwx.h uwx_env.h uwx_uinfo.h uwx_utable.h \ @@ -56,7 +62,8 @@ uwx_utable.o: uwx.h uwx_env.h uwx_utable.h uwx_swap.h uwx_trace.h -uwx_self.o: uwx.h uwx_env.h uwx_context.h uwx_trace.h uwx_self.h +uwx_self.o: uwx.h uwx_env.h uwx_context.h uwx_trace.h uwx_self.h \ + uwx_symbols.h uwx_self_context.o: uwx_self_context.s $(CC) -c $(CFLAGS) -o uwx_self_context.o uwx_self_context.s ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx.h#5 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -39,11 +39,14 @@ #define __EXTERN_C extern #endif -#define UWX_VERSION 1 /* Version id for callback interfaces */ +#define UWX_VERSION 3 /* Version id for callback interfaces */ /* Unwind environment structure (opaque) */ struct uwx_env; +/* Symbol Cache for uwx_find_symbol (opaque) */ +struct uwx_symbol_cache; + /* Allocate and free callbacks */ typedef void *(*alloc_cb)(size_t size); typedef void (*free_cb)(void *ptr); @@ -58,6 +61,9 @@ /* Put unwind express into cross-process mode */ __EXTERN_C int uwx_set_remote(struct uwx_env *env, int is_big_endian_target); +/* Put unwind express into reduced-context mode (no floating-point regs) */ +__EXTERN_C int uwx_set_nofr(struct uwx_env *env); + /* Copy-in callback */ typedef int (*copyin_cb)( int request, /* request code (see below) */ @@ -107,6 +113,17 @@ /* Step one frame */ __EXTERN_C int uwx_step(struct uwx_env *env); +/* Get module name and text base, if available, for current frame */ +__EXTERN_C int uwx_get_module_info( + struct uwx_env *env, /* unwind environment */ + char **modp, /* load module name (out) */ + uint64_t *text_base); /* base address of text segment (out) */ + +/* Get function start address for current frame */ +__EXTERN_C int uwx_get_funcstart( + struct uwx_env *env, /* unwind environment */ + uint64_t *funcstart); /* function start address (out) */ + /* Get symbol information, if available, for current frame */ __EXTERN_C int uwx_get_sym_info( struct uwx_env *env, /* unwind environment */ @@ -114,6 +131,22 @@ char **symp, /* function name (out) */ uint64_t *offsetp); /* offset from start of function (out) */ +/* Get symbol information, given module name and IP */ +__EXTERN_C int uwx_find_symbol( + struct uwx_env *env, /* unwind environment */ + struct uwx_symbol_cache **cachep, + /* ptr to symbol cache ptr (in/out) */ + char *mod, /* load module name */ + uint64_t relip, /* IP, relative to text segment */ + char **symp, /* function name (out) */ + uint64_t *offsetp); /* offset from start of function (out) */ + +/* Release memory used by symbol cache */ +__EXTERN_C void uwx_release_symbol_cache( + struct uwx_env *env, /* unwind environment */ + struct uwx_symbol_cache *symbol_cache); + /* symbol cache ptr */ + /* Get the value of a register from the current context */ __EXTERN_C int uwx_get_reg( struct uwx_env *env, /* unwind environment */ @@ -135,6 +168,10 @@ /* Get the ABI context code (if uwx_step returned UWX_ABI_FRAME) */ __EXTERN_C int uwx_get_abi_context_code(struct uwx_env *env); +/* Increment/Decrement the bsp by a number of slots */ +/* (accounts for NaT collections) */ +__EXTERN_C uint64_t uwx_add_to_bsp(uint64_t bsp, int nslots); + /* Return status codes for uwx_ APIs */ #define UWX_OK 0 #define UWX_BOTTOM 1 /* Hit bottom of stack */ @@ -158,6 +195,8 @@ #define UWX_ERR_CANTUNWIND (-17) /* Can't unwind */ #define UWX_ERR_NOCALLBACKS (-18) /* No callbacks registered */ #define UWX_ERR_NOCONTEXT (-19) /* Context not initialized */ +#define UWX_ERR_UCACCESS (-20) /* Failure in libuca */ +#define UWX_ERR_NOSYM (-21) /* Symbol not found */ /* Request codes for copyin callback */ #define UWX_COPYIN_UINFO 1 /* Reading unwind info */ @@ -169,6 +208,7 @@ #define UWX_LKUP_LOOKUP 1 /* Lookup IP */ #define UWX_LKUP_FREE 2 /* Free result vector */ #define UWX_LKUP_SYMBOLS 3 /* Lookup symbolic information */ +#define UWX_LKUP_MODULE 4 /* Get module name */ /* Return status codes for lookup IP callback */ #define UWX_LKUP_NOTFOUND 0 /* IP not found */ @@ -199,11 +239,13 @@ #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 */ +#define UWX_KEY_GP 7 /* GP value for module */ /* 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. */ +/* Use UWX_KEY_GP for the module's gp value. */ #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 */ @@ -212,6 +254,7 @@ #define UWX_KEY_NEWIP 5 /* Remapped IP */ /* Keys returned with UWX_LKUP_UINFO */ +/* Use UWX_KEY_GP for the module's gp value. */ /* 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 */ @@ -219,6 +262,7 @@ /* 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. */ +/* Use UWX_KEY_TBASE for the base of the text segment */ #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 */ @@ -246,6 +290,7 @@ #define UWX_REG_AR_FPSR 12 /* ar.fpsr */ #define UWX_REG_AR_LC 13 /* ar.lc */ #define UWX_REG_AR_PFS 14 /* ar.pfs */ +#define UWX_REG_GP 15 /* gp (pseudo-register) */ #define UWX_REG_GR(gr) (0x100 | (gr)) #define UWX_REG_FR(fr) (0x200 | (fr)) #define UWX_REG_BR(br) (0x300 | (br)) @@ -321,10 +366,27 @@ return uwx_step(env); } + int get_module_info(char **modp, uint64_t *text_base_p) { + return uwx_get_module_info(env, modp, text_base_p); + } + + int get_funcstart(uint64_t *funcstart) { + return uwx_get_funcstart(env, funcstart); + } + int get_sym_info(char **modp, char **symp, uint64_t *offsetp) { return uwx_get_sym_info(env, modp, symp, offsetp); } + int find_symbol(struct uwx_symbol_cache **cachep, + char *mod, uint64_t relip, char **symp, uint64_t *offsetp) { + return uwx_find_symbol(env, cachep, mod, relip, symp, offsetp); + } + + void release_symbol_cache(struct uwx_symbol_cache *symbol_cache) { + uwx_release_symbol_cache(env, symbol_cache); + } + int get_reg(int regid, uint64_t *valp) { return uwx_get_reg(env, regid, valp); } ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_bstream.c#3 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -46,7 +46,7 @@ } else { bstream->source = 0; - bstream->bufp = (unsigned char *) source; + bstream->bufp = (unsigned char *) (intptr_t) source; bstream->nbuf = len; bstream->copyin = 0; bstream->cb_token = 0; ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_bstream.h#3 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_context.c#5 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -23,7 +23,6 @@ */ #include "uwx_env.h" -#include "uwx_context.h" #include "uwx_scoreboard.h" #include "uwx_step.h" #include "uwx_trace.h" @@ -182,7 +181,7 @@ bsp = uwx_add_to_bsp(bsp, regid); natcollp = bsp | 0x01f8; n = (*env->copyin)(UWX_COPYIN_RSTACK, (char *)&natcoll, - bsp, DWORDSZ, env->cb_token); + natcollp, DWORDSZ, env->cb_token); if (n != DWORDSZ) return UWX_ERR_COPYIN_RSTK; *natp = (int)(natcoll >> (((int)bsp >> 3) & 0x3f)) & 0x01; @@ -208,8 +207,17 @@ if (regid == UWX_REG_GR(12)) regid = UWX_REG_SP; - if (regid < NSPECIALREG) + if (regid < NSPECIALREG) { + if (regid == UWX_REG_PSP || regid == UWX_REG_RP || + regid == UWX_REG_PFS) { + if (!(env->context.valid_regs & (1 << regid))) { + status = uwx_restore_markers(env); + if (status != UWX_OK) + return status; + } + } *dispp = env->history.special[regid]; + } else if (regid >= UWX_REG_GR(4) && regid <= UWX_REG_GR(7)) *dispp = env->history.gr[regid - UWX_REG_GR(4)]; else if (regid >= UWX_REG_GR(32) && regid <= UWX_REG_GR(127)) { @@ -313,7 +321,7 @@ * ^ * | * bsp - * <------- adjusted (nslots + bias) -------> + * <------------ nslots + bias -----------> * When subtracting from bsp, we avoid depending on the sign of * the quotient by adding 63*8 before division and subtracting 8 @@ -325,12 +333,12 @@ * | X X| * +---------------------------------------------------------------+ * <-- bias --> - * <--- |nslots| ---> + * <--- (-nslots) ---> * ^ * | * bsp * <-----------------> - * adjusted |nslots + bias| + * -(nslots + bias) */ bias = ((unsigned int)bsp & 0x1f8) / DWORDSZ; @@ -366,7 +374,7 @@ if (r >= 1000) r -= 1000; for (j = 0; j < 96; j++) { - p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, j); + p = (uint64_t *)(intptr_t)uwx_add_to_bsp((uint64_t)bsp, j); if (*p != (r + j)) { failed++; printf("%d [%08lx] + %d -> %08lx ", @@ -385,7 +393,7 @@ if (r >= 1000) r -= 1000; for (j = 0; j < 96; j++) { - p = (uint64_t *)uwx_add_to_bsp((uint64_t)bsp, -j); + p = (uint64_t *)(intptr_t)uwx_add_to_bsp((uint64_t)bsp, -j); if (*p != (r - j)) { failed++; printf("%d [%08lx] - %d -> %08lx ", ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_context.h#3 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_env.c#4 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -68,52 +68,97 @@ return UWX_OK; } +int uwx_init_env(struct uwx_env *env, size_t total_size) +{ + int i; + struct uwx_str_pool *str_pool; + struct uwx_scoreboard *scoreboards; + + str_pool = (struct uwx_str_pool *)(env + 1); + scoreboards = (struct uwx_scoreboard *)(str_pool + 1); + + if (sizeof(struct uwx_env) + sizeof(struct uwx_str_pool) > total_size) + return UWX_ERR_NOMEM; + total_size -= sizeof(struct uwx_env) + sizeof(struct uwx_str_pool); + + env->context.valid_regs = 0; + env->context.valid_frs = 0; + for (i = 0; i < NSPECIALREG; i++) + env->context.special[i] = 0; + for (i = 0; i < NPRESERVEDGR; i++) + env->context.gr[i] = 0; + for (i = 0; i < NPRESERVEDBR; i++) + env->context.br[i] = 0; + for (i = 0; i < NPRESERVEDFR; i++) { + env->context.fr[i].part0 = 0; + env->context.fr[i].part1 = 0; + } + env->rstate = 0; + env->remapped_ip = 0; + env->function_offset = 0; + env->ptr_size = DWORDSZ; + env->uinfo_hdr = 0; + env->uinfo_end = 0; + env->code_start = 0; + env->text_base = 0; + (void)uwx_init_history(env); + if (uwx_allocate_cb != NULL) + env->allocate_cb = uwx_allocate_cb; + else + env->allocate_cb = NULL; + if (uwx_free_cb != NULL) + env->free_cb = uwx_free_cb; + else + env->free_cb = NULL; + env->free_scoreboards = 0; + env->used_scoreboards = 0; + env->labeled_scoreboards = 0; + (void)uwx_init_str_pool(env, str_pool); + env->module_name = 0; + env->function_name = 0; + env->cb_token = 0; + env->copyin = 0; + env->lookupip = 0; + env->remote = 0; + env->byte_swap = 0; + env->abi_context = 0; + env->nsbreg = NSBREG; + env->nscoreboards = 0; + env->on_heap = 0; + env->trace = 0; + TRACE_INIT + for (i = 0; total_size >= sizeof(struct uwx_scoreboard); i++) { + (void) uwx_prealloc_scoreboard(env, &scoreboards[i]); + total_size -= sizeof(struct uwx_scoreboard); + } + return UWX_OK; +} + +int uwx_set_nofr(struct uwx_env *env) +{ + if (env == 0) + return UWX_ERR_NOENV; + + env->nsbreg = NSBREG_NOFR; + return UWX_OK; +} + struct uwx_env *uwx_init() { - int i; struct uwx_env *env; + size_t total_size; + + total_size = sizeof(struct uwx_env) + + sizeof(struct uwx_str_pool) + + NSCOREBOARDS * sizeof(struct uwx_scoreboard); if (uwx_allocate_cb == 0) - env = (struct uwx_env *) malloc(sizeof(struct uwx_env)); + env = (struct uwx_env *) malloc(total_size); else - env = (struct uwx_env *) (*uwx_allocate_cb)(sizeof(struct uwx_env)); + env = (struct uwx_env *) (*uwx_allocate_cb)(total_size); if (env != 0) { - env->context.valid_regs = 0; - env->context.valid_frs = 0; - for (i = 0; i < NSPECIALREG; i++) - env->context.special[i] = 0; - for (i = 0; i < NPRESERVEDGR; i++) - env->context.gr[i] = 0; - for (i = 0; i < NPRESERVEDBR; i++) - env->context.br[i] = 0; - for (i = 0; i < NPRESERVEDFR; i++) { - env->context.fr[i].part0 = 0; - 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; - env->free_cb = uwx_free_cb; - env->free_scoreboards = 0; - env->used_scoreboards = 0; - env->labeled_scoreboards = 0; - (void)uwx_init_str_pool(env); - env->module_name = 0; - env->function_name = 0; - env->cb_token = 0; - env->copyin = 0; - env->lookupip = 0; - env->remote = 0; - env->byte_swap = 0; - env->abi_context = 0; - env->nsbreg = NSBREG_NOFR; - env->nscoreboards = 0; - env->trace = 0; - TRACE_INIT - for (i = 0; i < NSCOREBOARDS; i++) - (void) uwx_alloc_scoreboard(env); + uwx_init_env(env, total_size); + env->on_heap = 1; } return env; } @@ -165,10 +210,12 @@ if (env != 0) { uwx_free_scoreboards(env); uwx_free_str_pool(env); - if (env->free_cb == 0) - free((void *)env); - else - (*env->free_cb)((void *)env); + if (env->on_heap) { + if (env->free_cb == 0) + free((void *)env); + else + (*env->free_cb)((void *)env); + } } return UWX_OK; } ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_env.h#5 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -80,6 +80,11 @@ uint64_t *rstate; uint64_t remapped_ip; int64_t function_offset; + uint64_t ptr_size; + uint64_t uinfo_hdr; + uint64_t uinfo_end; + uint64_t code_start; + uint64_t text_base; struct uwx_history history; alloc_cb allocate_cb; free_cb free_cb; @@ -97,8 +102,10 @@ int abi_context; int nsbreg; int nscoreboards; + int on_heap; int trace; }; extern alloc_cb uwx_allocate_cb; extern free_cb uwx_free_cb; +extern int uwx_init_env(struct uwx_env *env, size_t total_size); ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_scoreboard.c#5 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -58,6 +58,15 @@ #endif +void uwx_prealloc_scoreboard(struct uwx_env *env, struct uwx_scoreboard *sb) +{ + sb->id = env->nscoreboards++; + sb->nextused = env->used_scoreboards; + sb->prealloc = 1; + env->used_scoreboards = sb; + TRACE_B_PREALLOC(sb->id) +} + struct uwx_scoreboard *uwx_alloc_scoreboard(struct uwx_env *env) { struct uwx_scoreboard *sb; @@ -79,6 +88,7 @@ return 0; sb->id = env->nscoreboards++; sb->nextused = env->used_scoreboards; + sb->prealloc = 0; env->used_scoreboards = sb; TRACE_B_ALLOC(sb->id) } @@ -291,10 +301,12 @@ for (sb = env->used_scoreboards; sb != 0; sb = next) { TRACE_B_FREE(sb->id) next = sb->nextused; - if (env->free_cb == 0) - free((void *)sb); - else - (*env->free_cb)((void *)sb); + if (!sb->prealloc) { + if (env->free_cb == 0) + free((void *)sb); + else + (*env->free_cb)((void *)sb); + } } env->free_scoreboards = 0; env->used_scoreboards = 0; ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_scoreboard.h#3 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -51,8 +51,13 @@ uint64_t rstate[NSBREG]; int label; int id; + int prealloc; }; +extern void uwx_prealloc_scoreboard( + struct uwx_env *env, + struct uwx_scoreboard *sb); + extern struct uwx_scoreboard *uwx_alloc_scoreboard(struct uwx_env *env); extern struct uwx_scoreboard *uwx_init_scoreboards(struct uwx_env *env); ==== //depot/projects/smpng/sys/contrib/ia64/libuwx/src/uwx_self.c#5 (text+ko) ==== @@ -1,5 +1,5 @@ /* -Copyright (c) 2003 Hewlett-Packard Development Company, L.P. +Copyright (c) 2003-2006 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 @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -31,52 +32,49 @@ #include "uwx_context.h" #include "uwx_trace.h" #include "uwx_self.h" +#include "uwx_self_info.h" #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]; - uint64_t sendsig_start; - uint64_t sendsig_end; - alloc_cb allocate_cb; - free_cb free_cb; - int trace; -}; +void uwx_free_load_module_cache(struct uwx_self_info *info); + +int uwx_self_init_info_block(struct uwx_env *env, struct uwx_self_info *info) +{ + info->env = env; + info->ucontext = 0; + info->bspstore = 0; + info->sendsig_start = __load_info->li_sendsig_txt; + info->sendsig_end = __load_info->li_sendsig_txt + + __load_info->li_sendsig_tsz; + info->on_heap = 0; + info->trace = env->trace; + info->load_module_cache = NULL; + + return UWX_OK; +} struct uwx_self_info *uwx_self_init_info(struct uwx_env *env) { struct uwx_self_info *info; - if (env->allocate_cb == 0) - info = (struct uwx_self_info *) - malloc(sizeof(struct uwx_self_info)); - else - info = (struct uwx_self_info *) + info = (struct uwx_self_info *) (*env->allocate_cb)(sizeof(struct uwx_self_info)); if (info == 0) return 0; - info->env = env; - info->ucontext = 0; - info->bspstore = 0; - info->sendsig_start = __load_info->li_sendsig_txt; - info->sendsig_end = __load_info->li_sendsig_txt + - __load_info->li_sendsig_tsz; - info->allocate_cb = env->allocate_cb; - info->free_cb = env->free_cb; - info->trace = env->trace; + uwx_self_init_info_block(env, info); + info->on_heap = 1; return info; } int uwx_self_free_info(struct uwx_self_info *info) { - if (info->free_cb == 0) - free((void *)info); - else - (*info->free_cb)((void *)info); + int i; + + if (info->load_module_cache != NULL) + uwx_free_load_module_cache(info); + if (info->on_heap) + (*info->env->free_cb)((void *)info); return UWX_OK; } @@ -97,17 +95,37 @@ info->ucontext = ucontext; status = __uc_get_reason(ucontext, &reason); + if (status != 0) + return UWX_ERR_UCACCESS; status = __uc_get_ip(ucontext, &ip); + if (status != 0) + return UWX_ERR_UCACCESS; status = __uc_get_grs(ucontext, 12, 1, &sp, &nat); + if (status != 0) + return UWX_ERR_UCACCESS; status = __uc_get_cfm(ucontext, &cfm); + if (status != 0) + return UWX_ERR_UCACCESS; #ifdef NEW_UC_GET_AR status = __uc_get_ar_bsp(ucontext, &bsp); + if (status != 0) + return UWX_ERR_UCACCESS; status = __uc_get_ar_bspstore(ucontext, &info->bspstore); + if (status != 0) + return UWX_ERR_UCACCESS; status = __uc_get_ar_ec(ucontext, &ec); + if (status != 0) + return UWX_ERR_UCACCESS; #else status = __uc_get_ar(ucontext, 17, &bsp); + if (status != 0) + return UWX_ERR_UCACCESS; status = __uc_get_ar(ucontext, 18, &info->bspstore); + if (status != 0) + return UWX_ERR_UCACCESS; status = __uc_get_ar(ucontext, 66, &ec); + if (status != 0) + return UWX_ERR_UCACCESS; #endif /* The returned bsp needs to be adjusted. */ /* For interrupt frames, where bsp was advanced by a cover */ @@ -136,9 +154,10 @@ if (abi_context != UWX_ABI_HPUX_SIGCONTEXT) return UWX_SELF_ERR_BADABICONTEXT; status = uwx_get_reg(env, UWX_REG_GR(32), (uint64_t *)&ucontext); - if (status != 0) + if (status != UWX_OK) return status; - return uwx_self_init_from_sigcontext(env, info, (ucontext_t *)ucontext); + return uwx_self_init_from_sigcontext(env, info, + (ucontext_t *)(intptr_t)ucontext); } int uwx_self_copyin( @@ -164,12 +183,12 @@ case UWX_COPYIN_MSTACK: if (len == 4) { wp = (unsigned long *) loc; - *wp = *(unsigned long *)rem; + *wp = *(unsigned long *)(intptr_t)rem; TRACE_SELF_COPYIN4(rem, len, wp) status = 0; } else if (len == 8) { - *dp = *(uint64_t *)rem; + *dp = *(uint64_t *)(intptr_t)rem; TRACE_SELF_COPYIN8(rem, len, dp) status = 0; } @@ -181,13 +200,13 @@ status = 0; } else if (info->ucontext == 0 || rem < info->bspstore) { - *dp = *(uint64_t *)rem; + *dp = *(uint64_t *)(intptr_t)rem; TRACE_SELF_COPYIN8(rem, len, dp) status = 0; } else { status = __uc_get_rsebs(info->ucontext, - (uint64_t *)rem, 1, dp); + (uint64_t *)(intptr_t)rem, 1, dp); } } break; @@ -230,6 +249,88 @@ return len; } +#define MODULE_CACHE_SIZE 4 + +struct load_module_cache { + int clock; + char *names[MODULE_CACHE_SIZE]; + struct load_module_desc descs[MODULE_CACHE_SIZE]; + struct uwx_symbol_cache *symbol_cache; +}; + +void uwx_free_load_module_cache(struct uwx_self_info *info) +{ + int i; + + for (i = 0; i < MODULE_CACHE_SIZE; i++) { + if (info->load_module_cache->names[i] != NULL) + (*info->env->free_cb)((void *)info->load_module_cache->names[i]); + } + + if (info->load_module_cache->symbol_cache != NULL) + uwx_release_symbol_cache(info->env, + info->load_module_cache->symbol_cache); + + (*info->env->free_cb)((void *)info->load_module_cache); +} + +struct load_module_desc *uwx_get_modinfo( + struct uwx_self_info *info, + uint64_t ip, + char **module_name_p) +{ + int i; + UINT64 handle; + struct load_module_cache *cache; + struct load_module_desc *desc; + char *module_name; + + cache = info->load_module_cache; + if (cache == NULL) { + cache = (struct load_module_cache *) + (*info->env->allocate_cb)(sizeof(struct load_module_cache)); + if (cache == NULL) + return NULL; + for (i = 0; i < MODULE_CACHE_SIZE; i++) { + desc = &cache->descs[i]; + desc->text_base = 0; + desc->text_size = 0; + cache->names[i] = NULL; + } + cache->clock = 0; + cache->symbol_cache = NULL; + info->load_module_cache = cache; + } + for (i = 0; i < MODULE_CACHE_SIZE; i++) { + desc = &cache->descs[i]; + if (ip >= desc->text_base && ip < desc->text_base + desc->text_size) + break; + } + if (i >= MODULE_CACHE_SIZE) { + i = cache->clock; + cache->clock = (cache->clock + 1) % MODULE_CACHE_SIZE; + desc = &cache->descs[i]; + handle = dlmodinfo(ip, desc, sizeof(*desc), 0, 0, 0); + if (handle == 0) + return NULL; + if (cache->names[i] != NULL) + (*info->env->free_cb)(cache->names[i]); + cache->names[i] = NULL; + } + if (module_name_p != NULL) { + if (cache->names[i] == NULL) { + module_name = dlgetname(desc, sizeof(*desc), 0, 0, 0); + if (module_name != NULL) { + cache->names[i] = (char *) + (*info->env->allocate_cb)(strlen(module_name)+1); + if (cache->names[i] != NULL) >>> TRUNCATED FOR MAIL (1000 lines) <<<