[3528] | 1 | /* $Id: kDbgInternal.h 3534 2007-08-23 00:28:15Z 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 |
|
---|
[3534] | 45 | /** Pointer to the next debug module readers.
|
---|
| 46 | * This is only used for dynamically registered readers. */
|
---|
| 47 | struct KDBGMODOPS *pNext;
|
---|
| 48 |
|
---|
[3528] | 49 | /**
|
---|
[3534] | 50 | * Tries to open the module.
|
---|
| 51 | *
|
---|
| 52 | * @returns 0 on success, KDBG_ERR on failure.
|
---|
| 53 | * @param pFile The file
|
---|
| 54 | * @param off The file offset of the debug info. This is 0 if there isn't
|
---|
| 55 | * any specfic debug info section and the reader should start
|
---|
| 56 | * looking for debug info at the start of the file.
|
---|
| 57 | * @param cb The size of the debug info in the file. INT64_MAX if we don't
|
---|
| 58 | * know or there isn't any particular debug info section in the file.
|
---|
| 59 | * @param pLdrMod The associated loader module. This can be NULL.
|
---|
| 60 | * @param ppMod Where to store the module that's been opened.
|
---|
| 61 | *
|
---|
| 62 | * @remark This is NULL for the builtin readers.
|
---|
| 63 | */
|
---|
| 64 | int (*pfnOpen)(PKDBGHLPFILE pFile, int64_t off, int64_t cb, PKLDRMOD pLdrMod, PKDBGMOD pMod);
|
---|
| 65 |
|
---|
| 66 | /**
|
---|
[3528] | 67 | * Closes the module.
|
---|
| 68 | *
|
---|
| 69 | * This should free all resources associated with the module
|
---|
| 70 | * except the pMod which is freed by the caller.
|
---|
| 71 | *
|
---|
| 72 | * @returns IPRT status code.
|
---|
| 73 | * @param pMod The module.
|
---|
| 74 | */
|
---|
| 75 | int (*pfnClose)(PKDBGMOD pMod);
|
---|
| 76 |
|
---|
| 77 | /**
|
---|
| 78 | * Gets a symbol by segment:offset.
|
---|
| 79 | * This will be approximated to the nearest symbol if there is no exact match.
|
---|
| 80 | *
|
---|
[3534] | 81 | * @returns 0 on success. KLDR_ERR_* on failure.
|
---|
[3528] | 82 | * @param pMod The module.
|
---|
| 83 | * @param iSegment The segment this offset is relative to.
|
---|
| 84 | * The -1 segment is special, it means that the addres is relative to
|
---|
| 85 | * the image base. The image base is where the first bit of the image
|
---|
| 86 | * is mapped during load.
|
---|
| 87 | * @param off The offset into the segment.
|
---|
| 88 | * @param pSym Where to store the symbol details.
|
---|
| 89 | */
|
---|
| 90 | int (*pfnQuerySymbol)(PKDBGMOD pMod, int32_t iSegment, KDBGADDR off, PKDBGSYMBOL pSym);
|
---|
| 91 |
|
---|
| 92 | /**
|
---|
| 93 | * Gets a line number entry by segment:offset.
|
---|
| 94 | * This will be approximated to the nearest line number there is no exact match.
|
---|
| 95 | *
|
---|
[3534] | 96 | * @returns 0 on success. KLDR_ERR_* on failure.
|
---|
[3528] | 97 | * @param pMod The module.
|
---|
| 98 | * @param iSegment The segment this offset is relative to.
|
---|
| 99 | * The -1 segment is special, it means that the addres is relative to
|
---|
| 100 | * the image base. The image base is where the first bit of the image
|
---|
| 101 | * is mapped during load.
|
---|
| 102 | * @param off The offset into the segment.
|
---|
| 103 | * @param pLine Where to store the line number details.
|
---|
| 104 | */
|
---|
| 105 | int (*pfnQueryLine)(PKDBGMOD pMod, int32_t iSegment, KDBGADDR uOffset, PKDBGLINE pLine);
|
---|
| 106 |
|
---|
| 107 | } KDBGMODOPS;
|
---|
| 108 | /** Pointer to a module method table. */
|
---|
| 109 | typedef KDBGMODOPS *PKDBGMODOPS;
|
---|
| 110 | /** Pointer to a const module method table. */
|
---|
| 111 | typedef const KDBGMODOPS *PCKDBGMODOPS;
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | /**
|
---|
| 115 | * Internal representation of a debug module.
|
---|
| 116 | */
|
---|
| 117 | typedef struct KDBGMOD
|
---|
| 118 | {
|
---|
| 119 | /** Magic value (KDBGMOD_MAGIC). */
|
---|
| 120 | uint32_t u32Magic;
|
---|
| 121 | /** The handle to the module. (If closed, this is NIL_RTFILE.) */
|
---|
| 122 | PKDBGHLPFILE pFile;
|
---|
| 123 | /** Pointer to the method table. */
|
---|
| 124 | PCKDBGMODOPS pOps;
|
---|
| 125 | } KDBGMOD;
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | /** The magic value for the debug module structure. (Some dead english writer) */
|
---|
| 129 | #define KDBGMOD_MAGIC 0x00000000
|
---|
| 130 | /** The magic value of a dead module structure. */
|
---|
| 131 | #define KDBGMOD_MAGIC_DEAD 0x00000001
|
---|
| 132 |
|
---|
| 133 |
|
---|
| 134 | int kdbgModPEOpen(PKDBGHLPFILE pFile, KDBGADDR offHdr, const char *pszModulePath, PKDBGMOD *ppDbgMod);
|
---|
[3534] | 135 | int kdbgModWinDbgHelpOpen(PKDBGHLPFILE pFile, const char *pszModulePath, PKDBGMOD *ppDbgMod);
|
---|
[3528] | 136 |
|
---|
| 137 | #ifdef __cplusplus
|
---|
| 138 | }
|
---|
| 139 | #endif
|
---|
| 140 |
|
---|
| 141 | #endif
|
---|
| 142 |
|
---|