Changeset 3565
- Timestamp:
- Aug 27, 2007, 6:06:17 AM (18 years ago)
- Location:
- trunk/kStuff/kProfile
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kProfile/Makefile.kmk
r3537 r3565 1 1 # $Id: $ 2 2 ## @file 3 #4 3 # kProfiler Mark 2 5 4 # 6 # Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net> 5 7 6 # 7 # Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 8 # 9 # This file is part of k LIBC.9 # This file is part of kProfiler. 10 10 # 11 # k LIBC is free software; you can redistribute it and/or modify12 # it under the terms of the GNU General Public License as published by13 # the Free Software Foundation; either version 2 of the License, or14 # (at your option) any later version.11 # kProfiler is free software; you can redistribute it and/or 12 # modify it under the terms of the GNU Lesser General Public 13 # License as published by the Free Software Foundation; either 14 # version 2.1 of the License, or (at your option) any later version. 15 15 # 16 # k LIBCis distributed in the hope that it will be useful,16 # kProfiler is distributed in the hope that it will be useful, 17 17 # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 # GNUGeneral Public License for more details.18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 # Lesser General Public License for more details. 20 20 # 21 # You should have received a copy of the GNU General Public License22 # along with kLIBC; if not, write to the Free Software23 # Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA21 # You should have received a copy of the GNU Lesser General Public 22 # License along with kProfiler; if not, write to the Free Software 23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 # 25 # 25 26 26 27 27 DEPTH = ../.. … … 68 68 TEMPLATE_kPrf2_ASFLAGS.win.amd64 = -f win64 -g cv8 69 69 70 TEMPLATE_kPrf2_INCS = \ 71 ../include 70 72 #TEMPLATE_kPrf2_INCS.win = \ 71 73 # $(PATH_DEV)/x86.win32/vcc70/include \ … … 113 115 # kPrf2Read - The read & producer of statistics. 114 116 # 115 kPrf2Read_TEMPLATE = kPrf2 117 #kPrf2Read_TEMPLATE = kPrf2 118 kPrf2Read_TEMPLATE = kStuffEXE 116 119 kPrf2Read_SOURCES = \ 117 120 kPrf2Read.cpp 118 119 # kDbg stuff 120 KDBG_ROOT ?= $(PATH_CURRENT)/../kProfile 121 kPrf2Read_INCS += $(KDBG_ROOT) 122 kPrf2Read_SOURCES += \ 123 dbgmodule.cpp \ 124 dbgline.cpp \ 125 dbgsymbol.cpp 126 ifeq ($(BUILD_TARGET),win) 127 kPrf2Read_SOURCES.win += dbgModPE-win.cpp 128 else 129 kPrf2Read_SOURCES += dbgModPE-generic.cpp 130 endif 121 kPrf2Read_LIBS = \ 122 $(PATH_LIB)/kDbgStatic$(SUFF_LIB) \ 123 $(PATH_LIB)/kRdrStatic$(SUFF_LIB) \ 124 $(PATH_LIB)/kHlpCRTStatic$(SUFF_LIB) 131 125 132 126 # kLdr stuff 133 127 KLDR_ROOT ?= $(PATH_CURRENT)/../kLdr 134 128 kPrf2Read_INCS += $(KLDR_ROOT) 135 136 # IPRT stuff137 VBOX_ROOT ?= y:/coding/vbox/svn/trunk138 kPrf2Read_INCS += $(VBOX_ROOT)/include139 kPrf2Read_DEFS += IN_RING3 IN_RT_R3 KDBG_USE_IPRT KCOMMON_ALREADY_INCLUDED_STD_TYPES140 ifeq ($(BUILD_TARGET),win)141 kPrf2Read_LIBS = \142 $(VBOX_ROOT)/out/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)/lib/VBoxRT$(SUFF_LIB)143 else144 kPrf2Read_LIBS = \145 $(VBOX_ROOT)/out/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)/bin/VBoxRT$(SUFF_DLL)146 endif147 129 148 130 -
trunk/kStuff/kProfile/dllmain-win.cpp
r3537 r3565 1 /* $Id: $ */ 2 /** @file 3 * kProfiler Mark 2 - The Windows DllMain for the profiler DLL. 4 */ 1 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kProfile. 10 * 11 * kProfile is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * kProfile is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfile; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 * 25 */ 2 26 3 27 … … 6 30 *******************************************************************************/ 7 31 #include <Windows.h> 8 9 32 #include "kProfileR3.h" 10 33 11 34 12 13 35 /** 14 * The DLL Main for the IPRTDLL.36 * The DLL Main for the kPrf DLL. 15 37 * 16 * This is required for profiling, it is not (currently) used for any 17 * other purposes. (It could be used to track the death of alian threads 18 * perhaps, if we decide to adopt them automatically.) 38 * This is required because we need to initialize the profiler at some point 39 * and because we need to know when threads terminate. (We don't care about 40 * when threads get created, we simply pick them up when we see them the 41 * first time.) 19 42 * 20 43 * @returns Success indicator. -
trunk/kStuff/kProfile/kPrf2-win-amd64.def
r3537 r3565 1 ; $Id: $LIBRARY kPrf2 2 ;; @file 3 ; kProfiler Mark 2 - Windows Linker Definition File, AMD64. 4 ; 5 6 ; 7 ; Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 ; 9 ; This file is part of kProfiler. 10 ; 11 ; kProfiler is free software; you can redistribute it and/or 12 ; modify it under the terms of the GNU Lesser General Public 13 ; License as published by the Free Software Foundation; either 14 ; version 2.1 of the License, or (at your option) any later version. 15 ; 16 ; kProfiler is distributed in the hope that it will be useful, 17 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 ; Lesser General Public License for more details. 20 ; 21 ; You should have received a copy of the GNU Lesser General Public 22 ; License along with kProfiler; if not, write to the Free Software 23 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 ; 25 26 1 27 LIBRARY kPrf2 2 28 EXPORTS … … 4 30 _pexit 5 31 KPrfInit 32 33 -
trunk/kStuff/kProfile/kPrf2-win-x86.def
r3537 r3565 1 ; $Id: $ 2 ;; @file 3 ; kProfiler Mark 2 - Windows Linker Definition File, x86. 4 ; 5 6 ; 7 ; Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 ; 9 ; This file is part of kProfiler. 10 ; 11 ; kProfiler is free software; you can redistribute it and/or 12 ; modify it under the terms of the GNU Lesser General Public 13 ; License as published by the Free Software Foundation; either 14 ; version 2.1 of the License, or (at your option) any later version. 15 ; 16 ; kProfiler is distributed in the hope that it will be useful, 17 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 ; Lesser General Public License for more details. 20 ; 21 ; You should have received a copy of the GNU Lesser General Public 22 ; License along with kProfiler; if not, write to the Free Software 23 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 ; 25 26 1 27 LIBRARY kPrf2 2 28 EXPORTS … … 4 30 _pexit 5 31 KPrfInit 32 -
trunk/kStuff/kProfile/kPrf2Read.cpp
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * 4 * kProfiler Mark 2 - The reader and statistics producer.5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 7 * 8 * 9 * This file is part of k LIBC.10 * 11 * k LIBC is free software; you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation; either version 2 of the License, or14 * (at your option) any later version.15 * 16 * k LIBCis distributed in the hope that it will be useful,3 * kProfiler Mark 2 - The reader and producer of statistics. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kProfiler. 10 * 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 26 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 * 25 */ 27 26 28 27 … … 34 33 #include <string.h> 35 34 #include <stdarg.h> 36 #if 0 37 # ifdef KPRF_OS_WINDOWS 38 # include <malloc.h> 39 typedef unsigned char uint8_t; 40 typedef signed char int8_t; 41 typedef unsigned short uint16_t; 42 typedef signed short int16_t; 43 typedef unsigned int uint32_t; 44 typedef signed int int32_t; 45 typedef unsigned _int64 uint64_t; 46 typedef signed _int64 int64_t; 47 typedef size_t uintptr_t; 48 # else 49 # include <stdint.h> 50 # endif 51 #else 52 /* iprt mode */ 53 #include <iprt/types.h> 54 #include <iprt/err.h> 55 #include <iprt/avl.h> 56 #if 1 57 # include <iprt/alloc.h> 58 # define malloc(cb) RTMemAlloc(cb) 59 # define free(pv) RTMemFree(pv) 60 #endif 61 #endif 62 63 #include "dbg.h" 35 #include <k/kDbg.h> 64 36 65 37 … … 69 41 */ 70 42 #define KPRF_OFF2PTR(TypePrefix, TypeName, off, pHdr) \ 71 ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + ( uintptr_t)pHdr) )43 ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + (KUPTR)pHdr) ) 72 44 73 45 /** @def KPRF_ALIGN … … 78 50 79 51 /** @def KPRF_OFFSETOF 80 * My usual extended OFFSETOF macro, except this returns uint32_tand mangles the type name.52 * My usual extended offsetof macro, except this returns KU32 and mangles the type name. 81 53 * @internal 82 54 */ 83 #define KPRF_OFFSETOF(kPrfType, Member) ( ( uint32_t)(uintptr_t)&((KPRF_TYPE(P,kPrfType))0)->Member )55 #define KPRF_OFFSETOF(kPrfType, Member) ( (KU32)(KUPTR)&((KPRF_TYPE(P,kPrfType))0)->Member ) 84 56 85 57 /** @def PRF_SIZEOF … … 161 133 * @param pOut Where to write errors. 162 134 */ 163 PKPRFHDR kPrfLoad(const char *pszFilename, uint32_t*pcb, FILE *pOut)135 PKPRFHDR kPrfLoad(const char *pszFilename, KU32 *pcb, FILE *pOut) 164 136 { 165 137 FILE *pFile = fopen(pszFilename, "rb"); … … 215 187 * @param pOut Where to write error messages. 216 188 */ 217 static bool kPrfIsValidate(PCKPRFHDR pHdr, uint32_tcb, FILE *pOut)189 static bool kPrfIsValidate(PCKPRFHDR pHdr, KU32 cb, FILE *pOut) 218 190 { 219 191 /* … … 254 226 KPRF_VALIDATE_SIZE(Thread, sizeof(KPRF32THREAD), sizeof(KPRF64THREAD)); 255 227 KPRF_VALIDATE_SIZE(Stack, 256 ( uint32_t)&((PKPRF32STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames],257 ( uint32_t)&((PKPRF64STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames]);258 259 uintptr_t cbHeader = (uintptr_t)&pHdr->Hdr32.aiFunctions[pHdr->Hdr32.cFunctions] - (uintptr_t)pHdr;260 if ( cbHeader != ( uint32_t)cbHeader228 (KU32)&((PKPRF32STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames], 229 (KU32)&((PKPRF64STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames]); 230 231 KUPTR cbHeader = (KUPTR)&pHdr->Hdr32.aiFunctions[pHdr->Hdr32.cFunctions] - (KUPTR)pHdr; 232 if ( cbHeader != (KU32)cbHeader 261 233 || cbHeader >= cb) 262 234 { … … 267 239 268 240 /* The space assignment is hereby required to be equal to the member order in the header. */ 269 uint32_toffMin = cbHeader;241 KU32 offMin = cbHeader; 270 242 #define KPRF_VALIDATE_OFF(off, name) do {\ 271 243 if ( off > 0 \ … … 322 294 * Validate the function lookup table 323 295 */ 324 for ( uint32_ti = 0; i < pHdr->Hdr32.cFunctions; i++)296 for (KU32 i = 0; i < pHdr->Hdr32.cFunctions; i++) 325 297 if (pHdr->Hdr32.aiFunctions[i] >= pHdr->Hdr32.cFunctions) 326 298 { … … 362 334 * Load and validate the data set. 363 335 */ 364 uint32_tcb;336 KU32 cb; 365 337 PKPRFHDR pHdr = kPrfLoad(pszFilename, &cb, pOut); 366 338 if (!pHdr) … … 407 379 * Load and validate the data set. 408 380 */ 409 uint32_tcb;381 KU32 cb; 410 382 PKPRFHDR pHdr = kPrfLoad(pszFilename, &cb, pOut); 411 383 if (!pHdr) -
trunk/kStuff/kProfile/kProfileR3.cpp
r3537 r3565 1 /* $Id: $ */ 2 /** @file 3 * kProfiler Mark 2 - The Ring-3 Implementation. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kProfiler. 10 * 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 * 25 */ 1 26 2 27 … … 8 33 # include <psapi.h> 9 34 # include <malloc.h> 10 typedef unsigned char uint8_t;11 typedef signed char int8_t;12 typedef unsigned short uint16_t;13 typedef signed short int16_t;14 typedef unsigned int uint32_t;15 typedef signed int int32_t;16 typedef unsigned _int64 uint64_t;17 typedef signed _int64 int64_t;18 typedef size_t uintptr_t;19 35 # if _MSC_VER >= 1400 20 36 # include <intrin.h> … … 45 61 #endif 46 62 63 #include <k/kDefs.h> 64 #include <k/kTypes.h> 47 65 48 66 /* … … 100 118 /** Update the state. */ 101 119 #define KPRF_RWLOCK_SETSTATE(pRWLock, enmNewState) \ 102 kPrfAtomicSet32((volatile uint32_t *)&(pRWLock)->enmState, (uint32_t)(enmNewState))120 kPrfAtomicSet32((volatile KU32 *)&(pRWLock)->enmState, (KU32)(enmNewState)) 103 121 104 122 /** Read/Write lock type. */ … … 109 127 KPRF_TYPE(,MUTEX) Mutex; 110 128 /** The current number of readers. */ 111 uint32_tcReaders;129 KU32 cReaders; 112 130 /** The number of readers waiting. */ 113 uint32_tcReadersWaiting;131 KU32 cReadersWaiting; 114 132 /** The current number of waiting writers. */ 115 uint32_tcWritersWaiting;133 KU32 cWritersWaiting; 116 134 # if defined(KPRF_OS_WINDOWS) 117 135 /** The handle of the event object on which the waiting readers block. (manual reset). */ … … 218 236 * @returns The thread id. 219 237 */ 220 static inline uintptr_tkPrfGetThreadId(void)238 static inline KUPTR kPrfGetThreadId(void) 221 239 { 222 240 /* Win32/64 */ 223 241 #if defined(KPRF_OS_WINDOWS) 224 uintptr_t ThreadId = (uintptr_t)GetCurrentThreadId();242 KUPTR ThreadId = (KUPTR)GetCurrentThreadId(); 225 243 226 244 /* Posix Threads */ 227 245 #elif defined(KPRF_USE_PTHREAD) 228 uintptr_t ThreadId = (uintptr_t)pthread_self();246 KUPTR ThreadId = (KUPTR)pthread_self(); 229 247 230 248 #elif defined(KPRF_OS_OS2) … … 248 266 * @returns The process id. 249 267 */ 250 static inline uintptr_tkPrfGetProcessId(void)268 static inline KUPTR kPrfGetProcessId(void) 251 269 { 252 270 /* Win32/64 */ 253 271 #if defined(KPRF_OS_WINDOWS) 254 uintptr_t ThreadId = (uintptr_t)GetProcessId(GetCurrentProcess());272 KUPTR ThreadId = (KUPTR)GetProcessId(GetCurrentProcess()); 255 273 256 274 #elif defined(KPRF_OS_OS2) … … 261 279 262 280 #else 263 uintptr_t ThreadId = (uintptr_t)getpid();281 KUPTR ThreadId = (KUPTR)getpid(); 264 282 #endif 265 283 … … 302 320 * This must correspond to what the assembly code are doing. 303 321 */ 304 static inline uint64_tkPrfNow(void)322 static inline KU64 kPrfNow(void) 305 323 { 306 324 #if defined(HAVE_INTRIN) … … 309 327 union 310 328 { 311 uint64_tu64;329 KU64 u64; 312 330 struct 313 331 { 314 uint32_tu32Lo;315 uint32_tu32Hi;332 KU32 u32Lo; 333 KU32 u32Hi; 316 334 } s; 317 335 } u; … … 336 354 * Atomically set a 32-bit value. 337 355 */ 338 static inline void kPrfAtomicSet32(volatile uint32_t *pu32, const uint32_tu32)356 static inline void kPrfAtomicSet32(volatile KU32 *pu32, const KU32 u32) 339 357 { 340 358 #if defined(HAVE_INTRIN) … … 365 383 * Atomically set a 64-bit value. 366 384 */ 367 static inline void kPrfAtomicSet64(volatile uint64_t *pu64, uint64_tu64)385 static inline void kPrfAtomicSet64(volatile KU64 *pu64, KU64 u64) 368 386 { 369 387 #if defined(HAVE_INTRIN) && KPRF_BITS == 64 370 _InterlockedExchange64(( int64_t *)pu64, (const int64_t)u64);388 _InterlockedExchange64((KI64 *)pu64, (const KI64)u64); 371 389 372 390 #elif defined(__GNUC__) && KPRF_BITS == 64 … … 382 400 "=m" (*pu64) 383 401 : "0" (*pu64), 384 "b" ( ( uint32_t)u64 ),385 "c" ( ( uint32_t)(u64 >> 32) ));402 "b" ( (KU32)u64 ), 403 "c" ( (KU32)(u64 >> 32) )); 386 404 387 405 #elif _MSC_VER … … 407 425 * Atomically add a 32-bit integer to another. 408 426 */ 409 static inline void kPrfAtomicAdd32(volatile uint32_t *pu32, const uint32_tu32)427 static inline void kPrfAtomicAdd32(volatile KU32 *pu32, const KU32 u32) 410 428 { 411 429 #if defined(HAVE_INTRIN) … … 431 449 #define KPRF_ATOMIC_ADD32(a,b) kPrfAtomicAdd32(a, b) 432 450 #define KPRF_ATOMIC_INC32(a) kPrfAtomicAdd32(a, 1); 433 #define KPRF_ATOMIC_DEC32(a) kPrfAtomicAdd32(a, ( uint32_t)-1);451 #define KPRF_ATOMIC_DEC32(a) kPrfAtomicAdd32(a, (KU32)-1); 434 452 435 453 … … 438 456 * Atomically isn't quite required, just a non-corruptive manner, assuming all updates are adds. 439 457 */ 440 static inline void kPrfAtomicAdd64(volatile uint64_t *pu64, const uint64_tu64)458 static inline void kPrfAtomicAdd64(volatile KU64 *pu64, const KU64 u64) 441 459 { 442 460 #if defined(HAVE_INTRIN) && KPRF_BITS == 64 443 _InterlockedExchangeAdd64((volatile int64_t *)pu64, (const int64_t)u64);461 _InterlockedExchangeAdd64((volatile KI64 *)pu64, (const KI64)u64); 444 462 445 463 #elif defined(__GNUC__) && KPRF_BITS == 64 … … 451 469 __asm__ __volatile__("lock; addl %0, %2\n\t" 452 470 "lock; adcl %1, %3\n\t" 453 : "=m" (*(volatile uint32_t*)pu64),454 "=m" (*((volatile uint32_t*)pu64 + 1))455 : "r" (( uint32_t)u64),456 "r" (( uint32_t)(u64 >> 32)));471 : "=m" (*(volatile KU32 *)pu64), 472 "=m" (*((volatile KU32 *)pu64 + 1)) 473 : "r" ((KU32)u64), 474 "r" ((KU32)(u64 >> 32))); 457 475 458 476 #elif _MSC_VER … … 922 940 * 923 941 */ 924 static int kPrfGetModSeg(KPRF_TYPE(,UPTR) uAddress, char *pszPath, uint32_t cchPath, uint32_t*piSegment,942 static int kPrfGetModSeg(KPRF_TYPE(,UPTR) uAddress, char *pszPath, KU32 cchPath, KU32 *piSegment, 925 943 KPRF_TYPE(P,UPTR) puBasePtr, KPRF_TYPE(P,UPTR) pcbSegmentMinusOne) 926 944 { … … 945 963 __try 946 964 { 947 const uintptr_t uImageBase = (uintptr_t)pahModules[i];965 const KUPTR uImageBase = (KUPTR)pahModules[i]; 948 966 union 949 967 { 950 uint8_t*pu8;968 KU8 *pu8; 951 969 PIMAGE_DOS_HEADER pDos; 952 970 PIMAGE_NT_HEADERS pNt; 953 971 PIMAGE_NT_HEADERS32 pNt32; 954 972 PIMAGE_NT_HEADERS64 pNt64; 955 uintptr_tu;973 KUPTR u; 956 974 } u; 957 975 u.u = uImageBase; … … 970 988 971 989 /* Extract necessary info from the optional header (comes in 32-bit and 64-bit variations, we simplify a bit). */ 972 uint32_tcbImage;990 KU32 cbImage; 973 991 PIMAGE_SECTION_HEADER paSHs; 974 992 if (u.pNt->FileHeader.SizeOfOptionalHeader == sizeof(IMAGE_OPTIONAL_HEADER32)) … … 986 1004 987 1005 /* Is our address within the image size */ 988 uintptr_t uRVA = uAddress - (uintptr_t)pahModules[i];1006 KUPTR uRVA = uAddress - (KUPTR)pahModules[i]; 989 1007 if (uRVA >= cbImage) 990 1008 continue; … … 994 1012 * (segment == section + 1) 995 1013 */ 996 const uint32_tcSHs = u.pNt->FileHeader.NumberOfSections;1014 const KU32 cSHs = u.pNt->FileHeader.NumberOfSections; 997 1015 if (uRVA < paSHs[0].VirtualAddress) 998 1016 { … … 1004 1022 else 1005 1023 { 1006 uint32_tiSH = 0;1024 KU32 iSH = 0; 1007 1025 for (;;) 1008 1026 { … … 1063 1081 ULONG cb = ~0UL; 1064 1082 ULONG fFlags = ~0UL; 1065 uAddress &= ~( uintptr_t)0xfff;1083 uAddress &= ~(KUPTR)0xfff; 1066 1084 rc = DosQueryMem((PVOID)(uAddress, &cb, &fFlags); 1067 1085 if (!rc) 1068 1086 { 1069 *pcbSegmentMinusOne = (offObj & ~( uintptr_t)0xfff) + KPRF_ALIGN(cb, 0x1000) - 1;1087 *pcbSegmentMinusOne = (offObj & ~(KUPTR)0xfff) + KPRF_ALIGN(cb, 0x1000) - 1; 1070 1088 if ((fFlags & PAG_BASE) && cb <= 0x1000) /* don't quite remember if PAG_BASE returns one page or not */ 1071 1089 { … … 1118 1136 static KPRF_TYPE(P,THREAD) kPrfGetThreadAutoReg(void) 1119 1137 { 1120 uintptr_tuStackBasePtr;1138 KUPTR uStackBasePtr; 1121 1139 1122 1140 #if 0 … … 1129 1147 DosGetInfoBlocks(&pTib, &pPib); /* never fails except if you give it bad input, thus 'Get' not 'Query'. */ 1130 1148 /* I never recall which of these is the right one... */ 1131 uStackBasePtr = ( uintptr_t)pTib->tib_pstack < (uintptr_t)pTib->tib_pstack_limit1132 ? ( uintptr_t)pTib->tib_pstack1133 : ( uintptr_t)pTib->tib_pstack_limit;1149 uStackBasePtr = (KUPTR)pTib->tib_pstack < (KUPTR)pTib->tib_pstack_limit 1150 ? (KUPTR)pTib->tib_pstack 1151 : (KUPTR)pTib->tib_pstack_limit; 1134 1152 1135 1153 #else 1136 1154 /* the default is top of the current stack page (assuming a page to be 4KB) */ 1137 uStackBasePtr = ( uintptr_t)&uStackBasePtr;1138 uStackBasePtr = (uStackBasePtr + 0xfff) & ~( uintptr_t)0xfff;1155 uStackBasePtr = (KUPTR)&uStackBasePtr; 1156 uStackBasePtr = (uStackBasePtr + 0xfff) & ~(KUPTR)0xfff; 1139 1157 #endif 1140 1158 … … 1152 1170 * @param pszDefault The default value. 1153 1171 */ 1154 static char *kPrfGetEnvString(const char *pszVar, char *pszValue, uint32_tcchValue, const char *pszDefault)1172 static char *kPrfGetEnvString(const char *pszVar, char *pszValue, KU32 cchValue, const char *pszDefault) 1155 1173 { 1156 1174 #if defined(KPRF_OS_WINDOWS) … … 1191 1209 * @param uDefault The default value. 1192 1210 */ 1193 static uint32_t kPrfGetEnvValue(const char *pszVar, uint32_tuDefault)1211 static KU32 kPrfGetEnvValue(const char *pszVar, KU32 uDefault) 1194 1212 { 1195 1213 #if defined(KPRF_OS_WINDOWS) … … 1223 1241 */ 1224 1242 unsigned uBase = 10; 1225 uint32_tuValue = 0;1243 KU32 uValue = 0; 1226 1244 const char *psz = pszValue; 1227 1245 … … 1279 1297 * @param cb The amount of memory (in bytes) to allocate. 1280 1298 */ 1281 static void *kPrfAllocMem( uint32_tcb)1299 static void *kPrfAllocMem(KU32 cb) 1282 1300 { 1283 1301 #if defined(KPRF_OS_WINDOWS) … … 1342 1360 * @param cbData The amount of data to write. 1343 1361 */ 1344 static int kPrfWriteFile(const char *pszName, const void *pvData, uint32_tcbData)1362 static int kPrfWriteFile(const char *pszName, const void *pvData, KU32 cbData) 1345 1363 { 1346 1364 #if defined(KPRF_OS_WINDOWS) … … 1412 1430 * Initial suggestions. 1413 1431 */ 1414 uint32_tcbModSegs = kPrfGetEnvValue("KPRF2_CBMODSEGS", 128*1024);1415 uint32_tcFunctions = kPrfGetEnvValue("KPRF2_CFUNCTIONS", 8192);1416 uint32_tcThreads = kPrfGetEnvValue("KPRF2_CTHREADS", 256);1417 uint32_tcStacks = kPrfGetEnvValue("KPRF2_CSTACKS", 48);1418 uint32_tcFrames = kPrfGetEnvValue("KPRF2_CFRAMES", 448);1419 1420 uint32_tcb = KPRF_NAME(CalcSize)(cFunctions, cbModSegs, cThreads, cStacks, cFrames);1432 KU32 cbModSegs = kPrfGetEnvValue("KPRF2_CBMODSEGS", 128*1024); 1433 KU32 cFunctions = kPrfGetEnvValue("KPRF2_CFUNCTIONS", 8192); 1434 KU32 cThreads = kPrfGetEnvValue("KPRF2_CTHREADS", 256); 1435 KU32 cStacks = kPrfGetEnvValue("KPRF2_CSTACKS", 48); 1436 KU32 cFrames = kPrfGetEnvValue("KPRF2_CFRAMES", 448); 1437 1438 KU32 cb = KPRF_NAME(CalcSize)(cFunctions, cbModSegs, cThreads, cStacks, cFrames); 1421 1439 1422 1440 /* … … 1548 1566 1549 1567 /* append the process id */ 1550 uintptr_tpid = kPrfGetProcessId();1568 KUPTR pid = kPrfGetProcessId(); 1551 1569 char *psz = szName; 1552 1570 while (*psz) … … 1554 1572 1555 1573 static char s_szDigits[0x11] = "0123456789abcdef"; 1556 uint32_tuShift = KPRF_BITS - 4;1574 KU32 uShift = KPRF_BITS - 4; 1557 1575 while ( uShift > 0 1558 1576 && !(pid & (0xf << uShift))) -
trunk/kStuff/kProfile/kProfileR3.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Internal header, Ring-3. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler Mark 2 - Internal header, Ring-3.9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ 26 26 27 #ifndef __ kProfileR3_h__28 #define __ kProfileR3_h__27 #ifndef ___kProfileR3_h___ 28 #define ___kProfileR3_h___ 29 29 30 30 int kPrfInitialize(void); … … 34 34 #endif 35 35 36 -
trunk/kStuff/kProfile/prfamd64msc.asm
r3537 r3565 1 ; $Id: $ 1 ; $Id: $; 2 2 ;; @file 3 ; 4 ; kProfiler MK2 - Microsoft C/C++ Compiler Interaction, AMD64. 5 ; 6 ; 7 ; Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 8 ; 9 ; 10 ; This file is part of kLIBC. 11 ; 12 ; kLIBC is free software; you can redistribute it and/or modify 13 ; it under the terms of the GNU General Public License as published by 14 ; the Free Software Foundation; either version 2 of the License, or 15 ; (at your option) any later version. 16 ; 17 ; kLIBC is distributed in the hope that it will be useful, 3 ; kProfiler Mark 2 - Microsoft C/C++ Compiler Interaction, AMD64. 4 ; 5 6 ; 7 ; Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 ; 9 ; This file is part of kProfiler. 10 ; 11 ; kProfiler is free software; you can redistribute it and/or 12 ; modify it under the terms of the GNU Lesser General Public 13 ; License as published by the Free Software Foundation; either 14 ; version 2.1 of the License, or (at your option) any later version. 15 ; 16 ; kProfiler is distributed in the hope that it will be useful, 18 17 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 ; GNUGeneral Public License for more details.21 ; 22 ; You should have received a copy of the GNU General Public License23 ; along with kLIBC; if not, write to the Free Software24 ; Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA25 ; 26 ; 18 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 ; Lesser General Public License for more details. 20 ; 21 ; You should have received a copy of the GNU Lesser General Public 22 ; License along with kProfiler; if not, write to the Free Software 23 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 ; 25 27 26 28 27 [section .data] -
trunk/kStuff/kProfile/prfcore.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * 4 * kProfiler - Core Code (template).5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 7 * 8 * 9 * This file is part of k LIBC.10 * 11 * k LIBC is free software; you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation; either version 2 of the License, or14 * (at your option) any later version.15 * 16 * k LIBCis distributed in the hope that it will be useful,3 * kProfiler Mark 2 - Core Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kProfiler. 10 * 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNUGeneral Public License for more details.20 * 21 * You should have received a copy of the GNU General Public License22 * along with kLIBC; if not, write to the Free Software23 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 37 37 38 38 KPRF_FUNCS_READ_LOCK(); 39 int32_tiStart = 0;40 int32_tiLast = pHdr->cFunctions - 1;41 int32_ti = iLast / 2;39 KI32 iStart = 0; 40 KI32 iLast = pHdr->cFunctions - 1; 41 KI32 i = iLast / 2; 42 42 for (;;) 43 43 { 44 uint32_tiFunction = pHdr->aiFunctions[i];44 KU32 iFunction = pHdr->aiFunctions[i]; 45 45 KPRF_TYPE(,IPTR) iDiff = uPC - paFunctions[iFunction].uEntryPtr; 46 46 if (!iDiff) … … 73 73 * Unwind one frame. 74 74 */ 75 static uint64_t* KPRF_NAME(UnwindOne)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,STACK) pStack, KPRF_TYPE(,UPTR) uPC, uint64_tTS)75 static KU64* KPRF_NAME(UnwindOne)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,STACK) pStack, KPRF_TYPE(,UPTR) uPC, KU64 TS) 76 76 { 77 77 /* … … 79 79 */ 80 80 KPRF_TYPE(P,FRAME) pFrame = &pStack->aFrames[--pStack->cFrames]; 81 uint64_t*pCurOverheadTicks;81 KU64 *pCurOverheadTicks; 82 82 if (pStack->cFrames) 83 83 { … … 108 108 109 109 /* Time on stack */ 110 uint64_tTicks = TS - pFrame->OnStackStart;110 KU64 Ticks = TS - pFrame->OnStackStart; 111 111 Ticks -= pFrame->OverheadTicks + pFrame->CurOverheadTicks + pFrame->SleepTicks; 112 112 /** @todo adjust overhead */ … … 142 142 * Unwinds the stack. 143 143 */ 144 static uint64_t* KPRF_NAME(UnwindInt)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,STACK) pStack, KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, uint64_tTS)144 static KU64* KPRF_NAME(UnwindInt)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,STACK) pStack, KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, KU64 TS) 145 145 { 146 146 /** @todo need to deal with alternative stacks! */ … … 149 149 * Pop the stack until we're down below the current frame (uFramePtr). 150 150 */ 151 int32_tiFrame = pStack->cFrames - 1;151 KI32 iFrame = pStack->cFrames - 1; 152 152 KPRF_TYPE(P,FRAME) pFrame = &pStack->aFrames[iFrame]; 153 153 /* the most frequent case first. */ … … 160 160 161 161 /* one or more, possibly all */ 162 uint64_t*pCurOverheadTicks = KPRF_NAME(UnwindOne)(pHdr, pStack, uPC, TS);162 KU64 *pCurOverheadTicks = KPRF_NAME(UnwindOne)(pHdr, pStack, uPC, TS); 163 163 pFrame++; 164 164 if ( iFrame > 0 … … 198 198 * @internal ? 199 199 */ 200 KPRF_DECL_FUNC( uint64_t *, Enter)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const uint64_tTS)200 KPRF_DECL_FUNC(KU64 *, Enter)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const KU64 TS) 201 201 { 202 202 /* … … 252 252 */ 253 253 KPRF_TYPE(P,STACK) pStack = KPRF_OFF2PTR(P,STACK, pThread->offStack, pHdr); 254 uint32_tiFrame = pStack->cFrames;254 KU32 iFrame = pStack->cFrames; 255 255 KPRF_TYPE(P,FRAME) pFrame = &pStack->aFrames[iFrame]; 256 256 if ( iFrame … … 329 329 * @internal 330 330 */ 331 KPRF_DECL_FUNC( uint64_t *, Leave)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const uint64_tTS)331 KPRF_DECL_FUNC(KU64 *, Leave)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const KU64 TS) 332 332 { 333 333 /* … … 371 371 * Leave it to the caller to update the overhead. 372 372 */ 373 uint64_t*pCurOverheadTicks = KPRF_NAME(UnwindInt)(pHdr, pStack, uPC, uFramePtr, TS);373 KU64 *pCurOverheadTicks = KPRF_NAME(UnwindInt)(pHdr, pStack, uPC, uFramePtr, TS); 374 374 375 375 pThread->enmState = enmThreadState; … … 407 407 { 408 408 KPRF_TYPE(P,STACK) pStack = KPRF_OFF2PTR(P,STACK, pHdr->offStacks, pHdr); 409 uint32_tcLeft = pHdr->cMaxStacks;409 KU32 cLeft = pHdr->cMaxStacks; 410 410 do 411 411 { … … 467 467 * @param TS The timestamp to use when terminating the thread. 468 468 */ 469 KPRF_DECL_FUNC(void, TerminateThread)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,THREAD) pThread, uint64_tTS)469 KPRF_DECL_FUNC(void, TerminateThread)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,THREAD) pThread, KU64 TS) 470 470 { 471 471 if (pThread->enmState == KPRF_TYPE(,THREADSTATE_TERMINATED)) … … 479 479 { 480 480 KPRF_TYPE(P,STACK) pStack = KPRF_OFF2PTR(P,STACK, pThread->offStack, pHdr); 481 for ( uint32_tcFrames = pStack->cFrames; cFrames > 0; cFrames--)481 for (KU32 cFrames = pStack->cFrames; cFrames > 0; cFrames--) 482 482 KPRF_NAME(UnwindOne)(pHdr, pStack, 0, TS); 483 483 … … 499 499 KPRF_DECL_FUNC(void, DeregisterThread)(void) 500 500 { 501 uint64_tTS = KPRF_NOW();501 KU64 TS = KPRF_NOW(); 502 502 503 503 /* … … 524 524 KPRF_DECL_FUNC(void, ResumeThread)(int fReset) 525 525 { 526 uint64_tTS = KPRF_NOW();526 KU64 TS = KPRF_NOW(); 527 527 528 528 /* … … 546 546 if (fReset) 547 547 { 548 uint32_tcFrames = pStack->cFrames;548 KU32 cFrames = pStack->cFrames; 549 549 while (cFrames-- > 0) 550 550 KPRF_NAME(UnwindOne)(pHdr, pStack, 0, TS); … … 579 579 KPRF_DECL_FUNC(void, SuspendThread)(int fUnwind) 580 580 { 581 uint64_tTS = KPRF_NOW();581 KU64 TS = KPRF_NOW(); 582 582 583 583 /* … … 605 605 if (fUnwind) 606 606 { 607 uint32_tcFrames = pStack->cFrames;607 KU32 cFrames = pStack->cFrames; 608 608 while (cFrames-- > 0) 609 609 KPRF_NAME(UnwindOne)(pHdr, pStack, 0, TS); -
trunk/kStuff/kProfile/prfcore.h.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * 4 * kProfiler Core Header (template).5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 7 * 8 * 9 * This file is part of k LIBC.10 * 11 * k LIBC is free software; you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation; either version 2 of the License, or14 * (at your option) any later version.15 * 16 * k LIBCis distributed in the hope that it will be useful,3 * kProfiler Mark 2 - Core Header Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kProfiler. 10 * 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNUGeneral Public License for more details.20 * 21 * You should have received a copy of the GNU General Public License22 * along with kLIBC; if not, write to the Free Software23 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 61 61 */ 62 62 #if KPRF_BITS == 16 63 typedef uint16_tKPRF_TYPE(,UPTR);64 typedef int16_tKPRF_TYPE(,IPTR);63 typedef KU16 KPRF_TYPE(,UPTR); 64 typedef KI16 KPRF_TYPE(,IPTR); 65 65 #elif KPRF_BITS == 32 66 typedef uint32_tKPRF_TYPE(,UPTR);67 typedef int32_tKPRF_TYPE(,IPTR);66 typedef KU32 KPRF_TYPE(,UPTR); 67 typedef KI32 KPRF_TYPE(,IPTR); 68 68 #elif KPRF_BITS == 64 69 typedef uint64_tKPRF_TYPE(,UPTR);70 typedef int64_tKPRF_TYPE(,IPTR);69 typedef KU64 KPRF_TYPE(,UPTR); 70 typedef KI64 KPRF_TYPE(,IPTR); 71 71 #else 72 72 # error "KPRF_BITS has an invalid value. Supported values are 16, 32 and 64." … … 94 94 { 95 95 /** [0] The magic number for file data. (KPRF_TYPE(,HDR_MAGIC)) */ 96 uint32_tu32Magic;96 KU32 u32Magic; 97 97 /** [4] KPRF_BITS. */ 98 uint32_tcFormatBits;98 KU32 cFormatBits; 99 99 /** [8] The base address which all pointers should be relative to. */ 100 100 KPRF_TYPE(,UPTR) uBasePtr; 101 101 #if KPRF_BITS <= 16 102 102 /** [a] Reserved. */ 103 uint16_tu16Reserved;103 KU16 u16Reserved; 104 104 #endif 105 105 #if KPRF_BITS <= 32 106 106 /** [c] Reserved. */ 107 uint32_tu32Reserved;107 KU32 u32Reserved; 108 108 #endif 109 109 /** [10] The size of this data set. */ 110 uint32_tcb;110 KU32 cb; 111 111 /** [10] The allocated data set size. */ 112 uint32_tcbAllocated;112 KU32 cbAllocated; 113 113 114 114 /** [18] The max number of functions the function table can hold. */ 115 uint32_tcMaxFunctions;115 KU32 cMaxFunctions; 116 116 /** [1c] The current number of functions in the function table. */ 117 uint32_tcFunctions;117 KU32 cFunctions; 118 118 /** [20] The offset of the function table (relative to this header). */ 119 uint32_toffFunctions;119 KU32 offFunctions; 120 120 /** [24] The size of a function entry. */ 121 uint32_tcbFunction;121 KU32 cbFunction; 122 122 123 123 /** [28] The max number of bytes the module segments can occupy. */ 124 uint32_tcbMaxModSegs;124 KU32 cbMaxModSegs; 125 125 /** [2c] The current size of the module segment records. */ 126 uint32_tcbModSegs;126 KU32 cbModSegs; 127 127 /** [30] The offset of the module segment records (relative to this header). */ 128 uint32_toffModSegs;128 KU32 offModSegs; 129 129 130 130 /** [34] The max number of threads the thread table can contain. */ 131 uint32_tcMaxThreads;131 KU32 cMaxThreads; 132 132 /** [38] The current number of threads in the thread table. */ 133 uint32_tcThreads;133 KU32 cThreads; 134 134 /** [3c] The offset of the thread table (relative to this header). */ 135 uint32_toffThreads;135 KU32 offThreads; 136 136 /** [40] The size of a thread entry. */ 137 uint32_tcbThread;137 KU32 cbThread; 138 138 139 139 /** [44] The max number of stacks the stack table can contain. */ 140 uint32_tcMaxStacks;140 KU32 cMaxStacks; 141 141 /** [48] The max number of stacks. 142 142 * Unlike the other members, the stacks can be reused. It follows that 143 143 * this count doesn't specify the number of used slots from the start. */ 144 uint32_tcStacks;144 KU32 cStacks; 145 145 /** [4c] The offset of the thread table (relative to this header). 146 146 * This is usually 0 in a stored data set. */ 147 uint32_toffStacks;147 KU32 offStacks; 148 148 /** [50] The size of a stack. */ 149 uint32_tcbStack;149 KU32 cbStack; 150 150 /** [54] The maxium stack depth. */ 151 uint32_tcMaxStackFrames;151 KU32 cMaxStackFrames; 152 152 153 153 /** [58] The process commandline. … … 155 155 * where the stacks used to be. 156 156 */ 157 uint32_toffCommandLine;157 KU32 offCommandLine; 158 158 /** [5c] The length of the command line. (excludes the terminator). */ 159 uint32_tcchCommandLine;159 KU32 cchCommandLine; 160 160 161 161 /** [60] The function lookup table (it contains indexes). 162 162 * This is sorted by address so that a binary search can be performed. 163 163 * Access to this table is managed externally, but generally a read/write lock is employed. */ 164 uint32_taiFunctions[1];164 KU32 aiFunctions[1]; 165 165 } KPRF_TYPE(,HDR); 166 166 /** Pointer to a profiler data header. */ … … 176 176 { 177 177 /** The minimum period */ 178 uint64_t volatileMinTicks;178 KU64 volatile MinTicks; 179 179 /** The maximum period */ 180 uint64_t volatileMaxTicks;180 KU64 volatile MaxTicks; 181 181 /** The sum of all periods. */ 182 uint64_t volatileSumTicks;182 KU64 volatile SumTicks; 183 183 } KPRF_TYPE(,TIMESTAT); 184 184 /** Pointer to time statistics. */ … … 198 198 KPRF_TYPE(,UPTR) cbSegmentMinusOne; 199 199 /** The segment number. (0 based) */ 200 uint32_tiSegment;200 KU32 iSegment; 201 201 /** Flag indicating whether this segment is loaded or not. 202 202 * (A 16-bit value was choosen out of convenience, all that's stored is 0 or 1 anyway.) */ 203 uint16_tfLoaded;203 KU16 fLoaded; 204 204 /** The length of the path. 205 205 * This is used to calculate the length of the record: offsetof(MODSEG, szPath) + cchPath + 1 */ 206 uint16_tcchPath;206 KU16 cchPath; 207 207 /** The module name. */ 208 208 char szPath[1]; … … 223 223 KPRF_TYPE(,UPTR) uEntryPtr; 224 224 /** Offset (relative to the profiler header) of the module segment to which this function belongs. */ 225 uint32_toffModSeg;225 KU32 offModSeg; 226 226 227 227 /** The number times on the stack. */ 228 uint64_t volatilecOnStack;228 KU64 volatile cOnStack; 229 229 /** The number of calls made from this function. */ 230 uint64_t volatilecCalls;230 KU64 volatile cCalls; 231 231 232 232 /** Time on stack. */ … … 251 251 /** The accumulated overhead. 252 252 * Over head is accumulated by the parent frame when a child is poped off the stack. */ 253 uint64_tOverheadTicks;253 KU64 OverheadTicks; 254 254 /** The current (top of stack) overhead. */ 255 uint64_tCurOverheadTicks;255 KU64 CurOverheadTicks; 256 256 /** The accumulated sleep ticks. 257 257 * It's possible to notify the profiler that the thread is being put into a wait/sleep/yield 258 258 * state. The time spent sleeping is transfered to the parent frame when poping of a child one. */ 259 uint64_tSleepTicks;259 KU64 SleepTicks; 260 260 /** The start of the on-stack period. */ 261 uint64_tOnStackStart;261 KU64 OnStackStart; 262 262 /** The accumulated time on top (excludes overhead (sleep doesn't apply here obviously)). */ 263 uint64_tOnTopOfStackTicks;263 KU64 OnTopOfStackTicks; 264 264 /** The start of the current on-top-of-stack period. 265 265 * This is also to mark the start of a sleeping period, the ResumeThread function will always 266 266 * treat it as the start of the suspend period. */ 267 uint64_tOnTopOfStackStart;267 KU64 OnTopOfStackStart; 268 268 /** The number of calls made from this stack frame. */ 269 uint64_tcCalls;269 KU64 cCalls; 270 270 /** Stack address of this frame. 271 271 * This is used to detect throw and longjmp, and is also used to deal with overflow. (relative address) */ … … 273 273 /** Offset (relative to the profiler header) to the function record. 274 274 * This is 0 if we're out of function space. */ 275 uint32_toffFunction;275 KU32 offFunction; 276 276 } KPRF_TYPE(,FRAME); 277 277 /** Pointer to a stack frame. */ … … 288 288 /** The offset (relative to the profiler header) of the thread owning the stack. 289 289 * This is zero if not in use, and non-zero if in use. */ 290 uint32_toffThread;290 KU32 offThread; 291 291 /** The number of active stack frames. */ 292 uint32_tcFrames;292 KU32 cFrames; 293 293 /** The stack frames. 294 294 * The actual size of this array is specified in the header. */ … … 338 338 { 339 339 /** The native thread id. */ 340 uint64_tThreadId;340 KU64 ThreadId; 341 341 /** The thread name. (optional) */ 342 342 char szName[32]; … … 350 350 KPRF_TYPE(,UPTR) cbMaxStack; 351 351 /** The number of calls done by this thread. */ 352 uint64_tcCalls;352 KU64 cCalls; 353 353 /** The number of times the stack overflowed. */ 354 uint64_tcOverflows;354 KU64 cOverflows; 355 355 /** The number of times stack entries has been rejected because of a stack switch. */ 356 uint64_tcStackSwitchRejects;356 KU64 cStackSwitchRejects; 357 357 /** The number of times the stack has been unwinded more than one frame. */ 358 uint64_tcUnwinds;358 KU64 cUnwinds; 359 359 360 360 /** The profiled ticks. (This does not include sleep or overhead ticks.) 361 361 * This is the accumulated on-stack values for the final stack frames. */ 362 uint64_tProfiledTicks;362 KU64 ProfiledTicks; 363 363 /** The accumulated overhead of this thread. */ 364 uint64_tOverheadTicks;364 KU64 OverheadTicks; 365 365 /** The accumulated sleep ticks for this thread. 366 366 * See KPRF_TYPE(,FRAME)::SleepTicks for details. */ 367 uint64_tSleepTicks;367 KU64 SleepTicks; 368 368 369 369 /** The offset of the stack. */ 370 uint32_toffStack;370 KU32 offStack; 371 371 } KPRF_TYPE(,THREAD); 372 372 /** Pointer to a thread. */ -
trunk/kStuff/kProfile/prfcorefunction.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Core NewFunction Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler - Core New Function Code (template).9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 40 40 41 41 KPRF_TYPE(P,FUNC) paFunctions = KPRF_OFF2PTR(P,FUNC, pHdr->offFunctions, pHdr); 42 int32_tiStart = 0;43 int32_tiLast = pHdr->cFunctions - 1;44 int32_ti = iLast / 2;42 KI32 iStart = 0; 43 KI32 iLast = pHdr->cFunctions - 1; 44 KI32 i = iLast / 2; 45 45 for (;;) 46 46 { 47 uint32_tiFunction = pHdr->aiFunctions[i];47 KU32 iFunction = pHdr->aiFunctions[i]; 48 48 KPRF_TYPE(,IPTR) iDiff = uPC - paFunctions[iFunction].uEntryPtr; 49 49 if (!iDiff) … … 67 67 * (I've too much of a headache to figure out if the above loop leaves us where we should be.) 68 68 */ 69 const int32_tiNew = pHdr->cFunctions;69 const KI32 iNew = pHdr->cFunctions; 70 70 if (paFunctions[pHdr->aiFunctions[i]].uEntryPtr > uPC) 71 71 { … … 84 84 * Ensure that there still is space for the function. 85 85 */ 86 if (iNew >= ( int32_t)pHdr->cMaxFunctions)86 if (iNew >= (KI32)pHdr->cMaxFunctions) 87 87 { 88 88 KPRF_FUNCS_WRITE_UNLOCK(); … … 97 97 pNew->cOnStack = 0; 98 98 pNew->cCalls = 0; 99 pNew->OnStack.MinTicks = ~( uint64_t)0;99 pNew->OnStack.MinTicks = ~(KU64)0; 100 100 pNew->OnStack.MaxTicks = 0; 101 101 pNew->OnStack.SumTicks = 0; 102 pNew->OnTopOfStack.MinTicks = ~( uint64_t)0;102 pNew->OnTopOfStack.MinTicks = ~(KU64)0; 103 103 pNew->OnTopOfStack.MaxTicks = 0; 104 104 pNew->OnTopOfStack.SumTicks = 0; 105 105 106 106 /* shift the function index array and insert the new one. */ 107 int32_tj = iNew;107 KI32 j = iNew; 108 108 while (j > i) 109 109 { -
trunk/kStuff/kProfile/prfcoreinit.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Core Initialization Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler - Core Initialization Code (template).9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 40 40 * responsible for the input to make some sense. 41 41 */ 42 KPRF_DECL_FUNC( uint32_t, CalcSize)(uint32_t cMaxFunctions, uint32_t cbMaxModSegs, uint32_t cMaxThreads, uint32_t cMaxStacks, uint32_tcMaxStackFrames)42 KPRF_DECL_FUNC(KU32, CalcSize)(KU32 cMaxFunctions, KU32 cbMaxModSegs, KU32 cMaxThreads, KU32 cMaxStacks, KU32 cMaxStackFrames) 43 43 { 44 44 /* … … 55 55 * We do not take overflows into account, stupid user means stupid result. 56 56 */ 57 uint32_tcb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]);58 uint32_tcbTotal = KPRF_ALIGN(cb, 32);57 KU32 cb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]); 58 KU32 cbTotal = KPRF_ALIGN(cb, 32); 59 59 60 60 cb = cMaxFunctions * KPRF_SIZEOF(FUNC); … … 91 91 * 92 92 */ 93 KPRF_DECL_FUNC(KPRF_TYPE(P,HDR), Init)(void *pvData, uint32_t cbData, uint32_t cMaxFunctions, uint32_tcbMaxModSegs,94 uint32_t cMaxThreads, uint32_t cMaxStacks, uint32_tcMaxStackFrames)93 KPRF_DECL_FUNC(KPRF_TYPE(P,HDR), Init)(void *pvData, KU32 cbData, KU32 cMaxFunctions, KU32 cbMaxModSegs, 94 KU32 cMaxThreads, KU32 cMaxStacks, KU32 cMaxStackFrames) 95 95 { 96 96 /* … … 108 108 * The header. 109 109 */ 110 uint32_toff = 0;111 uint32_tcb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]);110 KU32 off = 0; 111 KU32 cb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]); 112 112 cb = KPRF_ALIGN(cb, 32); 113 113 if (cbData < off + cb || off > off + cb) -
trunk/kStuff/kProfile/prfcoremodseg.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Core Module Segment Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler - Core Module Segment Code (template header).9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 37 37 * (This is relative to the first moddule segment record (at pHdr->offModSegs).) 38 38 */ 39 static uint32_t KPRF_NAME(InsertModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(PC,MODSEG) pModSeg, uint32_toff)39 static KU32 KPRF_NAME(InsertModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(PC,MODSEG) pModSeg, KU32 off) 40 40 { 41 41 /* … … 60 60 if (off >= pHdr->cbModSegs) 61 61 { 62 uint32_tcbModSeg = KPRF_OFFSETOF(MODSEG, szPath[pModSeg->cchPath + 1]);62 KU32 cbModSeg = KPRF_OFFSETOF(MODSEG, szPath[pModSeg->cchPath + 1]); 63 63 cbModSeg = KPRF_ALIGN(cbModSeg, KPRF_SIZEOF(UPTR)); 64 64 if (off + cbModSeg <= pHdr->cbMaxModSegs) … … 71 71 pNew->cchPath = pModSeg->cchPath; 72 72 73 int32_tiPath = pModSeg->cchPath;73 KI32 iPath = pModSeg->cchPath; 74 74 do pNew->szPath[iPath] = pModSeg->szPath[iPath]; 75 75 while (--iPath >= 0); … … 99 99 ) 100 100 { 101 int32_t iPath = pModSeg->cchPath; 102 101 KI32 iPath = pModSeg->cchPath; 103 102 for (;;) 104 103 { … … 110 109 /* didn't match, continue searching */ 111 110 } 112 uint32_tcbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);111 KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]); 113 112 off += KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR)); 114 113 } … … 128 127 * (This is relative to the first moddule segment record (at pHdr->offModSegs).) 129 128 */ 130 static uint32_t KPRF_NAME(NewModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC, uint32_toff)129 static KU32 KPRF_NAME(NewModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC, KU32 off) 131 130 { 132 131 /* … … 165 164 * @param uPC Address within the module. 166 165 */ 167 static uint32_tKPRF_NAME(RecordModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC)166 static KU32 KPRF_NAME(RecordModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC) 168 167 { 169 168 /* 170 169 * Lookup the module segment, inserting it if not found (and there is room). 171 170 */ 172 uint32_toff = 0;171 KU32 off = 0; 173 172 KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(P,MODSEG, pHdr->offModSegs, pHdr); 174 const uint32_tcbModSegs = pHdr->cbModSegs;173 const KU32 cbModSegs = pHdr->cbModSegs; 175 174 for (;;) 176 175 { … … 186 185 return off + pHdr->offModSegs; 187 186 188 uint32_tcbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);187 KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]); 189 188 cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR)); 190 189 off += cbCur; 191 pCur = (KPRF_TYPE(PC,MODSEG))(( uint8_t*)pCur + cbCur);190 pCur = (KPRF_TYPE(PC,MODSEG))((KU8 *)pCur + cbCur); 192 191 } 193 192 } -
trunk/kStuff/kProfile/prfcorepost.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Core Post-Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler Core Post Code Header (template).9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ -
trunk/kStuff/kProfile/prfcorepre.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Core Pre-Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler - Core Pre Code (template).9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 55 55 (n) = (min); \ 56 56 else { \ 57 const uint32_tu32 = ((n) + ( (align) - 1)) & ~((align) - 1); \57 const KU32 u32 = ((n) + ( (align) - 1)) & ~((align) - 1); \ 58 58 if (u32 >= (n)) \ 59 59 (n) = u32; \ … … 62 62 63 63 /** @def KPRF_OFFSETOF 64 * My usual extended OFFSETOF macro, except this returns uint32_tand mangles the type name.64 * My usual extended OFFSETOF macro, except this returns KU32 and mangles the type name. 65 65 * @internal 66 66 */ 67 #define KPRF_OFFSETOF(kPrfType, Member) ( ( uint32_t)(uintptr_t)&((KPRF_TYPE(P,kPrfType))0)->Member )67 #define KPRF_OFFSETOF(kPrfType, Member) ( (KU32)(KUPTR)&((KPRF_TYPE(P,kPrfType))0)->Member ) 68 68 69 69 /** @def PRF_SIZEOF -
trunk/kStuff/kProfile/prfcorereloc.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Core SetBasePtr Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler - core Relocation Code (template).9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ -
trunk/kStuff/kProfile/prfcoreterm.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * kProfiler Mark 2 - Core Termination Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kProfiler - Core Termination Code (template).9 * This file is part of kProfiler. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 32 32 * @param pHdr The profiler data set header. 33 33 */ 34 KPRF_DECL_FUNC( uint32_t, TerminateAll)(KPRF_TYPE(P,HDR) pHdr)34 KPRF_DECL_FUNC(KU32, TerminateAll)(KPRF_TYPE(P,HDR) pHdr) 35 35 { 36 uint64_tTS = KPRF_NOW();36 KU64 TS = KPRF_NOW(); 37 37 if (!pHdr) 38 38 return 0; … … 42 42 */ 43 43 KPRF_TYPE(P,THREAD) paThread = KPRF_OFF2PTR(P,THREAD, pHdr->offThreads, pHdr); 44 for ( uint32_ti = 0; i < pHdr->cThreads; i++)44 for (KU32 i = 0; i < pHdr->cThreads; i++) 45 45 { 46 46 KPRF_TYPE(P,THREAD) pCur = &paThread[i]; … … 69 69 { 70 70 /* only if the stack is at the end of the data set. */ 71 const uint32_tcbStacks = KPRF_ALIGN(pHdr->cMaxStacks * pHdr->cbStack, 32);71 const KU32 cbStacks = KPRF_ALIGN(pHdr->cMaxStacks * pHdr->cbStack, 32); 72 72 if (pHdr->offStacks + cbStacks == pHdr->cb) 73 73 pHdr->cb -= cbStacks; … … 90 90 * @param papszArgs Pointer to an array of arguments. 91 91 */ 92 KPRF_DECL_FUNC( uint32_t, SetCommandLine)(KPRF_TYPE(P,HDR) pHdr, unsigned cArgs, const char * const *papszArgs)92 KPRF_DECL_FUNC(KU32, SetCommandLine)(KPRF_TYPE(P,HDR) pHdr, unsigned cArgs, const char * const *papszArgs) 93 93 { 94 94 if (!pHdr) -
trunk/kStuff/kProfile/prfreader.cpp.h
r3537 r3565 1 1 /* $Id: $ */ 2 2 /** @file 3 * 4 * kProfiler Mark 2 - Reader template.5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 7 * 8 * 9 * This file is part of k LIBC.10 * 11 * k LIBC is free software; you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation; either version 2 of the License, or14 * (at your option) any later version.15 * 16 * k LIBCis distributed in the hope that it will be useful,3 * kProfiler Mark 2 - Reader Code Template. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kProfiler. 10 * 11 * kProfiler is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * kProfiler is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNUGeneral Public License for more details.20 * 21 * You should have received a copy of the GNU General Public License22 * along with kLIBC; if not, write to the Free Software23 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kProfiler; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 36 36 * @param pOut Where to write error messages. 37 37 */ 38 static bool KPRF_NAME(IsValid)(KPRF_TYPE(PC,HDR) pHdr, uint32_tcb, FILE *pOut)38 static bool KPRF_NAME(IsValid)(KPRF_TYPE(PC,HDR) pHdr, KU32 cb, FILE *pOut) 39 39 { 40 40 KPRF_TYPE(,UPTR) uMaxPtr = ~(KPRF_TYPE(,UPTR))0 - pHdr->uBasePtr; … … 43 43 * Iterate the module segments. 44 44 */ 45 uint32_toff = pHdr->offModSegs;45 KU32 off = pHdr->offModSegs; 46 46 while (off < pHdr->offModSegs + pHdr->cbModSegs) 47 47 { 48 48 KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(PC,MODSEG, off, pHdr); 49 uint32_tcbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);49 KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]); 50 50 cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR)); 51 51 if (cbCur + off > pHdr->offModSegs + pHdr->cbModSegs) … … 73 73 */ 74 74 KPRF_TYPE(PC,FUNC) paFuncs = KPRF_OFF2PTR(PC,FUNC, pHdr->offFunctions, pHdr); 75 for ( uint32_ti = 0; i < pHdr->cFunctions; i++)75 for (KU32 i = 0; i < pHdr->cFunctions; i++) 76 76 { 77 77 KPRF_TYPE(PC,FUNC) pCur = &paFuncs[i]; … … 97 97 */ 98 98 KPRF_TYPE(PC,THREAD) paThreads = KPRF_OFF2PTR(PC,THREAD, pHdr->offThreads, pHdr); 99 for ( uint32_ti = 0; i < pHdr->cThreads; i++)99 for (KU32 i = 0; i < pHdr->cThreads; i++) 100 100 { 101 101 KPRF_TYPE(PC,THREAD) pCur = &paThreads[i]; … … 148 148 "----------------\n", 149 149 pHdr->offModSegs, pHdr->cbModSegs, pHdr->cbMaxModSegs); 150 uint32_toff = pHdr->offModSegs;150 KU32 off = pHdr->offModSegs; 151 151 while (off < pHdr->offModSegs + pHdr->cbModSegs) 152 152 { 153 153 KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(PC,MODSEG, off, pHdr); 154 uint32_tcbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);154 KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]); 155 155 cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR)); 156 156 … … 172 172 pHdr->offFunctions, pHdr->cFunctions, pHdr->cMaxFunctions); 173 173 KPRF_TYPE(PC,FUNC) paFuncs = KPRF_OFF2PTR(PC,FUNC, pHdr->offFunctions, pHdr); 174 for ( uint32_ti = 0; i < pHdr->cFunctions; i++)174 for (KU32 i = 0; i < pHdr->cFunctions; i++) 175 175 { 176 176 KPRF_TYPE(PC,FUNC) pCur = &paFuncs[i]; … … 188 188 189 189 #if 1 190 P RTDBGMOD pMod;191 int rc = RTDbgModuleOpen(pModSeg->szPath, &pMod);192 if ( RT_SUCCESS(rc))190 PKDBGMOD pMod; 191 int rc = kDbgModuleOpen(&pMod, pModSeg->szPath, NULL /* pLdrMod */); 192 if (!rc) 193 193 { 194 RTDBGSYMBOL Sym;195 rc = RTDbgModuleQuerySymbol(pMod, pModSeg->iSegment, (RTUINTPTR)(pCur->uEntryPtr - pModSeg->uBasePtr), &Sym);196 if ( RT_SUCCESS(rc))194 KDBGSYMBOL Sym; 195 rc = kDbgModuleQuerySymbol(pMod, pModSeg->iSegment, pCur->uEntryPtr - pModSeg->uBasePtr, &Sym); 196 if (!rc) 197 197 { 198 198 fprintf(pOut, " %s\n", Sym.szName); 199 199 } 200 RTDbgModuleClose(pMod);200 kDbgModuleClose(pMod); 201 201 } 202 202 #endif … … 214 214 pHdr->offThreads, pHdr->cThreads, pHdr->cMaxThreads, pHdr->cStacks, pHdr->cMaxStacks, pHdr->cMaxStackFrames); 215 215 KPRF_TYPE(PC,THREAD) paThreads = KPRF_OFF2PTR(PC,THREAD, pHdr->offThreads, pHdr); 216 for ( uint32_ti = 0; i < pHdr->cThreads; i++)216 for (KU32 i = 0; i < pHdr->cThreads; i++) 217 217 { 218 218 KPRF_TYPE(PC,THREAD) pCur = &paThreads[i]; … … 248 248 { 249 249 /** AVL node core. The key is the data set offset of the module segment record. */ 250 AVLU32NODECORE Core; 250 KDBGADDR offSegment; 251 struct KPRF_TYPE(,REPORTMODSEG) *mpLeft; /**< AVL left branch. */ 252 struct KPRF_TYPE(,REPORTMODSEG) *mpRight; /**< AVL rigth branch. */ 251 253 /** Pointer to the next segment for the module. */ 252 254 KPRF_TYPE(P,REPORTMODSEG) pNext; … … 256 258 KPRF_TYPE(P,REPORTMOD) pMod; 257 259 /** The time this segment has spent on the stack.. */ 258 uint64_tOnStackTicks;260 KU64 OnStackTicks; 259 261 /** The time this segment has spent on the top of the stack.. */ 260 uint64_tOnTopOfStackTicks;262 KU64 OnTopOfStackTicks; 261 263 /** The number of profiled functions from this segment. */ 262 uint32_t cFunctions; 264 KU32 cFunctions; 265 KU8 mHeight; /**< AVL Subtree height. */ 263 266 } KPRF_TYPE(,REPORTMODSEG), *KPRF_TYPE(P,REPORTMODSEG); 264 267 268 /* Instantiate the AVL tree code. */ 269 #define KAVL_CHECK_FOR_EQUAL_INSERT 270 #define KAVL_MAX_STACK 32 271 #define KAVL_STD_KEY_COMP 272 #define mKey offSegment 273 #define KAVLKEY KDBGADDR 274 #define KAVLNODE KPRF_TYPE(,REPORTMODSEG) 275 #define KAVL_FN(name) KPRF_NAME(ReportTree ## name) 276 #define KAVL_TYPE(prefix,name) KPRF_TYPE(prefix, REPORTMODESEG ## name) 277 #define KAVL_INT(name) KPRF_NAME(REPORTMODESEGINT ## name) 278 #define KAVL_DECL(type) K_DECL_INLINE(type) 279 #include <k/kAvlTmpl/kAvlBase.h> 280 #include <k/kAvlTmpl/kAvlDestroy.h> 281 #include <k/kAvlTmpl/kAvlGet.h> 282 #include <k/kAvlTmpl/kAvlUndef.h> 283 265 284 266 285 /** … … 272 291 { 273 292 /** The module number. */ 274 uint32_tiMod;293 KU32 iMod; 275 294 /** Pointer to the next module in the list. */ 276 295 KPRF_TYPE(P,REPORTMOD) pNext; … … 278 297 KPRF_TYPE(P,REPORTMODSEG) pFirstSeg; 279 298 /** The debug module handle. */ 280 P RTDBGMODpDbgMod;299 PKDBGMOD pDbgMod; 281 300 /** The time this segment has spent on the stack.. */ 282 uint64_tOnStackTicks;301 KU64 OnStackTicks; 283 302 /** The time this segment has spent on the top of the stack.. */ 284 uint64_tOnTopOfStackTicks;303 KU64 OnTopOfStackTicks; 285 304 /** The number of profiled functions from this segment. */ 286 uint32_tcFunctions;305 KU32 cFunctions; 287 306 } KPRF_TYPE(,REPORTMOD), *KPRF_TYPE(P,REPORTMOD); 288 307 … … 300 319 KPRF_TYPE(P,REPORTMODSEG) pModSeg; 301 320 /** Pointer to the function symbol. */ 302 P RTDBGSYMBOLpSym;321 PKDBGSYMBOL pSym; 303 322 /** Pointer to the function line number. */ 304 PKDBGLINE pLine;323 PKDBGLINE pLine; 305 324 } KPRF_TYPE(,REPORTFUNC), *KPRF_TYPE(P,REPORTFUNC); 306 325 … … 499 518 { 500 519 /** Pointer to the data set. */ 501 KPRF_TYPE(PC,HDR) pHdr;520 KPRF_TYPE(PC,HDR) pHdr; 502 521 503 522 /** @name Data-set item wrappers. … … 510 529 KPRF_TYPE(P,REPORTMOD) pFirstMod; 511 530 /** The number of modules in the list. */ 512 uint32_tcMods;531 KU32 cMods; 513 532 /** The module segment tree. */ 514 PAVLU32NODECOREpModSegTree;533 KPRF_TYPE(P,REPORTMODSEG) pModSegTree; 515 534 /** The number of module segments in the tree. */ 516 uint32_tcModSegs;535 KU32 cModSegs; 517 536 /** @} */ 518 537 … … 528 547 * @{ */ 529 548 /** Sum of the profiled ticks. */ 530 uint64_tProfiledTicks;549 KU64 ProfiledTicks; 531 550 /** Sum of the overhead ticks. */ 532 uint64_tOverheadTicks;551 KU64 OverheadTicks; 533 552 /** Sum of the sleep ticks. */ 534 uint64_tSleepTicks;553 KU64 SleepTicks; 535 554 /** Sum of calls performed. */ 536 uint64_tcCalls;555 KU64 cCalls; 537 556 /** @} */ 538 557 … … 552 571 * Everything but the mods and modsegs is allocated in the same block as the report. 553 572 */ 554 size_tcb = KPRF_ALIGN(KPRF_SIZEOF(REPORT), 32);555 uintptr_toffThreads = cb;573 KSIZE cb = KPRF_ALIGN(KPRF_SIZEOF(REPORT), 32); 574 KUPTR offThreads = cb; 556 575 cb += KPRF_ALIGN(KPRF_SIZEOF(REPORTTHREAD) * pHdr->cThreads, 32); 557 uintptr_toffFunctions = cb;576 KUPTR offFunctions = cb; 558 577 cb += KPRF_ALIGN(KPRF_SIZEOF(REPORTFUNC) * pHdr->cFunctions, 32); 559 uintptr_toffSortedThreads = cb;578 KUPTR offSortedThreads = cb; 560 579 cb += KPRF_ALIGN(sizeof(KPRF_TYPE(P,REPORTTHREAD)) * pHdr->cThreads, 32); 561 uintptr_toffSortedFunctions = cb;580 KUPTR offSortedFunctions = cb; 562 581 cb += KPRF_ALIGN(sizeof(KPRF_TYPE(P,REPORTFUNC)) * pHdr->cFunctions, 32); 563 582 KPRF_TYPE(P,REPORT) pReport = (KPRF_TYPE(P,REPORT))malloc(cb); … … 569 588 */ 570 589 pReport->pHdr = pHdr; 571 pReport->paThreads = (KPRF_TYPE(P,REPORTTHREAD))(( uint8_t*)pReport + offThreads);572 pReport->paFunctions = (KPRF_TYPE(P,REPORTFUNC))(( uint8_t*)pReport + offFunctions);590 pReport->paThreads = (KPRF_TYPE(P,REPORTTHREAD))((KU8 *)pReport + offThreads); 591 pReport->paFunctions = (KPRF_TYPE(P,REPORTFUNC))((KU8 *)pReport + offFunctions); 573 592 pReport->pFirstMod = NULL; 574 593 pReport->cMods = 0; 575 594 pReport->pModSegTree = NULL; 576 595 pReport->cModSegs = 0; 577 pReport->papSortedThreads = (KPRF_TYPE(P,REPORTTHREAD) *)(( uint8_t*)pReport + offSortedThreads);578 pReport->papSortedFunctions = (KPRF_TYPE(P,REPORTFUNC) *)(( uint8_t*)pReport + offSortedFunctions);596 pReport->papSortedThreads = (KPRF_TYPE(P,REPORTTHREAD) *)((KU8 *)pReport + offSortedThreads); 597 pReport->papSortedFunctions = (KPRF_TYPE(P,REPORTFUNC) *)((KU8 *)pReport + offSortedFunctions); 579 598 pReport->ProfiledTicks = 0; 580 599 pReport->OverheadTicks = 0; … … 593 612 * @param pvParam User parameter, ignored. 594 613 */ 595 static DECLCALLBACK(int) KPRF_NAME(DeleteModSeg)(PAVLU32NODECOREpCore, void *pvParam)614 static int KPRF_NAME(DeleteModSeg)(KPRF_TYPE(P,REPORTMODSEG) pCore, void *pvParam) 596 615 { 597 616 free(pCore); … … 614 633 KPRF_TYPE(P,REPORTMOD) pFree = pReport->pFirstMod; 615 634 pReport->pFirstMod = pFree->pNext; 616 RTDbgModuleClose(pFree->pDbgMod);635 kDbgModuleClose(pFree->pDbgMod); 617 636 free(pFree); 618 637 } 619 638 620 RTAvlU32Destroy(&pReport->pModSegTree, KPRF_NAME(DeleteModSeg), NULL);639 KPRF_NAME(ReportTreeDestroy)(&pReport->pModSegTree, KPRF_NAME(DeleteModSeg), NULL); 621 640 622 641 /* 623 642 * The function debug info. 624 643 */ 625 uint32_ti = pReport->pHdr->cFunctions;644 KU32 i = pReport->pHdr->cFunctions; 626 645 while (i-- > 0) 627 646 { 628 RTDbgSymbolFree(pReport->paFunctions[i].pSym);629 RTDbgLineFree(pReport->paFunctions[i].pLine);647 kDbgSymbolFree(pReport->paFunctions[i].pSym); 648 kDbgLineFree(pReport->paFunctions[i].pLine); 630 649 } 631 650 … … 645 664 * @param pReport The report to work on. 646 665 */ 647 static int KPRF_NAME(Analy seModSegs)(KPRF_TYPE(P,REPORT) pReport)648 { 649 const uint32_toffEnd = pReport->pHdr->offModSegs + pReport->pHdr->cbModSegs;650 uint32_toff = pReport->pHdr->offModSegs;666 static int KPRF_NAME(AnalyzeModSegs)(KPRF_TYPE(P,REPORT) pReport) 667 { 668 const KU32 offEnd = pReport->pHdr->offModSegs + pReport->pHdr->cbModSegs; 669 KU32 off = pReport->pHdr->offModSegs; 651 670 while (off < offEnd) 652 671 { 653 672 KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(PC,MODSEG, off, pReport->pHdr); 654 uint32_tcbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);673 KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]); 655 674 cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR)); 656 675 … … 662 681 return -1; 663 682 664 pSeg-> Core.Key= off;683 pSeg->offSegment = off; 665 684 pSeg->pModSeg = pCur; 666 685 pSeg->pMod = NULL; /* below */ … … 669 688 pSeg->cFunctions = 0; 670 689 671 if (! RTAvlU32Insert(&pReport->pModSegTree, &pSeg->Core))690 if (!KPRF_NAME(ReportTreeInsert)(&pReport->pModSegTree, pSeg)) 672 691 { 673 692 free(pSeg); … … 707 726 pMod->cFunctions = 0; 708 727 709 int rc = RTDbgModuleOpen(pSeg->pModSeg->szPath, &pMod->pDbgMod);710 if ( RT_FAILURE(rc))728 int rc = kDbgModuleOpen(&pMod->pDbgMod, pSeg->pModSeg->szPath, NULL /* kLdrMod */); 729 if (rc) 711 730 pMod->pDbgMod = NULL; 712 731 } … … 729 748 static int KPRF_NAME(AnalyseFunctions)(KPRF_TYPE(P,REPORT) pReport) 730 749 { 731 uint32_tiFunc = pReport->pHdr->cFunctions;750 KU32 iFunc = pReport->pHdr->cFunctions; 732 751 KPRF_TYPE(PC,FUNC) pFunc = KPRF_OFF2PTR(PC,FUNC, pReport->pHdr->offFunctions + iFunc * sizeof(*pFunc), pReport->pHdr); 733 752 KPRF_TYPE(P,REPORTFUNC) pReportFunc = &pReport->paFunctions[iFunc]; … … 739 758 pReport->papSortedFunctions[iFunc] = pReportFunc; 740 759 pReportFunc->pFunc = pFunc; 741 pReportFunc->pModSeg = (KPRF_TYPE(P,REPORTMODSEG))RTAvlU32Get(&pReport->pModSegTree, pFunc->offModSeg);760 pReportFunc->pModSeg = KPRF_NAME(ReportTreeGet)(&pReport->pModSegTree, pFunc->offModSeg); 742 761 pReportFunc->pSym = NULL; 743 762 pReportFunc->pLine = NULL; … … 756 775 757 776 /* Get debug info. */ 758 RTUINTPTR offSegment = (RTUINTPTR)(pFunc->uEntryPtr - pModSeg->pModSeg->uBasePtr);759 int rc = RTDbgModuleQuerySymbolA(pMod->pDbgMod, pModSeg->pModSeg->iSegment, offSegment, &pReportFunc->pSym);777 KDBGADDR offSegment = pFunc->uEntryPtr - pModSeg->pModSeg->uBasePtr; 778 int rc = kDbgModuleQuerySymbolA(pMod->pDbgMod, pModSeg->pModSeg->iSegment, offSegment, &pReportFunc->pSym); 760 779 /** @todo check displacement! */ 761 if ( RT_FAILURE(rc))780 if (rc) 762 781 pReportFunc->pSym = NULL; 763 rc = RTDbgModuleQueryLineA(pMod->pDbgMod, pModSeg->pModSeg->iSegment, offSegment, &pReportFunc->pLine);764 if ( RT_FAILURE(rc))782 rc = kDbgModuleQueryLineA(pMod->pDbgMod, pModSeg->pModSeg->iSegment, offSegment, &pReportFunc->pLine); 783 if (rc) 765 784 pReportFunc->pLine = NULL; 766 785 } … … 779 798 static int KPRF_NAME(AnalyseThreads)(KPRF_TYPE(P,REPORT) pReport) 780 799 { 781 uint32_tiThread = pReport->pHdr->cThreads;800 KU32 iThread = pReport->pHdr->cThreads; 782 801 KPRF_TYPE(PC,THREAD) pThread = KPRF_OFF2PTR(PC,THREAD, pReport->pHdr->offThreads + iThread * sizeof(*pThread), pReport->pHdr); 783 802 KPRF_TYPE(P,REPORTTHREAD) pReportThread = &pReport->paThreads[iThread]; … … 820 839 821 840 /* read module segments */ 822 int rc = KPRF_NAME(Analy seModSegs)(pReport);841 int rc = KPRF_NAME(AnalyzeModSegs)(pReport); 823 842 if (!rc) 824 843 { … … 846 865 * @internal 847 866 */ 848 static void KPRF_NAME(HtmlWriteRowU32X32)(FILE *pOut, const char *pszName, uint32_tu32, const char *pszUnit)867 static void KPRF_NAME(HtmlWriteRowU32X32)(FILE *pOut, const char *pszName, KU32 u32, const char *pszUnit) 849 868 { 850 869 fprintf(pOut, … … 862 881 * @internal 863 882 */ 864 static void KPRF_NAME(HtmlWriteRowU32)(FILE *pOut, const char *pszName, uint32_tu32, const char *pszUnit)883 static void KPRF_NAME(HtmlWriteRowU32)(FILE *pOut, const char *pszName, KU32 u32, const char *pszUnit) 865 884 { 866 885 fprintf(pOut, … … 878 897 * @internal 879 898 */ 880 static void KPRF_NAME(HtmlWriteRowU64)(FILE *pOut, const char *pszName, uint64_tu64, const char *pszUnit)899 static void KPRF_NAME(HtmlWriteRowU64)(FILE *pOut, const char *pszName, KU64 u64, const char *pszUnit) 881 900 { 882 901 fprintf(pOut, … … 894 913 * @internal 895 914 */ 896 static void KPRF_NAME(HtmlWriteRowX64)(FILE *pOut, const char *pszName, uint64_tu64, const char *pszUnit)915 static void KPRF_NAME(HtmlWriteRowX64)(FILE *pOut, const char *pszName, KU64 u64, const char *pszUnit) 897 916 { 898 917 fprintf(pOut, … … 909 928 * Writes a ticks. 910 929 */ 911 static void KPRF_NAME(HtmlWriteParts)(FILE *pOut, uint64_t cTicks, uint64_tcTotalTicks)930 static void KPRF_NAME(HtmlWriteParts)(FILE *pOut, KU64 cTicks, KU64 cTotalTicks) 912 931 { 913 932 /** U+2030 PER MILLE SIGN */ 914 static const uint8_ts_szPerMilleSignUtf8[4] = { 0xe2, 0x80, 0xb0, 0};933 static const KU8 s_szPerMilleSignUtf8[4] = { 0xe2, 0x80, 0xb0, 0}; 915 934 916 935 if (cTicks * 100 / cTotalTicks) 917 936 { 918 uint32_t u = (uint32_t)((cTicks * 1000) / cTotalTicks);937 KU32 u = (KU32)((cTicks * 1000) / cTotalTicks); 919 938 fprintf(pOut, "%u.%01u%%", u / 10, u %10); 920 939 } 921 940 else //if (cTicks * 100000 / cTotalTicks) 922 941 { 923 uint32_t u = (uint32_t)((cTicks * 100000) / cTotalTicks);942 KU32 u = (KU32)((cTicks * 100000) / cTotalTicks); 924 943 fprintf(pOut, "%u.%02u%s", u / 100, u % 100, s_szPerMilleSignUtf8); 925 944 } … … 936 955 * Writes a ticks. 937 956 */ 938 static void KPRF_NAME(HtmlWriteTicks)(FILE *pOut, uint64_t cTicks, uint64_tcTotalTicks)957 static void KPRF_NAME(HtmlWriteTicks)(FILE *pOut, KU64 cTicks, KU64 cTotalTicks) 939 958 { 940 959 fprintf(pOut, "%" KPRF_FMT_U64 "", cTicks); … … 956 975 * @internal 957 976 */ 958 static void KPRF_NAME(HtmlWriteRowTicks)(FILE *pOut, const char *pszName, uint64_t cTicks, uint64_tcTotalTicks)977 static void KPRF_NAME(HtmlWriteRowTicks)(FILE *pOut, const char *pszName, KU64 cTicks, KU64 cTotalTicks) 959 978 { 960 979 fprintf(pOut, … … 980 999 * @internal 981 1000 */ 982 static void KPRF_NAME(HtmlWriteRowTimeStat)(FILE *pOut, const char *pszName, KPRF_TYPE(PC,TIMESTAT) pTimeStat, uint64_tcTotalTicks)1001 static void KPRF_NAME(HtmlWriteRowTimeStat)(FILE *pOut, const char *pszName, KPRF_TYPE(PC,TIMESTAT) pTimeStat, KU64 cTotalTicks) 983 1002 { 984 1003 fprintf(pOut, … … 1008 1027 * @internal 1009 1028 */ 1010 static void KPRF_NAME(HtmlWriteRowCalls)(FILE *pOut, const char *pszName, uint64_t cCalls, uint64_tcTotalCalls)1029 static void KPRF_NAME(HtmlWriteRowCalls)(FILE *pOut, const char *pszName, KU64 cCalls, KU64 cTotalCalls) 1011 1030 { 1012 1031 fprintf(pOut, … … 1123 1142 " </tr>\n"); 1124 1143 1125 for ( uint32_tiFunc = 0; iFunc < pReport->pHdr->cFunctions; iFunc++)1144 for (KU32 iFunc = 0; iFunc < pReport->pHdr->cFunctions; iFunc++) 1126 1145 { 1127 1146 KPRF_TYPE(P,REPORTFUNC) pReportFunc = pReport->papSortedFunctions[iFunc]; … … 1243 1262 "<head>\n" 1244 1263 " <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n" 1245 " <title>kProfile 2 - %s</title>\n"1264 " <title>kProfiler 2 - %s</title>\n" 1246 1265 "</head>\n" 1247 1266 "<style>\n" … … 1396 1415 KPRF_NAME(HtmlWriteRowCalls)(pOut, "Recorded Calls", pReport->cCalls, pReport->cCalls); 1397 1416 fprintf(pOut, "<tr><td class=\"BlankRow\" colspan=7> </td></tr>\n"); 1398 KPRF_NAME(HtmlWriteRowString)(pOut, "kProfile Version ", NULL, "Mark 2 Alpha 1");1399 KPRF_NAME(HtmlWriteRowString)(pOut, "kProfile Build Time ", NULL, __DATE__ " " __TIME__);1417 KPRF_NAME(HtmlWriteRowString)(pOut, "kProfiler Version ", NULL, "Mark 2 Alpha 1"); 1418 KPRF_NAME(HtmlWriteRowString)(pOut, "kProfiler Build Time ", NULL, __DATE__ " " __TIME__); 1400 1419 fprintf(pOut, 1401 1420 "</table>\n" … … 1440 1459 "<p>\n" 1441 1460 "<table class=\"Functions\">\n"); 1442 for ( uint32_tiFunc = 0; iFunc < pHdr->cFunctions; iFunc++)1461 for (KU32 iFunc = 0; iFunc < pHdr->cFunctions; iFunc++) 1443 1462 { 1444 1463 KPRF_TYPE(P,REPORTFUNC) pReportFunc = &pReport->paFunctions[iFunc]; … … 1486 1505 "<table class=\"Threads\">\n"); 1487 1506 1488 for ( uint32_tiThread = 0; iThread < pHdr->cThreads; iThread++)1507 for (KU32 iThread = 0; iThread < pHdr->cThreads; iThread++) 1489 1508 { 1490 1509 KPRF_TYPE(PC,THREAD) pThread = pReport->paThreads[iThread].pThread; … … 1527 1546 1528 1547 KPRF_TYPE(P,REPORTMOD) pMod = pReport->pFirstMod; 1529 uint32_tiMod = 0;1548 KU32 iMod = 0; 1530 1549 while (pMod) 1531 1550 { -
trunk/kStuff/kProfile/prfx86msc.asm
r3537 r3565 1 1 ; $Id: $ 2 2 ;; @file 3 ; 4 ; kProfiler MK2 - Microsoft C/C++ Compiler Interaction. 5 ; 6 ; 7 ; Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de> 8 ; 9 ; 10 ; This file is part of kLIBC. 11 ; 12 ; kLIBC is free software; you can redistribute it and/or modify 13 ; it under the terms of the GNU General Public License as published by 14 ; the Free Software Foundation; either version 2 of the License, or 15 ; (at your option) any later version. 16 ; 17 ; kLIBC is distributed in the hope that it will be useful, 3 ; kProfiler Mark 2 - Microsoft C/C++ Compiler Interaction, x86. 4 ; 5 6 ; 7 ; Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 ; 9 ; This file is part of kProfiler. 10 ; 11 ; kProfiler is free software; you can redistribute it and/or 12 ; modify it under the terms of the GNU Lesser General Public 13 ; License as published by the Free Software Foundation; either 14 ; version 2.1 of the License, or (at your option) any later version. 15 ; 16 ; kProfiler is distributed in the hope that it will be useful, 18 17 ; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 ; GNUGeneral Public License for more details.21 ; 22 ; You should have received a copy of the GNU General Public License23 ; along with kLIBC; if not, write to the Free Software24 ; Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA25 ; 26 ; 18 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 ; Lesser General Public License for more details. 20 ; 21 ; You should have received a copy of the GNU Lesser General Public 22 ; License along with kProfiler; if not, write to the Free Software 23 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 ; 25 27 26 28 27 [section .data]
Note:
See TracChangeset
for help on using the changeset viewer.