Changeset 3565


Ignore:
Timestamp:
Aug 27, 2007, 6:06:17 AM (18 years ago)
Author:
bird
Message:

Use kStuff.

Location:
trunk/kStuff/kProfile
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/kStuff/kProfile/Makefile.kmk

    r3537 r3565  
    11# $Id: $
    22## @file
    3 #
    43# kProfiler Mark 2
    54#
    6 # Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net>
     5
    76#
     7# Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
    88#
    9 # This file is part of kLIBC.
     9# This file is part of kProfiler.
    1010#
    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.
     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.
    1515#
    16 # kLIBC is distributed in the hope that it will be useful,
     16# kProfiler is distributed in the hope that it will be useful,
    1717# 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.
     18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19# Lesser General Public License for more details.
    2020#
    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
    2424#
    25 #
     25
    2626
    2727DEPTH = ../..
     
    6868TEMPLATE_kPrf2_ASFLAGS.win.amd64 = -f win64 -g cv8
    6969
     70TEMPLATE_kPrf2_INCS             = \
     71        ../include
    7072#TEMPLATE_kPrf2_INCS.win            = \
    7173#       $(PATH_DEV)/x86.win32/vcc70/include \
     
    113115# kPrf2Read - The read & producer of statistics.
    114116#
    115 kPrf2Read_TEMPLATE = kPrf2
     117#kPrf2Read_TEMPLATE = kPrf2
     118kPrf2Read_TEMPLATE = kStuffEXE
    116119kPrf2Read_SOURCES  = \
    117120        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
     121kPrf2Read_LIBS  = \
     122        $(PATH_LIB)/kDbgStatic$(SUFF_LIB) \
     123        $(PATH_LIB)/kRdrStatic$(SUFF_LIB) \
     124        $(PATH_LIB)/kHlpCRTStatic$(SUFF_LIB)
    131125
    132126# kLdr stuff
    133127KLDR_ROOT ?= $(PATH_CURRENT)/../kLdr
    134128kPrf2Read_INCS += $(KLDR_ROOT)
    135 
    136 # IPRT stuff
    137 VBOX_ROOT ?= y:/coding/vbox/svn/trunk
    138 kPrf2Read_INCS += $(VBOX_ROOT)/include
    139 kPrf2Read_DEFS += IN_RING3 IN_RT_R3 KDBG_USE_IPRT KCOMMON_ALREADY_INCLUDED_STD_TYPES
    140 ifeq ($(BUILD_TARGET),win)
    141 kPrf2Read_LIBS = \
    142         $(VBOX_ROOT)/out/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)/lib/VBoxRT$(SUFF_LIB)
    143 else
    144 kPrf2Read_LIBS = \
    145         $(VBOX_ROOT)/out/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)/bin/VBoxRT$(SUFF_DLL)
    146 endif
    147129
    148130
  • trunk/kStuff/kProfile/dllmain-win.cpp

    r3537 r3565  
     1/* $Id: $ */
     2/** @file
     3 * kProfiler Mark 2 - The Windows DllMain for the profiler DLL.
     4 */
    15
     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 */
    226
    327
     
    630*******************************************************************************/
    731#include <Windows.h>
    8 
    932#include "kProfileR3.h"
    1033
    1134
    12 
    1335/**
    14  * The DLL Main for the IPRT DLL.
     36 * The DLL Main for the kPrf DLL.
    1537 *
    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.)
    1942 *
    2043 * @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
    127LIBRARY kPrf2
    228EXPORTS
     
    430    _pexit
    531    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
    127LIBRARY kPrf2
    228EXPORTS
     
    430    _pexit
    531    KPrfInit
     32
  • trunk/kStuff/kProfile/kPrf2Read.cpp

    r3537 r3565  
    11/* $Id: $ */
    22/** @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 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,
     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,
    1717 * 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 */
    2726
    2827
     
    3433#include <string.h>
    3534#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>
    6436
    6537
     
    6941 */
    7042#define KPRF_OFF2PTR(TypePrefix, TypeName, off, pHdr) \
    71     ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + (uintptr_t)pHdr) )
     43    ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + (KUPTR)pHdr) )
    7244
    7345/** @def KPRF_ALIGN
     
    7850
    7951/** @def KPRF_OFFSETOF
    80  * My usual extended OFFSETOF macro, except this returns uint32_t and mangles the type name.
     52 * My usual extended offsetof macro, except this returns KU32 and mangles the type name.
    8153 * @internal
    8254 */
    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 )
    8456
    8557/** @def PRF_SIZEOF
     
    161133 * @param   pOut                Where to write errors.
    162134 */
    163 PKPRFHDR kPrfLoad(const char *pszFilename, uint32_t *pcb, FILE *pOut)
     135PKPRFHDR kPrfLoad(const char *pszFilename, KU32 *pcb, FILE *pOut)
    164136{
    165137    FILE *pFile = fopen(pszFilename, "rb");
     
    215187 * @param   pOut        Where to write error messages.
    216188 */
    217 static bool kPrfIsValidate(PCKPRFHDR pHdr, uint32_t cb, FILE *pOut)
     189static bool kPrfIsValidate(PCKPRFHDR pHdr, KU32 cb, FILE *pOut)
    218190{
    219191    /*
     
    254226    KPRF_VALIDATE_SIZE(Thread, sizeof(KPRF32THREAD), sizeof(KPRF64THREAD));
    255227    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)cbHeader
     228                       (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
    261233        ||  cbHeader >= cb)
    262234    {
     
    267239
    268240    /* The space assignment is hereby required to be equal to the member order in the header. */
    269     uint32_t offMin = cbHeader;
     241    KU32 offMin = cbHeader;
    270242#define KPRF_VALIDATE_OFF(off, name) do {\
    271243        if (    off > 0 \
     
    322294     * Validate the function lookup table
    323295     */
    324     for (uint32_t i = 0; i < pHdr->Hdr32.cFunctions; i++)
     296    for (KU32 i = 0; i < pHdr->Hdr32.cFunctions; i++)
    325297        if (pHdr->Hdr32.aiFunctions[i] >= pHdr->Hdr32.cFunctions)
    326298        {
     
    362334     * Load and validate the data set.
    363335     */
    364     uint32_t cb;
     336    KU32 cb;
    365337    PKPRFHDR pHdr = kPrfLoad(pszFilename, &cb, pOut);
    366338    if (!pHdr)
     
    407379     * Load and validate the data set.
    408380     */
    409     uint32_t cb;
     381    KU32 cb;
    410382    PKPRFHDR pHdr = kPrfLoad(pszFilename, &cb, pOut);
    411383    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 */
    126
    227
     
    833# include <psapi.h>
    934# 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;
    1935# if _MSC_VER >= 1400
    2036#  include <intrin.h>
     
    4561#endif
    4662
     63#include <k/kDefs.h>
     64#include <k/kTypes.h>
    4765
    4866/*
     
    100118/** Update the state. */
    101119#define KPRF_RWLOCK_SETSTATE(pRWLock, enmNewState) \
    102     kPrfAtomicSet32((volatile uint32_t *)&(pRWLock)->enmState, (uint32_t)(enmNewState))
     120    kPrfAtomicSet32((volatile KU32 *)&(pRWLock)->enmState, (KU32)(enmNewState))
    103121
    104122/** Read/Write lock type. */
     
    109127    KPRF_TYPE(,MUTEX)       Mutex;
    110128    /** The current number of readers. */
    111     uint32_t                cReaders;
     129    KU32                    cReaders;
    112130    /** The number of readers waiting. */
    113     uint32_t                cReadersWaiting;
     131    KU32                    cReadersWaiting;
    114132    /** The current number of waiting writers. */
    115     uint32_t                cWritersWaiting;
     133    KU32                    cWritersWaiting;
    116134# if defined(KPRF_OS_WINDOWS)
    117135    /** The handle of the event object on which the waiting readers block. (manual reset). */
     
    218236 * @returns The thread id.
    219237 */
    220 static inline uintptr_t kPrfGetThreadId(void)
     238static inline KUPTR kPrfGetThreadId(void)
    221239{
    222240/* Win32/64 */
    223241#if defined(KPRF_OS_WINDOWS)
    224     uintptr_t ThreadId = (uintptr_t)GetCurrentThreadId();
     242    KUPTR ThreadId = (KUPTR)GetCurrentThreadId();
    225243
    226244/* Posix Threads */
    227245#elif defined(KPRF_USE_PTHREAD)
    228     uintptr_t ThreadId = (uintptr_t)pthread_self();
     246    KUPTR ThreadId = (KUPTR)pthread_self();
    229247
    230248#elif defined(KPRF_OS_OS2)
     
    248266 * @returns The process id.
    249267 */
    250 static inline uintptr_t kPrfGetProcessId(void)
     268static inline KUPTR kPrfGetProcessId(void)
    251269{
    252270/* Win32/64 */
    253271#if defined(KPRF_OS_WINDOWS)
    254     uintptr_t ThreadId = (uintptr_t)GetProcessId(GetCurrentProcess());
     272    KUPTR ThreadId = (KUPTR)GetProcessId(GetCurrentProcess());
    255273
    256274#elif defined(KPRF_OS_OS2)
     
    261279
    262280#else
    263     uintptr_t ThreadId = (uintptr_t)getpid();
     281    KUPTR ThreadId = (KUPTR)getpid();
    264282#endif
    265283
     
    302320 * This must correspond to what the assembly code are doing.
    303321 */
    304 static inline uint64_t kPrfNow(void)
     322static inline KU64 kPrfNow(void)
    305323{
    306324#if defined(HAVE_INTRIN)
     
    309327    union
    310328    {
    311         uint64_t u64;
     329        KU64 u64;
    312330        struct
    313331        {
    314             uint32_t u32Lo;
    315             uint32_t u32Hi;
     332            KU32 u32Lo;
     333            KU32 u32Hi;
    316334        } s;
    317335    } u;
     
    336354 * Atomically set a 32-bit value.
    337355 */
    338 static inline void kPrfAtomicSet32(volatile uint32_t *pu32, const uint32_t u32)
     356static inline void kPrfAtomicSet32(volatile KU32 *pu32, const KU32 u32)
    339357{
    340358#if defined(HAVE_INTRIN)
     
    365383 * Atomically set a 64-bit value.
    366384 */
    367 static inline void kPrfAtomicSet64(volatile uint64_t *pu64, uint64_t u64)
     385static inline void kPrfAtomicSet64(volatile KU64 *pu64, KU64 u64)
    368386{
    369387#if defined(HAVE_INTRIN) && KPRF_BITS == 64
    370     _InterlockedExchange64((int64_t *)pu64, (const int64_t)u64);
     388    _InterlockedExchange64((KI64 *)pu64, (const KI64)u64);
    371389
    372390#elif defined(__GNUC__) && KPRF_BITS == 64
     
    382400                           "=m" (*pu64)
    383401                         : "0" (*pu64),
    384                            "b" ( (uint32_t)u64 ),
    385                            "c" ( (uint32_t)(u64 >> 32) ));
     402                           "b" ( (KU32)u64 ),
     403                           "c" ( (KU32)(u64 >> 32) ));
    386404
    387405#elif _MSC_VER
     
    407425 * Atomically add a 32-bit integer to another.
    408426 */
    409 static inline void kPrfAtomicAdd32(volatile uint32_t *pu32, const uint32_t u32)
     427static inline void kPrfAtomicAdd32(volatile KU32 *pu32, const KU32 u32)
    410428{
    411429#if defined(HAVE_INTRIN)
     
    431449#define KPRF_ATOMIC_ADD32(a,b)          kPrfAtomicAdd32(a, b)
    432450#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);
    434452
    435453
     
    438456 * Atomically isn't quite required, just a non-corruptive manner, assuming all updates are adds.
    439457 */
    440 static inline void kPrfAtomicAdd64(volatile uint64_t *pu64, const uint64_t u64)
     458static inline void kPrfAtomicAdd64(volatile KU64 *pu64, const KU64 u64)
    441459{
    442460#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);
    444462
    445463#elif defined(__GNUC__) && KPRF_BITS == 64
     
    451469    __asm__ __volatile__("lock; addl %0, %2\n\t"
    452470                         "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)));
    457475
    458476#elif _MSC_VER
     
    922940 *
    923941 */
    924 static int kPrfGetModSeg(KPRF_TYPE(,UPTR) uAddress, char *pszPath, uint32_t cchPath, uint32_t *piSegment,
     942static int kPrfGetModSeg(KPRF_TYPE(,UPTR) uAddress, char *pszPath, KU32 cchPath, KU32 *piSegment,
    925943                         KPRF_TYPE(P,UPTR) puBasePtr, KPRF_TYPE(P,UPTR) pcbSegmentMinusOne)
    926944{
     
    945963            __try
    946964            {
    947                 const uintptr_t uImageBase = (uintptr_t)pahModules[i];
     965                const KUPTR uImageBase = (KUPTR)pahModules[i];
    948966                union
    949967                {
    950                     uint8_t            *pu8;
     968                    KU8                *pu8;
    951969                    PIMAGE_DOS_HEADER   pDos;
    952970                    PIMAGE_NT_HEADERS   pNt;
    953971                    PIMAGE_NT_HEADERS32 pNt32;
    954972                    PIMAGE_NT_HEADERS64 pNt64;
    955                     uintptr_t           u;
     973                    KUPTR               u;
    956974                } u;
    957975                u.u = uImageBase;
     
    970988
    971989                /* Extract necessary info from the optional header (comes in 32-bit and 64-bit variations, we simplify a bit). */
    972                 uint32_t                cbImage;
     990                KU32                    cbImage;
    973991                PIMAGE_SECTION_HEADER   paSHs;
    974992                if (u.pNt->FileHeader.SizeOfOptionalHeader == sizeof(IMAGE_OPTIONAL_HEADER32))
     
    9861004
    9871005                /* Is our address within the image size */
    988                 uintptr_t uRVA = uAddress - (uintptr_t)pahModules[i];
     1006                KUPTR uRVA = uAddress - (KUPTR)pahModules[i];
    9891007                if (uRVA >= cbImage)
    9901008                    continue;
     
    9941012                 * (segment == section + 1)
    9951013                 */
    996                 const uint32_t cSHs = u.pNt->FileHeader.NumberOfSections;
     1014                const KU32 cSHs = u.pNt->FileHeader.NumberOfSections;
    9971015                if (uRVA < paSHs[0].VirtualAddress)
    9981016                {
     
    10041022                else
    10051023                {
    1006                     uint32_t iSH = 0;
     1024                    KU32 iSH = 0;
    10071025                    for (;;)
    10081026                    {
     
    10631081        ULONG cb     = ~0UL;
    10641082        ULONG fFlags = ~0UL;
    1065         uAddress &= ~(uintptr_t)0xfff;
     1083        uAddress &= ~(KUPTR)0xfff;
    10661084        rc = DosQueryMem((PVOID)(uAddress, &cb, &fFlags);
    10671085        if (!rc)
    10681086        {
    1069             *pcbSegmentMinusOne = (offObj & ~(uintptr_t)0xfff) + KPRF_ALIGN(cb, 0x1000) - 1;
     1087            *pcbSegmentMinusOne = (offObj & ~(KUPTR)0xfff) + KPRF_ALIGN(cb, 0x1000) - 1;
    10701088            if ((fFlags & PAG_BASE) && cb <= 0x1000) /* don't quite remember if PAG_BASE returns one page or not */
    10711089            {
     
    11181136static KPRF_TYPE(P,THREAD) kPrfGetThreadAutoReg(void)
    11191137{
    1120     uintptr_t uStackBasePtr;
     1138    KUPTR uStackBasePtr;
    11211139
    11221140#if 0
     
    11291147    DosGetInfoBlocks(&pTib, &pPib); /* never fails except if you give it bad input, thus 'Get' not 'Query'. */
    11301148    /* I never recall which of these is the right one... */
    1131     uStackBasePtr = (uintptr_t)pTib->tib_pstack < (uintptr_t)pTib->tib_pstack_limit
    1132         ? (uintptr_t)pTib->tib_pstack
    1133         : (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;
    11341152
    11351153#else
    11361154    /* 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;
    11391157#endif
    11401158
     
    11521170 * @param   pszDefault  The default value.
    11531171 */
    1154 static char *kPrfGetEnvString(const char *pszVar, char *pszValue, uint32_t cchValue, const char *pszDefault)
     1172static char *kPrfGetEnvString(const char *pszVar, char *pszValue, KU32 cchValue, const char *pszDefault)
    11551173{
    11561174#if defined(KPRF_OS_WINDOWS)
     
    11911209 * @param   uDefault    The default value.
    11921210 */
    1193 static uint32_t kPrfGetEnvValue(const char *pszVar, uint32_t uDefault)
     1211static KU32 kPrfGetEnvValue(const char *pszVar, KU32 uDefault)
    11941212{
    11951213#if defined(KPRF_OS_WINDOWS)
     
    12231241     */
    12241242    unsigned    uBase = 10;
    1225     uint32_t    uValue = 0;
     1243    KU32        uValue = 0;
    12261244    const char *psz = pszValue;
    12271245
     
    12791297 * @param   cb      The amount of memory (in bytes) to allocate.
    12801298 */
    1281 static void *kPrfAllocMem(uint32_t cb)
     1299static void *kPrfAllocMem(KU32 cb)
    12821300{
    12831301#if defined(KPRF_OS_WINDOWS)
     
    13421360 * @param   cbData      The amount of data to write.
    13431361 */
    1344 static int kPrfWriteFile(const char *pszName, const void *pvData, uint32_t cbData)
     1362static int kPrfWriteFile(const char *pszName, const void *pvData, KU32 cbData)
    13451363{
    13461364#if defined(KPRF_OS_WINDOWS)
     
    14121430     * Initial suggestions.
    14131431     */
    1414     uint32_t    cbModSegs  = kPrfGetEnvValue("KPRF2_CBMODSEGS",  128*1024);
    1415     uint32_t    cFunctions = kPrfGetEnvValue("KPRF2_CFUNCTIONS", 8192);
    1416     uint32_t    cThreads   = kPrfGetEnvValue("KPRF2_CTHREADS",   256);
    1417     uint32_t    cStacks    = kPrfGetEnvValue("KPRF2_CSTACKS",    48);
    1418     uint32_t    cFrames    = kPrfGetEnvValue("KPRF2_CFRAMES",    448);
    1419 
    1420     uint32_t cb = 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);
    14211439
    14221440    /*
     
    15481566
    15491567    /* append the process id */
    1550     uintptr_t pid = kPrfGetProcessId();
     1568    KUPTR pid = kPrfGetProcessId();
    15511569    char *psz = szName;
    15521570    while (*psz)
     
    15541572
    15551573    static char s_szDigits[0x11] = "0123456789abcdef";
    1556     uint32_t uShift = KPRF_BITS - 4;
     1574    KU32 uShift = KPRF_BITS - 4;
    15571575    while (     uShift > 0
    15581576           &&   !(pid & (0xf << uShift)))
  • trunk/kStuff/kProfile/kProfileR3.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler Mark 2 - Internal header, Ring-3.
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
    2626
    27 #ifndef __kProfileR3_h__
    28 #define __kProfileR3_h__
     27#ifndef ___kProfileR3_h___
     28#define ___kProfileR3_h___
    2929
    3030int kPrfInitialize(void);
     
    3434#endif
    3535
    36 
  • trunk/kStuff/kProfile/prfamd64msc.asm

    r3537 r3565  
    1 ; $Id: $
     1; $Id: $;
    22;; @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,
    1817; but WITHOUT ANY WARRANTY; without even the implied warranty of
    19 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20 ; GNU General Public License for more details.
    21 ;
    22 ; You should have received a copy of the GNU General Public License
    23 ; along with kLIBC; if not, write to the Free Software
    24 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    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
    2726
    2827[section .data]
  • trunk/kStuff/kProfile/prfcore.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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 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,
     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,
    1717 * 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
     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
    2424 *
    2525 */
     
    3737
    3838    KPRF_FUNCS_READ_LOCK();
    39     int32_t iStart = 0;
    40     int32_t iLast  = pHdr->cFunctions - 1;
    41     int32_t i      = iLast / 2;
     39    KI32 iStart = 0;
     40    KI32 iLast  = pHdr->cFunctions - 1;
     41    KI32 i      = iLast / 2;
    4242    for (;;)
    4343    {
    44         uint32_t iFunction = pHdr->aiFunctions[i];
     44        KU32 iFunction = pHdr->aiFunctions[i];
    4545        KPRF_TYPE(,IPTR) iDiff = uPC - paFunctions[iFunction].uEntryPtr;
    4646        if (!iDiff)
     
    7373 * Unwind one frame.
    7474 */
    75 static uint64_t* KPRF_NAME(UnwindOne)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,STACK) pStack, KPRF_TYPE(,UPTR) uPC, uint64_t TS)
     75static KU64* KPRF_NAME(UnwindOne)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,STACK) pStack, KPRF_TYPE(,UPTR) uPC, KU64 TS)
    7676{
    7777    /*
     
    7979     */
    8080    KPRF_TYPE(P,FRAME) pFrame = &pStack->aFrames[--pStack->cFrames];
    81     uint64_t *pCurOverheadTicks;
     81    KU64 *pCurOverheadTicks;
    8282    if (pStack->cFrames)
    8383    {
     
    108108
    109109        /* Time on stack */
    110         uint64_t Ticks = TS - pFrame->OnStackStart;
     110        KU64 Ticks = TS - pFrame->OnStackStart;
    111111        Ticks -= pFrame->OverheadTicks + pFrame->CurOverheadTicks + pFrame->SleepTicks;
    112112/** @todo adjust overhead */
     
    142142 * Unwinds the stack.
    143143 */
    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_t TS)
     144static KU64* KPRF_NAME(UnwindInt)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,STACK) pStack, KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, KU64 TS)
    145145{
    146146    /** @todo need to deal with alternative stacks! */
     
    149149     * Pop the stack until we're down below the current frame (uFramePtr).
    150150     */
    151     int32_t iFrame = pStack->cFrames - 1;
     151    KI32 iFrame = pStack->cFrames - 1;
    152152    KPRF_TYPE(P,FRAME) pFrame = &pStack->aFrames[iFrame];
    153153    /* the most frequent case first. */
     
    160160
    161161    /* 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);
    163163    pFrame++;
    164164    if (    iFrame > 0
     
    198198 * @internal ?
    199199 */
    200 KPRF_DECL_FUNC(uint64_t *, Enter)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const uint64_t TS)
     200KPRF_DECL_FUNC(KU64 *, Enter)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const KU64 TS)
    201201{
    202202    /*
     
    252252     */
    253253    KPRF_TYPE(P,STACK) pStack = KPRF_OFF2PTR(P,STACK, pThread->offStack, pHdr);
    254     uint32_t iFrame = pStack->cFrames;
     254    KU32 iFrame = pStack->cFrames;
    255255    KPRF_TYPE(P,FRAME) pFrame = &pStack->aFrames[iFrame];
    256256    if (    iFrame
     
    329329 * @internal
    330330 */
    331 KPRF_DECL_FUNC(uint64_t *, Leave)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const uint64_t TS)
     331KPRF_DECL_FUNC(KU64 *, Leave)(KPRF_TYPE(,UPTR) uPC, KPRF_TYPE(,UPTR) uFramePtr, const KU64 TS)
    332332{
    333333    /*
     
    371371     * Leave it to the caller to update the overhead.
    372372     */
    373     uint64_t *pCurOverheadTicks = KPRF_NAME(UnwindInt)(pHdr, pStack, uPC, uFramePtr, TS);
     373    KU64 *pCurOverheadTicks = KPRF_NAME(UnwindInt)(pHdr, pStack, uPC, uFramePtr, TS);
    374374
    375375    pThread->enmState = enmThreadState;
     
    407407    {
    408408        KPRF_TYPE(P,STACK) pStack = KPRF_OFF2PTR(P,STACK, pHdr->offStacks, pHdr);
    409         uint32_t            cLeft = pHdr->cMaxStacks;
     409        KU32               cLeft = pHdr->cMaxStacks;
    410410        do
    411411        {
     
    467467 * @param   TS          The timestamp to use when terminating the thread.
    468468 */
    469 KPRF_DECL_FUNC(void, TerminateThread)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,THREAD) pThread, uint64_t TS)
     469KPRF_DECL_FUNC(void, TerminateThread)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(P,THREAD) pThread, KU64 TS)
    470470{
    471471    if (pThread->enmState == KPRF_TYPE(,THREADSTATE_TERMINATED))
     
    479479    {
    480480        KPRF_TYPE(P,STACK) pStack = KPRF_OFF2PTR(P,STACK, pThread->offStack, pHdr);
    481         for (uint32_t cFrames = pStack->cFrames; cFrames > 0; cFrames--)
     481        for (KU32 cFrames = pStack->cFrames; cFrames > 0; cFrames--)
    482482            KPRF_NAME(UnwindOne)(pHdr, pStack, 0, TS);
    483483
     
    499499KPRF_DECL_FUNC(void, DeregisterThread)(void)
    500500{
    501     uint64_t TS = KPRF_NOW();
     501    KU64 TS = KPRF_NOW();
    502502
    503503    /*
     
    524524KPRF_DECL_FUNC(void, ResumeThread)(int fReset)
    525525{
    526     uint64_t TS = KPRF_NOW();
     526    KU64 TS = KPRF_NOW();
    527527
    528528    /*
     
    546546    if (fReset)
    547547    {
    548         uint32_t cFrames = pStack->cFrames;
     548        KU32 cFrames = pStack->cFrames;
    549549        while (cFrames-- > 0)
    550550            KPRF_NAME(UnwindOne)(pHdr, pStack, 0, TS);
     
    579579KPRF_DECL_FUNC(void, SuspendThread)(int fUnwind)
    580580{
    581     uint64_t TS = KPRF_NOW();
     581    KU64 TS = KPRF_NOW();
    582582
    583583    /*
     
    605605    if (fUnwind)
    606606    {
    607         uint32_t cFrames = pStack->cFrames;
     607        KU32 cFrames = pStack->cFrames;
    608608        while (cFrames-- > 0)
    609609            KPRF_NAME(UnwindOne)(pHdr, pStack, 0, TS);
  • trunk/kStuff/kProfile/prfcore.h.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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 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,
     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,
    1717 * 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
     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
    2424 *
    2525 */
     
    6161 */
    6262#if KPRF_BITS == 16
    63 typedef uint16_t KPRF_TYPE(,UPTR);
    64 typedef int16_t  KPRF_TYPE(,IPTR);
     63typedef KU16    KPRF_TYPE(,UPTR);
     64typedef KI16    KPRF_TYPE(,IPTR);
    6565#elif KPRF_BITS == 32
    66 typedef uint32_t KPRF_TYPE(,UPTR);
    67 typedef int32_t  KPRF_TYPE(,IPTR);
     66typedef KU32    KPRF_TYPE(,UPTR);
     67typedef KI32    KPRF_TYPE(,IPTR);
    6868#elif KPRF_BITS == 64
    69 typedef uint64_t KPRF_TYPE(,UPTR);
    70 typedef int64_t  KPRF_TYPE(,IPTR);
     69typedef KU64    KPRF_TYPE(,UPTR);
     70typedef KI64    KPRF_TYPE(,IPTR);
    7171#else
    7272# error "KPRF_BITS has an invalid value. Supported values are 16, 32 and 64."
     
    9494{
    9595    /** [0] The magic number for file data. (KPRF_TYPE(,HDR_MAGIC)) */
    96     uint32_t                u32Magic;
     96    KU32                    u32Magic;
    9797    /** [4] KPRF_BITS. */
    98     uint32_t                cFormatBits;
     98    KU32                    cFormatBits;
    9999    /** [8] The base address which all pointers should be relative to. */
    100100    KPRF_TYPE(,UPTR)        uBasePtr;
    101101#if KPRF_BITS <= 16
    102102    /** [a] Reserved. */
    103     uint16_t                u16Reserved;
     103    KU16                    u16Reserved;
    104104#endif
    105105#if KPRF_BITS <= 32
    106106    /** [c] Reserved. */
    107     uint32_t                u32Reserved;
     107    KU32                    u32Reserved;
    108108#endif
    109109    /** [10] The size of this data set. */
    110     uint32_t                cb;
     110    KU32                    cb;
    111111    /** [10] The allocated data set size. */
    112     uint32_t                cbAllocated;
     112    KU32                    cbAllocated;
    113113
    114114    /** [18] The max number of functions the function table can hold. */
    115     uint32_t                cMaxFunctions;
     115    KU32                    cMaxFunctions;
    116116    /** [1c] The current number of functions in the function table. */
    117     uint32_t                cFunctions;
     117    KU32                    cFunctions;
    118118    /** [20] The offset of the function table (relative to this header). */
    119     uint32_t                offFunctions;
     119    KU32                    offFunctions;
    120120    /** [24] The size of a function entry. */
    121     uint32_t                cbFunction;
     121    KU32                    cbFunction;
    122122
    123123    /** [28] The max number of bytes the module segments can occupy. */
    124     uint32_t                cbMaxModSegs;
     124    KU32                    cbMaxModSegs;
    125125    /** [2c] The current size of the module segment records. */
    126     uint32_t                cbModSegs;
     126    KU32                    cbModSegs;
    127127    /** [30] The offset of the module segment records (relative to this header). */
    128     uint32_t                offModSegs;
     128    KU32                    offModSegs;
    129129
    130130    /** [34] The max number of threads the thread table can contain. */
    131     uint32_t                cMaxThreads;
     131    KU32                    cMaxThreads;
    132132    /** [38] The current number of threads in the thread table. */
    133     uint32_t                cThreads;
     133    KU32                    cThreads;
    134134    /** [3c] The offset of the thread table (relative to this header). */
    135     uint32_t                offThreads;
     135    KU32                    offThreads;
    136136    /** [40] The size of a thread entry. */
    137     uint32_t                cbThread;
     137    KU32                    cbThread;
    138138
    139139    /** [44] The max number of stacks the stack table can contain. */
    140     uint32_t                cMaxStacks;
     140    KU32                    cMaxStacks;
    141141    /** [48] The max number of stacks.
    142142     * Unlike the other members, the stacks can be reused. It follows that
    143143     * this count doesn't specify the number of used slots from the start. */
    144     uint32_t                cStacks;
     144    KU32                    cStacks;
    145145    /** [4c] The offset of the thread table (relative to this header).
    146146     * This is usually 0 in a stored data set. */
    147     uint32_t                offStacks;
     147    KU32                    offStacks;
    148148    /** [50] The size of a stack. */
    149     uint32_t                cbStack;
     149    KU32                    cbStack;
    150150    /** [54] The maxium stack depth. */
    151     uint32_t                cMaxStackFrames;
     151    KU32                    cMaxStackFrames;
    152152
    153153    /** [58] The process commandline.
     
    155155     * where the stacks used to be.
    156156     */
    157     uint32_t                offCommandLine;
     157    KU32                    offCommandLine;
    158158    /** [5c] The length of the command line. (excludes the terminator). */
    159     uint32_t                cchCommandLine;
     159    KU32                    cchCommandLine;
    160160
    161161    /** [60]  The function lookup table (it contains indexes).
    162162     * This is sorted by address so that a binary search can be performed.
    163163     * Access to this table is managed externally, but generally a read/write lock is employed. */
    164     uint32_t                aiFunctions[1];
     164    KU32                    aiFunctions[1];
    165165} KPRF_TYPE(,HDR);
    166166/** Pointer to a profiler data header. */
     
    176176{
    177177    /** The minimum period */
    178     uint64_t volatile       MinTicks;
     178    KU64 volatile           MinTicks;
    179179    /** The maximum period */
    180     uint64_t volatile       MaxTicks;
     180    KU64 volatile           MaxTicks;
    181181    /** The sum of all periods. */
    182     uint64_t volatile       SumTicks;
     182    KU64 volatile           SumTicks;
    183183} KPRF_TYPE(,TIMESTAT);
    184184/** Pointer to time statistics. */
     
    198198    KPRF_TYPE(,UPTR)        cbSegmentMinusOne;
    199199    /** The segment number. (0 based) */
    200     uint32_t                iSegment;
     200    KU32                    iSegment;
    201201    /** Flag indicating whether this segment is loaded or not.
    202202     * (A 16-bit value was choosen out of convenience, all that's stored is 0 or 1 anyway.) */
    203     uint16_t                fLoaded;
     203    KU16                    fLoaded;
    204204    /** The length of the path.
    205205     * This is used to calculate the length of the record: offsetof(MODSEG, szPath) + cchPath + 1 */
    206     uint16_t                cchPath;
     206    KU16                    cchPath;
    207207    /** The module name. */
    208208    char                    szPath[1];
     
    223223    KPRF_TYPE(,UPTR)        uEntryPtr;
    224224    /** Offset (relative to the profiler header) of the module segment to which this function belongs. */
    225     uint32_t                offModSeg;
     225    KU32                    offModSeg;
    226226
    227227    /** The number times on the stack. */
    228     uint64_t volatile       cOnStack;
     228    KU64 volatile           cOnStack;
    229229    /** The number of calls made from this function. */
    230     uint64_t volatile       cCalls;
     230    KU64 volatile           cCalls;
    231231
    232232    /** Time on stack. */
     
    251251    /** The accumulated overhead.
    252252     * Over head is accumulated by the parent frame when a child is poped off the stack. */
    253     uint64_t                OverheadTicks;
     253    KU64                    OverheadTicks;
    254254    /** The current (top of stack) overhead. */
    255     uint64_t                CurOverheadTicks;
     255    KU64                    CurOverheadTicks;
    256256    /** The accumulated sleep ticks.
    257257     * It's possible to notify the profiler that the thread is being put into a wait/sleep/yield
    258258     * state. The time spent sleeping is transfered to the parent frame when poping of a child one. */
    259     uint64_t                SleepTicks;
     259    KU64                    SleepTicks;
    260260    /** The start of the on-stack period. */
    261     uint64_t                OnStackStart;
     261    KU64                    OnStackStart;
    262262    /** The accumulated time on top (excludes overhead (sleep doesn't apply here obviously)). */
    263     uint64_t                OnTopOfStackTicks;
     263    KU64                    OnTopOfStackTicks;
    264264    /** The start of the current on-top-of-stack period.
    265265     * This is also to mark the start of a sleeping period, the ResumeThread function will always
    266266     * treat it as the start of the suspend period. */
    267     uint64_t                OnTopOfStackStart;
     267    KU64                    OnTopOfStackStart;
    268268    /** The number of calls made from this stack frame. */
    269     uint64_t                cCalls;
     269    KU64                    cCalls;
    270270    /** Stack address of this frame.
    271271     * This is used to detect throw and longjmp, and is also used to deal with overflow. (relative address) */
     
    273273    /** Offset (relative to the profiler header) to the function record.
    274274     * This is 0 if we're out of function space. */
    275     uint32_t                offFunction;
     275    KU32                    offFunction;
    276276} KPRF_TYPE(,FRAME);
    277277/** Pointer to a stack frame. */
     
    288288    /** The offset (relative to the profiler header) of the thread owning the stack.
    289289     * This is zero if not in use, and non-zero if in use. */
    290     uint32_t                    offThread;
     290    KU32                        offThread;
    291291    /** The number of active stack frames. */
    292     uint32_t                    cFrames;
     292    KU32                        cFrames;
    293293    /** The stack frames.
    294294     * The actual size of this array is specified in the header. */
     
    338338{
    339339    /** The native thread id. */
    340     uint64_t                    ThreadId;
     340    KU64                        ThreadId;
    341341    /** The thread name. (optional) */
    342342    char                        szName[32];
     
    350350    KPRF_TYPE(,UPTR)            cbMaxStack;
    351351    /** The number of calls done by this thread. */
    352     uint64_t                    cCalls;
     352    KU64                        cCalls;
    353353    /** The number of times the stack overflowed. */
    354     uint64_t                    cOverflows;
     354    KU64                        cOverflows;
    355355    /** The number of times stack entries has been rejected because of a stack switch. */
    356     uint64_t                    cStackSwitchRejects;
     356    KU64                        cStackSwitchRejects;
    357357    /** The number of times the stack has been unwinded more than one frame. */
    358     uint64_t                    cUnwinds;
     358    KU64                        cUnwinds;
    359359
    360360    /** The profiled ticks. (This does not include sleep or overhead ticks.)
    361361     * This is the accumulated on-stack values for the final stack frames. */
    362     uint64_t                    ProfiledTicks;
     362    KU64                        ProfiledTicks;
    363363    /** The accumulated overhead of this thread. */
    364     uint64_t                    OverheadTicks;
     364    KU64                        OverheadTicks;
    365365    /** The accumulated sleep ticks for this thread.
    366366     * See KPRF_TYPE(,FRAME)::SleepTicks for details. */
    367     uint64_t                    SleepTicks;
     367    KU64                        SleepTicks;
    368368
    369369    /** The offset of the stack. */
    370     uint32_t                    offStack;
     370    KU32                        offStack;
    371371} KPRF_TYPE(,THREAD);
    372372/** Pointer to a thread. */
  • trunk/kStuff/kProfile/prfcorefunction.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler - Core New Function Code (template).
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
     
    4040
    4141    KPRF_TYPE(P,FUNC) paFunctions = KPRF_OFF2PTR(P,FUNC, pHdr->offFunctions, pHdr);
    42     int32_t iStart = 0;
    43     int32_t iLast  = pHdr->cFunctions - 1;
    44     int32_t i      = iLast / 2;
     42    KI32 iStart = 0;
     43    KI32 iLast  = pHdr->cFunctions - 1;
     44    KI32 i      = iLast / 2;
    4545    for (;;)
    4646    {
    47         uint32_t iFunction = pHdr->aiFunctions[i];
     47        KU32 iFunction = pHdr->aiFunctions[i];
    4848        KPRF_TYPE(,IPTR) iDiff = uPC - paFunctions[iFunction].uEntryPtr;
    4949        if (!iDiff)
     
    6767     * (I've too much of a headache to figure out if the above loop leaves us where we should be.)
    6868     */
    69     const int32_t iNew = pHdr->cFunctions;
     69    const KI32 iNew = pHdr->cFunctions;
    7070    if (paFunctions[pHdr->aiFunctions[i]].uEntryPtr > uPC)
    7171    {
     
    8484     * Ensure that there still is space for the function.
    8585     */
    86     if (iNew >= (int32_t)pHdr->cMaxFunctions)
     86    if (iNew >= (KI32)pHdr->cMaxFunctions)
    8787    {
    8888        KPRF_FUNCS_WRITE_UNLOCK();
     
    9797    pNew->cOnStack   = 0;
    9898    pNew->cCalls     = 0;
    99     pNew->OnStack.MinTicks      = ~(uint64_t)0;
     99    pNew->OnStack.MinTicks      = ~(KU64)0;
    100100    pNew->OnStack.MaxTicks      = 0;
    101101    pNew->OnStack.SumTicks      = 0;
    102     pNew->OnTopOfStack.MinTicks = ~(uint64_t)0;
     102    pNew->OnTopOfStack.MinTicks = ~(KU64)0;
    103103    pNew->OnTopOfStack.MaxTicks = 0;
    104104    pNew->OnTopOfStack.SumTicks = 0;
    105105
    106106    /* shift the function index array and insert the new one. */
    107     int32_t j = iNew;
     107    KI32 j = iNew;
    108108    while (j > i)
    109109    {
  • trunk/kStuff/kProfile/prfcoreinit.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler - Core Initialization Code (template).
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
     
    4040 *          responsible for the input to make some sense.
    4141 */
    42 KPRF_DECL_FUNC(uint32_t, CalcSize)(uint32_t cMaxFunctions, uint32_t cbMaxModSegs, uint32_t cMaxThreads, uint32_t cMaxStacks, uint32_t cMaxStackFrames)
     42KPRF_DECL_FUNC(KU32, CalcSize)(KU32 cMaxFunctions, KU32 cbMaxModSegs, KU32 cMaxThreads, KU32 cMaxStacks, KU32 cMaxStackFrames)
    4343{
    4444    /*
     
    5555     * We do not take overflows into account, stupid user means stupid result.
    5656     */
    57     uint32_t cb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]);
    58     uint32_t cbTotal = KPRF_ALIGN(cb, 32);
     57    KU32 cb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]);
     58    KU32 cbTotal = KPRF_ALIGN(cb, 32);
    5959
    6060    cb = cMaxFunctions * KPRF_SIZEOF(FUNC);
     
    9191 *
    9292 */
    93 KPRF_DECL_FUNC(KPRF_TYPE(P,HDR), Init)(void *pvData, uint32_t cbData, uint32_t cMaxFunctions, uint32_t cbMaxModSegs,
    94                                        uint32_t cMaxThreads, uint32_t cMaxStacks, uint32_t cMaxStackFrames)
     93KPRF_DECL_FUNC(KPRF_TYPE(P,HDR), Init)(void *pvData, KU32 cbData, KU32 cMaxFunctions, KU32 cbMaxModSegs,
     94                                       KU32 cMaxThreads, KU32 cMaxStacks, KU32 cMaxStackFrames)
    9595{
    9696    /*
     
    108108     * The header.
    109109     */
    110     uint32_t off = 0;
    111     uint32_t cb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]);
     110    KU32 off = 0;
     111    KU32 cb = KPRF_OFFSETOF(HDR, aiFunctions[cMaxFunctions]);
    112112    cb = KPRF_ALIGN(cb, 32);
    113113    if (cbData < off + cb || off > off + cb)
  • trunk/kStuff/kProfile/prfcoremodseg.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler - Core Module Segment Code (template header).
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
     
    3737 *                      (This is relative to the first moddule segment record (at pHdr->offModSegs).)
    3838 */
    39 static uint32_t KPRF_NAME(InsertModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(PC,MODSEG) pModSeg, uint32_t off)
     39static KU32 KPRF_NAME(InsertModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(PC,MODSEG) pModSeg, KU32 off)
    4040{
    4141    /*
     
    6060            if (off >= pHdr->cbModSegs)
    6161            {
    62                 uint32_t cbModSeg = KPRF_OFFSETOF(MODSEG, szPath[pModSeg->cchPath + 1]);
     62                KU32 cbModSeg = KPRF_OFFSETOF(MODSEG, szPath[pModSeg->cchPath + 1]);
    6363                cbModSeg = KPRF_ALIGN(cbModSeg, KPRF_SIZEOF(UPTR));
    6464                if (off + cbModSeg <= pHdr->cbMaxModSegs)
     
    7171                    pNew->cchPath           = pModSeg->cchPath;
    7272
    73                     int32_t iPath = pModSeg->cchPath;
     73                    KI32 iPath = pModSeg->cchPath;
    7474                    do  pNew->szPath[iPath] = pModSeg->szPath[iPath];
    7575                    while (--iPath >= 0);
     
    9999           )
    100100        {
    101             int32_t iPath = pModSeg->cchPath;
    102 
     101            KI32 iPath = pModSeg->cchPath;
    103102            for (;;)
    104103            {
     
    110109            /* didn't match, continue searching */
    111110        }
    112         uint32_t cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
     111        KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
    113112        off += KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR));
    114113    }
     
    128127 *                      (This is relative to the first moddule segment record (at pHdr->offModSegs).)
    129128 */
    130 static uint32_t KPRF_NAME(NewModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC, uint32_t off)
     129static KU32 KPRF_NAME(NewModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC, KU32 off)
    131130{
    132131    /*
     
    165164 * @param   uPC         Address within the module.
    166165 */
    167 static uint32_t KPRF_NAME(RecordModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC)
     166static KU32 KPRF_NAME(RecordModSeg)(KPRF_TYPE(P,HDR) pHdr, KPRF_TYPE(,UPTR) uPC)
    168167{
    169168    /*
    170169     * Lookup the module segment, inserting it if not found (and there is room).
    171170     */
    172     uint32_t off = 0;
     171    KU32 off = 0;
    173172    KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(P,MODSEG, pHdr->offModSegs, pHdr);
    174     const uint32_t cbModSegs = pHdr->cbModSegs;
     173    const KU32 cbModSegs = pHdr->cbModSegs;
    175174    for (;;)
    176175    {
     
    186185            return off + pHdr->offModSegs;
    187186
    188         uint32_t cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
     187        KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
    189188        cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR));
    190189        off += cbCur;
    191         pCur = (KPRF_TYPE(PC,MODSEG))((uint8_t *)pCur + cbCur);
     190        pCur = (KPRF_TYPE(PC,MODSEG))((KU8 *)pCur + cbCur);
    192191    }
    193192}
  • trunk/kStuff/kProfile/prfcorepost.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler Core Post Code Header (template).
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
  • trunk/kStuff/kProfile/prfcorepre.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler - Core Pre Code (template).
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
     
    5555            (n) = (min); \
    5656        else { \
    57             const uint32_t u32 = ((n) + ( (align) - 1)) & ~((align) - 1); \
     57            const KU32 u32 = ((n) + ( (align) - 1)) & ~((align) - 1); \
    5858            if (u32 >= (n)) \
    5959                (n) = u32; \
     
    6262
    6363/** @def KPRF_OFFSETOF
    64  * My usual extended OFFSETOF macro, except this returns uint32_t and mangles the type name.
     64 * My usual extended OFFSETOF macro, except this returns KU32 and mangles the type name.
    6565 * @internal
    6666 */
    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 )
    6868
    6969/** @def PRF_SIZEOF
  • trunk/kStuff/kProfile/prfcorereloc.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler - core Relocation Code (template).
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
  • trunk/kStuff/kProfile/prfcoreterm.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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>
    38 *
    4  * kProfiler - Core Termination Code (template).
     9 * This file is part of kProfiler.
    510 *
    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.
    715 *
     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.
    820 *
    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
    2424 *
    2525 */
     
    3232 * @param   pHdr        The profiler data set header.
    3333 */
    34 KPRF_DECL_FUNC(uint32_t, TerminateAll)(KPRF_TYPE(P,HDR) pHdr)
     34KPRF_DECL_FUNC(KU32, TerminateAll)(KPRF_TYPE(P,HDR) pHdr)
    3535{
    36     uint64_t TS = KPRF_NOW();
     36    KU64 TS = KPRF_NOW();
    3737    if (!pHdr)
    3838        return 0;
     
    4242     */
    4343    KPRF_TYPE(P,THREAD) paThread = KPRF_OFF2PTR(P,THREAD, pHdr->offThreads, pHdr);
    44     for (uint32_t i = 0; i < pHdr->cThreads; i++)
     44    for (KU32 i = 0; i < pHdr->cThreads; i++)
    4545    {
    4646        KPRF_TYPE(P,THREAD) pCur = &paThread[i];
     
    6969    {
    7070        /* only if the stack is at the end of the data set. */
    71         const uint32_t cbStacks = KPRF_ALIGN(pHdr->cMaxStacks * pHdr->cbStack, 32);
     71        const KU32 cbStacks = KPRF_ALIGN(pHdr->cMaxStacks * pHdr->cbStack, 32);
    7272        if (pHdr->offStacks + cbStacks == pHdr->cb)
    7373            pHdr->cb -= cbStacks;
     
    9090 * @param   papszArgs   Pointer to an array of arguments.
    9191 */
    92 KPRF_DECL_FUNC(uint32_t, SetCommandLine)(KPRF_TYPE(P,HDR) pHdr, unsigned cArgs, const char * const *papszArgs)
     92KPRF_DECL_FUNC(KU32, SetCommandLine)(KPRF_TYPE(P,HDR) pHdr, unsigned cArgs, const char * const *papszArgs)
    9393{
    9494    if (!pHdr)
  • trunk/kStuff/kProfile/prfreader.cpp.h

    r3537 r3565  
    11/* $Id: $ */
    22/** @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 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,
     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,
    1717 * 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
     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
    2424 *
    2525 */
     
    3636 * @param   pOut        Where to write error messages.
    3737 */
    38 static bool KPRF_NAME(IsValid)(KPRF_TYPE(PC,HDR) pHdr, uint32_t cb, FILE *pOut)
     38static bool KPRF_NAME(IsValid)(KPRF_TYPE(PC,HDR) pHdr, KU32 cb, FILE *pOut)
    3939{
    4040    KPRF_TYPE(,UPTR) uMaxPtr = ~(KPRF_TYPE(,UPTR))0 - pHdr->uBasePtr;
     
    4343     * Iterate the module segments.
    4444     */
    45     uint32_t off = pHdr->offModSegs;
     45    KU32 off = pHdr->offModSegs;
    4646    while (off < pHdr->offModSegs + pHdr->cbModSegs)
    4747    {
    4848        KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(PC,MODSEG, off, pHdr);
    49         uint32_t cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
     49        KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
    5050        cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR));
    5151        if (cbCur + off > pHdr->offModSegs + pHdr->cbModSegs)
     
    7373     */
    7474    KPRF_TYPE(PC,FUNC) paFuncs = KPRF_OFF2PTR(PC,FUNC, pHdr->offFunctions, pHdr);
    75     for (uint32_t i = 0; i < pHdr->cFunctions; i++)
     75    for (KU32 i = 0; i < pHdr->cFunctions; i++)
    7676    {
    7777        KPRF_TYPE(PC,FUNC) pCur = &paFuncs[i];
     
    9797     */
    9898    KPRF_TYPE(PC,THREAD) paThreads = KPRF_OFF2PTR(PC,THREAD, pHdr->offThreads, pHdr);
    99     for (uint32_t i = 0; i < pHdr->cThreads; i++)
     99    for (KU32 i = 0; i < pHdr->cThreads; i++)
    100100    {
    101101        KPRF_TYPE(PC,THREAD) pCur = &paThreads[i];
     
    148148            "----------------\n",
    149149            pHdr->offModSegs, pHdr->cbModSegs, pHdr->cbMaxModSegs);
    150     uint32_t off = pHdr->offModSegs;
     150    KU32 off = pHdr->offModSegs;
    151151    while (off < pHdr->offModSegs + pHdr->cbModSegs)
    152152    {
    153153        KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(PC,MODSEG, off, pHdr);
    154         uint32_t cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
     154        KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
    155155        cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR));
    156156
     
    172172            pHdr->offFunctions, pHdr->cFunctions, pHdr->cMaxFunctions);
    173173    KPRF_TYPE(PC,FUNC) paFuncs = KPRF_OFF2PTR(PC,FUNC, pHdr->offFunctions, pHdr);
    174     for (uint32_t i = 0; i < pHdr->cFunctions; i++)
     174    for (KU32 i = 0; i < pHdr->cFunctions; i++)
    175175    {
    176176        KPRF_TYPE(PC,FUNC) pCur = &paFuncs[i];
     
    188188
    189189#if 1
    190             PRTDBGMOD 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)
    193193            {
    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)
    197197                {
    198198                    fprintf(pOut, "  %s\n", Sym.szName);
    199199                }
    200                 RTDbgModuleClose(pMod);
     200                kDbgModuleClose(pMod);
    201201            }
    202202#endif
     
    214214            pHdr->offThreads, pHdr->cThreads, pHdr->cMaxThreads, pHdr->cStacks, pHdr->cMaxStacks, pHdr->cMaxStackFrames);
    215215    KPRF_TYPE(PC,THREAD) paThreads = KPRF_OFF2PTR(PC,THREAD, pHdr->offThreads, pHdr);
    216     for (uint32_t i = 0; i < pHdr->cThreads; i++)
     216    for (KU32 i = 0; i < pHdr->cThreads; i++)
    217217    {
    218218        KPRF_TYPE(PC,THREAD) pCur = &paThreads[i];
     
    248248{
    249249    /** 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. */
    251253    /** Pointer to the next segment for the module. */
    252254    KPRF_TYPE(P,REPORTMODSEG)   pNext;
     
    256258    KPRF_TYPE(P,REPORTMOD)      pMod;
    257259    /** The time this segment has spent on the stack.. */
    258     uint64_t                    OnStackTicks;
     260    KU64                        OnStackTicks;
    259261    /** The time this segment has spent on the top of the stack.. */
    260     uint64_t                    OnTopOfStackTicks;
     262    KU64                        OnTopOfStackTicks;
    261263    /** The number of profiled functions from this segment. */
    262     uint32_t                    cFunctions;
     264    KU32                        cFunctions;
     265    KU8                         mHeight;        /**< AVL Subtree height. */
    263266} KPRF_TYPE(,REPORTMODSEG), *KPRF_TYPE(P,REPORTMODSEG);
    264267
     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
    265284
    266285/**
     
    272291{
    273292    /** The module number. */
    274     uint32_t                    iMod;
     293    KU32                        iMod;
    275294    /** Pointer to the next module in the list. */
    276295    KPRF_TYPE(P,REPORTMOD)      pNext;
     
    278297    KPRF_TYPE(P,REPORTMODSEG)   pFirstSeg;
    279298    /** The debug module handle. */
    280     PRTDBGMOD                   pDbgMod;
     299    PKDBGMOD                    pDbgMod;
    281300    /** The time this segment has spent on the stack.. */
    282     uint64_t                    OnStackTicks;
     301    KU64                        OnStackTicks;
    283302    /** The time this segment has spent on the top of the stack.. */
    284     uint64_t                    OnTopOfStackTicks;
     303    KU64                        OnTopOfStackTicks;
    285304    /** The number of profiled functions from this segment. */
    286     uint32_t                    cFunctions;
     305    KU32                        cFunctions;
    287306} KPRF_TYPE(,REPORTMOD), *KPRF_TYPE(P,REPORTMOD);
    288307
     
    300319    KPRF_TYPE(P,REPORTMODSEG)   pModSeg;
    301320    /** Pointer to the function symbol. */
    302     PRTDBGSYMBOL                pSym;
     321    PKDBGSYMBOL                 pSym;
    303322    /** Pointer to the function line number. */
    304     PKDBGLINE                  pLine;
     323    PKDBGLINE                   pLine;
    305324} KPRF_TYPE(,REPORTFUNC), *KPRF_TYPE(P,REPORTFUNC);
    306325
     
    499518{
    500519    /** Pointer to the data set. */
    501     KPRF_TYPE(PC,HDR)   pHdr;
     520    KPRF_TYPE(PC,HDR)           pHdr;
    502521
    503522    /** @name Data-set item wrappers.
     
    510529    KPRF_TYPE(P,REPORTMOD)      pFirstMod;
    511530    /** The number of modules in the list. */
    512     uint32_t                    cMods;
     531    KU32                        cMods;
    513532    /** The module segment tree. */
    514     PAVLU32NODECORE             pModSegTree;
     533    KPRF_TYPE(P,REPORTMODSEG)   pModSegTree;
    515534    /** The number of module segments in the tree. */
    516     uint32_t                    cModSegs;
     535    KU32                        cModSegs;
    517536    /** @} */
    518537
     
    528547     * @{ */
    529548    /** Sum of the profiled ticks. */
    530     uint64_t                    ProfiledTicks;
     549    KU64                        ProfiledTicks;
    531550    /** Sum of the overhead ticks. */
    532     uint64_t                    OverheadTicks;
     551    KU64                        OverheadTicks;
    533552    /** Sum of the sleep ticks. */
    534     uint64_t                    SleepTicks;
     553    KU64                        SleepTicks;
    535554    /** Sum of calls performed. */
    536     uint64_t                    cCalls;
     555    KU64                        cCalls;
    537556    /** @} */
    538557
     
    552571     * Everything but the mods and modsegs is allocated in the same block as the report.
    553572     */
    554     size_t cb = KPRF_ALIGN(KPRF_SIZEOF(REPORT), 32);
    555     uintptr_t offThreads = cb;
     573    KSIZE cb = KPRF_ALIGN(KPRF_SIZEOF(REPORT), 32);
     574    KUPTR offThreads = cb;
    556575    cb += KPRF_ALIGN(KPRF_SIZEOF(REPORTTHREAD) * pHdr->cThreads, 32);
    557     uintptr_t offFunctions = cb;
     576    KUPTR offFunctions = cb;
    558577    cb += KPRF_ALIGN(KPRF_SIZEOF(REPORTFUNC) * pHdr->cFunctions, 32);
    559     uintptr_t offSortedThreads = cb;
     578    KUPTR offSortedThreads = cb;
    560579    cb += KPRF_ALIGN(sizeof(KPRF_TYPE(P,REPORTTHREAD)) * pHdr->cThreads, 32);
    561     uintptr_t offSortedFunctions = cb;
     580    KUPTR offSortedFunctions = cb;
    562581    cb += KPRF_ALIGN(sizeof(KPRF_TYPE(P,REPORTFUNC)) * pHdr->cFunctions, 32);
    563582    KPRF_TYPE(P,REPORT) pReport = (KPRF_TYPE(P,REPORT))malloc(cb);
     
    569588     */
    570589    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);
    573592    pReport->pFirstMod = NULL;
    574593    pReport->cMods = 0;
    575594    pReport->pModSegTree = NULL;
    576595    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);
    579598    pReport->ProfiledTicks = 0;
    580599    pReport->OverheadTicks = 0;
     
    593612 * @param   pvParam     User parameter, ignored.
    594613 */
    595 static DECLCALLBACK(int) KPRF_NAME(DeleteModSeg)(PAVLU32NODECORE pCore, void *pvParam)
     614static int KPRF_NAME(DeleteModSeg)(KPRF_TYPE(P,REPORTMODSEG) pCore, void *pvParam)
    596615{
    597616    free(pCore);
     
    614633        KPRF_TYPE(P,REPORTMOD) pFree = pReport->pFirstMod;
    615634        pReport->pFirstMod = pFree->pNext;
    616         RTDbgModuleClose(pFree->pDbgMod);
     635        kDbgModuleClose(pFree->pDbgMod);
    617636        free(pFree);
    618637    }
    619638
    620     RTAvlU32Destroy(&pReport->pModSegTree, KPRF_NAME(DeleteModSeg), NULL);
     639    KPRF_NAME(ReportTreeDestroy)(&pReport->pModSegTree, KPRF_NAME(DeleteModSeg), NULL);
    621640
    622641    /*
    623642     * The function debug info.
    624643     */
    625     uint32_t i = pReport->pHdr->cFunctions;
     644    KU32 i = pReport->pHdr->cFunctions;
    626645    while (i-- > 0)
    627646    {
    628         RTDbgSymbolFree(pReport->paFunctions[i].pSym);
    629         RTDbgLineFree(pReport->paFunctions[i].pLine);
     647        kDbgSymbolFree(pReport->paFunctions[i].pSym);
     648        kDbgLineFree(pReport->paFunctions[i].pLine);
    630649    }
    631650
     
    645664 * @param   pReport     The report to work on.
    646665 */
    647 static int KPRF_NAME(AnalyseModSegs)(KPRF_TYPE(P,REPORT) pReport)
    648 {
    649     const uint32_t offEnd = pReport->pHdr->offModSegs + pReport->pHdr->cbModSegs;
    650     uint32_t off = pReport->pHdr->offModSegs;
     666static 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;
    651670    while (off < offEnd)
    652671    {
    653672        KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(PC,MODSEG, off, pReport->pHdr);
    654         uint32_t cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
     673        KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
    655674        cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR));
    656675
     
    662681            return -1;
    663682
    664         pSeg->Core.Key = off;
     683        pSeg->offSegment = off;
    665684        pSeg->pModSeg = pCur;
    666685        pSeg->pMod = NULL; /* below */
     
    669688        pSeg->cFunctions = 0;
    670689
    671         if (!RTAvlU32Insert(&pReport->pModSegTree, &pSeg->Core))
     690        if (!KPRF_NAME(ReportTreeInsert)(&pReport->pModSegTree, pSeg))
    672691        {
    673692            free(pSeg);
     
    707726            pMod->cFunctions = 0;
    708727
    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)
    711730                pMod->pDbgMod = NULL;
    712731        }
     
    729748static int KPRF_NAME(AnalyseFunctions)(KPRF_TYPE(P,REPORT) pReport)
    730749{
    731     uint32_t iFunc = pReport->pHdr->cFunctions;
     750    KU32 iFunc = pReport->pHdr->cFunctions;
    732751    KPRF_TYPE(PC,FUNC) pFunc = KPRF_OFF2PTR(PC,FUNC, pReport->pHdr->offFunctions + iFunc * sizeof(*pFunc), pReport->pHdr);
    733752    KPRF_TYPE(P,REPORTFUNC) pReportFunc = &pReport->paFunctions[iFunc];
     
    739758        pReport->papSortedFunctions[iFunc] = pReportFunc;
    740759        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);
    742761        pReportFunc->pSym = NULL;
    743762        pReportFunc->pLine = NULL;
     
    756775
    757776            /* 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);
    760779            /** @todo check displacement! */
    761             if (RT_FAILURE(rc))
     780            if (rc)
    762781                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)
    765784                pReportFunc->pLine = NULL;
    766785        }
     
    779798static int KPRF_NAME(AnalyseThreads)(KPRF_TYPE(P,REPORT) pReport)
    780799{
    781     uint32_t iThread = pReport->pHdr->cThreads;
     800    KU32 iThread = pReport->pHdr->cThreads;
    782801    KPRF_TYPE(PC,THREAD) pThread = KPRF_OFF2PTR(PC,THREAD, pReport->pHdr->offThreads + iThread * sizeof(*pThread), pReport->pHdr);
    783802    KPRF_TYPE(P,REPORTTHREAD) pReportThread = &pReport->paThreads[iThread];
     
    820839
    821840    /* read module segments */
    822     int rc = KPRF_NAME(AnalyseModSegs)(pReport);
     841    int rc = KPRF_NAME(AnalyzeModSegs)(pReport);
    823842    if (!rc)
    824843    {
     
    846865 * @internal
    847866 */
    848 static void KPRF_NAME(HtmlWriteRowU32X32)(FILE *pOut, const char *pszName, uint32_t u32, const char *pszUnit)
     867static void KPRF_NAME(HtmlWriteRowU32X32)(FILE *pOut, const char *pszName, KU32 u32, const char *pszUnit)
    849868{
    850869    fprintf(pOut,
     
    862881 * @internal
    863882 */
    864 static void KPRF_NAME(HtmlWriteRowU32)(FILE *pOut, const char *pszName, uint32_t u32, const char *pszUnit)
     883static void KPRF_NAME(HtmlWriteRowU32)(FILE *pOut, const char *pszName, KU32 u32, const char *pszUnit)
    865884{
    866885    fprintf(pOut,
     
    878897 * @internal
    879898 */
    880 static void KPRF_NAME(HtmlWriteRowU64)(FILE *pOut, const char *pszName, uint64_t u64, const char *pszUnit)
     899static void KPRF_NAME(HtmlWriteRowU64)(FILE *pOut, const char *pszName, KU64 u64, const char *pszUnit)
    881900{
    882901    fprintf(pOut,
     
    894913 * @internal
    895914 */
    896 static void KPRF_NAME(HtmlWriteRowX64)(FILE *pOut, const char *pszName, uint64_t u64, const char *pszUnit)
     915static void KPRF_NAME(HtmlWriteRowX64)(FILE *pOut, const char *pszName, KU64 u64, const char *pszUnit)
    897916{
    898917    fprintf(pOut,
     
    909928 * Writes a ticks.
    910929 */
    911 static void KPRF_NAME(HtmlWriteParts)(FILE *pOut, uint64_t cTicks, uint64_t cTotalTicks)
     930static void KPRF_NAME(HtmlWriteParts)(FILE *pOut, KU64 cTicks, KU64 cTotalTicks)
    912931{
    913932    /** U+2030 PER MILLE SIGN */
    914     static const uint8_t s_szPerMilleSignUtf8[4] = { 0xe2, 0x80, 0xb0, 0};
     933    static const KU8 s_szPerMilleSignUtf8[4] = { 0xe2, 0x80, 0xb0, 0};
    915934
    916935    if (cTicks * 100 / cTotalTicks)
    917936    {
    918         uint32_t u = (uint32_t)((cTicks * 1000) / cTotalTicks);
     937        KU32 u = (KU32)((cTicks * 1000) / cTotalTicks);
    919938        fprintf(pOut, "%u.%01u%%", u / 10, u %10);
    920939    }
    921940    else //if (cTicks * 100000 / cTotalTicks)
    922941    {
    923         uint32_t u = (uint32_t)((cTicks * 100000) / cTotalTicks);
     942        KU32 u = (KU32)((cTicks * 100000) / cTotalTicks);
    924943        fprintf(pOut, "%u.%02u%s", u / 100, u % 100, s_szPerMilleSignUtf8);
    925944    }
     
    936955 * Writes a ticks.
    937956 */
    938 static void KPRF_NAME(HtmlWriteTicks)(FILE *pOut, uint64_t cTicks, uint64_t cTotalTicks)
     957static void KPRF_NAME(HtmlWriteTicks)(FILE *pOut, KU64 cTicks, KU64 cTotalTicks)
    939958{
    940959    fprintf(pOut, "%" KPRF_FMT_U64 "", cTicks);
     
    956975 * @internal
    957976 */
    958 static void KPRF_NAME(HtmlWriteRowTicks)(FILE *pOut, const char *pszName, uint64_t cTicks, uint64_t cTotalTicks)
     977static void KPRF_NAME(HtmlWriteRowTicks)(FILE *pOut, const char *pszName, KU64 cTicks, KU64 cTotalTicks)
    959978{
    960979    fprintf(pOut,
     
    980999 * @internal
    9811000 */
    982 static void KPRF_NAME(HtmlWriteRowTimeStat)(FILE *pOut, const char *pszName, KPRF_TYPE(PC,TIMESTAT) pTimeStat, uint64_t cTotalTicks)
     1001static void KPRF_NAME(HtmlWriteRowTimeStat)(FILE *pOut, const char *pszName, KPRF_TYPE(PC,TIMESTAT) pTimeStat, KU64 cTotalTicks)
    9831002{
    9841003    fprintf(pOut,
     
    10081027 * @internal
    10091028 */
    1010 static void KPRF_NAME(HtmlWriteRowCalls)(FILE *pOut, const char *pszName, uint64_t cCalls, uint64_t cTotalCalls)
     1029static void KPRF_NAME(HtmlWriteRowCalls)(FILE *pOut, const char *pszName, KU64 cCalls, KU64 cTotalCalls)
    10111030{
    10121031    fprintf(pOut,
     
    11231142            "  </tr>\n");
    11241143
    1125     for (uint32_t iFunc = 0; iFunc < pReport->pHdr->cFunctions; iFunc++)
     1144    for (KU32 iFunc = 0; iFunc < pReport->pHdr->cFunctions; iFunc++)
    11261145    {
    11271146        KPRF_TYPE(P,REPORTFUNC) pReportFunc = pReport->papSortedFunctions[iFunc];
     
    12431262            "<head>\n"
    12441263            "  <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"
    12461265            "</head>\n"
    12471266            "<style>\n"
     
    13961415    KPRF_NAME(HtmlWriteRowCalls)(pOut, "Recorded Calls", pReport->cCalls, pReport->cCalls);
    13971416    fprintf(pOut, "<tr><td class=\"BlankRow\" colspan=7>&nbsp;</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__);
    14001419    fprintf(pOut,
    14011420            "</table>\n"
     
    14401459            "<p>\n"
    14411460            "<table class=\"Functions\">\n");
    1442     for (uint32_t iFunc = 0; iFunc < pHdr->cFunctions; iFunc++)
     1461    for (KU32 iFunc = 0; iFunc < pHdr->cFunctions; iFunc++)
    14431462    {
    14441463        KPRF_TYPE(P,REPORTFUNC) pReportFunc = &pReport->paFunctions[iFunc];
     
    14861505            "<table class=\"Threads\">\n");
    14871506
    1488     for (uint32_t iThread = 0; iThread < pHdr->cThreads; iThread++)
     1507    for (KU32 iThread = 0; iThread < pHdr->cThreads; iThread++)
    14891508    {
    14901509        KPRF_TYPE(PC,THREAD) pThread = pReport->paThreads[iThread].pThread;
     
    15271546
    15281547    KPRF_TYPE(P,REPORTMOD) pMod = pReport->pFirstMod;
    1529     uint32_t iMod = 0;
     1548    KU32 iMod = 0;
    15301549    while (pMod)
    15311550    {
  • trunk/kStuff/kProfile/prfx86msc.asm

    r3537 r3565  
    11; $Id: $
    22;; @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,
    1817; but WITHOUT ANY WARRANTY; without even the implied warranty of
    19 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20 ; GNU General Public License for more details.
    21 ;
    22 ; You should have received a copy of the GNU General Public License
    23 ; along with kLIBC; if not, write to the Free Software
    24 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    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
    2726
    2827[section .data]
Note: See TracChangeset for help on using the changeset viewer.