Changeset 53657 in vbox for trunk/src/VBox
- Timestamp:
- Jan 2, 2015 12:28:56 PM (10 years ago)
- Location:
- trunk/src/VBox/ExtPacks/VBoxDTrace
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ExtPacks/VBoxDTrace/Config.kmk
r53652 r53657 37 37 VBOXDT_PATH_CMD = $(VBOXDT_PATH_ONNV)/cmd 38 38 VBOXDT_PATH_LIBCTF = $(VBOXDT_PATH_ONNV)/lib/libctf 39 VBOXDT_PATH_CMN_CTF = $(VBOXDT_PATH_ONNV)/common/ctf 39 40 VBOXDT_PATH_LIBDTRACE = $(VBOXDT_PATH_ONNV)/lib/libdtrace 41 VBOXDT_PATH_CMN_DTRACE= $(VBOXDT_PATH_ONNV)/common/dtrace -
trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTrace/Makefile.kmk
r53655 r53657 34 34 PROGRAMS += VBoxDTrace 35 35 VBoxDTrace_TEMPLATE = VBOXR3NPEXE 36 VBoxDTrace_SDKS = VBOX_ZLIB 36 37 VBoxDTrace_INCS = \ 37 38 ../include \ 38 39 $(VBOXDT_PATH_UTS)/common \ 39 40 $(VBOXDT_PATH_LIBCTF)/common \ 40 $(VBOXDT_PATH_LIBDTRACE)/common 41 $(VBOXDT_PATH_LIBDTRACE)/common \ 42 $(VBOXDT_PATH_CMN_CTF) 41 43 VBoxDTrace_SOURCES = \ 42 44 $(VBOXDT_PATH_CMD)/dtrace/dtrace.c \ … … 73 75 $(VBOXDT_PATH_LIBDTRACE)/common/dt_work.c \ 74 76 $(VBOXDT_PATH_LIBDTRACE)/common/dt_xlator.c \ 77 \ 78 $(VBOXDT_PATH_CMN_CTF)/ctf_create.c \ 79 $(VBOXDT_PATH_CMN_CTF)/ctf_error.c \ 80 $(VBOXDT_PATH_CMN_CTF)/ctf_decl.c \ 81 $(VBOXDT_PATH_CMN_CTF)/ctf_hash.c \ 82 $(VBOXDT_PATH_CMN_CTF)/ctf_labels.c \ 83 $(VBOXDT_PATH_CMN_CTF)/ctf_lookup.c \ 84 $(VBOXDT_PATH_CMN_CTF)/ctf_open.c \ 85 $(VBOXDT_PATH_CMN_CTF)/ctf_types.c \ 86 $(VBOXDT_PATH_CMN_CTF)/ctf_util.c \ 87 \ 88 $(VBOXDT_PATH_LIBCTF)/common/ctf_subr.c \ 89 $(VBOXDT_PATH_LIBCTF)/common/ctf_lib.c 90 91 VBoxDTrace_VBOX_TODO = \ 75 92 76 93 VBoxDTrace_VBOX_TODO = \ -
trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h
r53655 r53657 151 151 # define EALREADY (114) 152 152 # define EOVERFLOW (79) 153 # define ENOTSUP (48) 153 154 #endif 154 155 … … 424 425 } while (0) 425 426 426 #endif 427 /* 428 * gelf 429 */ 430 # include "../../../Runtime/include/internal/ldrELF64.h" 431 typedef Elf64_Half GElf_Half; 432 typedef Elf64_Shdr GElf_Shdr; 433 typedef Elf64_Ehdr GElf_Ehdr; 434 typedef Elf64_Sym GElf_Sym; 435 436 #endif /* IN_RING3 */ 427 437 428 438 RT_C_DECLS_END -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c
r53656 r53657 26 26 */ 27 27 28 #ifndef VBOX 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 29 30 … … 31 32 #include <sys/param.h> 32 33 #include <sys/mman.h> 34 #else /* VBOX */ 35 #endif /* VBOX */ 33 36 #include <ctf_impl.h> 34 37 … … 94 97 if (dmd->dmd_name) { 95 98 ctm.ctm_name = soff; 96 soff += strlen(dmd->dmd_name) + 1;99 soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1; 97 100 } else 98 101 ctm.ctm_name = 0; … … 117 120 if (dmd->dmd_name) { 118 121 ctlm.ctlm_name = soff; 119 soff += strlen(dmd->dmd_name) + 1;122 soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1; 120 123 } else 121 124 ctlm.ctlm_name = 0; … … 142 145 cte.cte_name = soff; 143 146 cte.cte_value = dmd->dmd_value; 144 soff += strlen(dmd->dmd_name) + 1;147 soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1; 145 148 bcopy(&cte, t, sizeof (cte)); 146 149 t += sizeof (cte); … … 258 261 * bcopy the finished header to the start of the buffer. 259 262 */ 260 hdr.cth_stroff = hdr.cth_typeoff + size;261 hdr.cth_strlen = fp->ctf_dtstrlen;263 hdr.cth_stroff = hdr.cth_typeoff + VBDTCAST(uint_t)size; 264 hdr.cth_strlen = VBDTCAST(uint_t)fp->ctf_dtstrlen; 262 265 size = sizeof (ctf_header_t) + hdr.cth_stroff + hdr.cth_strlen; 263 266 … … 597 600 598 601 dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, 0); 599 dtd->dtd_data.ctt_size = clp2(P2ROUNDUP(ep->cte_bits, NBBY) / NBBY);602 dtd->dtd_data.ctt_size = VBDTCAST(ushort_t)clp2(P2ROUNDUP(ep->cte_bits, NBBY) / NBBY); 600 603 dtd->dtd_u.dtu_enc = *ep; 601 604 … … 777 780 778 781 dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_ENUM, flag, 0); 779 dtd->dtd_data.ctt_size = fp->ctf_dmodel->ctd_int;782 dtd->dtd_data.ctt_size = VBDTCAST(ushort_t)fp->ctf_dmodel->ctd_int; 780 783 781 784 return (type); -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c
r53656 r53657 25 25 */ 26 26 27 #ifndef VBOX 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 #endif 28 30 29 31 /* … … 177 179 178 180 va_start(ap, format); 181 #ifndef VBOX 179 182 n = vsnprintf(cd->cd_ptr, len, format, ap); 183 #else 184 n = RTStrPrintfV(cd->cd_ptr, len, format, ap); 185 #endif 180 186 va_end(ap); 181 187 -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c
r53656 r53657 25 25 */ 26 26 27 #ifndef VBOX 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 #endif 28 30 29 31 #include <ctf_impl.h> -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c
r53656 r53657 26 26 */ 27 27 28 #ifndef VBOX 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 #endif 29 31 30 32 #include <ctf_impl.h> -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h
r53656 r53657 29 29 #define _CTF_IMPL_H 30 30 31 #ifndef VBOX 31 32 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 … … 34 35 #include <sys/errno.h> 35 36 #include <sys/sysmacros.h> 37 #else /* VBOX */ 38 # include "../../../../../Runtime/include/internal/ldrELF32.h" 39 # include "../../../../../Runtime/include/internal/ldrELF64.h" 40 # include <errno.h> 41 #endif /* VBOX */ 36 42 #include <sys/ctf_api.h> 37 43 38 44 #ifdef _KERNEL 39 45 46 #ifndef VBOX 40 47 #include <sys/systm.h> 41 48 #include <sys/cmn_err.h> 42 49 #include <sys/varargs.h> 50 #endif 43 51 44 52 #define isspace(c) \ … … 50 58 #else /* _KERNEL */ 51 59 60 #ifndef VBOX 52 61 #include <strings.h> 53 62 #include <stdlib.h> … … 56 65 #include <limits.h> 57 66 #include <ctype.h> 67 #endif 58 68 59 69 #endif /* _KERNEL */ … … 330 340 extern int _libctf_debug; /* debugging messages enabled */ 331 341 342 #ifdef VBOX 343 # ifndef MAP_FAILED /* returned by ctf_data_alloc on failure. */ 344 # define MAP_FAILED ((void *)~(uintptr_t)0) 345 # endif 346 #endif 347 332 348 #ifdef __cplusplus 333 349 } -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c
r53656 r53657 25 25 */ 26 26 27 #ifndef VBOX 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 #endif 28 30 29 31 #include <ctf_impl.h> -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c
r53656 r53657 26 26 */ 27 27 28 #ifndef VBOX 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 29 30 30 31 #include <sys/sysmacros.h> 32 #else /* VBOX */ 33 # include <ctype.h> 34 #endif /* VBOX */ 31 35 #include <ctf_impl.h> 32 36 … … 198 202 } 199 203 200 if (fp->ctf_sxlate[symidx] == -1u)204 if (fp->ctf_sxlate[symidx] == ~0u /*VBOX: -1u*/) 201 205 return (ctf_set_errno(fp, ECTF_NOTYPEDAT)); 202 206 … … 261 265 } 262 266 263 if (fp->ctf_sxlate[symidx] == -1u)267 if (fp->ctf_sxlate[symidx] == ~0u /*VBOX: -1u*/) 264 268 return (ctf_set_errno(fp, ECTF_NOFUNCDAT)); 265 269 -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c
r53656 r53657 26 26 */ 27 27 28 #ifndef VBOX 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 29 30 #endif 31 32 #ifndef VBOX 30 33 #include <ctf_impl.h> 31 34 #include <sys/mman.h> 32 35 #include <sys/zmod.h> 36 #else /* VBOX */ 37 # define CTF_OLD_VERSIONS 38 # include <ctf_impl.h> 39 # include <zlib.h> 40 # define z_compress compress 41 # define z_uncompress uncompress 42 # define z_strerror zError 43 #endif /* VBOX */ 33 44 34 45 static const ctf_dmodel_t _libctf_models[] = { … … 143 154 strcmp(name, "_START_") == 0 || 144 155 strcmp(name, "_END_") == 0) { 145 *xp = -1u;156 *xp = ~0u /*VBOX: -1u*/; 146 157 continue; 147 158 } … … 151 162 if (objtoff >= hp->cth_funcoff || 152 163 (gsp->st_shndx == SHN_ABS && gsp->st_value == 0)) { 153 *xp = -1u;164 *xp = ~0u /*VBOX: -1u*/; 154 165 break; 155 166 } … … 161 172 case STT_FUNC: 162 173 if (funcoff >= hp->cth_typeoff) { 163 *xp = -1u;174 *xp = ~0u /*VBOX: -1u*/; 164 175 break; 165 176 } … … 183 194 184 195 default: 185 *xp = -1u;196 *xp = ~0u /*VBOX: -1u*/; 186 197 break; 187 198 } … … 632 643 */ 633 644 if (hp.cth_flags & CTF_F_COMPRESS) { 645 #ifndef VBOX 634 646 size_t srclen, dstlen; 647 #else 648 uLong srclen; 649 uLong dstlen; 650 #endif 635 651 const void *src; 636 652 int rc = Z_OK; 637 653 654 #ifndef VBOX 638 655 if (ctf_zopen(errp) == NULL) 639 656 return (NULL); /* errp is set for us */ 657 #endif 640 658 641 659 if ((base = ctf_data_alloc(size + hdrsz)) == MAP_FAILED) … … 647 665 648 666 src = (uchar_t *)ctfsect->cts_data + hdrsz; 649 srclen = ctfsect->cts_size - hdrsz;650 dstlen = size;667 srclen = VBDTCAST(uLong)(ctfsect->cts_size - hdrsz); 668 dstlen = VBDTCAST(uLong)size; 651 669 652 670 if ((rc = z_uncompress(buf, &dstlen, src, srclen)) != Z_OK) { -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c
r53656 r53657 26 26 */ 27 27 28 #ifndef VBOX 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 #endif 29 31 30 32 #include <ctf_impl.h> … … 310 312 { 311 313 ssize_t rv = ctf_type_lname(fp, type, buf, len); 312 return (rv >= 0 && rv < len ? buf : NULL);314 return (rv >= 0 && VBDTCAST(size_t)rv < len ? buf : NULL); 313 315 } 314 316 … … 406 408 for (; n != 0; n--, mp++) { 407 409 ssize_t am = ctf_type_align(fp, mp->ctm_type); 408 align = MAX( align, am);410 align = MAX(VBDTCAST(ssize_t)align, am); 409 411 } 410 412 } else { … … 412 414 for (; n != 0; n--, lmp++) { 413 415 ssize_t am = ctf_type_align(fp, lmp->ctlm_type); 414 align = MAX( align, am);416 align = MAX(VBDTCAST(ssize_t)align, am); 415 417 } 416 418 } -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c
r53656 r53657 25 25 */ 26 26 27 #ifndef VBOX 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 #endif 28 30 29 31 #include <ctf_impl.h> -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c
r53650 r53657 25 25 */ 26 26 27 #ifndef VBOX 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 … … 36 37 #include <dlfcn.h> 37 38 #include <gelf.h> 38 39 #else 40 # include <libctf.h> 41 # include <ctf_impl.h> 42 # include <iprt/param.h> 43 # include <sys/stat.h> 44 # include <stdio.h> 45 # include <fcntl.h> 46 # ifdef _MSC_VER 47 # include <io.h> 48 # else 49 # include <unistd.h> 50 # endif 51 # define stat64 stat 52 # define fstat64 fstat 53 # define open64 open 54 # define off64_t int64_t 55 #endif 56 57 #ifndef VBOX /* staticly linked in */ 39 58 #ifdef _LP64 40 59 static const char *_libctf_zlib = "/usr/lib/64/libz.so"; … … 48 67 void *z_dlp; 49 68 } zlib; 69 #endif /* !VBOX */ 50 70 51 71 static size_t _PAGESIZE; 52 72 static size_t _PAGEMASK; 53 73 74 #ifndef VBOX 54 75 #pragma init(_libctf_init) 55 76 void 56 77 _libctf_init(void) 57 { 78 #else 79 void libctf_init(void) 80 #endif 81 { 82 #ifndef VBOX 58 83 const char *p = getenv("LIBCTF_DECOMPRESSOR"); 59 84 60 85 if (p != NULL) 61 86 _libctf_zlib = p; /* use alternate decompression library */ 87 #endif 62 88 63 89 _libctf_debug = getenv("LIBCTF_DEBUG") != NULL; 64 90 91 #ifndef VBOX 65 92 _PAGESIZE = getpagesize(); 93 #else 94 _PAGESIZE = PAGE_SIZE; 95 #endif 66 96 _PAGEMASK = ~(_PAGESIZE - 1); 67 97 } 98 99 #ifdef VBOX 100 /* 101 * Fake MMAP for read only access. 102 */ 103 # define munmap(a_pvMem, a_cbMem) \ 104 RTMemPageFree(a_pvMem, a_cbMem) 105 106 # define mmap64(a_pvAddr, a_cb, a_fProt, a_fFlags, a_fd, a_offFile) \ 107 VBoxCtfMap64Fake(a_pvAddr, a_cb, a_fProt, a_fFlags, a_fd, a_offFile) 108 109 # undef PROT_READ 110 # define PROT_READ 0xfeed 111 # undef MAP_PRIVATE 112 # define MAP_PRIVATE 0xbeef 113 114 static void *VBoxCtfMap64Fake(void *pvAddr, size_t cb, int fProt, int fFlags, int fd, int64_t offFile) 115 { 116 off_t const offSaved = lseek(fd, 0, SEEK_CUR); 117 void *pvRet; 118 int err; 119 120 Assert(pvAddr == NULL); NOREF(pvAddr); 121 Assert(fProt == PROT_READ); 122 Assert(fFlags == MAP_PRIVATE); 123 if ((off_t)offFile != offFile) { 124 errno = EIO; 125 return MAP_FAILED; 126 } 127 128 if (lseek(offFile, offFile, SEEK_SET) >= 0) { 129 130 pvRet = RTMemPageAllocZ(cb); 131 if (!pvRet) { 132 #ifdef _MSC_VER 133 ssize_t cbRead = read(fd, pvRet, (unsigned int)cb); 134 #else 135 ssize_t cbRead = read(fd, pvRet, cb); 136 #endif 137 if (cbRead < 0) { 138 RTMemPageFree(pvRet, cb); 139 pvRet = MAP_FAILED; 140 } 141 } else { 142 errno = ENOMEM; 143 pvRet = MAP_FAILED; 144 } 145 146 /* restore original position */ 147 err = errno; 148 lseek(offSaved, 0, SEEK_SET); 149 errno = err; 150 } 151 152 return pvRet; 153 } 154 155 /* 156 * pread64 157 */ 158 #define pread64(a_fd, a_pvBuf, a_cbToRead, a_offFile) \ 159 VBoxCtfPRead64(a_fd, a_pvBuf, a_cbToRead, a_offFile) 160 161 static ssize_t VBoxCtfPRead64(int fd, void *pvBuf, size_t cbToRead, int64_t offFile) 162 { 163 if ((off_t)offFile != offFile) { 164 errno = EIO; 165 return -1; 166 } 167 168 if (lseek(fd, offFile, SEEK_SET) < 0) 169 return -1; 170 #ifndef _MSC_VER 171 return read(fd, pvBuf, cbToRead); 172 #else 173 return read(fd, pvBuf, (unsigned int)cbToRead); 174 #endif 175 } 176 177 178 179 #endif /* VBOX */ 180 181 #ifndef VBOX 68 182 69 183 /* … … 113 227 return (zlib.z_error(err)); 114 228 } 229 230 #endif /* VBOX */ 115 231 116 232 /* -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c
r53650 r53657 25 25 */ 26 26 27 #ifndef VBOX 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 #endif 28 30 29 31 #include <ctf_impl.h> 30 32 #include <libctf.h> 33 #ifndef VBOX 31 34 #include <sys/mman.h> 32 35 #include <stdarg.h> 36 #else 37 # include <iprt/asm.h> 38 # include <iprt/log.h> 39 #endif 33 40 34 41 void * 35 42 ctf_data_alloc(size_t size) 36 43 { 44 #ifndef VBOX 37 45 return (mmap(NULL, size, PROT_READ | PROT_WRITE, 38 46 MAP_PRIVATE | MAP_ANON, -1, 0)); 47 #else 48 void *pv = RTMemPageAlloc(size); 49 return pv == NULL ? MAP_FAILED : pv; 50 #endif 39 51 } 40 52 … … 42 54 ctf_data_free(void *buf, size_t size) 43 55 { 56 #ifndef VBOX 44 57 (void) munmap(buf, size); 58 #else 59 RTMemPageFree(buf, size); 60 #endif 45 61 } 46 62 … … 48 64 ctf_data_protect(void *buf, size_t size) 49 65 { 66 #ifndef VBOX 50 67 (void) mprotect(buf, size, PROT_READ); 68 #else 69 int rc = RTMemProtect(buf, size, RTMEM_PROT_READ); 70 AssertRC(rc); 71 #endif 51 72 } 52 73 … … 54 75 ctf_alloc(size_t size) 55 76 { 77 #ifndef VBOX 56 78 return (malloc(size)); 79 #else 80 return RTMemAlloc(size); 81 #endif 57 82 } 58 83 … … 61 86 ctf_free(void *buf, size_t size) 62 87 { 88 #ifndef VBOX 63 89 free(buf); 90 #else 91 RTMemFree(buf); 92 #endif 64 93 } 65 94 … … 78 107 79 108 va_start(alist, format); 109 #ifndef VBOX 80 110 (void) fputs("libctf DEBUG: ", stderr); 81 111 (void) vfprintf(stderr, format, alist); 112 #else 113 RTLogPrintf("libctf DEBUG: %N", format, alist); 114 #endif 82 115 va_end(alist); 83 116 } -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h
r53652 r53657 56 56 extern int _libctf_debug; 57 57 58 #ifdef VBOX 59 extern void libctf_init(void); 60 #endif 61 58 62 #ifdef __cplusplus 59 63 } -
trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c
r53652 r53657 686 686 #ifdef VBOX 687 687 # include <iprt/critsect.h> 688 # include <libctf.h> 688 689 extern RTCRITSECT dt_qsort_lock; /* dt_aggregate.c */ 689 690 … … 703 704 } 704 705 #else 706 707 libctf_init(); 705 708 RTCritSectInit(&dt_qsort_lock); 706 709 #endif
Note:
See TracChangeset
for help on using the changeset viewer.