1 | /* $Id: dbg.h 19509 2009-05-08 02:18:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Debugging Routines.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2009 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___iprt_dbg_h
|
---|
23 | #define ___iprt_dbg_h
|
---|
24 |
|
---|
25 | #include <iprt/types.h>
|
---|
26 |
|
---|
27 | __BEGIN_DECLS
|
---|
28 |
|
---|
29 | /** @defgroup grp_rt_dbg RTDbg - Debugging Routines
|
---|
30 | * @ingroup grp_rt
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 |
|
---|
34 |
|
---|
35 | /** Debug segment index. */
|
---|
36 | typedef uint32_t RTDBGSEGIDX;
|
---|
37 | /** Pointer to a debug segment index. */
|
---|
38 | typedef RTDBGSEGIDX *PRTDBGSEGIDX;
|
---|
39 | /** Pointer to a const debug segment index. */
|
---|
40 | typedef RTDBGSEGIDX const *PCRTDBGSEGIDX;
|
---|
41 | /** NIL debug segment index. */
|
---|
42 | #define NIL_RTDBGSEGIDX UINT32_C(0xffffffff)
|
---|
43 | /** Special segment index that indicates that the offset is a relative
|
---|
44 | * virtual address (RVA). I.e. an offset from the start of the module. */
|
---|
45 | #define RTDBGSEGIDX_RVA UINT32_C(0xfffffff0)
|
---|
46 | /** Special segment index that indicates that the offset is a absolute. */
|
---|
47 | #define RTDBGSEGIDX_ABS UINT32_C(0xfffffff1)
|
---|
48 |
|
---|
49 | /** Max length (including '\\0') of a symbol name. */
|
---|
50 | #define RTDBG_SYMBOL_NAME_LENGTH (512 - 8 - 4 - 4 - 4)
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Debug symbol.
|
---|
54 | */
|
---|
55 | typedef struct RTDBGSYMBOL
|
---|
56 | {
|
---|
57 | /** Symbol value (address). */
|
---|
58 | RTUINTPTR Value;
|
---|
59 | /** Segment number when applicable or NIL_RTDBGSEGIDX. */
|
---|
60 | RTDBGSEGIDX iSeg;
|
---|
61 | /** Symbol size. */
|
---|
62 | uint32_t cb;
|
---|
63 | /** Symbol Flags. (reserved). */
|
---|
64 | uint32_t fFlags;
|
---|
65 | /** Symbol name. */
|
---|
66 | char szName[RTDBG_SYMBOL_NAME_LENGTH];
|
---|
67 | } RTDBGSYMBOL;
|
---|
68 | /** Pointer to debug symbol. */
|
---|
69 | typedef RTDBGSYMBOL *PRTDBGSYMBOL;
|
---|
70 | /** Pointer to const debug symbol. */
|
---|
71 | typedef const RTDBGSYMBOL *PCRTDBGSYMBOL;
|
---|
72 |
|
---|
73 | RTDECL(PRTDBGSYMBOL) RTDbgSymbolAlloc(void);
|
---|
74 | RTDECL(PRTDBGSYMBOL) RTDbgSymbolDup(PCRTDBGSYMBOL pSymbol);
|
---|
75 | RTDECL(void) RTDbgSymbolFree(PRTDBGSYMBOL pSymbol);
|
---|
76 |
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Debug line number information.
|
---|
80 | */
|
---|
81 | typedef struct RTDBGLINE
|
---|
82 | {
|
---|
83 | /** Address. */
|
---|
84 | RTUINTPTR Address;
|
---|
85 | /** Segment number when applicable or NIL_RTDBGSEGIDX. */
|
---|
86 | RTDBGSEGIDX iSeg;
|
---|
87 | /** Line number. */
|
---|
88 | uint32_t uLineNo;
|
---|
89 | /** Filename. */
|
---|
90 | char szFilename[260];
|
---|
91 | } RTDBGLINE;
|
---|
92 | /** Pointer to debug line number. */
|
---|
93 | typedef RTDBGLINE *PRTDBGLINE;
|
---|
94 | /** Pointer to const debug line number. */
|
---|
95 | typedef const RTDBGLINE *PCRTDBGLINE;
|
---|
96 |
|
---|
97 | RTDECL(PRTDBGLINE) RTDbgLineAlloc(void);
|
---|
98 | RTDECL(PRTDBGLINE) RTDbgLineDup(PCRTDBGLINE pLine);
|
---|
99 | RTDECL(void) RTDbgLineFree(PRTDBGLINE pLine);
|
---|
100 |
|
---|
101 |
|
---|
102 | /** @defgroup grp_rt_dbgas RTDbgAs - Debug Address Space
|
---|
103 | * @{
|
---|
104 | */
|
---|
105 | RTDECL(int) RTDbgAsCreate(PRTDBGAS phDbgAs, const char *pszName, RTUINTPTR FirstAddr, RTUINTPTR LastAddr);
|
---|
106 | RTDECL(int) RTDbgAsDestroy(PRTDBGAS phDbgAs);
|
---|
107 |
|
---|
108 | RTDECL(int) RTDbgAsModuleLink(PRTDBGAS phDbgAs, RTDBGMOD hDbgMod, RTUINTPTR ImageAddr);
|
---|
109 | RTDECL(int) RTDbgAsModuleLinkSeg(PRTDBGAS phDbgAs, RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR SegAddr);
|
---|
110 | RTDECL(int) RTDbgAsModuleUnlink(PRTDBGAS phDbgAs, RTDBGMOD hDbgMod);
|
---|
111 | RTDECL(int) RTDbgAsModuleUnlinkByAddr(PRTDBGAS phDbgAs, RTUINTPTR ImageAddr);
|
---|
112 | RTDECL(uint32_t) RTDbgAsModuleCount(PRTDBGAS phDbgAs);
|
---|
113 | RTDECL(RTDBGMOD) RTDbgAsModuleByIndex(PRTDBGAS phDbgAs, uint32_t iModule);
|
---|
114 | RTDECL(RTDBGMOD) RTDbgAsModuleByName(PRTDBGAS phDbgAs, RTUINTPTR Addr);
|
---|
115 | RTDECL(RTDBGMOD) RTDbgAsModuleByAddr(PRTDBGAS phDbgAs, const char *pszName);
|
---|
116 |
|
---|
117 | RTDECL(int) RTDbgAsSymbolAdd(RTDBGAS hDbgAs, const char *pszSymbol, RTUINTPTR Addr, uint32_t cb);
|
---|
118 | RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol);
|
---|
119 | RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol);
|
---|
120 | /** @} */
|
---|
121 |
|
---|
122 |
|
---|
123 | /** @defgroup grp_rt_dbgmod RTDbgMod - Debug Module Interperter
|
---|
124 | * @{
|
---|
125 | */
|
---|
126 | RTDECL(int) RTDbgModCreate(PRTDBGMOD phDbgMod, const char *pszName, const char *pszImgFile, const char *pszDbgFile);
|
---|
127 | RTDECL(int) RTDbgModDestroy(RTDBGMOD hDbgMod);
|
---|
128 | RTDECL(int) RTDbgModRetain(RTDBGMOD hDbgMod);
|
---|
129 | RTDECL(int) RTDbgModRelease(RTDBGMOD hDbgMod);
|
---|
130 |
|
---|
131 | RTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t cb);
|
---|
132 | RTDECL(uint32_t) RTDbgModSymbolCount(RTDBGMOD hDbgMod);
|
---|
133 | RTDECL(int) RTDbgModSymbolByIndex(RTDBGMOD hDbgMod, uint32_t iSymbol, PRTDBGSYMBOL pSymbol);
|
---|
134 | RTDECL(int) RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol);
|
---|
135 | RTDECL(int) RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymbol);
|
---|
136 | RTDECL(int) RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol);
|
---|
137 | RTDECL(int) RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol);
|
---|
138 |
|
---|
139 | RTDECL(int) RTDbgModLineByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE pLine);
|
---|
140 | RTDECL(int) RTDbgModLineByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE *ppLine);
|
---|
141 | /** @} */
|
---|
142 |
|
---|
143 | /** @} */
|
---|
144 |
|
---|
145 | __END_DECLS
|
---|
146 |
|
---|
147 | #endif
|
---|
148 |
|
---|