| 1 | /* $Id: kDbgInternal.h 3530 2007-08-20 03:42:03Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * kDbg - The Debug Info Reader, Internal Header.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
|---|
| 8 | *
|
|---|
| 9 | * This program is free software; you can redistribute it and/or modify
|
|---|
| 10 | * it under the terms of the GNU General Public License as published by
|
|---|
| 11 | * the Free Software Foundation; either version 2 of the License, or
|
|---|
| 12 | * (at your option) any later version.
|
|---|
| 13 | *
|
|---|
| 14 | * This program is distributed in the hope that it will be useful,
|
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | * GNU General Public License for more details.
|
|---|
| 18 | *
|
|---|
| 19 | * You should have received a copy of the GNU General Public License
|
|---|
| 20 | * along with This program; if not, write to the Free Software
|
|---|
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 22 | *
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | #ifndef ___kDbgInternal_h___
|
|---|
| 26 | #define ___kDbgInternal_h___
|
|---|
| 27 |
|
|---|
| 28 | #include "kDbgBase.h"
|
|---|
| 29 | #include "kDbgHlp.h"
|
|---|
| 30 | #include "kDbg.h"
|
|---|
| 31 |
|
|---|
| 32 | #ifdef __cplusplus
|
|---|
| 33 | extern "C" {
|
|---|
| 34 | #endif
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | /**
|
|---|
| 38 | * The debug module method table.
|
|---|
| 39 | */
|
|---|
| 40 | typedef struct KDBGMODOPS
|
|---|
| 41 | {
|
|---|
| 42 | /** The name of the reader. */
|
|---|
| 43 | const char *pszName;
|
|---|
| 44 |
|
|---|
| 45 | /**
|
|---|
| 46 | * Closes the module.
|
|---|
| 47 | *
|
|---|
| 48 | * This should free all resources associated with the module
|
|---|
| 49 | * except the pMod which is freed by the caller.
|
|---|
| 50 | *
|
|---|
| 51 | * @returns IPRT status code.
|
|---|
| 52 | * @param pMod The module.
|
|---|
| 53 | */
|
|---|
| 54 | int (*pfnClose)(PKDBGMOD pMod);
|
|---|
| 55 |
|
|---|
| 56 | /**
|
|---|
| 57 | * Gets a symbol by segment:offset.
|
|---|
| 58 | * This will be approximated to the nearest symbol if there is no exact match.
|
|---|
| 59 | *
|
|---|
| 60 | * @returns IPRT status code.
|
|---|
| 61 | * @param pMod The module.
|
|---|
| 62 | * @param iSegment The segment this offset is relative to.
|
|---|
| 63 | * The -1 segment is special, it means that the addres is relative to
|
|---|
| 64 | * the image base. The image base is where the first bit of the image
|
|---|
| 65 | * is mapped during load.
|
|---|
| 66 | * @param off The offset into the segment.
|
|---|
| 67 | * @param pSym Where to store the symbol details.
|
|---|
| 68 | */
|
|---|
| 69 | int (*pfnQuerySymbol)(PKDBGMOD pMod, int32_t iSegment, KDBGADDR off, PKDBGSYMBOL pSym);
|
|---|
| 70 |
|
|---|
| 71 | /**
|
|---|
| 72 | * Gets a line number entry by segment:offset.
|
|---|
| 73 | * This will be approximated to the nearest line number there is no exact match.
|
|---|
| 74 | *
|
|---|
| 75 | * @returns IPRT status code.
|
|---|
| 76 | * @param pMod The module.
|
|---|
| 77 | * @param iSegment The segment this offset is relative to.
|
|---|
| 78 | * The -1 segment is special, it means that the addres is relative to
|
|---|
| 79 | * the image base. The image base is where the first bit of the image
|
|---|
| 80 | * is mapped during load.
|
|---|
| 81 | * @param off The offset into the segment.
|
|---|
| 82 | * @param pLine Where to store the line number details.
|
|---|
| 83 | */
|
|---|
| 84 | int (*pfnQueryLine)(PKDBGMOD pMod, int32_t iSegment, KDBGADDR uOffset, PKDBGLINE pLine);
|
|---|
| 85 |
|
|---|
| 86 | } KDBGMODOPS;
|
|---|
| 87 | /** Pointer to a module method table. */
|
|---|
| 88 | typedef KDBGMODOPS *PKDBGMODOPS;
|
|---|
| 89 | /** Pointer to a const module method table. */
|
|---|
| 90 | typedef const KDBGMODOPS *PCKDBGMODOPS;
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | /**
|
|---|
| 94 | * Internal representation of a debug module.
|
|---|
| 95 | */
|
|---|
| 96 | typedef struct KDBGMOD
|
|---|
| 97 | {
|
|---|
| 98 | /** Magic value (KDBGMOD_MAGIC). */
|
|---|
| 99 | uint32_t u32Magic;
|
|---|
| 100 | /** The handle to the module. (If closed, this is NIL_RTFILE.) */
|
|---|
| 101 | PKDBGHLPFILE pFile;
|
|---|
| 102 | /** Pointer to the method table. */
|
|---|
| 103 | PCKDBGMODOPS pOps;
|
|---|
| 104 | } KDBGMOD;
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 | /** The magic value for the debug module structure. (Some dead english writer) */
|
|---|
| 108 | #define KDBGMOD_MAGIC 0x00000000
|
|---|
| 109 | /** The magic value of a dead module structure. */
|
|---|
| 110 | #define KDBGMOD_MAGIC_DEAD 0x00000001
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | int kdbgModPEOpen(PKDBGHLPFILE pFile, KDBGADDR offHdr, const char *pszModulePath, PKDBGMOD *ppDbgMod);
|
|---|
| 114 | int kdbgModWinDbgHelpOpen(PKDBGHLPFILE pFile, KDBGADDR offHdr, const char *pszModulePath, PKDBGMOD *ppDbgMod);
|
|---|
| 115 |
|
|---|
| 116 | #ifdef __cplusplus
|
|---|
| 117 | }
|
|---|
| 118 | #endif
|
|---|
| 119 |
|
|---|
| 120 | #endif
|
|---|
| 121 |
|
|---|