VirtualBox

source: vbox/trunk/src/VBox/VMM/DBGFModule.cpp@ 25046

Last change on this file since 25046 was 19757, checked in by vboxsync, 16 years ago

VMM,IPRT,DBGC: Debug address spaces.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.9 KB
Line 
1/* $Id: DBGFModule.cpp 19757 2009-05-15 23:37:31Z vboxsync $ */
2/** @file
3 * DBGF - Debugger Facility, Module & Segment Management.
4 */
5
6/*
7 * Copyright (C) 2008 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
23/** @page pg_dbgf_module DBGFModule - Module & Segment Management
24 *
25 * A module is our representation of an executable binary. It's main purpose
26 * is to provide segments that can be mapped into address spaces and thereby
27 * provide debug info for those parts for the guest code or data.
28 *
29 * This module will not deal directly with debug info, it will only serve
30 * as an interface between the debugger / symbol lookup and the debug info
31 * readers.
32 *
33 * An executable binary doesn't need to have a file, or that is, we don't
34 * need the file to create a module for it. There will be interfaces for
35 * ROMs to register themselves so we can get to their symbols, and there
36 * will be interfaces for the guest OS plugins (@see pg_dbgf_os) to
37 * register kernel, drivers and other global modules.
38 */
39
40#if 0
41#include <VBox/dbgf.h>
42
43
44/** Special segment number that indicates that the offset is a relative
45 * virtual address (RVA). I.e. an offset from the start of the module. */
46#define DBGF_SEG_RVA UINT32_C(0xfffffff0)
47
48/** @defgroup grp_dbgf_dbginfo Debug Info Types
49 * @{ */
50/** Other format. */
51#define DBGF_DBGINFO_OTHER RT_BIT_32(0)
52/** Stabs. */
53#define DBGF_DBGINFO_STABS RT_BIT_32(1)
54/** Debug With Arbitrary Record Format (DWARF). */
55#define DBGF_DBGINFO_DWARF RT_BIT_32(2)
56/** Microsoft Codeview debug info. */
57#define DBGF_DBGINFO_CODEVIEW RT_BIT_32(3)
58/** Watcom debug info. */
59#define DBGF_DBGINFO_WATCOM RT_BIT_32(4)
60/** IBM High Level Language debug info. */
61#define DBGF_DBGINFO_HLL RT_BIT_32(5)
62/** Old OS/2 and Windows symbol file. */
63#define DBGF_DBGINFO_SYM RT_BIT_32(6)
64/** Map file. */
65#define DBGF_DBGINFO_MAP RT_BIT_32(7)
66/** @} */
67
68/** @defgroup grp_dbgf_exeimg Executable Image Types
69 * @{ */
70/** Some other format. */
71#define DBGF_EXEIMG_OTHER RT_BIT_32(0)
72/** Portable Executable. */
73#define DBGF_EXEIMG_PE RT_BIT_32(1)
74/** Linear eXecutable. */
75#define DBGF_EXEIMG_LX RT_BIT_32(2)
76/** Linear Executable. */
77#define DBGF_EXEIMG_LE RT_BIT_32(3)
78/** New Executable. */
79#define DBGF_EXEIMG_NE RT_BIT_32(4)
80/** DOS Executable (Mark Zbikowski). */
81#define DBGF_EXEIMG_MZ RT_BIT_32(5)
82/** COM Executable. */
83#define DBGF_EXEIMG_COM RT_BIT_32(6)
84/** a.out Executable. */
85#define DBGF_EXEIMG_AOUT RT_BIT_32(7)
86/** Executable and Linkable Format. */
87#define DBGF_EXEIMG_ELF RT_BIT_32(8)
88/** Mach-O Executable (including FAT ones). */
89#define DBGF_EXEIMG_MACHO RT_BIT_32(9)
90/** @} */
91
92/** Pointer to a module. */
93typedef struct DBGFMOD *PDBGFMOD;
94
95
96/**
97 * Virtual method table for executable image interpreters.
98 */
99typedef struct DBGFMODVTIMG
100{
101 /** Magic number (DBGFMODVTIMG_MAGIC). */
102 uint32_t u32Magic;
103 /** Mask of supported debug info types, see grp_dbgf_exeimg.
104 * Used to speed up the search for a suitable interpreter. */
105 uint32_t fSupports;
106 /** The name of the interpreter. */
107 const char *pszName;
108
109 /**
110 * Try open the image.
111 *
112 * This combines probing and opening.
113 *
114 * @returns VBox status code. No informational returns defined.
115 *
116 * @param pMod Pointer to the module that is being opened.
117 *
118 * The DBGFMOD::pszDbgFile member will point to
119 * the filename of any debug info we're aware of
120 * on input. Also, or alternatively, it is expected
121 * that the interpreter will look for debug info in
122 * the executable image file when present and that it
123 * may ask the image interpreter for this when it's
124 * around.
125 *
126 * Upon successful return the method is expected to
127 * initialize pDbgOps and pvDbgPriv.
128 */
129 DECLCALLBACKMEMBER(int, pfnTryOpen)(PDBGFMOD pMod);
130
131 /**
132 * Close the interpreter, freeing all associated resources.
133 *
134 * The caller sets the pDbgOps and pvDbgPriv DBGFMOD members
135 * to NULL upon return.
136 *
137 * @param pMod Pointer to the module structure.
138 */
139 DECLCALLBACKMEMBER(int, pfnClose)(PDBGFMOD pMod);
140
141} DBGFMODVTIMG
142
143/**
144 * Virtual method table for debug info interpreters.
145 */
146typedef struct DBGFMODVTDBG
147{
148 /** Magic number (DBGFMODVTDBG_MAGIC). */
149 uint32_t u32Magic;
150 /** Mask of supported debug info types, see grp_dbgf_dbginfo.
151 * Used to speed up the search for a suitable interpreter. */
152 uint32_t fSupports;
153 /** The name of the interpreter. */
154 const char *pszName;
155
156 /**
157 * Try open the image.
158 *
159 * This combines probing and opening.
160 *
161 * @returns VBox status code. No informational returns defined.
162 *
163 * @param pMod Pointer to the module that is being opened.
164 *
165 * The DBGFMOD::pszDbgFile member will point to
166 * the filename of any debug info we're aware of
167 * on input. Also, or alternatively, it is expected
168 * that the interpreter will look for debug info in
169 * the executable image file when present and that it
170 * may ask the image interpreter for this when it's
171 * around.
172 *
173 * Upon successful return the method is expected to
174 * initialize pDbgOps and pvDbgPriv.
175 */
176 DECLCALLBACKMEMBER(int, pfnTryOpen)(PDBGFMOD pMod);
177
178 /**
179 * Close the interpreter, freeing all associated resources.
180 *
181 * The caller sets the pDbgOps and pvDbgPriv DBGFMOD members
182 * to NULL upon return.
183 *
184 * @param pMod Pointer to the module structure.
185 */
186 DECLCALLBACKMEMBER(int, pfnClose)(PDBGFMOD pMod);
187
188 /**
189 * Queries symbol information by symbol name.
190 *
191 * @returns VBox status code.
192 * @retval VINF_SUCCESS on success, no informational status code.
193 * @retval VERR_DBGF_NO_SYMBOLS if there aren't any symbols.
194 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
195 *
196 * @param pMod Pointer to the module structure.
197 * @param pszSymbol The symbol name.
198 * @para pSymbol Where to store the symbol information.
199 */
200 DECLCALLBACKMEMBER(int, pfnSymbolByName)(PDBGFMOD pMod, const char *pszSymbol, PDBGFSYMBOL pSymbol);
201
202 /**
203 * Queries symbol information by address.
204 *
205 * The returned symbol is what the debug info interpreter consideres the symbol
206 * most applicable to the specified address. This usually means a symbol with an
207 * address equal or lower than the requested.
208 *
209 * @returns VBox status code.
210 * @retval VINF_SUCCESS on success, no informational status code.
211 * @retval VERR_DBGF_NO_SYMBOLS if there aren't any symbols.
212 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
213 *
214 * @param pMod Pointer to the module structure.
215 * @param iSeg The segment number (0-based). DBGF_SEG_RVA can be used.
216 * @param off The offset into the segment.
217 * @param poffDisp Where to store the distance between the specified address
218 * and the returned symbol. Optional.
219 * @param pSymbol Where to store the symbol information.
220 */
221 DECLCALLBACKMEMBER(int, pfnSymbolByAddr)(PDBGFMOD pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PDBGFSYMBOL pSymbol);
222
223 /**
224 * Queries line number information by address.
225 *
226 * @returns VBox status code.
227 * @retval VINF_SUCCESS on success, no informational status code.
228 * @retval VERR_DBGF_NO_LINE_NUMBERS if there aren't any line numbers.
229 * @retval VERR_DBGF_LINE_NOT_FOUND if no suitable line number was found.
230 *
231 * @param pMod Pointer to the module structure.
232 * @param iSeg The segment number (0-based). DBGF_SEG_RVA can be used.
233 * @param off The offset into the segment.
234 * @param poffDisp Where to store the distance between the specified address
235 * and the returned line number. Optional.
236 * @param pLine Where to store the information about the closest line number.
237 */
238 DECLCALLBACKMEMBER(int, pfnLineByAddr)(PDBGFMOD pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PDBGFLINE pLine);
239
240 /**
241 * Adds a symbol to the module (optional).
242 *
243 * This method is used to implement DBGFR3SymbolAdd.
244 *
245 * @returns VBox status code.
246 * @retval VERR_NOT_SUPPORTED if the interpreter doesn't support this feature.
247 *
248 * @param pMod Pointer to the module structure.
249 * @param pszSymbol The symbol name.
250 * @param iSeg The segment number (0-based). DBGF_SEG_RVA can be used.
251 * @param off The offset into the segment.
252 * @param cbSymbol The area covered by the symbol. 0 is fine.
253 */
254 DECLCALLBACKMEMBER(int, pfnSymbolAdd)(PDBGFMOD pMod, const char *pszSymbol, uint32_t iSeg, RTGCUINTPTR off, RTUINT cbSymbol);
255
256 /** For catching initialization errors (DBGFMODVTDBG_MAGIC). */
257 uint32_t u32EndMagic;
258} DBGFMODVTDBG;
259
260#define DBGFMODVTDBG_MAGIC 123
261
262/**
263 * Module.
264 */
265typedef struct DBGFMOD
266{
267 /** Magic value (DBGFMOD_MAGIC). */
268 uint32_t u32Magic;
269 /** The number of address spaces this module is currently linked into.
270 * This is used to perform automatic cleanup and sharing. */
271 uint32_t cLinks;
272 /** The module name (short). */
273 const char *pszName;
274 /** The module filename. Can be NULL. */
275 const char *pszImgFile;
276 /** The debug info file (if external). Can be NULL. */
277 const char *pszDbgFile;
278
279 /** The method table for the executable image interpreter. */
280 PCDBGFMODVTIMG pImgVt;
281 /** Pointer to the private data of the executable image interpreter. */
282 void *pvImgPriv;
283
284 /** The method table for the debug info interpreter. */
285 PCDBGFMODVTDBG pDbgVt;
286 /** Pointer to the private data of the debug info interpreter. */
287 void *pvDbgPriv;
288
289} DBGFMOD;
290
291#define DBGFMOD_MAGIC 0x12345678
292
293#endif
294
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette