Changeset 3565 for trunk/kStuff/kProfile/kPrf2Read.cpp
- Timestamp:
- Aug 27, 2007, 6:06:17 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.