VirtualBox

source: vbox/trunk/include/iprt/dbg.h@ 73444

Last change on this file since 73444 was 73375, checked in by vboxsync, 7 years ago

IPRT: Added RTLDRPROP_UNWIND_INFO to RTLdrQueryPropEx. Added RTDbgModImageQueryProp, RTDbgModImageGetArch, and RTDbgModImageGetFormat.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 67.9 KB
Line 
1/* $Id: dbg.h 73375 2018-07-27 07:59:25Z vboxsync $ */
2/** @file
3 * IPRT - Debugging Routines.
4 */
5
6/*
7 * Copyright (C) 2008-2017 Oracle Corporation
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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___iprt_dbg_h
28#define ___iprt_dbg_h
29
30#include <iprt/types.h>
31#include <iprt/stdarg.h>
32#include <iprt/ldr.h>
33
34RT_C_DECLS_BEGIN
35
36# ifdef IN_RING3
37
38/** @defgroup grp_rt_dbg RTDbg - Debugging Routines
39 * @ingroup grp_rt
40 * @{
41 */
42
43
44/** Debug segment index. */
45typedef uint32_t RTDBGSEGIDX;
46/** Pointer to a debug segment index. */
47typedef RTDBGSEGIDX *PRTDBGSEGIDX;
48/** Pointer to a const debug segment index. */
49typedef RTDBGSEGIDX const *PCRTDBGSEGIDX;
50/** NIL debug segment index. */
51#define NIL_RTDBGSEGIDX UINT32_C(0xffffffff)
52/** The last normal segment index. */
53#define RTDBGSEGIDX_LAST UINT32_C(0xffffffef)
54/** Special segment index that indicates that the offset is a relative
55 * virtual address (RVA). I.e. an offset from the start of the module. */
56#define RTDBGSEGIDX_RVA UINT32_C(0xfffffff0)
57/** Special segment index that indicates that the offset is a absolute. */
58#define RTDBGSEGIDX_ABS UINT32_C(0xfffffff1)
59/** The last valid special segment index. */
60#define RTDBGSEGIDX_SPECIAL_LAST RTDBGSEGIDX_ABS
61/** The last valid special segment index. */
62#define RTDBGSEGIDX_SPECIAL_FIRST (RTDBGSEGIDX_LAST + 1U)
63
64
65
66/** @name RTDBGSYMADDR_FLAGS_XXX
67 * Flags used when looking up a symbol by address.
68 * @{ */
69/** Less or equal address. (default) */
70#define RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL UINT32_C(0)
71/** Greater or equal address. */
72#define RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL UINT32_C(1)
73/** Don't consider absolute symbols in deferred modules. */
74#define RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED UINT32_C(2)
75/** Don't search for absolute symbols if it's expensive. */
76#define RTDBGSYMADDR_FLAGS_SKIP_ABS UINT32_C(4)
77/** Mask of valid flags. */
78#define RTDBGSYMADDR_FLAGS_VALID_MASK UINT32_C(7)
79/** @} */
80
81
82/** Max length (including '\\0') of a segment name. */
83#define RTDBG_SEGMENT_NAME_LENGTH (128 - 8 - 8 - 8 - 4 - 4)
84
85/**
86 * Debug module segment.
87 */
88typedef struct RTDBGSEGMENT
89{
90 /** The load address.
91 * RTUINTPTR_MAX if not applicable. */
92 RTUINTPTR Address;
93 /** The image relative virtual address of the segment.
94 * RTUINTPTR_MAX if not applicable. */
95 RTUINTPTR uRva;
96 /** The segment size. */
97 RTUINTPTR cb;
98 /** The segment flags. (reserved) */
99 uint32_t fFlags;
100 /** The segment index. */
101 RTDBGSEGIDX iSeg;
102 /** Symbol name. */
103 char szName[RTDBG_SEGMENT_NAME_LENGTH];
104} RTDBGSEGMENT;
105/** Pointer to a debug module segment. */
106typedef RTDBGSEGMENT *PRTDBGSEGMENT;
107/** Pointer to a const debug module segment. */
108typedef RTDBGSEGMENT const *PCRTDBGSEGMENT;
109
110
111
112/** Max length (including '\\0') of a symbol name. */
113#define RTDBG_SYMBOL_NAME_LENGTH (512 - 8 - 8 - 8 - 4 - 4 - 8)
114
115/**
116 * Debug symbol.
117 */
118typedef struct RTDBGSYMBOL
119{
120 /** Symbol value (address).
121 * This depends a bit who you ask. It will be the same as offSeg when you
122 * as RTDbgMod, but the mapping address if you ask RTDbgAs. */
123 RTUINTPTR Value;
124 /** Symbol size. */
125 RTUINTPTR cb;
126 /** Offset into the segment specified by iSeg. */
127 RTUINTPTR offSeg;
128 /** Segment number. */
129 RTDBGSEGIDX iSeg;
130 /** Symbol Flags. (reserved). */
131 uint32_t fFlags;
132 /** Symbol ordinal.
133 * This is set to UINT32_MAX if the ordinals aren't supported. */
134 uint32_t iOrdinal;
135 /** Symbol name. */
136 char szName[RTDBG_SYMBOL_NAME_LENGTH];
137} RTDBGSYMBOL;
138/** Pointer to debug symbol. */
139typedef RTDBGSYMBOL *PRTDBGSYMBOL;
140/** Pointer to const debug symbol. */
141typedef const RTDBGSYMBOL *PCRTDBGSYMBOL;
142
143/**
144 * Allocate a new symbol structure.
145 *
146 * @returns Pointer to a new structure on success, NULL on failure.
147 */
148RTDECL(PRTDBGSYMBOL) RTDbgSymbolAlloc(void);
149
150/**
151 * Duplicates a symbol structure.
152 *
153 * @returns Pointer to duplicate on success, NULL on failure.
154 *
155 * @param pSymInfo The symbol info to duplicate.
156 */
157RTDECL(PRTDBGSYMBOL) RTDbgSymbolDup(PCRTDBGSYMBOL pSymInfo);
158
159/**
160 * Free a symbol structure previously allocated by a RTDbg method.
161 *
162 * @param pSymInfo The symbol info to free. NULL is ignored.
163 */
164RTDECL(void) RTDbgSymbolFree(PRTDBGSYMBOL pSymInfo);
165
166
167/** Max length (including '\\0') of a debug info file name. */
168#define RTDBG_FILE_NAME_LENGTH (260)
169
170
171/**
172 * Debug line number information.
173 */
174typedef struct RTDBGLINE
175{
176 /** Address.
177 * This depends a bit who you ask. It will be the same as offSeg when you
178 * as RTDbgMod, but the mapping address if you ask RTDbgAs. */
179 RTUINTPTR Address;
180 /** Offset into the segment specified by iSeg. */
181 RTUINTPTR offSeg;
182 /** Segment number. */
183 RTDBGSEGIDX iSeg;
184 /** Line number. */
185 uint32_t uLineNo;
186 /** Symbol ordinal.
187 * This is set to UINT32_MAX if the ordinals aren't supported. */
188 uint32_t iOrdinal;
189 /** Filename. */
190 char szFilename[RTDBG_FILE_NAME_LENGTH];
191} RTDBGLINE;
192/** Pointer to debug line number. */
193typedef RTDBGLINE *PRTDBGLINE;
194/** Pointer to const debug line number. */
195typedef const RTDBGLINE *PCRTDBGLINE;
196
197/**
198 * Allocate a new line number structure.
199 *
200 * @returns Pointer to a new structure on success, NULL on failure.
201 */
202RTDECL(PRTDBGLINE) RTDbgLineAlloc(void);
203
204/**
205 * Duplicates a line number structure.
206 *
207 * @returns Pointer to duplicate on success, NULL on failure.
208 *
209 * @param pLine The line number to duplicate.
210 */
211RTDECL(PRTDBGLINE) RTDbgLineDup(PCRTDBGLINE pLine);
212
213/**
214 * Free a line number structure previously allocated by a RTDbg method.
215 *
216 * @param pLine The line number to free. NULL is ignored.
217 */
218RTDECL(void) RTDbgLineFree(PRTDBGLINE pLine);
219
220
221/** @defgroup grp_rt_dbgcfg RTDbgCfg - Debugging Configuration
222 *
223 * The settings used when loading and processing debug info is kept in a
224 * RTDBGCFG instance since it's generally shared for a whole debugging session
225 * and anyhow would be a major pain to pass as individual parameters to each
226 * call. The debugging config API not only keeps the settings information but
227 * also provide APIs for making use of it, and in some cases, like for instance
228 * symbol severs, retriving and maintaining it.
229 *
230 * @todo Work in progress - APIs are still missing, adding when needed.
231 *
232 * @{
233 */
234
235/** Debugging configuration handle. */
236typedef struct RTDBGCFGINT *RTDBGCFG;
237/** Pointer to a debugging configuration handle. */
238typedef RTDBGCFG *PRTDBGCFG;
239/** NIL debug configuration handle. */
240#define NIL_RTDBGCFG ((RTDBGCFG)0)
241
242/** @name RTDBGCFG_FLAGS_XXX - Debugging configuration flags.
243 * @{ */
244/** Use deferred loading. */
245#define RTDBGCFG_FLAGS_DEFERRED RT_BIT_64(0)
246/** Don't use the symbol server (http). */
247#define RTDBGCFG_FLAGS_NO_SYM_SRV RT_BIT_64(1)
248/** Don't use system search paths.
249 * On windows this means not using _NT_ALT_SYMBOL_PATH, _NT_SYMBOL_PATH,
250 * _NT_SOURCE_PATH, and _NT_EXECUTABLE_PATH.
251 * On other systems the effect has yet to be determined. */
252#define RTDBGCFG_FLAGS_NO_SYSTEM_PATHS RT_BIT_64(2)
253/** Don't search the debug and image paths recursively. */
254#define RTDBGCFG_FLAGS_NO_RECURSIV_SEARCH RT_BIT_64(3)
255/** Don't search the source paths recursively. */
256#define RTDBGCFG_FLAGS_NO_RECURSIV_SRC_SEARCH RT_BIT_64(4)
257/** @} */
258
259/**
260 * Debugging configuration properties.
261 *
262 * The search paths are using the DOS convention of semicolon as separator
263 * character. The the special 'srv' + asterisk syntax known from the windows
264 * debugger search paths are also supported to some extent, as is 'cache' +
265 * asterisk.
266 */
267typedef enum RTDBGCFGPROP
268{
269 /** The customary invalid 0 value. */
270 RTDBGCFGPROP_INVALID = 0,
271 /** RTDBGCFG_FLAGS_XXX.
272 * Env: _FLAGS
273 * The environment variable can be specified as a unsigned value or one or more
274 * mnemonics separated by spaces. */
275 RTDBGCFGPROP_FLAGS,
276 /** List of paths to search for symbol files and images.
277 * Env: _PATH */
278 RTDBGCFGPROP_PATH,
279 /** List of symbol file suffixes (semicolon separated).
280 * Env: _SUFFIXES */
281 RTDBGCFGPROP_SUFFIXES,
282 /** List of paths to search for source files.
283 * Env: _SRC_PATH */
284 RTDBGCFGPROP_SRC_PATH,
285 /** End of valid values. */
286 RTDBGCFGPROP_END,
287 /** The customary 32-bit type hack. */
288 RTDBGCFGPROP_32BIT_HACK = 0x7fffffff
289} RTDBGCFGPROP;
290
291/**
292 * Configuration property change operation.
293 */
294typedef enum RTDBGCFGOP
295{
296 /** Customary invalid 0 value. */
297 RTDBGCFGOP_INVALID = 0,
298 /** Replace the current value with the given one. */
299 RTDBGCFGOP_SET,
300 /** Append the given value to the existing one. For integer values this is
301 * considered a bitwise OR operation. */
302 RTDBGCFGOP_APPEND,
303 /** Prepend the given value to the existing one. For integer values this is
304 * considered a bitwise OR operation. */
305 RTDBGCFGOP_PREPEND,
306 /** Removes the value from the existing one. For interger values the value is
307 * complemented and ANDed with the existing one, clearing all the specified
308 * flags/bits. */
309 RTDBGCFGOP_REMOVE,
310 /** End of valid values. */
311 RTDBGCFGOP_END,
312 /** Customary 32-bit type hack. */
313 RTDBGCFGOP_32BIT_HACK = 0x7fffffff
314} RTDBGCFGOP;
315
316
317
318/**
319 * Initializes a debugging configuration.
320 *
321 * @returns IPRT status code.
322 * @param phDbgCfg Where to return the configuration handle.
323 * @param pszEnvVarPrefix The environment variable prefix. If NULL, the
324 * environment is not consulted.
325 * @param fNativePaths Whether to pick up native paths from the
326 * environment.
327 *
328 * @sa RTDbgCfgChangeString, RTDbgCfgChangeUInt.
329 */
330RTDECL(int) RTDbgCfgCreate(PRTDBGCFG phDbgCfg, const char *pszEnvVarPrefix, bool fNativePaths);
331
332/**
333 * Retains a new reference to a debugging config.
334 *
335 * @returns New reference count.
336 * UINT32_MAX is returned if the handle is invalid (asserted).
337 * @param hDbgCfg The config handle.
338 */
339RTDECL(uint32_t) RTDbgCfgRetain(RTDBGCFG hDbgCfg);
340
341/**
342 * Releases a references to a debugging config.
343 *
344 * @returns New reference count, if 0 the config was freed. UINT32_MAX is
345 * returned if the handle is invalid (asserted).
346 * @param hDbgCfg The config handle.
347 */
348RTDECL(uint32_t) RTDbgCfgRelease(RTDBGCFG hDbgCfg);
349
350/**
351 * Changes a property value by string.
352 *
353 * For string values the string is used more or less as given. For integer
354 * values and flags, it can contains both values (ORed together) or property
355 * specific mnemonics (ORed / ~ANDed).
356 *
357 * @returns IPRT status code.
358 * @retval VERR_DBG_CFG_INVALID_VALUE
359 * @param hDbgCfg The debugging configuration handle.
360 * @param enmProp The property to change.
361 * @param enmOp How to change the property.
362 * @param pszValue The property value to apply.
363 */
364RTDECL(int) RTDbgCfgChangeString(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, RTDBGCFGOP enmOp, const char *pszValue);
365
366/**
367 * Changes a property value by unsigned integer (64-bit).
368 *
369 * This can only be applied to integer and flag properties.
370 *
371 * @returns IPRT status code.
372 * @retval VERR_DBG_CFG_NOT_UINT_PROP
373 * @param hDbgCfg The debugging configuration handle.
374 * @param enmProp The property to change.
375 * @param enmOp How to change the property.
376 * @param uValue The property value to apply.
377 */
378RTDECL(int) RTDbgCfgChangeUInt(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, RTDBGCFGOP enmOp, uint64_t uValue);
379
380/**
381 * Query a property value as string.
382 *
383 * Integer and flags properties are returned as a list of mnemonics if possible,
384 * otherwise as simple hex values.
385 *
386 * @returns IPRT status code.
387 * @retval VERR_BUFFER_OVERFLOW if there isn't sufficient buffer space. Nothing
388 * is written.
389 * @param hDbgCfg The debugging configuration handle.
390 * @param enmProp The property to change.
391 * @param pszValue The output buffer.
392 * @param cbValue The size of the output buffer.
393 */
394RTDECL(int) RTDbgCfgQueryString(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, char *pszValue, size_t cbValue);
395
396/**
397 * Query a property value as unsigned integer (64-bit).
398 *
399 * Only integer and flags properties can be queried this way.
400 *
401 * @returns IPRT status code.
402 * @retval VERR_DBG_CFG_NOT_UINT_PROP
403 * @param hDbgCfg The debugging configuration handle.
404 * @param enmProp The property to change.
405 * @param puValue Where to return the value.
406 */
407RTDECL(int) RTDbgCfgQueryUInt(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, uint64_t *puValue);
408
409/**
410 * Log callback.
411 *
412 * @param hDbgCfg The debug config instance.
413 * @param iLevel The message level.
414 * @param pszMsg The message.
415 * @param pvUser User argument.
416 */
417typedef DECLCALLBACK(void) FNRTDBGCFGLOG(RTDBGCFG hDbgCfg, uint32_t iLevel, const char *pszMsg, void *pvUser);
418/** Pointer to a log callback. */
419typedef FNRTDBGCFGLOG *PFNRTDBGCFGLOG;
420
421/**
422 * Sets the log callback for the configuration.
423 *
424 * This will fail if there is already a log callback present, unless pfnCallback
425 * is NULL.
426 *
427 * @returns IPRT status code.
428 * @param hDbgCfg The debugging configuration handle.
429 * @param pfnCallback The callback function. NULL to unset.
430 * @param pvUser The user argument.
431 */
432RTDECL(int) RTDbgCfgSetLogCallback(RTDBGCFG hDbgCfg, PFNRTDBGCFGLOG pfnCallback, void *pvUser);
433
434/**
435 * Callback used by the RTDbgCfgOpen function to try out a file that was found.
436 *
437 * @returns On statuses other than VINF_CALLBACK_RETURN and
438 * VERR_CALLBACK_RETURN the search will continue till the end of the
439 * list. These status codes will not necessarily be propagated to the
440 * caller in any consistent manner.
441 * @retval VINF_CALLBACK_RETURN if successuflly opened the file and it's time
442 * to return
443 * @retval VERR_CALLBACK_RETURN if we shouldn't stop searching.
444 *
445 * @param hDbgCfg The debugging configuration handle.
446 * @param pszFilename The path to the file that should be tried out.
447 * @param pvUser1 First user parameter.
448 * @param pvUser2 Second user parameter.
449 */
450typedef DECLCALLBACK(int) FNRTDBGCFGOPEN(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2);
451/** Pointer to a open-file callback used to the RTDbgCfgOpen functions. */
452typedef FNRTDBGCFGOPEN *PFNRTDBGCFGOPEN;
453
454
455RTDECL(int) RTDbgCfgOpenPeImage(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t cbImage, uint32_t uTimestamp,
456 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
457RTDECL(int) RTDbgCfgOpenPdb70(RTDBGCFG hDbgCfg, const char *pszFilename, PCRTUUID pUuid, uint32_t uAge,
458 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
459RTDECL(int) RTDbgCfgOpenPdb20(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t cbImage, uint32_t uTimestamp, uint32_t uAge,
460 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
461RTDECL(int) RTDbgCfgOpenDbg(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t cbImage, uint32_t uTimestamp,
462 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
463RTDECL(int) RTDbgCfgOpenDwo(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t uCrc32,
464 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
465RTDECL(int) RTDbgCfgOpenDsymBundle(RTDBGCFG hDbgCfg, const char *pszFilename, PCRTUUID pUuid,
466 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
467RTDECL(int) RTDbgCfgOpenMachOImage(RTDBGCFG hDbgCfg, const char *pszFilename, PCRTUUID pUuid,
468 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
469
470
471/** @name Static symbol cache configuration
472 * @{ */
473/** The cache subdirectory containing the UUID mappings for .dSYM bundles.
474 * The UUID mappings implemented by IPRT are splitting the image/dsym UUID up
475 * into five 4 digit parts that maps to directories and one twelve digit part
476 * that maps to a symbolic link. The symlink points to the file in the
477 * Contents/Resources/DWARF/ directory of the .dSYM bundle for a .dSYM map, and
478 * to the image file (Contents/MacOS/bundlename for bundles) for image map.
479 *
480 * According to available documentation, both lldb and gdb are able to use these
481 * UUID maps to find debug info while debugging. See:
482 * http://lldb.llvm.org/symbols.html
483 */
484#define RTDBG_CACHE_UUID_MAP_DIR_DSYMS "dsym-uuids"
485/** The cache subdirectory containing the UUID mappings for image files. */
486#define RTDBG_CACHE_UUID_MAP_DIR_IMAGES "image-uuids"
487/** Suffix used for the cached .dSYM debug files.
488 * In .dSYM bundles only the .dSYM/Contents/Resources/DWARF/debug-file is
489 * copied into the cache, and in order to not clash with the stripped/rich image
490 * file, the cache tool slaps this suffix onto the name. */
491#define RTDBG_CACHE_DSYM_FILE_SUFFIX ".dwarf"
492/** @} */
493
494
495/** @} */
496
497
498/** @defgroup grp_rt_dbgas RTDbgAs - Debug Address Space
499 * @{
500 */
501
502/**
503 * Creates an empty address space.
504 *
505 * @returns IPRT status code.
506 *
507 * @param phDbgAs Where to store the address space handle on success.
508 * @param FirstAddr The first address in the address space.
509 * @param LastAddr The last address in the address space.
510 * @param pszName The name of the address space.
511 */
512RTDECL(int) RTDbgAsCreate(PRTDBGAS phDbgAs, RTUINTPTR FirstAddr, RTUINTPTR LastAddr, const char *pszName);
513
514/**
515 * Variant of RTDbgAsCreate that takes a name format string.
516 *
517 * @returns IPRT status code.
518 *
519 * @param phDbgAs Where to store the address space handle on success.
520 * @param FirstAddr The first address in the address space.
521 * @param LastAddr The last address in the address space.
522 * @param pszNameFmt The name format of the address space.
523 * @param va Format arguments.
524 */
525RTDECL(int) RTDbgAsCreateV(PRTDBGAS phDbgAs, RTUINTPTR FirstAddr, RTUINTPTR LastAddr,
526 const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(4, 0);
527
528/**
529 * Variant of RTDbgAsCreate that takes a name format string.
530 *
531 * @returns IPRT status code.
532 *
533 * @param phDbgAs Where to store the address space handle on success.
534 * @param FirstAddr The first address in the address space.
535 * @param LastAddr The last address in the address space.
536 * @param pszNameFmt The name format of the address space.
537 * @param ... Format arguments.
538 */
539RTDECL(int) RTDbgAsCreateF(PRTDBGAS phDbgAs, RTUINTPTR FirstAddr, RTUINTPTR LastAddr,
540 const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(4, 5);
541
542/**
543 * Retains a reference to the address space.
544 *
545 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
546 *
547 * @param hDbgAs The address space handle.
548 *
549 * @remarks Will not take any locks.
550 */
551RTDECL(uint32_t) RTDbgAsRetain(RTDBGAS hDbgAs);
552
553/**
554 * Release a reference to the address space.
555 *
556 * When the reference count reaches zero, the address space is destroyed.
557 * That means unlinking all the modules it currently contains, potentially
558 * causing some or all of them to be destroyed as they are managed by
559 * reference counting.
560 *
561 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
562 *
563 * @param hDbgAs The address space handle. The NIL handle is quietly
564 * ignored and 0 is returned.
565 *
566 * @remarks Will not take any locks.
567 */
568RTDECL(uint32_t) RTDbgAsRelease(RTDBGAS hDbgAs);
569
570/**
571 * Locks the address space for exclusive access.
572 *
573 * @returns IRPT status code
574 * @param hDbgAs The address space handle.
575 */
576RTDECL(int) RTDbgAsLockExcl(RTDBGAS hDbgAs);
577
578/**
579 * Counters the actions of one RTDbgAsUnlockExcl call.
580 *
581 * @returns IRPT status code
582 * @param hDbgAs The address space handle.
583 */
584RTDECL(int) RTDbgAsUnlockExcl(RTDBGAS hDbgAs);
585
586/**
587 * Gets the name of an address space.
588 *
589 * @returns read only address space name.
590 * NULL if hDbgAs is invalid.
591 *
592 * @param hDbgAs The address space handle.
593 *
594 * @remarks Will not take any locks.
595 */
596RTDECL(const char *) RTDbgAsName(RTDBGAS hDbgAs);
597
598/**
599 * Gets the first address in an address space.
600 *
601 * @returns The address.
602 * 0 if hDbgAs is invalid.
603 *
604 * @param hDbgAs The address space handle.
605 *
606 * @remarks Will not take any locks.
607 */
608RTDECL(RTUINTPTR) RTDbgAsFirstAddr(RTDBGAS hDbgAs);
609
610/**
611 * Gets the last address in an address space.
612 *
613 * @returns The address.
614 * 0 if hDbgAs is invalid.
615 *
616 * @param hDbgAs The address space handle.
617 *
618 * @remarks Will not take any locks.
619 */
620RTDECL(RTUINTPTR) RTDbgAsLastAddr(RTDBGAS hDbgAs);
621
622/**
623 * Gets the number of modules in the address space.
624 *
625 * This can be used together with RTDbgAsModuleByIndex
626 * to enumerate the modules.
627 *
628 * @returns The number of modules.
629 *
630 * @param hDbgAs The address space handle.
631 *
632 * @remarks Will not take any locks.
633 */
634RTDECL(uint32_t) RTDbgAsModuleCount(RTDBGAS hDbgAs);
635
636/** @name Flags for RTDbgAsModuleLink and RTDbgAsModuleLinkSeg
637 * @{ */
638/** Replace all conflicting module.
639 * (The conflicting modules will be removed the address space and their
640 * references released.) */
641#define RTDBGASLINK_FLAGS_REPLACE RT_BIT_32(0)
642/** Mask containing the valid flags. */
643#define RTDBGASLINK_FLAGS_VALID_MASK UINT32_C(0x00000001)
644/** @} */
645
646/**
647 * Links a module into the address space at the give address.
648 *
649 * The size of the mapping is determined using RTDbgModImageSize().
650 *
651 * @returns IPRT status code.
652 * @retval VERR_OUT_OF_RANGE if the specified address will put the module
653 * outside the address space.
654 * @retval VERR_ADDRESS_CONFLICT if the mapping clashes with existing mappings.
655 *
656 * @param hDbgAs The address space handle.
657 * @param hDbgMod The module handle of the module to be linked in.
658 * @param ImageAddr The address to link the module at.
659 * @param fFlags See RTDBGASLINK_FLAGS_*.
660 */
661RTDECL(int) RTDbgAsModuleLink(RTDBGAS hDbgAs, RTDBGMOD hDbgMod, RTUINTPTR ImageAddr, uint32_t fFlags);
662
663/**
664 * Links a segment into the address space at the give address.
665 *
666 * The size of the mapping is determined using RTDbgModSegmentSize().
667 *
668 * @returns IPRT status code.
669 * @retval VERR_OUT_OF_RANGE if the specified address will put the module
670 * outside the address space.
671 * @retval VERR_ADDRESS_CONFLICT if the mapping clashes with existing mappings.
672 *
673 * @param hDbgAs The address space handle.
674 * @param hDbgMod The module handle.
675 * @param iSeg The segment number (0-based) of the segment to be
676 * linked in.
677 * @param SegAddr The address to link the segment at.
678 * @param fFlags See RTDBGASLINK_FLAGS_*.
679 */
680RTDECL(int) RTDbgAsModuleLinkSeg(RTDBGAS hDbgAs, RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR SegAddr, uint32_t fFlags);
681
682/**
683 * Unlinks all the mappings of a module from the address space.
684 *
685 * @returns IPRT status code.
686 * @retval VERR_NOT_FOUND if the module wasn't found.
687 *
688 * @param hDbgAs The address space handle.
689 * @param hDbgMod The module handle of the module to be unlinked.
690 */
691RTDECL(int) RTDbgAsModuleUnlink(RTDBGAS hDbgAs, RTDBGMOD hDbgMod);
692
693/**
694 * Unlinks the mapping at the specified address.
695 *
696 * @returns IPRT status code.
697 * @retval VERR_NOT_FOUND if no module or segment is mapped at that address.
698 *
699 * @param hDbgAs The address space handle.
700 * @param Addr The address within the mapping to be unlinked.
701 */
702RTDECL(int) RTDbgAsModuleUnlinkByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr);
703
704/**
705 * Get a the handle of a module in the address space by is index.
706 *
707 * @returns A retained handle to the specified module. The caller must release
708 * the returned reference.
709 * NIL_RTDBGMOD if invalid index or handle.
710 *
711 * @param hDbgAs The address space handle.
712 * @param iModule The index of the module to get.
713 *
714 * @remarks The module indexes may change after calls to RTDbgAsModuleLink,
715 * RTDbgAsModuleLinkSeg, RTDbgAsModuleUnlink and
716 * RTDbgAsModuleUnlinkByAddr.
717 */
718RTDECL(RTDBGMOD) RTDbgAsModuleByIndex(RTDBGAS hDbgAs, uint32_t iModule);
719
720/**
721 * Queries mapping module information by handle.
722 *
723 * @returns IPRT status code.
724 * @retval VERR_NOT_FOUND if no mapping was found at the specified address.
725 *
726 * @param hDbgAs The address space handle.
727 * @param Addr Address within the mapping of the module or segment.
728 * @param phMod Where to the return the retained module handle.
729 * Optional.
730 * @param pAddr Where to return the base address of the mapping.
731 * Optional.
732 * @param piSeg Where to return the segment index. This is set to
733 * NIL if the entire module is mapped as a single
734 * mapping. Optional.
735 */
736RTDECL(int) RTDbgAsModuleByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTDBGMOD phMod, PRTUINTPTR pAddr, PRTDBGSEGIDX piSeg);
737
738/**
739 * Queries mapping module information by name.
740 *
741 * @returns IPRT status code.
742 * @retval VERR_NOT_FOUND if no mapping was found at the specified address.
743 * @retval VERR_OUT_OF_RANGE if the name index was out of range.
744 *
745 * @param hDbgAs The address space handle.
746 * @param pszName The module name.
747 * @param iName There can be more than one module by the same name
748 * in an address space. This argument indicates which
749 * is meant. (0 based)
750 * @param phMod Where to the return the retained module handle.
751 */
752RTDECL(int) RTDbgAsModuleByName(RTDBGAS hDbgAs, const char *pszName, uint32_t iName, PRTDBGMOD phMod);
753
754/**
755 * Information about a mapping.
756 *
757 * This is used by RTDbgAsModuleGetMapByIndex.
758 */
759typedef struct RTDBGASMAPINFO
760{
761 /** The mapping address. */
762 RTUINTPTR Address;
763 /** The segment mapped there.
764 * This is NIL_RTDBGSEGIDX if the entire module image is mapped here. */
765 RTDBGSEGIDX iSeg;
766} RTDBGASMAPINFO;
767/** Pointer to info about an address space mapping. */
768typedef RTDBGASMAPINFO *PRTDBGASMAPINFO;
769/** Pointer to const info about an address space mapping. */
770typedef RTDBGASMAPINFO const *PCRTDBGASMAPINFO;
771
772/**
773 * Queries mapping information for a module given by index.
774 *
775 * @returns IRPT status code.
776 * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
777 * @retval VERR_OUT_OF_RANGE if the name index was out of range.
778 * @retval VINF_BUFFER_OVERFLOW if the array is too small and the returned
779 * information is incomplete.
780 *
781 * @param hDbgAs The address space handle.
782 * @param iModule The index of the module to get.
783 * @param paMappings Where to return the mapping information. The buffer
784 * size is given by *pcMappings.
785 * @param pcMappings IN: Size of the paMappings array. OUT: The number of
786 * entries returned.
787 * @param fFlags Flags for reserved for future use. MBZ.
788 *
789 * @remarks See remarks for RTDbgAsModuleByIndex regarding the volatility of the
790 * iModule parameter.
791 */
792RTDECL(int) RTDbgAsModuleQueryMapByIndex(RTDBGAS hDbgAs, uint32_t iModule, PRTDBGASMAPINFO paMappings, uint32_t *pcMappings, uint32_t fFlags);
793
794/**
795 * Adds a symbol to a module in the address space.
796 *
797 * @returns IPRT status code. See RTDbgModSymbolAdd for more specific ones.
798 * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
799 * @retval VERR_NOT_FOUND if no module was found at the specified address.
800 * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding
801 * custom symbols.
802 *
803 * @param hDbgAs The address space handle.
804 * @param pszSymbol The symbol name.
805 * @param Addr The address of the symbol.
806 * @param cb The size of the symbol.
807 * @param fFlags Symbol flags.
808 * @param piOrdinal Where to return the symbol ordinal on success. If
809 * the interpreter doesn't do ordinals, this will be set to
810 * UINT32_MAX. Optional
811 */
812RTDECL(int) RTDbgAsSymbolAdd(RTDBGAS hDbgAs, const char *pszSymbol, RTUINTPTR Addr, RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal);
813
814/**
815 * Query a symbol by address.
816 *
817 * @returns IPRT status code. See RTDbgModSymbolAddr for more specific ones.
818 * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
819 * @retval VERR_NOT_FOUND if the address couldn't be mapped to a module.
820 * @retval VERR_INVALID_PARAMETER if incorrect flags.
821 *
822 * @param hDbgAs The address space handle.
823 * @param Addr The address which closest symbol is requested.
824 * @param fFlags Symbol search flags, see RTDBGSYMADDR_FLAGS_XXX.
825 * @param poffDisp Where to return the distance between the symbol
826 * and address. Optional.
827 * @param pSymbol Where to return the symbol info.
828 * @param phMod Where to return the module handle. Optional.
829 */
830RTDECL(int) RTDbgAsSymbolByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, uint32_t fFlags,
831 PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
832
833/**
834 * Query a symbol by address.
835 *
836 * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
837 * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
838 * @retval VERR_NOT_FOUND if the address couldn't be mapped to a module.
839 * @retval VERR_INVALID_PARAMETER if incorrect flags.
840 *
841 * @param hDbgAs The address space handle.
842 * @param Addr The address which closest symbol is requested.
843 * @param fFlags Symbol search flags, see RTDBGSYMADDR_FLAGS_XXX.
844 * @param poffDisp Where to return the distance between the symbol
845 * and address. Optional.
846 * @param ppSymInfo Where to return the pointer to the allocated symbol
847 * info. Always set. Free with RTDbgSymbolFree.
848 * @param phMod Where to return the module handle. Optional.
849 */
850RTDECL(int) RTDbgAsSymbolByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, uint32_t fFlags,
851 PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo, PRTDBGMOD phMod);
852
853/**
854 * Query a symbol by name.
855 *
856 * @returns IPRT status code.
857 * @retval VERR_SYMBOL_NOT_FOUND if not found.
858 *
859 * @param hDbgAs The address space handle.
860 * @param pszSymbol The symbol name. It is possible to limit the scope
861 * of the search by prefixing the symbol with a module
862 * name pattern followed by a bang (!) character.
863 * RTStrSimplePatternNMatch is used for the matching.
864 * @param pSymbol Where to return the symbol info.
865 * @param phMod Where to return the module handle. Optional.
866 */
867RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
868
869/**
870 * Query a symbol by name, allocating the returned symbol structure.
871 *
872 * @returns IPRT status code.
873 * @retval VERR_SYMBOL_NOT_FOUND if not found.
874 *
875 * @param hDbgAs The address space handle.
876 * @param pszSymbol The symbol name. See RTDbgAsSymbolByName for more.
877 * @param ppSymbol Where to return the pointer to the allocated
878 * symbol info. Always set. Free with RTDbgSymbolFree.
879 * @param phMod Where to return the module handle. Optional.
880 */
881RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol, PRTDBGMOD phMod);
882
883/**
884 * Adds a line number to a module in the address space.
885 *
886 * @returns IPRT status code. See RTDbgModLineAdd for more specific ones.
887 * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
888 * @retval VERR_NOT_FOUND if no module was found at the specified address.
889 * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding
890 * custom symbols.
891 *
892 * @param hDbgAs The address space handle.
893 * @param pszFile The file name.
894 * @param uLineNo The line number.
895 * @param Addr The address of the symbol.
896 * @param piOrdinal Where to return the line number ordinal on success.
897 * If the interpreter doesn't do ordinals, this will be
898 * set to UINT32_MAX. Optional.
899 */
900RTDECL(int) RTDbgAsLineAdd(RTDBGAS hDbgAs, const char *pszFile, uint32_t uLineNo, RTUINTPTR Addr, uint32_t *piOrdinal);
901
902/**
903 * Query a line number by address.
904 *
905 * @returns IPRT status code. See RTDbgModLineAddrA for more specific ones.
906 * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
907 * @retval VERR_NOT_FOUND if the address couldn't be mapped to a module.
908 *
909 * @param hDbgAs The address space handle.
910 * @param Addr The address which closest symbol is requested.
911 * @param poffDisp Where to return the distance between the line
912 * number and address.
913 * @param pLine Where to return the line number information.
914 * @param phMod Where to return the module handle. Optional.
915 */
916RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod);
917
918/**
919 * Query a line number by address.
920 *
921 * @returns IPRT status code. See RTDbgModLineAddrA for more specific ones.
922 * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
923 * @retval VERR_NOT_FOUND if the address couldn't be mapped to a module.
924 *
925 * @param hDbgAs The address space handle.
926 * @param Addr The address which closest symbol is requested.
927 * @param poffDisp Where to return the distance between the line
928 * number and address.
929 * @param ppLine Where to return the pointer to the allocated line
930 * number info. Always set. Free with RTDbgLineFree.
931 * @param phMod Where to return the module handle. Optional.
932 */
933RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine, PRTDBGMOD phMod);
934
935/** @todo Missing some bits here. */
936
937/** @} */
938
939
940/** @defgroup grp_rt_dbgmod RTDbgMod - Debug Module Interpreter
941 * @{
942 */
943
944/**
945 * Creates a module based on the default debug info container.
946 *
947 * This can be used to manually load a module and its symbol. The primary user
948 * group is the debug info interpreters, which use this API to create an
949 * efficient debug info container behind the scenes and forward all queries to
950 * it once the info has been loaded.
951 *
952 * @returns IPRT status code.
953 *
954 * @param phDbgMod Where to return the module handle.
955 * @param pszName The name of the module (mandatory).
956 * @param cbSeg The size of initial segment. If zero, segments will
957 * have to be added manually using RTDbgModSegmentAdd.
958 * @param fFlags Flags reserved for future extensions, MBZ for now.
959 */
960RTDECL(int) RTDbgModCreate(PRTDBGMOD phDbgMod, const char *pszName, RTUINTPTR cbSeg, uint32_t fFlags);
961
962RTDECL(int) RTDbgModCreateFromImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName,
963 RTLDRARCH enmArch, RTDBGCFG hDbgCfg);
964RTDECL(int) RTDbgModCreateFromMap(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTUINTPTR uSubtrahend,
965 RTDBGCFG hDbgCfg);
966RTDECL(int) RTDbgModCreateFromPeImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName,
967 PRTLDRMOD phLdrMod, uint32_t cbImage, uint32_t uTimeDateStamp, RTDBGCFG hDbgCfg);
968RTDECL(int) RTDbgModCreateFromDbg(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t cbImage,
969 uint32_t uTimeDateStamp, RTDBGCFG hDbgCfg);
970RTDECL(int) RTDbgModCreateFromPdb(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t cbImage,
971 PCRTUUID pUuid, uint32_t Age, RTDBGCFG hDbgCfg);
972RTDECL(int) RTDbgModCreateFromDwo(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t cbImage,
973 uint32_t uCrc32, RTDBGCFG hDbgCfg);
974RTDECL(int) RTDbgModCreateFromMachOImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName,
975 RTLDRARCH enmArch, uint32_t cbImage, uint32_t cSegs, PCRTDBGSEGMENT paSegs,
976 PCRTUUID pUuid, RTDBGCFG hDbgCfg, uint32_t fFlags);
977
978/** @name Flags for RTDbgModCreate and friends.
979 * @{ */
980/** Overrides the hDbgCfg settings and forces an image and/or symbol file
981 * search. RTDbgModCreate will quietly ignore this flag. */
982#define RTDBGMOD_F_NOT_DEFERRED RT_BIT_32(0)
983/** @} */
984
985
986/**
987 * Retains another reference to the module.
988 *
989 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
990 *
991 * @param hDbgMod The module handle.
992 *
993 * @remarks Will not take any locks.
994 */
995RTDECL(uint32_t) RTDbgModRetain(RTDBGMOD hDbgMod);
996
997/**
998 * Release a reference to the module.
999 *
1000 * When the reference count reaches zero, the module is destroyed.
1001 *
1002 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
1003 *
1004 * @param hDbgMod The module handle. The NIL handle is quietly ignored
1005 * and 0 is returned.
1006 *
1007 * @remarks Will not take any locks.
1008 */
1009RTDECL(uint32_t) RTDbgModRelease(RTDBGMOD hDbgMod);
1010
1011/**
1012 * Removes all content from the debug module (container), optionally only
1013 * leaving segments and image size intact.
1014 *
1015 * This is only possible on container modules, i.e. created by RTDbgModCreate().
1016 *
1017 * @returns IPRT status code.
1018 * @param hDbgMod The module handle.
1019 * @param fLeaveSegments Whether to leave segments (and image size) as is.
1020 */
1021RTDECL(int) RTDbgModRemoveAll(RTDBGMOD hDbgMod, bool fLeaveSegments);
1022
1023/**
1024 * Gets the module name.
1025 *
1026 * @returns Pointer to a read only string containing the name.
1027 *
1028 * @param hDbgMod The module handle.
1029 */
1030RTDECL(const char *) RTDbgModName(RTDBGMOD hDbgMod);
1031
1032/**
1033 * Gets the name of the debug info file we're using.
1034 *
1035 * @returns Pointer to a read only string containing the filename, NULL if we
1036 * don't use one.
1037 *
1038 * @param hDbgMod The module handle.
1039 */
1040RTDECL(const char *) RTDbgModDebugFile(RTDBGMOD hDbgMod);
1041
1042/**
1043 * Gets the image filename (as specified by the user).
1044 *
1045 * @returns Pointer to a read only string containing the filename.
1046 *
1047 * @param hDbgMod The module handle.
1048 */
1049RTDECL(const char *) RTDbgModImageFile(RTDBGMOD hDbgMod);
1050
1051/**
1052 * Gets the image filename actually used if it differs from RTDbgModImageFile.
1053 *
1054 * @returns Pointer to a read only string containing the filename, NULL if same
1055 * as RTDBgModImageFile.
1056 *
1057 * @param hDbgMod The module handle.
1058 */
1059RTDECL(const char *) RTDbgModImageFileUsed(RTDBGMOD hDbgMod);
1060
1061/**
1062 * Checks if the loading of the debug info has been postponed.
1063 *
1064 * @returns true if postponed, false if not or invalid handle.
1065 * @param hDbgMod The module handle.
1066 */
1067RTDECL(bool) RTDbgModIsDeferred(RTDBGMOD hDbgMod);
1068
1069/**
1070 * Checks if the debug info is exports only.
1071 *
1072 * @returns true if exports only, false if not or invalid handle.
1073 * @param hDbgMod The module handle.
1074 */
1075RTDECL(bool) RTDbgModIsExports(RTDBGMOD hDbgMod);
1076
1077/**
1078 * Converts an image relative address to a segment:offset address.
1079 *
1080 * @returns Segment index on success.
1081 * NIL_RTDBGSEGIDX is returned if the module handle or the RVA are
1082 * invalid.
1083 *
1084 * @param hDbgMod The module handle.
1085 * @param uRva The image relative address to convert.
1086 * @param poffSeg Where to return the segment offset. Optional.
1087 */
1088RTDECL(RTDBGSEGIDX) RTDbgModRvaToSegOff(RTDBGMOD hDbgMod, RTUINTPTR uRva, PRTUINTPTR poffSeg);
1089
1090/**
1091 * Gets the module tag value if any.
1092 *
1093 * @returns The tag. 0 if hDbgMod is invalid.
1094 *
1095 * @param hDbgMod The module handle.
1096 */
1097RTDECL(uint64_t) RTDbgModGetTag(RTDBGMOD hDbgMod);
1098
1099/**
1100 * Tags or untags the module.
1101 *
1102 * @returns IPRT status code.
1103 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1104 *
1105 * @param hDbgMod The module handle.
1106 * @param uTag The tag value. The convention is that 0 is no tag
1107 * and any other value means it's tagged. It's adviced
1108 * to use some kind of unique number like an address
1109 * (global or string cache for instance) to avoid
1110 * collisions with other users
1111 */
1112RTDECL(int) RTDbgModSetTag(RTDBGMOD hDbgMod, uint64_t uTag);
1113
1114
1115/**
1116 * Image size when mapped if segments are mapped adjacently.
1117 *
1118 * For ELF, PE, and Mach-O images this is (usually) a natural query, for LX and
1119 * NE and such it's a bit odder and the answer may not make much sense for them.
1120 *
1121 * @returns Image mapped size.
1122 * RTUINTPTR_MAX is returned if the handle is invalid.
1123 *
1124 * @param hDbgMod The module handle.
1125 */
1126RTDECL(RTUINTPTR) RTDbgModImageSize(RTDBGMOD hDbgMod);
1127
1128/**
1129 * Gets the image format.
1130 *
1131 * @returns Image format.
1132 * @retval RTLDRFMT_INVALID if the handle is invalid or if the format isn't known.
1133 * @param hDbgMod The debug module handle.
1134 * @sa RTLdrGetFormat
1135 */
1136RTDECL(RTLDRFMT) RTDbgModImageGetFormat(RTDBGMOD hDbgMod);
1137
1138/**
1139 * Gets the image architecture.
1140 *
1141 * @returns Image architecture.
1142 * @retval RTLDRARCH_INVALID if the handle is invalid.
1143 * @retval RTLDRARCH_WHATEVER if unknown.
1144 * @param hDbgMod The debug module handle.
1145 * @sa RTLdrGetArch
1146 */
1147RTDECL(RTLDRARCH) RTDbgModImageGetArch(RTDBGMOD hDbgMod);
1148
1149/**
1150 * Generic method for querying image properties.
1151 *
1152 * @returns IPRT status code.
1153 * @retval VERR_NOT_SUPPORTED if the property query isn't supported (either all
1154 * or that specific property). The caller must handle this result.
1155 * @retval VERR_NOT_FOUND the property was not found in the module. The caller
1156 * must also normally deal with this.
1157 * @retval VERR_INVALID_FUNCTION if the function value is wrong.
1158 * @retval VERR_INVALID_PARAMETER if the fixed buffer size is wrong. Correct
1159 * size in @a *pcbRet.
1160 * @retval VERR_BUFFER_OVERFLOW if the function doesn't have a fixed size
1161 * buffer and the buffer isn't big enough. Correct size in @a *pcbRet.
1162 * @retval VERR_INVALID_HANDLE if the handle is invalid.
1163 *
1164 * @param hDbgMod The debug module handle.
1165 * @param enmProp The property to query.
1166 * @param pvBuf Pointer to the input / output buffer. In most cases
1167 * it's only used for returning data.
1168 * @param cbBuf The size of the buffer.
1169 * @param pcbRet Where to return the amount of data returned. On
1170 * buffer size errors, this is set to the correct size.
1171 * Optional.
1172 * @sa RTLdrQueryPropEx
1173 */
1174RTDECL(int) RTDbgModImageQueryProp(RTDBGMOD hDbgMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet);
1175
1176
1177/**
1178 * Adds a segment to the module. Optional feature.
1179 *
1180 * This method is intended used for manually constructing debug info for a
1181 * module. The main usage is from other debug info interpreters that want to
1182 * avoid writing a debug info database and instead uses the standard container
1183 * behind the scenes.
1184 *
1185 * @returns IPRT status code.
1186 * @retval VERR_NOT_SUPPORTED if this feature isn't support by the debug info
1187 * interpreter. This is a common return code.
1188 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1189 * @retval VERR_DBG_ADDRESS_WRAP if uRva+cb wraps around.
1190 * @retval VERR_DBG_SEGMENT_NAME_OUT_OF_RANGE if pszName is too short or long.
1191 * @retval VERR_INVALID_PARAMETER if fFlags contains undefined flags.
1192 * @retval VERR_DBG_SPECIAL_SEGMENT if *piSeg is a special segment.
1193 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if *piSeg doesn't meet expectations.
1194 *
1195 * @param hDbgMod The module handle.
1196 * @param uRva The image relative address of the segment.
1197 * @param cb The size of the segment.
1198 * @param pszName The segment name. Does not normally need to be
1199 * unique, although this is somewhat up to the
1200 * debug interpreter to decide.
1201 * @param fFlags Segment flags. Reserved for future used, MBZ.
1202 * @param piSeg The segment index or NIL_RTDBGSEGIDX on input.
1203 * The assigned segment index on successful return.
1204 * Optional.
1205 */
1206RTDECL(int) RTDbgModSegmentAdd(RTDBGMOD hDbgMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName,
1207 uint32_t fFlags, PRTDBGSEGIDX piSeg);
1208
1209/**
1210 * Gets the number of segments in the module.
1211 *
1212 * This is can be used to determine the range which can be passed to
1213 * RTDbgModSegmentByIndex and derivates.
1214 *
1215 * @returns The segment relative address.
1216 * NIL_RTDBGSEGIDX if the handle is invalid.
1217 *
1218 * @param hDbgMod The module handle.
1219 */
1220RTDECL(RTDBGSEGIDX) RTDbgModSegmentCount(RTDBGMOD hDbgMod);
1221
1222/**
1223 * Query information about a segment.
1224 *
1225 * This can be used together with RTDbgModSegmentCount to enumerate segments.
1226 * The index starts a 0 and stops one below RTDbgModSegmentCount.
1227 *
1228 * @returns IPRT status code.
1229 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if iSeg is too high.
1230 * @retval VERR_DBG_SPECIAL_SEGMENT if iSeg indicates a special segment.
1231 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1232 *
1233 * @param hDbgMod The module handle.
1234 * @param iSeg The segment index. No special segments.
1235 * @param pSegInfo Where to return the segment info. The
1236 * RTDBGSEGMENT::Address member will be set to
1237 * RTUINTPTR_MAX or the load address used at link time.
1238 */
1239RTDECL(int) RTDbgModSegmentByIndex(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo);
1240
1241/**
1242 * Gets the size of a segment.
1243 *
1244 * This is a just a wrapper around RTDbgModSegmentByIndex.
1245 *
1246 * @returns The segment size.
1247 * RTUINTPTR_MAX is returned if either the handle and segment index are
1248 * invalid.
1249 *
1250 * @param hDbgMod The module handle.
1251 * @param iSeg The segment index. RTDBGSEGIDX_ABS is not allowed.
1252 * If RTDBGSEGIDX_RVA is used, the functions returns
1253 * the same value as RTDbgModImageSize.
1254 */
1255RTDECL(RTUINTPTR) RTDbgModSegmentSize(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg);
1256
1257/**
1258 * Gets the image relative address of a segment.
1259 *
1260 * This is a just a wrapper around RTDbgModSegmentByIndex.
1261 *
1262 * @returns The segment relative address.
1263 * RTUINTPTR_MAX is returned if either the handle and segment index are
1264 * invalid.
1265 *
1266 * @param hDbgMod The module handle.
1267 * @param iSeg The segment index. No special segment indexes
1268 * allowed (asserted).
1269 */
1270RTDECL(RTUINTPTR) RTDbgModSegmentRva(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg);
1271
1272
1273/**
1274 * Adds a line number to the module.
1275 *
1276 * @returns IPRT status code.
1277 * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding
1278 * custom symbols. This is a common place occurrence.
1279 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1280 * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
1281 * short.
1282 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
1283 * it's not inside any of the segments defined by the module.
1284 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
1285 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
1286 * end of the segment.
1287 * @retval VERR_DBG_ADDRESS_WRAP if off+cb wraps around.
1288 * @retval VERR_INVALID_PARAMETER if the symbol flags sets undefined bits.
1289 *
1290 * @param hDbgMod The module handle.
1291 * @param pszSymbol The symbol name.
1292 * @param iSeg The segment index.
1293 * @param off The segment offset.
1294 * @param cb The size of the symbol. Can be zero, although this
1295 * may depend somewhat on the debug interpreter.
1296 * @param fFlags Symbol flags. Reserved for the future, MBZ.
1297 * @param piOrdinal Where to return the symbol ordinal on success. If
1298 * the interpreter doesn't do ordinals, this will be set to
1299 * UINT32_MAX. Optional.
1300 */
1301RTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off,
1302 RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal);
1303
1304/**
1305 * Gets the symbol count.
1306 *
1307 * This can be used together wtih RTDbgModSymbolByOrdinal or
1308 * RTDbgModSymbolByOrdinalA to enumerate all the symbols.
1309 *
1310 * @returns The number of symbols in the module.
1311 * UINT32_MAX is returned if the module handle is invalid or some other
1312 * error occurs.
1313 *
1314 * @param hDbgMod The module handle.
1315 */
1316RTDECL(uint32_t) RTDbgModSymbolCount(RTDBGMOD hDbgMod);
1317
1318/**
1319 * Queries symbol information by ordinal number.
1320 *
1321 * @returns IPRT status code.
1322 * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number.
1323 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
1324 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1325 * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
1326 *
1327 * @param hDbgMod The module handle.
1328 * @param iOrdinal The symbol ordinal number. 0-based. The highest
1329 * number is RTDbgModSymbolCount() - 1.
1330 * @param pSymInfo Where to store the symbol information.
1331 */
1332RTDECL(int) RTDbgModSymbolByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo);
1333
1334/**
1335 * Queries symbol information by ordinal number.
1336 *
1337 * @returns IPRT status code.
1338 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
1339 * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
1340 * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number.
1341 * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
1342 *
1343 * @param hDbgMod The module handle.
1344 * @param iOrdinal The symbol ordinal number. 0-based. The highest
1345 * number is RTDbgModSymbolCount() - 1.
1346 * @param ppSymInfo Where to store the pointer to the returned
1347 * symbol information. Always set. Free with
1348 * RTDbgSymbolFree.
1349 */
1350RTDECL(int) RTDbgModSymbolByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL *ppSymInfo);
1351
1352/**
1353 * Queries symbol information by address.
1354 *
1355 * The returned symbol is what the debug info interpreter considers the symbol
1356 * most applicable to the specified address. This usually means a symbol with an
1357 * address equal or lower than the requested.
1358 *
1359 * @returns IPRT status code.
1360 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
1361 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
1362 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1363 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
1364 * it's not inside any of the segments defined by the module.
1365 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
1366 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
1367 * end of the segment.
1368 * @retval VERR_INVALID_PARAMETER if incorrect flags.
1369 *
1370 * @param hDbgMod The module handle.
1371 * @param iSeg The segment number.
1372 * @param off The offset into the segment.
1373 * @param fFlags Symbol search flags, see RTDBGSYMADDR_FLAGS_XXX.
1374 * @param poffDisp Where to store the distance between the
1375 * specified address and the returned symbol.
1376 * Optional.
1377 * @param pSymInfo Where to store the symbol information.
1378 */
1379RTDECL(int) RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
1380 PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo);
1381
1382/**
1383 * Queries symbol information by address.
1384 *
1385 * The returned symbol is what the debug info interpreter considers the symbol
1386 * most applicable to the specified address. This usually means a symbol with an
1387 * address equal or lower than the requested.
1388 *
1389 * @returns IPRT status code.
1390 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
1391 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
1392 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1393 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
1394 * it's not inside any of the segments defined by the module.
1395 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
1396 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
1397 * end of the segment.
1398 * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
1399 * @retval VERR_INVALID_PARAMETER if incorrect flags.
1400 *
1401 * @param hDbgMod The module handle.
1402 * @param iSeg The segment index.
1403 * @param off The offset into the segment.
1404 * @param fFlags Symbol search flags, see RTDBGSYMADDR_FLAGS_XXX.
1405 * @param poffDisp Where to store the distance between the
1406 * specified address and the returned symbol. Optional.
1407 * @param ppSymInfo Where to store the pointer to the returned
1408 * symbol information. Always set. Free with
1409 * RTDbgSymbolFree.
1410 */
1411RTDECL(int) RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
1412 PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo);
1413
1414/**
1415 * Queries symbol information by symbol name.
1416 *
1417 * @returns IPRT status code.
1418 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
1419 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
1420 * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
1421 * short.
1422 *
1423 * @param hDbgMod The module handle.
1424 * @param pszSymbol The symbol name.
1425 * @param pSymInfo Where to store the symbol information.
1426 */
1427RTDECL(int) RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymInfo);
1428
1429/**
1430 * Queries symbol information by symbol name.
1431 *
1432 * @returns IPRT status code.
1433 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
1434 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
1435 * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
1436 * short.
1437 * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
1438 *
1439 * @param hDbgMod The module handle.
1440 * @param pszSymbol The symbol name.
1441 * @param ppSymInfo Where to store the pointer to the returned
1442 * symbol information. Always set. Free with
1443 * RTDbgSymbolFree.
1444 */
1445RTDECL(int) RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymInfo);
1446
1447/**
1448 * Adds a line number to the module.
1449 *
1450 * @returns IPRT status code.
1451 * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding
1452 * custom symbols. This should be consider a normal response.
1453 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1454 * @retval VERR_DBG_FILE_NAME_OUT_OF_RANGE if the file name is too longer or
1455 * empty.
1456 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
1457 * it's not inside any of the segments defined by the module.
1458 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
1459 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
1460 * end of the segment.
1461 * @retval VERR_INVALID_PARAMETER if the line number flags sets undefined bits.
1462 *
1463 * @param hDbgMod The module handle.
1464 * @param pszFile The file name.
1465 * @param uLineNo The line number.
1466 * @param iSeg The segment index.
1467 * @param off The segment offset.
1468 * @param piOrdinal Where to return the line number ordinal on
1469 * success. If the interpreter doesn't do ordinals,
1470 * this will be set to UINT32_MAX. Optional.
1471 */
1472RTDECL(int) RTDbgModLineAdd(RTDBGMOD hDbgMod, const char *pszFile, uint32_t uLineNo,
1473 RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t *piOrdinal);
1474
1475/**
1476 * Gets the line number count.
1477 *
1478 * This can be used together wtih RTDbgModLineByOrdinal or RTDbgModSymbolByLineA
1479 * to enumerate all the line number information.
1480 *
1481 * @returns The number of line numbers in the module.
1482 * UINT32_MAX is returned if the module handle is invalid or some other
1483 * error occurs.
1484 *
1485 * @param hDbgMod The module handle.
1486 */
1487RTDECL(uint32_t) RTDbgModLineCount(RTDBGMOD hDbgMod);
1488
1489/**
1490 * Queries line number information by ordinal number.
1491 *
1492 * This can be used to enumerate the line numbers for the module. Use
1493 * RTDbgModLineCount() to figure the end of the ordinals.
1494 *
1495 * @returns IPRT status code.
1496 * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
1497 * @retval VERR_DBG_LINE_NOT_FOUND if there is no line number with that
1498 * ordinal.
1499 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1500
1501 * @param hDbgMod The module handle.
1502 * @param iOrdinal The line number ordinal number.
1503 * @param pLineInfo Where to store the information about the line
1504 * number.
1505 */
1506RTDECL(int) RTDbgModLineByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo);
1507
1508/**
1509 * Queries line number information by ordinal number.
1510 *
1511 * This can be used to enumerate the line numbers for the module. Use
1512 * RTDbgModLineCount() to figure the end of the ordinals.
1513 *
1514 * @returns IPRT status code.
1515 * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
1516 * @retval VERR_DBG_LINE_NOT_FOUND if there is no line number with that
1517 * ordinal.
1518 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1519 * @retval VERR_NO_MEMORY if RTDbgLineAlloc fails.
1520 *
1521 * @param hDbgMod The module handle.
1522 * @param iOrdinal The line number ordinal number.
1523 * @param ppLineInfo Where to store the pointer to the returned line
1524 * number information. Always set. Free with
1525 * RTDbgLineFree.
1526 */
1527RTDECL(int) RTDbgModLineByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGLINE *ppLineInfo);
1528
1529/**
1530 * Queries line number information by address.
1531 *
1532 * The returned line number is what the debug info interpreter considers the
1533 * one most applicable to the specified address. This usually means a line
1534 * number with an address equal or lower than the requested.
1535 *
1536 * @returns IPRT status code.
1537 * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
1538 * @retval VERR_DBG_LINE_NOT_FOUND if no suitable line number was found.
1539 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1540 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
1541 * it's not inside any of the segments defined by the module.
1542 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
1543 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
1544 * end of the segment.
1545 *
1546 * @param hDbgMod The module handle.
1547 * @param iSeg The segment number.
1548 * @param off The offset into the segment.
1549 * @param poffDisp Where to store the distance between the
1550 * specified address and the returned symbol.
1551 * Optional.
1552 * @param pLineInfo Where to store the line number information.
1553 */
1554RTDECL(int) RTDbgModLineByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE pLineInfo);
1555
1556/**
1557 * Queries line number information by address.
1558 *
1559 * The returned line number is what the debug info interpreter considers the
1560 * one most applicable to the specified address. This usually means a line
1561 * number with an address equal or lower than the requested.
1562 *
1563 * @returns IPRT status code.
1564 * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
1565 * @retval VERR_DBG_LINE_NOT_FOUND if no suitable line number was found.
1566 * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
1567 * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
1568 * it's not inside any of the segments defined by the module.
1569 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
1570 * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
1571 * end of the segment.
1572 * @retval VERR_NO_MEMORY if RTDbgLineAlloc fails.
1573 *
1574 * @param hDbgMod The module handle.
1575 * @param iSeg The segment number.
1576 * @param off The offset into the segment.
1577 * @param poffDisp Where to store the distance between the
1578 * specified address and the returned symbol.
1579 * Optional.
1580 * @param ppLineInfo Where to store the pointer to the returned line
1581 * number information. Always set. Free with
1582 * RTDbgLineFree.
1583 */
1584RTDECL(int) RTDbgModLineByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE *ppLineInfo);
1585/** @} */
1586
1587# endif /* IN_RING3 */
1588
1589
1590/** @name Kernel Debug Info API
1591 *
1592 * This is a specialized API for obtaining symbols and structure information
1593 * about the running kernel. It is relatively OS specific. Its purpose and
1594 * operation is doesn't map all that well onto RTDbgMod, so a few dedicated
1595 * functions was created for it.
1596 *
1597 * @{ */
1598
1599/** Handle to the kernel debug info. */
1600typedef struct RTDBGKRNLINFOINT *RTDBGKRNLINFO;
1601/** Pointer to a kernel debug info handle. */
1602typedef RTDBGKRNLINFO *PRTDBGKRNLINFO;
1603/** Nil kernel debug info handle. */
1604#define NIL_RTDBGKRNLINFO ((RTDBGKRNLINFO)0)
1605
1606/**
1607 * Opens the kernel debug info.
1608 *
1609 * @returns IPRT status code. Can fail for any number of reasons.
1610 *
1611 * @param phKrnlInfo Where to return the kernel debug info handle on
1612 * success.
1613 * @param fFlags Flags reserved for future use. Must be zero.
1614 */
1615RTR0DECL(int) RTR0DbgKrnlInfoOpen(PRTDBGKRNLINFO phKrnlInfo, uint32_t fFlags);
1616
1617/**
1618 * Retains a reference to the kernel debug info handle.
1619 *
1620 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
1621 * @param hKrnlInfo The kernel info handle.
1622 */
1623RTR0DECL(uint32_t) RTR0DbgKrnlInfoRetain(RTDBGKRNLINFO hKrnlInfo);
1624
1625
1626/**
1627 * Releases a reference to the kernel debug info handle, destroying it when the
1628 * counter reaches zero.
1629 *
1630 * @returns New reference count, UINT32_MAX on invalid handle (asserted).
1631 * @param hKrnlInfo The kernel info handle. NIL_RTDBGKRNLINFO is
1632 * quietly ignored.
1633 */
1634RTR0DECL(uint32_t) RTR0DbgKrnlInfoRelease(RTDBGKRNLINFO hKrnlInfo);
1635
1636/**
1637 * Queries the offset (in bytes) of a member of a kernel structure.
1638 *
1639 * @returns IPRT status code.
1640 * @retval VINF_SUCCESS and offset at @a poffMember.
1641 * @retval VERR_NOT_FOUND if the structure or the member was not found.
1642 * @retval VERR_INVALID_HANDLE if hKrnlInfo is bad.
1643 * @retval VERR_INVALID_POINTER if any of the pointers are bad.
1644 *
1645 * @param hKrnlInfo The kernel info handle.
1646 * @param pszModule The name of the module to search, pass NULL to
1647 * search the default kernel module(s).
1648 * @param pszStructure The structure name.
1649 * @param pszMember The member name.
1650 * @param poffMember Where to return the offset.
1651 */
1652RTR0DECL(int) RTR0DbgKrnlInfoQueryMember(RTDBGKRNLINFO hKrnlInfo, const char *pszModule, const char *pszStructure,
1653 const char *pszMember, size_t *poffMember);
1654
1655
1656/**
1657 * Queries the value (usually the address) of a kernel symbol.
1658 *
1659 * This may go looking for the symbol in other modules, in which case it will
1660 * always check the kernel symbol table first.
1661 *
1662 * @returns IPRT status code.
1663 * @retval VINF_SUCCESS and value at @a ppvSymbol.
1664 * @retval VERR_SYMBOL_NOT_FOUND
1665 * @retval VERR_INVALID_HANDLE if hKrnlInfo is bad.
1666 * @retval VERR_INVALID_POINTER if any of the pointers are bad.
1667 *
1668 * @param hKrnlInfo The kernel info handle.
1669 * @param pszModule Reserved for future extensions. Pass NULL.
1670 * @param pszSymbol The C name of the symbol.
1671 * @param ppvSymbol Where to return the symbol value, passing NULL is
1672 * OK. This may be modified even on failure, in
1673 * particular, it will be set to NULL when
1674 * VERR_SYMBOL_NOT_FOUND is returned.
1675 *
1676 * @sa RTR0DbgKrnlInfoGetSymbol, RTLdrGetSymbol
1677 */
1678RTR0DECL(int) RTR0DbgKrnlInfoQuerySymbol(RTDBGKRNLINFO hKrnlInfo, const char *pszModule,
1679 const char *pszSymbol, void **ppvSymbol);
1680
1681/**
1682 * Wrapper around RTR0DbgKrnlInfoQuerySymbol that returns the symbol.
1683 *
1684 * @return Symbol address if found, NULL if not found or some invalid parameter
1685 * or something.
1686 * @param hKrnlInfo The kernel info handle.
1687 * @param pszModule Reserved for future extensions. Pass NULL.
1688 * @param pszSymbol The C name of the symbol.
1689 * @sa RTR0DbgKrnlInfoQuerySymbol, RTLdrGetSymbol
1690 */
1691RTR0DECL(void *) RTR0DbgKrnlInfoGetSymbol(RTDBGKRNLINFO hKrnlInfo, const char *pszModule, const char *pszSymbol);
1692
1693/**
1694 * Queries the size (in bytes) of a kernel data type.
1695 *
1696 * @returns IPRT status code.
1697 * @retval VINF_SUCCESS and size at @a pcbType.
1698 * @retval VERR_NOT_FOUND if the type was not found.
1699 * @retval VERR_INVALID_HANDLE if hKrnlInfo is bad.
1700 * @retval VERR_INVALID_POINTER if any of the pointers are bad.
1701 * @retval VERR_WRONG_TYPE if the type was not a valid data type (e.g. a
1702 * function)
1703 *
1704 * @param hKrnlInfo The kernel info handle.
1705 * @param pszModule The name of the module to search, pass NULL to
1706 * search the default kernel module(s).
1707 * @param pszType The type name.
1708 * @param pcbType Where to return the size of the type.
1709 */
1710RTR0DECL(int) RTR0DbgKrnlInfoQuerySize(RTDBGKRNLINFO hKrnlInfo, const char *pszModule,
1711 const char *pszType, size_t *pcbType);
1712/** @} */
1713
1714/** @} */
1715
1716RT_C_DECLS_END
1717
1718#endif
1719
Note: See TracBrowser for help on using the repository browser.

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