VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/dbgmod.h@ 80035

Last change on this file since 80035 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.4 KB
Line 
1/* $Id: dbgmod.h 76585 2019-01-01 06:31:29Z vboxsync $ */
2/** @file
3 * IPRT - Internal Header for RTDbgMod and the associated interpreters.
4 */
5
6/*
7 * Copyright (C) 2008-2019 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_INCLUDED_INTERNAL_dbgmod_h
28#define IPRT_INCLUDED_INTERNAL_dbgmod_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/types.h>
34#include <iprt/critsect.h>
35#include <iprt/ldr.h> /* for PFNRTLDRENUMDBG */
36#include "internal/magics.h"
37
38RT_C_DECLS_BEGIN
39
40/** @addtogroup grp_rt_dbgmod
41 * @internal
42 * @{
43 */
44
45
46/** Pointer to the internal module structure. */
47typedef struct RTDBGMODINT *PRTDBGMODINT;
48
49/**
50 * Virtual method table for executable image interpreters.
51 */
52typedef struct RTDBGMODVTIMG
53{
54 /** Magic number (RTDBGMODVTIMG_MAGIC). */
55 uint32_t u32Magic;
56 /** Reserved. */
57 uint32_t fReserved;
58 /** The name of the interpreter. */
59 const char *pszName;
60
61 /**
62 * Try open the image.
63 *
64 * This combines probing and opening.
65 *
66 * @returns IPRT status code. No informational returns defined.
67 *
68 * @param pMod Pointer to the module that is being opened.
69 *
70 * The RTDBGMOD::pszDbgFile member will point to
71 * the filename of any debug info we're aware of
72 * on input. Also, or alternatively, it is expected
73 * that the interpreter will look for debug info in
74 * the executable image file when present and that it
75 * may ask the image interpreter for this when it's
76 * around.
77 *
78 * Upon successful return the method is expected to
79 * initialize pImgOps and pvImgPriv.
80 * @param enmArch The desired architecture.
81 */
82 DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod, RTLDRARCH enmArch);
83
84 /**
85 * Close the interpreter, freeing all associated resources.
86 *
87 * The caller sets the pDbgOps and pvDbgPriv RTDBGMOD members
88 * to NULL upon return.
89 *
90 * @param pMod Pointer to the module structure.
91 */
92 DECLCALLBACKMEMBER(int, pfnClose)(PRTDBGMODINT pMod);
93
94 /**
95 * Enumerate the debug info contained in the executable image.
96 *
97 * Identical to RTLdrEnumDbgInfo.
98 *
99 * @returns IPRT status code or whatever pfnCallback returns.
100 *
101 * @param pMod Pointer to the module structure.
102 * @param pfnCallback The callback function. Ignore the module
103 * handle argument!
104 * @param pvUser The user argument.
105 */
106 DECLCALLBACKMEMBER(int, pfnEnumDbgInfo)(PRTDBGMODINT pMod, PFNRTLDRENUMDBG pfnCallback, void *pvUser);
107
108 /**
109 * Enumerate the segments in the executable image.
110 *
111 * Identical to RTLdrEnumSegments.
112 *
113 * @returns IPRT status code or whatever pfnCallback returns.
114 *
115 * @param pMod Pointer to the module structure.
116 * @param pfnCallback The callback function. Ignore the module
117 * handle argument!
118 * @param pvUser The user argument.
119 */
120 DECLCALLBACKMEMBER(int, pfnEnumSegments)(PRTDBGMODINT pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser);
121
122 /**
123 * Enumerates the symbols exported by the module.
124 *
125 * @returns iprt status code, which might have been returned by pfnCallback.
126 * @param pMod Pointer to the module structure.
127 * @param fFlags Flags indicating what to return and such.
128 * @param BaseAddress The image base addressto use when calculating the
129 * symbol values.
130 * @param pfnCallback The callback function which each symbol is to be fed
131 * to.
132 * @param pvUser User argument to pass to the enumerator.
133 */
134 DECLCALLBACKMEMBER(int, pfnEnumSymbols)(PRTDBGMODINT pMod, uint32_t fFlags, RTLDRADDR BaseAddress,
135 PFNRTLDRENUMSYMS pfnCallback, void *pvUser);
136
137 /**
138 * Gets the size of the loaded image.
139 *
140 * Identical to RTLdrSize.
141 *
142 * @returns The size in bytes, RTUINTPTR_MAX on failure.
143 *
144 * @param pMod Pointer to the module structure.
145 */
146 DECLCALLBACKMEMBER(RTUINTPTR, pfnImageSize)(PRTDBGMODINT pMod);
147
148 /**
149 * Converts a link address to a segment:offset address (RVA included).
150 *
151 * @returns IPRT status code.
152 *
153 * @param pMod Pointer to the module structure.
154 * @param LinkAddress The link address to convert.
155 * @param piSeg The segment index.
156 * @param poffSeg Where to return the segment offset.
157 */
158 DECLCALLBACKMEMBER(int, pfnLinkAddressToSegOffset)(PRTDBGMODINT pMod, RTLDRADDR LinkAddress,
159 PRTDBGSEGIDX piSeg, PRTLDRADDR poffSeg);
160
161 /**
162 * Converts an image relative virtual address to a segment:offset.
163 *
164 * @returns IPRT status code.
165 *
166 * @param pMod Pointer to the loader module structure.
167 * @param Rva The RVA to convert.
168 * @param piSeg The segment index.
169 * @param poffSeg Where to return the segment offset.
170 */
171 DECLCALLBACKMEMBER(int, pfnRvaToSegOffset)(PRTDBGMODINT pMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg);
172
173 /**
174 * Creates a read-only mapping of a part of the image file.
175 *
176 * @returns IPRT status code and *ppvMap set on success.
177 *
178 * @param pMod Pointer to the module structure.
179 * @param iDbgInfo The debug info ordinal number if the request
180 * corresponds exactly to a debug info part from
181 * pfnEnumDbgInfo. Otherwise, pass UINT32_MAX.
182 * @param off The offset into the image file.
183 * @param cb The number of bytes to map.
184 * @param ppvMap Where to return the mapping address on success.
185 *
186 * @remarks Fixups will only be applied if @a iDbgInfo is specified.
187 */
188 DECLCALLBACKMEMBER(int, pfnMapPart)(PRTDBGMODINT pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void const **ppvMap);
189
190 /**
191 * Unmaps memory previously mapped by pfnMapPart.
192 *
193 * @returns IPRT status code, *ppvMap set to NULL on success.
194 *
195 * @param pMod Pointer to the module structure.
196 * @param cb The size of the mapping.
197 * @param ppvMap The mapping address on input, NULL on
198 * successful return.
199 */
200 DECLCALLBACKMEMBER(int, pfnUnmapPart)(PRTDBGMODINT pMod, size_t cb, void const **ppvMap);
201
202 /**
203 * Reads data from the image file.
204 *
205 * @returns IPRT status code, *ppvMap set to NULL on success.
206 *
207 * @param pMod Pointer to the module structure.
208 * @param iDbgInfoHint The debug info ordinal number hint, pass UINT32_MAX
209 * if not know or sure.
210 * @param off The offset into the image file.
211 * @param pvBuf The buffer to read into.
212 * @param cb The number of bytes to read.
213 */
214 DECLCALLBACKMEMBER(int, pfnReadAt)(PRTDBGMODINT pMod, uint32_t iDbgInfoHint, RTFOFF off, void *pvBuf, size_t cb);
215
216 /**
217 * Gets the image format.
218 *
219 * @returns Valid image format on success, RTLDRFMT_INVALID if not supported.
220 * @param pMod Pointer to the module structure.
221 */
222 DECLCALLBACKMEMBER(RTLDRFMT, pfnGetFormat)(PRTDBGMODINT pMod);
223
224 /**
225 * Gets the image architecture.
226 *
227 * @returns Valid image architecutre on success, RTLDRARCH_WHATEVER if not
228 * supported.
229 * @param pMod Pointer to the module structure.
230 */
231 DECLCALLBACKMEMBER(RTLDRARCH, pfnGetArch)(PRTDBGMODINT pMod);
232
233 /**
234 * Generic method for querying image properties.
235 *
236 * @returns IPRT status code.
237 * @param pMod Pointer to the module structure.
238 * @param enmProp The property to query.
239 * @param pvBuf Pointer to the return buffer.
240 * @param cbBuf The size of the return buffer.
241 * @param pcbRet How many bytes was actually returned. In the
242 * case of VERR_BUFFER_OVERFLOW this will contain
243 * the required buffer size. Optional.
244 * @sa RTLdrQueryPropEx
245 */
246 DECLCALLBACKMEMBER(int, pfnQueryProp)(PRTDBGMODINT pMod, RTLDRPROP enmProp, void *pvBuf, size_t cbBuf, size_t *pcbRet);
247
248 /**
249 * Try use unwind information to unwind one frame.
250 *
251 * @returns IPRT status code. Last informational status from stack reader callback.
252 * @retval VERR_DBG_NO_UNWIND_INFO if the module contains no unwind information.
253 * @retval VERR_DBG_UNWIND_INFO_NOT_FOUND if no unwind information was found
254 * for the location given by iSeg:off.
255 *
256 * @param pMod Pointer to the module structure.
257 * @param iSeg The segment number of the program counter.
258 * @param off The offset into @a iSeg. Together with @a iSeg
259 * this corresponds to the RTDBGUNWINDSTATE::uPc
260 * value pointed to by @a pState.
261 * @param pState The unwind state to work.
262 *
263 * @sa RTLdrUnwindFrame, RTDbgModUnwindFrame
264 */
265 DECLCALLBACKMEMBER(int, pfnUnwindFrame)(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTDBGUNWINDSTATE pState);
266
267 /** For catching initialization errors (RTDBGMODVTIMG_MAGIC). */
268 uint32_t u32EndMagic;
269} RTDBGMODVTIMG;
270/** Pointer to a const RTDBGMODVTIMG. */
271typedef RTDBGMODVTIMG const *PCRTDBGMODVTIMG;
272
273
274/**
275 * Virtual method table for debug info interpreters.
276 */
277typedef struct RTDBGMODVTDBG
278{
279 /** Magic number (RTDBGMODVTDBG_MAGIC). */
280 uint32_t u32Magic;
281 /** Mask of supported debug info types, see grp_rt_dbg_type.
282 * Used to speed up the search for a suitable interpreter. */
283 uint32_t fSupports;
284 /** The name of the interpreter. */
285 const char *pszName;
286
287 /**
288 * Try open the image.
289 *
290 * This combines probing and opening.
291 *
292 * @returns IPRT status code. No informational returns defined.
293 *
294 * @param pMod Pointer to the module that is being opened.
295 *
296 * The RTDBGMOD::pszDbgFile member will point to
297 * the filename of any debug info we're aware of
298 * on input. Also, or alternatively, it is expected
299 * that the interpreter will look for debug info in
300 * the executable image file when present and that it
301 * may ask the image interpreter for this when it's
302 * around.
303 *
304 * Upon successful return the method is expected to
305 * initialize pDbgOps and pvDbgPriv.
306 * @param enmArch The desired architecture.
307 */
308 DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod, RTLDRARCH enmArch);
309
310 /**
311 * Close the interpreter, freeing all associated resources.
312 *
313 * The caller sets the pDbgOps and pvDbgPriv RTDBGMOD members
314 * to NULL upon return.
315 *
316 * @param pMod Pointer to the module structure.
317 */
318 DECLCALLBACKMEMBER(int, pfnClose)(PRTDBGMODINT pMod);
319
320
321
322 /**
323 * Converts an image relative virtual address address to a segmented address.
324 *
325 * @returns Segment index on success, NIL_RTDBGSEGIDX on failure.
326 * @param pMod Pointer to the module structure.
327 * @param uRva The image relative address to convert.
328 * @param poffSeg Where to return the segment offset. Optional.
329 */
330 DECLCALLBACKMEMBER(RTDBGSEGIDX, pfnRvaToSegOff)(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg);
331
332 /**
333 * Image size when mapped if segments are mapped adjacently.
334 *
335 * For ELF, PE, and Mach-O images this is (usually) a natural query, for LX and
336 * NE and such it's a bit odder and the answer may not make much sense for them.
337 *
338 * @returns Image mapped size.
339 * @param pMod Pointer to the module structure.
340 */
341 DECLCALLBACKMEMBER(RTUINTPTR, pfnImageSize)(PRTDBGMODINT pMod);
342
343
344
345 /**
346 * Adds a segment to the module (optional).
347 *
348 * @returns IPRT status code.
349 * @retval VERR_NOT_SUPPORTED if the interpreter doesn't support this feature.
350 * @retval VERR_DBG_SEGMENT_INDEX_CONFLICT if the segment index exists already.
351 *
352 * @param pMod Pointer to the module structure.
353 * @param uRva The segment image relative address.
354 * @param cb The segment size.
355 * @param pszName The segment name.
356 * @param cchName The length of the segment name.
357 * @param fFlags Segment flags.
358 * @param piSeg The segment index or NIL_RTDBGSEGIDX on input.
359 * The assigned segment index on successful return.
360 * Optional.
361 */
362 DECLCALLBACKMEMBER(int, pfnSegmentAdd)(PRTDBGMODINT pMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName, size_t cchName,
363 uint32_t fFlags, PRTDBGSEGIDX piSeg);
364
365 /**
366 * Gets the segment count.
367 *
368 * @returns Number of segments.
369 * @retval NIL_RTDBGSEGIDX if unknown.
370 *
371 * @param pMod Pointer to the module structure.
372 */
373 DECLCALLBACKMEMBER(RTDBGSEGIDX, pfnSegmentCount)(PRTDBGMODINT pMod);
374
375 /**
376 * Gets information about a segment.
377 *
378 * @returns IPRT status code.
379 * @retval VERR_DBG_INVALID_SEGMENT_INDEX if iSeg is too high.
380 *
381 * @param pMod Pointer to the module structure.
382 * @param iSeg The segment.
383 * @param pSegInfo Where to store the segment information.
384 */
385 DECLCALLBACKMEMBER(int, pfnSegmentByIndex)(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo);
386
387
388
389 /**
390 * Adds a symbol to the module (optional).
391 *
392 * @returns IPRT code.
393 * @retval VERR_NOT_SUPPORTED if the interpreter doesn't support this feature.
394 *
395 * @param pMod Pointer to the module structure.
396 * @param pszSymbol The symbol name.
397 * @param cchSymbol The length for the symbol name.
398 * @param iSeg The segment number (0-based). RTDBGMOD_SEG_RVA can be used.
399 * @param off The offset into the segment.
400 * @param cb The area covered by the symbol. 0 is fine.
401 * @param fFlags Flags.
402 * @param piOrdinal Where to return the symbol ordinal on success. If the
403 * interpreter doesn't do ordinals, this will be set to
404 * UINT32_MAX. Optional
405 */
406 DECLCALLBACKMEMBER(int, pfnSymbolAdd)(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
407 uint32_t iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags,
408 uint32_t *piOrdinal);
409
410 /**
411 * Gets the number of symbols in the module.
412 *
413 * This is used for figuring out the max value to pass to pfnSymbolByIndex among
414 * other things.
415 *
416 * @returns The number of symbols, UINT32_MAX if not known/supported.
417 *
418 * @param pMod Pointer to the module structure.
419 */
420 DECLCALLBACKMEMBER(uint32_t, pfnSymbolCount)(PRTDBGMODINT pMod);
421
422 /**
423 * Queries symbol information by ordinal number.
424 *
425 * @returns IPRT status code.
426 * @retval VINF_SUCCESS on success, no informational status code.
427 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
428 * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
429 * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at that index.
430 *
431 * @param pMod Pointer to the module structure.
432 * @param iOrdinal The symbol ordinal number.
433 * @param pSymInfo Where to store the symbol information.
434 */
435 DECLCALLBACKMEMBER(int, pfnSymbolByOrdinal)(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo);
436
437 /**
438 * Queries symbol information by symbol name.
439 *
440 * @returns IPRT status code.
441 * @retval VINF_SUCCESS on success, no informational status code.
442 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
443 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
444 *
445 * @param pMod Pointer to the module structure.
446 * @param pszSymbol The symbol name.
447 * @param cchSymbol The length of the symbol name.
448 * @param pSymInfo Where to store the symbol information.
449 */
450 DECLCALLBACKMEMBER(int, pfnSymbolByName)(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol, PRTDBGSYMBOL pSymInfo);
451
452 /**
453 * Queries symbol information by address.
454 *
455 * The returned symbol is what the debug info interpreter considers the symbol
456 * most applicable to the specified address. This usually means a symbol with an
457 * address equal or lower than the requested.
458 *
459 * @returns IPRT status code.
460 * @retval VINF_SUCCESS on success, no informational status code.
461 * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
462 * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
463 *
464 * @param pMod Pointer to the module structure.
465 * @param iSeg The segment number (0-based) or RTDBGSEGIDX_ABS.
466 * @param off The offset into the segment.
467 * @param fFlags Symbol search flags, see RTDBGSYMADDR_FLAGS_XXX.
468 * @param poffDisp Where to store the distance between the specified address
469 * and the returned symbol. Optional.
470 * @param pSymInfo Where to store the symbol information.
471 */
472 DECLCALLBACKMEMBER(int, pfnSymbolByAddr)(PRTDBGMODINT pMod, uint32_t iSeg, RTUINTPTR off, uint32_t fFlags,
473 PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo);
474
475
476
477 /**
478 * Adds a line number to the module (optional).
479 *
480 * @returns IPRT status code.
481 * @retval VERR_NOT_SUPPORTED if the interpreter doesn't support this feature.
482 *
483 * @param pMod Pointer to the module structure.
484 * @param pszFile The filename.
485 * @param cchFile The length of the filename.
486 * @param uLineNo The line number.
487 * @param iSeg The segment number (0-based).
488 * @param off The offset into the segment.
489 * @param piOrdinal Where to return the line number ordinal on success. If
490 * the interpreter doesn't do ordinals, this will be set to
491 * UINT32_MAX. Optional
492 */
493 DECLCALLBACKMEMBER(int, pfnLineAdd)(PRTDBGMODINT pMod, const char *pszFile, size_t cchFile, uint32_t uLineNo,
494 uint32_t iSeg, RTUINTPTR off, uint32_t *piOrdinal);
495
496 /**
497 * Gets the number of line numbers in the module.
498 *
499 * @returns The number or UINT32_MAX if not known/supported.
500 *
501 * @param pMod Pointer to the module structure.
502 */
503 DECLCALLBACKMEMBER(uint32_t, pfnLineCount)(PRTDBGMODINT pMod);
504
505 /**
506 * Queries line number information by ordinal number.
507 *
508 * @returns IPRT status code.
509 * @retval VINF_SUCCESS on success, no informational status code.
510 * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
511 * @retval VERR_DBG_LINE_NOT_FOUND if there is no line number with that
512 * ordinal.
513 *
514 * @param pMod Pointer to the module structure.
515 * @param iOrdinal The line number ordinal number.
516 * @param pLineInfo Where to store the information about the line number.
517 */
518 DECLCALLBACKMEMBER(int, pfnLineByOrdinal)(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo);
519
520 /**
521 * Queries line number information by address.
522 *
523 * @returns IPRT status code.
524 * @retval VINF_SUCCESS on success, no informational status code.
525 * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
526 * @retval VERR_DBG_LINE_NOT_FOUND if no suitable line number was found.
527 *
528 * @param pMod Pointer to the module structure.
529 * @param iSeg The segment number (0-based) or RTDBGSEGIDX_ABS.
530 * @param off The offset into the segment.
531 * @param poffDisp Where to store the distance between the specified address
532 * and the returned line number. Optional.
533 * @param pLineInfo Where to store the information about the closest line
534 * number.
535 */
536 DECLCALLBACKMEMBER(int, pfnLineByAddr)(PRTDBGMODINT pMod, uint32_t iSeg, RTUINTPTR off,
537 PRTINTPTR poffDisp, PRTDBGLINE pLineInfo);
538
539 /**
540 * Try use unwind information to unwind one frame.
541 *
542 * @returns IPRT status code. Last informational status from stack reader callback.
543 * @retval VERR_DBG_NO_UNWIND_INFO if the module contains no unwind information.
544 * @retval VERR_DBG_UNWIND_INFO_NOT_FOUND if no unwind information was found
545 * for the location given by iSeg:off.
546 *
547 * @param pMod Pointer to the module structure.
548 * @param iSeg The segment number of the program counter.
549 * @param off The offset into @a iSeg. Together with @a iSeg
550 * this corresponds to the RTDBGUNWINDSTATE::uPc
551 * value pointed to by @a pState.
552 * @param pState The unwind state to work.
553 *
554 * @sa RTDbgModUnwindFrame
555 */
556 DECLCALLBACKMEMBER(int, pfnUnwindFrame)(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTDBGUNWINDSTATE pState);
557
558 /** For catching initialization errors (RTDBGMODVTDBG_MAGIC). */
559 uint32_t u32EndMagic;
560} RTDBGMODVTDBG;
561/** Pointer to a const RTDBGMODVTDBG. */
562typedef RTDBGMODVTDBG const *PCRTDBGMODVTDBG;
563
564
565/**
566 * Deferred loading callback.
567 *
568 * @returns IPRT status code. On success the necessary method tables should be
569 * installed in @a pMod.
570 * @param pDbgMod Pointer to the debug module structure.
571 * @param pDeferred The deferred load data.
572 */
573typedef DECLCALLBACK(int) FNRTDBGMODDEFERRED(PRTDBGMODINT pDbgMod, struct RTDBGMODDEFERRED *pDeferred);
574/** Pointer to a deferred loading callback. */
575typedef FNRTDBGMODDEFERRED *PFNRTDBGMODDEFERRED;
576
577
578/**
579 * Structure pointed to by pvDbgPriv and/or pvImgPriv when
580 * g_rtDbgModVtDbgDeferred and/or g_rtDbgModVtImgDeferred are being used.
581 */
582typedef struct RTDBGMODDEFERRED
583{
584 /** Magic value (RTDBGMODDEFERRED_MAGIC). */
585 uint32_t u32Magic;
586 /** Reference counter. */
587 uint32_t volatile cRefs;
588 /** The image size.
589 * Deferred loading is almost pointless without knowing the module size, as
590 * it cannot be mapped (correctly) without it. */
591 RTUINTPTR cbImage;
592 /** The configuration instance (referenced), can be NIL. */
593 RTDBGCFG hDbgCfg;
594 /** Performs deferred loading of the module. */
595 PFNRTDBGMODDEFERRED pfnDeferred;
596 /** Callback specific data. */
597 union
598 {
599 struct
600 {
601 /** The time/date stamp of the executable image and codeview file. */
602 uint32_t uTimestamp;
603 } PeImage,
604 OldCodeView;
605
606 struct
607 {
608 /** The PDB uuid. */
609 RTUUID Uuid;
610 /** The PDB age. */
611 uint32_t uAge;
612 } NewCodeview;
613
614 struct
615 {
616 /** The CRC-32 value found in the .gnu_debuglink section. */
617 uint32_t uCrc32;
618 } GnuDebugLink;
619
620 struct
621 {
622 /** The image UUID. */
623 RTUUID Uuid;
624 /** Image architecture. */
625 RTLDRARCH enmArch;
626 /** Number of segment mappings. */
627 uint32_t cSegs;
628 /** Segment mappings. */
629 RTDBGSEGMENT aSegs[1];
630 } MachO;
631 } u;
632} RTDBGMODDEFERRED;
633/** Pointer to the deferred loading data. */
634typedef RTDBGMODDEFERRED *PRTDBGMODDEFERRED;
635
636
637/**
638 * Debug module structure.
639 */
640typedef struct RTDBGMODINT
641{
642 /** Magic value (RTDBGMOD_MAGIC). */
643 uint32_t u32Magic;
644 /** The number of reference there are to this module.
645 * This is used to perform automatic cleanup and sharing. */
646 uint32_t volatile cRefs;
647 /** The module tag. */
648 uint64_t uTag;
649
650 /** When set, the loading of the image and debug info (including locating any
651 * external files), will not have taken place yet. */
652 uint32_t fDeferred : 1;
653 /** Set if deferred loading failed. */
654 uint32_t fDeferredFailed : 1;
655 /** Set if the debug info is based on image exports and segments. */
656 uint32_t fExports : 1;
657 /** Alignment padding. */
658 uint32_t fPadding1 : 29;
659#if ARCH_BITS == 64
660 uint32_t u32Padding2;
661#endif
662
663 /** The module name (short). */
664 char const *pszName;
665 /** The image file specified by the user. Can be NULL. */
666 char const *pszImgFileSpecified;
667 /** The module filename. Can be NULL. */
668 char const *pszImgFile;
669 /** The debug info file (if external). Can be NULL. */
670 char const *pszDbgFile;
671
672 /** The method table for the executable image interpreter. */
673 PCRTDBGMODVTIMG pImgVt;
674 /** Pointer to the private data of the executable image interpreter. */
675 void *pvImgPriv;
676
677 /** The method table for the debug info interpreter. */
678 PCRTDBGMODVTDBG pDbgVt;
679 /** Pointer to the private data of the debug info interpreter. */
680 void *pvDbgPriv;
681
682 /** Critical section serializing access to the module. */
683 RTCRITSECT CritSect;
684} RTDBGMODINT;
685/** Pointer to an debug module structure. */
686typedef RTDBGMODINT *PRTDBGMODINT;
687
688
689extern DECLHIDDEN(RTSTRCACHE) g_hDbgModStrCache;
690extern DECLHIDDEN(RTDBGMODVTDBG const) g_rtDbgModVtDbgCodeView;
691extern DECLHIDDEN(RTDBGMODVTDBG const) g_rtDbgModVtDbgDwarf;
692extern DECLHIDDEN(RTDBGMODVTDBG const) g_rtDbgModVtDbgNm;
693extern DECLHIDDEN(RTDBGMODVTDBG const) g_rtDbgModVtDbgMapSym;
694#ifdef RT_OS_WINDOWS
695extern DECLHIDDEN(RTDBGMODVTDBG const) g_rtDbgModVtDbgDbgHelp;
696#endif
697extern DECLHIDDEN(RTDBGMODVTDBG const) g_rtDbgModVtDbgDeferred;
698extern DECLHIDDEN(RTDBGMODVTDBG const) g_rtDbgModVtDbgContainer;
699
700extern DECLHIDDEN(RTDBGMODVTIMG const) g_rtDbgModVtImgLdr;
701extern DECLHIDDEN(RTDBGMODVTIMG const) g_rtDbgModVtImgDeferred;
702
703DECLHIDDEN(int) rtDbgModContainerCreate(PRTDBGMODINT pMod, RTUINTPTR cbSeg);
704DECLHIDDEN(int) rtDbgModContainer_SymbolRemoveAll(PRTDBGMODINT pMod);
705DECLHIDDEN(int) rtDbgModContainer_LineRemoveAll(PRTDBGMODINT pMod);
706DECLHIDDEN(int) rtDbgModContainer_RemoveAll(PRTDBGMODINT pMod);
707
708DECLHIDDEN(int) rtDbgModCreateForExports(PRTDBGMODINT pDbgMod);
709DECLHIDDEN(int) rtDbgModDeferredCreate(PRTDBGMODINT pDbgMod, PFNRTDBGMODDEFERRED pfnDeferred, RTUINTPTR cbImage,
710 RTDBGCFG hDbgCfg, size_t cbDeferred, PRTDBGMODDEFERRED *ppDeferred);
711
712DECLHIDDEN(int) rtDbgModLdrOpenFromHandle(PRTDBGMODINT pDbgMod, RTLDRMOD hLdrMod);
713
714DECLHIDDEN(int) rtDwarfUnwind_EhData(void const *pvSection, size_t cbSection, RTUINTPTR uRvaSection,
715 RTDBGSEGIDX idxSeg, RTUINTPTR offSeg, RTUINTPTR uRva,
716 PRTDBGUNWINDSTATE pState, RTLDRARCH enmArch);
717
718/** @} */
719
720RT_C_DECLS_END
721
722#endif /* !IPRT_INCLUDED_INTERNAL_dbgmod_h */
723
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