Changeset 3550 for trunk/kStuff/include/k/kDbg.h
- Timestamp:
- Aug 26, 2007, 3:13:35 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/include/k/kDbg.h
r3541 r3550 23 23 */ 24 24 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> 29 31 30 32 #ifdef __cplusplus … … 36 38 */ 37 39 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. */ 54 typedef KU64 KDBGADDR; 55 /** Pointer to a kDbg address. */ 56 typedef KDBGADDR *PKDBGADDR; 57 /** Pointer to a const kDbg address. */ 58 typedef 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 43 72 44 73 /** @name Special Segments … … 47 76 * The specified offset is relative to the image base. The image base is the lowest memory 48 77 * 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) 50 79 /** Absolute segment. The offset isn't relative to anything. */ 51 #define KDBGSEG_ABS (-2)80 #define KDBGSEG_ABS (-2) 52 81 /** @} */ 53 82 83 84 /** The max filename path length used by the debug reader. */ 85 #define KDBG_PATH_MAX 260 54 86 55 87 /** … … 63 95 KDBGADDR offSegment; 64 96 /** The segment number. */ 65 int32_tiSegment;97 KI32 iSegment; 66 98 /** The Line number. */ 67 uint32_t iLine; 99 KU32 iLine; 100 /** The actual size of this structure. */ 101 KU16 cbSelf; 68 102 /** The length of the filename. */ 69 uint16_tcchFile;103 KU16 cchFile; 70 104 /** The name of the file this line number relates to. */ 71 105 char szFile[KDBG_PATH_MAX]; … … 105 139 * @{ */ 106 140 /** The symbol is weak. */ 107 #define KDBGSYM_FLAGS_WEAK UINT32_C(0x00000000)141 #define KDBGSYM_FLAGS_WEAK KU32_C(0x00000000) 108 142 /** The symbol is absolute. 109 143 * (This also indicated by the segment number.) */ 110 #define KDBGSYM_FLAGS_ABS UINT32_C(0x00000001)144 #define KDBGSYM_FLAGS_ABS KU32_C(0x00000001) 111 145 /** The symbol is exported. */ 112 #define KDBGSYM_FLAGS_EXPORTED UINT32_C(0x00000002)146 #define KDBGSYM_FLAGS_EXPORTED KU32_C(0x00000002) 113 147 /** 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) 115 149 /** The symbol is some kind of data. */ 116 #define KDBGSYM_FLAGS_DATA UINT32_C(0x00000008)150 #define KDBGSYM_FLAGS_DATA KU32_C(0x00000008) 117 151 /** @} */ 152 153 /** The max symbol name length used by the debug reader. */ 154 #define KDBG_SYMBOL_MAX 384 118 155 119 156 /** … … 130 167 KDBGADDR offSegment; 131 168 /** The segment number. */ 132 int32_tiSegment;169 KI32 iSegment; 133 170 /** The symbol flags. */ 134 uint32_tfFlags;171 KU32 fFlags; 135 172 /** @todo type info? */ 173 /** The actual size of this structure. */ 174 KU16 cbSelf; 136 175 /** The length of the symbol name. */ 137 uint16_tcchName;176 KU16 cchName; 138 177 /** The symbol name. */ 139 178 char szName[KDBG_SYMBOL_MAX]; … … 170 209 171 210 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. */ 176 212 typedef 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. */ 214 typedef PKDBGMOD *PPKDBGMOD; 215 216 217 KDBG_DECL(int) kDbgModuleOpen(PPKDBGMOD ppDbgMod, const char *pszFilename, struct KLDRMOD *pLdrMod); 218 KDBG_DECL(int) kDbgModuleOpenFile(PPKDBGMOD ppDbgMod, PKRDR pRdr, struct KLDRMOD *pLdrMod); 219 KDBG_DECL(int) kDbgModuleOpenFilePart(PPKDBGMOD ppDbgMod, PKRDR pRdr, KFOFF off, KFOFF cb, struct KLDRMOD *pLdrMod); 311 220 KDBG_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 to321 * the image base. The image base is where the first bit of the image322 * is mapped during load.323 * @param off The offset into the segment.324 * @param pSym Where to store the symbol details.325 */326 221 KDBG_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 to336 * the image base. The image base is where the first bit of the image337 * 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 */342 222 KDBG_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 to352 * the image base. The image base is where the first bit of the image353 * is mapped during load.354 * @param off The offset into the segment.355 * @param pLine Where to store the line number details.356 */357 223 KDBG_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 to367 * the image base. The image base is where the first bit of the image368 * 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 */373 224 KDBG_DECL(int) kDbgModuleQueryLineA(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PPKDBGLINE ppLine); 374 225
Note:
See TracChangeset
for help on using the changeset viewer.