Ignore:
Timestamp:
Aug 26, 2007, 3:13:35 AM (18 years ago)
Author:
bird
Message:

made kDbg compile again (not linking yet though).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kStuff/include/k/kDbg.h

    r3541 r3550  
    2323 */
    2424
    25 #ifndef ___kDbg_h___
    26 #define ___kDbg_h___
    27 
    28 #include "kDbgBase.h"
     25#ifndef ___k_kDbg_h___
     26#define ___k_kDbg_h___
     27
     28#include <k/kDefs.h>
     29#include <k/kTypes.h>
     30#include <k/kRdr.h>
    2931
    3032#ifdef __cplusplus
     
    3638 */
    3739
    38 /** The max filename path length used by the debug reader. */
    39 #define KDBG_PATH_MAX       260
    40 
    41 /** The max symbol name length used by the debug reader. */
    42 #define KDBG_SYMBOL_MAX     384
     40/** @def KDBG_DECL
     41 * Declares a kDbg function according to build context.
     42 * @param type          The return type.
     43 */
     44#if defined(KDBG_BUILDING_DYNAMIC)
     45# define KDBG_DECL(type)        K_DECL_EXPORT(type)
     46#elif defined(KDBG_BUILT_DYNAMIC)
     47# define KDBG_DECL(type)        K_DECL_IMPORT(type)
     48#else
     49# define KDBG_DECL(type)        type
     50#endif
     51
     52
     53/** The kDbg address type. */
     54typedef KU64                    KDBGADDR;
     55/** Pointer to a kDbg address. */
     56typedef KDBGADDR               *PKDBGADDR;
     57/** Pointer to a const kDbg address. */
     58typedef const KDBGADDR         *PCKDBGADDR;
     59/** @def KDBGADDR_PRI
     60 * printf format type. */
     61#define KDBGADDR_PRI            KX64_PRI
     62/** @def KDBGADDR_MAX
     63 * Max kDbg address value. */
     64#define KDBGADDR_MAX            KU64_C(0xfffffffffffffffe)
     65/** @def KDBGADDR_C
     66 * kDbg address constant.
     67 * @param c         The constant value. */
     68#define KDBGADDR_C(c)           KU64_C(c)
     69/** NIL address. */
     70#define NIL_KDBGADDR            KU64_MAX
     71
    4372
    4473/** @name   Special Segments
     
    4776 * The specified offset is relative to the image base. The image base is the lowest memory
    4877 * address used by the image when loaded with the address assignments indicated in the image. */
    49 #define KDBGSEG_RVA (-1)
     78#define KDBGSEG_RVA             (-1)
    5079/** Absolute segment. The offset isn't relative to anything. */
    51 #define KDBGSEG_ABS (-2)
     80#define KDBGSEG_ABS             (-2)
    5281/** @} */
    5382
     83
     84/** The max filename path length used by the debug reader. */
     85#define KDBG_PATH_MAX           260
    5486
    5587/**
     
    6395    KDBGADDR    offSegment;
    6496    /** The segment number. */
    65     int32_t     iSegment;
     97    KI32        iSegment;
    6698    /** The Line number. */
    67     uint32_t    iLine;
     99    KU32        iLine;
     100    /** The actual size of this structure. */
     101    KU16        cbSelf;
    68102    /** The length of the filename. */
    69     uint16_t    cchFile;
     103    KU16        cchFile;
    70104    /** The name of the file this line number relates to. */
    71105    char        szFile[KDBG_PATH_MAX];
     
    105139 * @{ */
    106140/** The symbol is weak. */
    107 #define KDBGSYM_FLAGS_WEAK      UINT32_C(0x00000000)
     141#define KDBGSYM_FLAGS_WEAK      KU32_C(0x00000000)
    108142/** The symbol is absolute.
    109143 * (This also indicated by the segment number.) */
    110 #define KDBGSYM_FLAGS_ABS       UINT32_C(0x00000001)
     144#define KDBGSYM_FLAGS_ABS       KU32_C(0x00000001)
    111145/** The symbol is exported. */
    112 #define KDBGSYM_FLAGS_EXPORTED  UINT32_C(0x00000002)
     146#define KDBGSYM_FLAGS_EXPORTED  KU32_C(0x00000002)
    113147/** The symbol is a function/method/procedure/whatever-executable-code. */
    114 #define KDBGSYM_FLAGS_CODE      UINT32_C(0x00000004)
     148#define KDBGSYM_FLAGS_CODE      KU32_C(0x00000004)
    115149/** The symbol is some kind of data. */
    116 #define KDBGSYM_FLAGS_DATA      UINT32_C(0x00000008)
     150#define KDBGSYM_FLAGS_DATA      KU32_C(0x00000008)
    117151/** @} */
     152
     153/** The max symbol name length used by the debug reader. */
     154#define KDBG_SYMBOL_MAX         384
    118155
    119156/**
     
    130167    KDBGADDR    offSegment;
    131168    /** The segment number. */
    132     int32_t     iSegment;
     169    KI32        iSegment;
    133170    /** The symbol flags. */
    134     uint32_t    fFlags;
     171    KU32        fFlags;
    135172/** @todo type info? */
     173    /** The actual size of this structure. */
     174    KU16        cbSelf;
    136175    /** The length of the symbol name. */
    137     uint16_t    cchName;
     176    KU16        cchName;
    138177    /** The symbol name. */
    139178    char        szName[KDBG_SYMBOL_MAX];
     
    170209
    171210
    172 /** Pointer to a kDbgHlp file structure (abstract). */
    173 typedef struct KDBGHLPFILE *PKDBGHLPFILE;
    174 
    175 /** A debug module handle. */
     211/** Pointer to a debug module. */
    176212typedef struct KDBGMOD *PKDBGMOD;
    177 
    178 /**
    179  * The debug module method table.
    180  */
    181 typedef struct KDBGMODOPS
    182 {
    183     /** The name of the reader. */
    184     const char *pszName;
    185 
    186     /** Pointer to the next debug module readers.
    187      * This is only used for dynamically registered readers. */
    188     struct KDBGMODOPS  *pNext;
    189 
    190     /**
    191      * Tries to open the module.
    192      *
    193      * @returns 0 on success, KDBG_ERR on failure.
    194      * @param   pFile           The file
    195      * @param   ppMod           Where to store the module that's been opened.
    196      * @param   off             The file offset of the debug info. This is 0 if there isn't
    197      *                          any specfic debug info section and the reader should start
    198      *                          looking for debug info at the start of the file.
    199      * @param   cb              The size of the debug info in the file. INT64_MAX if we don't
    200      *                          know or there isn't any particular debug info section in the file.
    201      * @param   pLdrMod         The associated loader module. This can be NULL.
    202      *
    203      * @remark  This is NULL for the builtin readers.
    204      */
    205     int (*pfnOpen)(PKDBGMOD *ppMod, PKDBGHLPFILE pFile, KFOFF off, KFOFF cb, struct KLDRMOD *pLdrMod);
    206 
    207     /**
    208      * Closes the module.
    209      *
    210      * This should free all resources associated with the module
    211      * except the pMod which is freed by the caller.
    212      *
    213      * @returns IPRT status code.
    214      * @param   pMod        The module.
    215      */
    216     int (*pfnClose)(PKDBGMOD pMod);
    217 
    218     /**
    219      * Gets a symbol by segment:offset.
    220      * This will be approximated to the nearest symbol if there is no exact match.
    221      *
    222      * @returns 0 on success. KLDR_ERR_* on failure.
    223      * @param   pMod        The module.
    224      * @param   iSegment    The segment this offset is relative to.
    225      *                      The -1 segment is special, it means that the addres is relative to
    226      *                      the image base. The image base is where the first bit of the image
    227      *                      is mapped during load.
    228      * @param   off         The offset into the segment.
    229      * @param   pSym        Where to store the symbol details.
    230      */
    231     int (*pfnQuerySymbol)(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGSYMBOL pSym);
    232 
    233     /**
    234      * Gets a line number entry by segment:offset.
    235      * This will be approximated to the nearest line number there is no exact match.
    236      *
    237      * @returns 0 on success. KLDR_ERR_* on failure.
    238      * @param   pMod        The module.
    239      * @param   iSegment    The segment this offset is relative to.
    240      *                      The -1 segment is special, it means that the addres is relative to
    241      *                      the image base. The image base is where the first bit of the image
    242      *                      is mapped during load.
    243      * @param   off         The offset into the segment.
    244      * @param   pLine       Where to store the line number details.
    245      */
    246     int (*pfnQueryLine)(PKDBGMOD pMod, KI32 iSegment, KDBGADDR uOffset, PKDBGLINE pLine);
    247 
    248     /** This is just to make sure you've initialized all the fields.
    249      * Must be identical to pszName. */
    250     const char *pszName2;
    251 } KDBGMODOPS;
    252 /** Pointer to a module method table. */
    253 typedef KDBGMODOPS *PKDBGMODOPS;
    254 /** Pointer to a const module method table. */
    255 typedef const KDBGMODOPS *PCKDBGMODOPS;
    256 
    257 /**
    258  * Register a debug module reader with the kDbgModule component.
    259  *
    260  * Dynamically registered readers are kept in FIFO order, and external
    261  * readers will be tried after the builtin ones.
    262  *
    263  * @returns 0 on success.
    264  * @returns KERR_INVALID_POINTER if pOps is missing bits.
    265  * @returns KERR_INVALID_PARAMETER if pOps is already in the list.
    266  * @param   pOps        The reader method table, kDbg takes owner ship of
    267  *                      this. This must be writeable as the pNext pointer
    268  *                      will be update. It must also stick around for as
    269  *                      long as kDbg is in use.
    270  */
    271 KDBG_DECL(int) kDbgModuleRegisterReader(PKDBGMODOPS pOps)
    272 ;
    273 
    274 
    275 
    276 /**
    277  * Internal representation of a debug module.
    278  */
    279 typedef struct KDBGMOD
    280 {
    281     /** Magic value (KDBGMOD_MAGIC). */
    282     KI32            u32Magic;
    283     /** The handle to the module. (If closed, this is NIL_RTFILE.) */
    284     PKDBGHLPFILE    pFile;
    285     /** Pointer to the method table. */
    286     PCKDBGMODOPS    pOps;
    287 } KDBGMOD;
    288 
    289 
    290 /** The magic value for the debug module structure. (Some dead english writer) */
    291 #define KDBGMOD_MAGIC      0x19200501
    292 /** The magic value of a dead module structure. */
    293 #define KDBGMOD_MAGIC_DEAD 0x19991231
    294 
    295 
    296 /**
    297  * Opens the debug info for a specified executable module.
    298  *
    299  * @returns IPRT status code.
    300  * @param   pszModulePath       The path to the executable module.
    301  * @param   ppDbgMod            Where to store the debug module handle.
    302  */
    303 KDBG_DECL(int) kDbgModuleOpen(const char *pszModulePath, PKDBGMOD *ppDbgMod);
    304 
    305 /**
    306  * Closes the module.
    307  *
    308  * @returns IPRT status code.
    309  * @param   pMod        The module handle.
    310  */
     213/** Pointer to a debug module pointer. */
     214typedef PKDBGMOD *PPKDBGMOD;
     215
     216
     217KDBG_DECL(int) kDbgModuleOpen(PPKDBGMOD ppDbgMod, const char *pszFilename, struct KLDRMOD *pLdrMod);
     218KDBG_DECL(int) kDbgModuleOpenFile(PPKDBGMOD ppDbgMod, PKRDR pRdr, struct KLDRMOD *pLdrMod);
     219KDBG_DECL(int) kDbgModuleOpenFilePart(PPKDBGMOD ppDbgMod, PKRDR pRdr, KFOFF off, KFOFF cb, struct KLDRMOD *pLdrMod);
    311220KDBG_DECL(int) kDbgModuleClose(PKDBGMOD pMod);
    312 
    313 /**
    314  * Gets a symbol by segment:offset.
    315  * This will be approximated to the nearest symbol if there is no exact match.
    316  *
    317  * @returns IPRT status code.
    318  * @param   pMod        The module.
    319  * @param   iSegment    The segment this offset is relative to.
    320  *                      The -1 segment is special, it means that the addres is relative to
    321  *                      the image base. The image base is where the first bit of the image
    322  *                      is mapped during load.
    323  * @param   off         The offset into the segment.
    324  * @param   pSym        Where to store the symbol details.
    325  */
    326221KDBG_DECL(int) kDbgModuleQuerySymbol(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGSYMBOL pSym);
    327 
    328 /**
    329  * Gets & allocates a symbol by segment:offset.
    330  * This will be approximated to the nearest symbol if there is no exact match.
    331  *
    332  * @returns IPRT status code.
    333  * @param   pMod        The module.
    334  * @param   iSegment    The segment this offset is relative to.
    335  *                      The -1 segment is special, it means that the addres is relative to
    336  *                      the image base. The image base is where the first bit of the image
    337  *                      is mapped during load.
    338  * @param   off         The offset into the segment.
    339  * @param   ppSym       Where to store the pointer to the symbol info.
    340  *                      Free the returned symbol using kDbgSymbolFree().
    341  */
    342222KDBG_DECL(int) kDbgModuleQuerySymbolA(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PPKDBGSYMBOL ppSym);
    343 
    344 /**
    345  * Gets a line number entry by segment:offset.
    346  * This will be approximated to the nearest line number there is no exact match.
    347  *
    348  * @returns IPRT status code.
    349  * @param   pMod        The module.
    350  * @param   iSegment    The segment this offset is relative to.
    351  *                      The -1 segment is special, it means that the addres is relative to
    352  *                      the image base. The image base is where the first bit of the image
    353  *                      is mapped during load.
    354  * @param   off         The offset into the segment.
    355  * @param   pLine       Where to store the line number details.
    356  */
    357223KDBG_DECL(int) kDbgModuleQueryLine(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGLINE pLine);
    358 
    359 /**
    360  * Gets & allocates a line number entry by segment:offset.
    361  * This will be approximated to the nearest line number there is no exact match.
    362  *
    363  * @returns IPRT status code.
    364  * @param   pMod        The module.
    365  * @param   iSegment    The segment this offset is relative to.
    366  *                      The -1 segment is special, it means that the addres is relative to
    367  *                      the image base. The image base is where the first bit of the image
    368  *                      is mapped during load.
    369  * @param   off         The offset into the segment.
    370  * @param   ppLine      Where to store the pointer to the line number info.
    371  *                      Free the returned line number using kDbgLineFree().
    372  */
    373224KDBG_DECL(int) kDbgModuleQueryLineA(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PPKDBGLINE ppLine);
    374225
Note: See TracChangeset for help on using the changeset viewer.