[2] | 1 | /* $Id: kDbgAll.h 29 2009-07-01 20:30:29Z bird $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * kDbg - The Debug Info Read, All Details and Dependencies Included.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[29] | 7 | * Copyright (c) 2006-2007 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
|
---|
[2] | 8 | *
|
---|
[29] | 9 | * Permission is hereby granted, free of charge, to any person
|
---|
| 10 | * obtaining a copy of this software and associated documentation
|
---|
| 11 | * files (the "Software"), to deal in the Software without
|
---|
| 12 | * restriction, including without limitation the rights to use,
|
---|
| 13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
| 14 | * copies of the Software, and to permit persons to whom the
|
---|
| 15 | * Software is furnished to do so, subject to the following
|
---|
| 16 | * conditions:
|
---|
[2] | 17 | *
|
---|
[29] | 18 | * The above copyright notice and this permission notice shall be
|
---|
| 19 | * included in all copies or substantial portions of the Software.
|
---|
[2] | 20 | *
|
---|
[29] | 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
| 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
| 23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
| 24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
| 25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
| 26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
| 27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
| 28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
[2] | 29 | */
|
---|
| 30 |
|
---|
| 31 | #ifndef ___k_kDbgAll_h___
|
---|
| 32 | #define ___k_kDbgAll_h___
|
---|
| 33 |
|
---|
| 34 | #include <k/kDefs.h>
|
---|
| 35 | #include <k/kTypes.h>
|
---|
| 36 | #include <k/kRdr.h>
|
---|
| 37 | #include <k/kLdr.h>
|
---|
| 38 | #include <k/kDbg.h>
|
---|
| 39 |
|
---|
| 40 | #ifdef __cplusplus
|
---|
| 41 | extern "C" {
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
| 44 | /** @defgroup grp_kDbgAll All
|
---|
| 45 | * @addtogroup grp_kDbg
|
---|
| 46 | * @{
|
---|
| 47 | */
|
---|
| 48 |
|
---|
| 49 | /**
|
---|
| 50 | * The debug module method table.
|
---|
| 51 | */
|
---|
| 52 | typedef struct KDBGMODOPS
|
---|
| 53 | {
|
---|
| 54 | /** The name of the reader. */
|
---|
| 55 | const char *pszName;
|
---|
| 56 |
|
---|
| 57 | /** Pointer to the next debug module readers.
|
---|
| 58 | * This is only used for dynamically registered readers. */
|
---|
| 59 | struct KDBGMODOPS *pNext;
|
---|
| 60 |
|
---|
| 61 | /**
|
---|
| 62 | * Tries to open the module.
|
---|
| 63 | *
|
---|
| 64 | * @returns 0 on success, KDBG_ERR on failure.
|
---|
| 65 | * @param ppMod Where to store the module that's been opened.
|
---|
| 66 | * @param pRdr The file provider.
|
---|
| 67 | * @param fCloseRdrs Whether the reader should be closed or not when the module is destroyed.
|
---|
| 68 | * @param off The file offset of the debug info. This is 0 if there isn't
|
---|
| 69 | * any specfic debug info section and the reader should start
|
---|
| 70 | * looking for debug info at the start of the file.
|
---|
| 71 | * @param cb The size of the debug info in the file. INT64_MAX if we don't
|
---|
| 72 | * know or there isn't any particular debug info section in the file.
|
---|
| 73 | * @param pLdrMod The associated loader module. This can be NULL.
|
---|
| 74 | */
|
---|
| 75 | int (*pfnOpen)(PKDBGMOD *ppMod, PKRDR pRdr, KBOOL fCloseRdr, KFOFF off, KFOFF cb, struct KLDRMOD *pLdrMod);
|
---|
| 76 |
|
---|
| 77 | /**
|
---|
| 78 | * Closes the module.
|
---|
| 79 | *
|
---|
| 80 | * This should free all resources associated with the module
|
---|
| 81 | * except the pMod which is freed by the caller.
|
---|
| 82 | *
|
---|
| 83 | * @returns IPRT status code.
|
---|
| 84 | * @param pMod The module.
|
---|
| 85 | */
|
---|
| 86 | int (*pfnClose)(PKDBGMOD pMod);
|
---|
| 87 |
|
---|
| 88 | /**
|
---|
| 89 | * Gets a symbol by segment:offset.
|
---|
| 90 | * This will be approximated to the nearest symbol if there is no exact match.
|
---|
| 91 | *
|
---|
| 92 | * @returns 0 on success. KLDR_ERR_* on failure.
|
---|
| 93 | * @param pMod The module.
|
---|
| 94 | * @param iSegment The segment this offset is relative to.
|
---|
| 95 | * The -1 segment is special, it means that the addres is relative to
|
---|
| 96 | * the image base. The image base is where the first bit of the image
|
---|
| 97 | * is mapped during load.
|
---|
| 98 | * @param off The offset into the segment.
|
---|
| 99 | * @param pSym Where to store the symbol details.
|
---|
| 100 | */
|
---|
| 101 | int (*pfnQuerySymbol)(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGSYMBOL pSym);
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
| 104 | * Gets a line number entry by segment:offset.
|
---|
| 105 | * This will be approximated to the nearest line number there is no exact match.
|
---|
| 106 | *
|
---|
| 107 | * @returns 0 on success. KLDR_ERR_* on failure.
|
---|
| 108 | * @param pMod The module.
|
---|
| 109 | * @param iSegment The segment this offset is relative to.
|
---|
| 110 | * The -1 segment is special, it means that the addres is relative to
|
---|
| 111 | * the image base. The image base is where the first bit of the image
|
---|
| 112 | * is mapped during load.
|
---|
| 113 | * @param off The offset into the segment.
|
---|
| 114 | * @param pLine Where to store the line number details.
|
---|
| 115 | */
|
---|
| 116 | int (*pfnQueryLine)(PKDBGMOD pMod, KI32 iSegment, KDBGADDR uOffset, PKDBGLINE pLine);
|
---|
| 117 |
|
---|
| 118 | /** This is just to make sure you've initialized all the fields.
|
---|
| 119 | * Must be identical to pszName. */
|
---|
| 120 | const char *pszName2;
|
---|
| 121 | } KDBGMODOPS;
|
---|
| 122 | /** Pointer to a module method table. */
|
---|
| 123 | typedef KDBGMODOPS *PKDBGMODOPS;
|
---|
| 124 | /** Pointer to a const module method table. */
|
---|
| 125 | typedef const KDBGMODOPS *PCKDBGMODOPS;
|
---|
| 126 |
|
---|
| 127 | /**
|
---|
| 128 | * Register a debug module reader with the kDbgModule component.
|
---|
| 129 | *
|
---|
| 130 | * Dynamically registered readers are kept in FIFO order, and external
|
---|
| 131 | * readers will be tried after the builtin ones.
|
---|
| 132 | *
|
---|
| 133 | * @returns 0 on success.
|
---|
| 134 | * @returns KERR_INVALID_POINTER if pOps is missing bits.
|
---|
| 135 | * @returns KERR_INVALID_PARAMETER if pOps is already in the list.
|
---|
| 136 | * @param pOps The reader method table, kDbg takes owner ship of
|
---|
| 137 | * this. This must be writeable as the pNext pointer
|
---|
| 138 | * will be update. It must also stick around for as
|
---|
| 139 | * long as kDbg is in use.
|
---|
| 140 | */
|
---|
| 141 | KDBG_DECL(int) kDbgModuleRegisterReader(PKDBGMODOPS pOps);
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 |
|
---|
| 145 | /**
|
---|
| 146 | * Internal representation of a debug module.
|
---|
| 147 | */
|
---|
| 148 | typedef struct KDBGMOD
|
---|
| 149 | {
|
---|
| 150 | /** Magic value (KDBGMOD_MAGIC). */
|
---|
| 151 | KI32 u32Magic;
|
---|
| 152 | /** Pointer to the method table. */
|
---|
| 153 | PCKDBGMODOPS pOps;
|
---|
| 154 | /** The file provider for the file containing the debug info. */
|
---|
| 155 | PKRDR pRdr;
|
---|
| 156 | /** Whether or not to close pRdr. */
|
---|
| 157 | KBOOL fCloseRdr;
|
---|
| 158 | /** The associated kLdr module. This may be NULL. */
|
---|
| 159 | PKLDRMOD pLdrMod;
|
---|
| 160 | } KDBGMOD;
|
---|
| 161 |
|
---|
| 162 | /** @}*/
|
---|
| 163 |
|
---|
| 164 | #ifdef __cplusplus
|
---|
| 165 | }
|
---|
| 166 | #endif
|
---|
| 167 |
|
---|
| 168 | #endif
|
---|