Changeset 3541 for trunk/kStuff/include/k/kDbg.h
- Timestamp:
- Aug 25, 2007, 5:46:14 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/include/k/kDbg.h
r3540 r3541 41 41 /** The max symbol name length used by the debug reader. */ 42 42 #define KDBG_SYMBOL_MAX 384 43 44 /** @name kDbg Status codes45 * (Success is indicated by the value 0.)46 * @{ */47 #define KDBG_ERR_BASE 43000048 49 /** An API was given an invalid parameter. */50 #define KDBG_ERR_INVALID_PARAMETER (KDBG_ERR_BASE + 0)51 /** A pointer argument is not valid. */52 #define KDBG_ERR_INVALID_POINTER (KDBG_ERR_BASE + 1)53 /** A handle argument is not valid. */54 #define KDBG_ERR_INVALID_HANDLE (KDBG_ERR_BASE + 2)55 /** A parameter is out of range. */56 #define KDBG_ERR_OUT_OF_RANGE (KDBG_ERR_BASE + 3)57 /** Out of memory. */58 #define KDBG_ERR_NO_MEMORY (KDBG_ERR_BASE + 4)59 /** The specified file was not found. */60 #define KDBG_ERR_FILE_NOT_FOUND (KDBG_ERR_BASE + 5)61 /** Hit some unimplemented functionality - feel free to implement it :-) . */62 #define KDBG_ERR_NOT_IMPLEMENTED (KDBG_ERR_BASE + 6)63 /** Generic error. */64 #define KDBG_ERR_GENERAL_FAILURE (KDBG_ERR_BASE + 9)65 66 /** The (module) format isn't known to use. */67 #define KDBG_ERR_UNKOWN_FORMAT (KDBG_ERR_BASE + 10)68 /** The (module) format isn't supported by this kDbg build. */69 #define KDBG_ERR_FORMAT_NOT_SUPPORTED (KDBG_ERR_BASE + 11)70 /** A specified address or an address found in the debug info is invalid. */71 #define KDBG_ERR_INVALID_ADDRESS (KDBG_ERR_BASE + 12)72 /** The dbghelp.dll is too old or something like that. */73 #define KDBG_ERR_DBGHLP_VERSION_MISMATCH (KDBG_ERR_BASE + 13)74 /** Invalid executable format. */75 #define KDBG_ERR_BAD_EXE_FORMAT (KDBG_ERR_BASE + 14)76 77 /** @} */78 79 43 80 44 /** @name Special Segments … … 131 95 * 132 96 * @returns VINF_SUCCESS on success. 133 * @returns K DBG_ERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in.97 * @returns KERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in. 134 98 * 135 99 * @param pLine The line number to be freed. … … 199 163 * 200 164 * @returns VINF_SUCCESS on success. 201 * @returns K DBG_ERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in.165 * @returns KERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in. 202 166 * 203 167 * @param pSymbol The symbol to be freed. … … 206 170 207 171 172 /** Pointer to a kDbgHlp file structure (abstract). */ 173 typedef struct KDBGHLPFILE *PKDBGHLPFILE; 208 174 209 175 /** A debug module handle. */ 210 176 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 211 295 212 296 /** … … 240 324 * @param pSym Where to store the symbol details. 241 325 */ 242 KDBG_DECL(int) kDbgModuleQuerySymbol(PKDBGMOD pMod, int32_tiSegment, KDBGADDR off, PKDBGSYMBOL pSym);326 KDBG_DECL(int) kDbgModuleQuerySymbol(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGSYMBOL pSym); 243 327 244 328 /** … … 256 340 * Free the returned symbol using kDbgSymbolFree(). 257 341 */ 258 KDBG_DECL(int) kDbgModuleQuerySymbolA(PKDBGMOD pMod, int32_tiSegment, KDBGADDR off, PPKDBGSYMBOL ppSym);342 KDBG_DECL(int) kDbgModuleQuerySymbolA(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PPKDBGSYMBOL ppSym); 259 343 260 344 /** … … 271 355 * @param pLine Where to store the line number details. 272 356 */ 273 KDBG_DECL(int) kDbgModuleQueryLine(PKDBGMOD pMod, int32_tiSegment, KDBGADDR off, PKDBGLINE pLine);357 KDBG_DECL(int) kDbgModuleQueryLine(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGLINE pLine); 274 358 275 359 /** … … 287 371 * Free the returned line number using kDbgLineFree(). 288 372 */ 289 KDBG_DECL(int) kDbgModuleQueryLineA(PKDBGMOD pMod, int32_tiSegment, KDBGADDR off, PPKDBGLINE ppLine);373 KDBG_DECL(int) kDbgModuleQueryLineA(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PPKDBGLINE ppLine); 290 374 291 375
Note:
See TracChangeset
for help on using the changeset viewer.