VirtualBox

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

Last change on this file since 73895 was 73531, checked in by vboxsync, 6 years ago

IPRT: Some work on stack unwinding using dwarf info. bugref:3897

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