VirtualBox

source: kStuff/trunk/include/k/kDbg.h@ 13

Last change on this file since 13 was 2, checked in by bird, 17 years ago

Imported http://svn.netlabs.org/repos/libc/trunk/kStuff, revision 3612.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.3 KB
Line 
1/* $Id: kDbg.h 2 2007-11-16 16:07:14Z bird $ */
2/** @file
3 * kDbg - The Debug Info Reader.
4 */
5
6/*
7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with This program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
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>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/** @defgroup grp_kDbg Debug Info Reader
37 * @{
38 */
39
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. */
54typedef KU64 KDBGADDR;
55/** Pointer to a kDbg address. */
56typedef KDBGADDR *PKDBGADDR;
57/** Pointer to a const kDbg address. */
58typedef 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
72
73/** @name Special Segments
74 * @{ */
75/** Relative Virtual Address.
76 * The specified offset is relative to the image base. The image base is the lowest memory
77 * address used by the image when loaded with the address assignments indicated in the image. */
78#define KDBGSEG_RVA (-1)
79/** Absolute segment. The offset isn't relative to anything. */
80#define KDBGSEG_ABS (-2)
81/** @} */
82
83
84/** The max filename path length used by the debug reader. */
85#define KDBG_PATH_MAX 260
86
87/**
88 * Line number details.
89 */
90typedef struct KDBGLINE
91{
92 /** The relative virtual address. */
93 KDBGADDR RVA;
94 /** The offset into the segment. */
95 KDBGADDR offSegment;
96 /** The segment number. */
97 KI32 iSegment;
98 /** The Line number. */
99 KU32 iLine;
100 /** The actual size of this structure. */
101 KU16 cbSelf;
102 /** The length of the filename. */
103 KU16 cchFile;
104 /** The name of the file this line number relates to. */
105 char szFile[KDBG_PATH_MAX];
106} KDBGLINE;
107/** Pointer to line number details. */
108typedef KDBGLINE *PKDBGLINE;
109/** Pointer to const line number details. */
110typedef const KDBGLINE *PCKDBGLINE;
111/** Pointer to a pointer to line number details. */
112typedef PKDBGLINE *PPKDBGLINE;
113
114/**
115 * Duplicates a line number.
116 *
117 * To save heap space, the returned line number will not own more heap space
118 * than it strictly need to. So, it's not possible to append stuff to the symbol
119 * or anything of that kind.
120 *
121 * @returns Pointer to the duplicate.
122 * This must be freed using RTDbgSymbolFree().
123 * @param pLine The line number to be duplicated.
124 */
125KDBG_DECL(PKDBGLINE) kDbgLineDup(PCKDBGLINE pLine);
126
127/**
128 * Frees a line number obtained from the RTDbg API.
129 *
130 * @returns VINF_SUCCESS on success.
131 * @returns KERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in.
132 *
133 * @param pLine The line number to be freed.
134 */
135KDBG_DECL(int) kDbgLineFree(PKDBGLINE pLine);
136
137
138/** @name Symbol Flags.
139 * @{ */
140/** The symbol is weak. */
141#define KDBGSYM_FLAGS_WEAK KU32_C(0x00000000)
142/** The symbol is absolute.
143 * (This also indicated by the segment number.) */
144#define KDBGSYM_FLAGS_ABS KU32_C(0x00000001)
145/** The symbol is exported. */
146#define KDBGSYM_FLAGS_EXPORTED KU32_C(0x00000002)
147/** The symbol is a function/method/procedure/whatever-executable-code. */
148#define KDBGSYM_FLAGS_CODE KU32_C(0x00000004)
149/** The symbol is some kind of data. */
150#define KDBGSYM_FLAGS_DATA KU32_C(0x00000008)
151/** @} */
152
153/** The max symbol name length used by the debug reader. */
154#define KDBG_SYMBOL_MAX 384
155
156/**
157 * Symbol details.
158 */
159typedef struct KDBGSYMBOL
160{
161 /** The adddress of this symbol in the relevant space.
162 * This is NIL_KDBGADDR unless the information was
163 * returned by a kDbgSpace API. */
164 KDBGADDR Address;
165 /** The relative virtual address. */
166 KDBGADDR RVA;
167 /** The symbol size.
168 * This is not a reliable field, it could be a bad guess. Ignore if zero. */
169 KDBGADDR cb;
170 /** The offset into the segment. */
171 KDBGADDR offSegment;
172 /** The segment number. */
173 KI32 iSegment;
174 /** The symbol flags. */
175 KU32 fFlags;
176/** @todo type info. */
177 /** The actual size of this structure. */
178 KU16 cbSelf;
179 /** The length of the symbol name. */
180 KU16 cchName;
181 /** The symbol name. */
182 char szName[KDBG_SYMBOL_MAX];
183} KDBGSYMBOL;
184/** Pointer to symbol details. */
185typedef KDBGSYMBOL *PKDBGSYMBOL;
186/** Pointer to const symbol details. */
187typedef const KDBGSYMBOL *PCKDBGSYMBOL;
188/** Pointer to a pointer to symbol details. */
189typedef PKDBGSYMBOL *PPKDBGSYMBOL;
190
191/**
192 * Duplicates a symbol.
193 *
194 * To save heap space, the returned symbol will not own more heap space than
195 * it strictly need to. So, it's not possible to append stuff to the symbol
196 * or anything of that kind.
197 *
198 * @returns Pointer to the duplicate.
199 * This must be freed using kDbgSymbolFree().
200 * @param pSymbol The symbol to be freed.
201 */
202KDBG_DECL(PKDBGSYMBOL) kDbgSymbolDup(PCKDBGSYMBOL pSymbol);
203
204/**
205 * Frees a symbol obtained from the kDbg API.
206 *
207 * @returns VINF_SUCCESS on success.
208 * @returns KERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in.
209 *
210 * @param pSymbol The symbol to be freed.
211 */
212KDBG_DECL(int) kDbgSymbolFree(PKDBGSYMBOL pSymbol);
213
214
215/** Pointer to a debug module. */
216typedef struct KDBGMOD *PKDBGMOD;
217/** Pointer to a debug module pointer. */
218typedef PKDBGMOD *PPKDBGMOD;
219
220
221KDBG_DECL(int) kDbgModuleOpen(PPKDBGMOD ppDbgMod, const char *pszFilename, struct KLDRMOD *pLdrMod);
222KDBG_DECL(int) kDbgModuleOpenFile(PPKDBGMOD ppDbgMod, PKRDR pRdr, struct KLDRMOD *pLdrMod);
223KDBG_DECL(int) kDbgModuleOpenFilePart(PPKDBGMOD ppDbgMod, PKRDR pRdr, KFOFF off, KFOFF cb, struct KLDRMOD *pLdrMod);
224KDBG_DECL(int) kDbgModuleClose(PKDBGMOD pMod);
225KDBG_DECL(int) kDbgModuleQuerySymbol(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGSYMBOL pSym);
226KDBG_DECL(int) kDbgModuleQuerySymbolA(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PPKDBGSYMBOL ppSym);
227KDBG_DECL(int) kDbgModuleQueryLine(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGLINE pLine);
228KDBG_DECL(int) kDbgModuleQueryLineA(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PPKDBGLINE ppLine);
229
230
231/** @} */
232
233#ifdef __cplusplus
234}
235#endif
236
237#endif
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