dbgmoddwarf.cpp revision d3656847ea82ea03feaf0e44ac142c965e744209
/* $Id$ */
/** @file
* IPRT - Debug Info Reader For DWARF.
*/
/*
* Copyright (C) 2011-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_DBG_DWARF
#define RTDBGMODDWARF_WITH_MEM_CACHE
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
# include <iprt/memcache.h>
#endif
#include <iprt/strcache.h>
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** @name Standard DWARF Line Number Opcodes
* @{ */
/** @} */
/** @name Extended DWARF Line Number Opcodes
* @{ */
/** @} */
/** @name DIE Tags.
* @{ */
/** @} */
/** @name DIE Attributes.
* @{ */
/** Used by GCC and others, same as DW_AT_linkage_name. See http://wiki.dwarfstd.org/index.php?title=DW_AT_linkage_name*/
#define DW_AT_MIPS_linkage_name UINT16_C(0x2007)
#define DW_AT_hi_user UINT16_C(0x3fff)
/** @} */
/** @name DIE Forms.
* @{ */
/* What was 0x02? */
/** @} */
/** @name Address classes.
* @{ */
#define DW_ADDR_none UINT8_C(0)
/** @} */
/** @name Location Expression Opcodes
* @{ */
#define DW_OP_bregx UINT8_C(0x92) /**< 2 operands, a ULEB128 register followed by a SLEB128 offset. */
/** @} */
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/** Pointer to a DWARF section reader. */
typedef struct RTDWARFCURSOR *PRTDWARFCURSOR;
/** Pointer to an attribute descriptor. */
typedef struct RTDWARFATTRDESC const *PCRTDWARFATTRDESC;
/** Pointer to a DIE. */
typedef struct RTDWARFDIE *PRTDWARFDIE;
/** Pointer to a const DIE. */
typedef struct RTDWARFDIE const *PCRTDWARFDIE;
/**
* DWARF sections.
*/
typedef enum krtDbgModDwarfSect
{
/** End of valid parts (exclusive). */
/**
* Abbreviation cache entry.
*/
typedef struct RTDWARFABBREV
{
/** Whether there are children or not. */
bool fChildren;
/** The tag. */
/** Offset into the abbrev section of the specification pairs. */
/** The abbreviation table offset this is entry is valid for.
* UINT32_MAX if not valid. */
/** Pointer to an abbreviation cache entry. */
typedef RTDWARFABBREV *PRTDWARFABBREV;
/** Pointer to a const abbreviation cache entry. */
typedef RTDWARFABBREV const *PCRTDWARFABBREV;
/**
* Structure for gathering segment info.
*/
typedef struct RTDBGDWARFSEG
{
/** The highest offset in the segment. */
/** Calculated base address. */
/** Estimated The segment size. */
/** Segment number (RTLDRSEG::Sel16bit). */
/** Pointer to segment info. */
typedef RTDBGDWARFSEG *PRTDBGDWARFSEG;
/**
* The instance data of the DWARF reader.
*/
typedef struct RTDBGMODDWARF
{
/** The debug container containing doing the real work. */
/** The image module (no reference). */
/** The debug info module (no reference). */
/** Nested image module (with reference ofc). */
/** DWARF debug info sections. */
struct
{
/** The file offset of the part. */
/** The size of the part. */
/** The memory mapping of the part. */
void const *pv;
/** Set if present. */
bool fPresent;
/** The debug info ordinal number in the image file. */
/** The offset into the abbreviation section of the current cache. */
/** The number of cached abbreviations we've allocated space for. */
/** Array of cached abbreviations, indexed by code. */
/** Used by rtDwarfAbbrev_Lookup when the result is uncachable. */
/** The list of compilation units (RTDWARFDIE). */
/** Set if we have to use link addresses because the module does not have
* fixups (mach_kernel). */
bool fUseLinkAddress;
/** This is set to -1 if we're doing everything in one pass.
* Otherwise it's 1 or 2:
* - In pass 1, we collect segment info.
* - In pass 2, we add debug info to the container.
* The two pass parsing is necessary for watcom generated symbol files as
* these contains no information about the code and data segments in the
* image. So we have to figure out some approximate stuff based on the
* segments and offsets we encounter in the debug info. */
/** Segment index hint. */
/** The number of segments in paSegs.
* (During segment copying, this is abused to count useful segments.) */
/** Pointer to segments if iWatcomPass isn't -1. */
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
/** DIE allocators. */
struct
{
} aDieAllocators[2];
#endif
/** Pointer to instance data of the DWARF reader. */
typedef RTDBGMODDWARF *PRTDBGMODDWARF;
/**
* DWARF cursor for reading byte data.
*/
typedef struct RTDWARFCURSOR
{
/** The current position. */
/** The number of bytes left to read. */
/** The number of bytes left to read in the current unit. */
/** The DWARF debug info reader instance. */
/** Set if this is 64-bit DWARF, clear if 32-bit. */
bool f64bitDwarf;
/** Set if the format endian is native, clear if endian needs to be
* inverted. */
bool fNativEndian;
/** The size of a native address. */
/** The cursor status code. This is VINF_SUCCESS until some error
* occurs. */
int rc;
/** The start of the area covered by the cursor.
* Used for repositioning the cursor relative to the start of a section. */
/** The section. */
/**
* DWARF line number program state.
*/
typedef struct RTDWARFLINESTATE
{
/** Virtual Line Number Machine Registers. */
struct
{
bool fIsStatement;
bool fBasicBlock;
bool fEndSequence;
bool fPrologueEnd;
bool fEpilogueBegin;
} Regs;
/** @} */
/** Header. */
struct
{
uint8_t const *pacStdOperands;
} Hdr;
/** @name Include Path Table (0-based)
* @{ */
const char **papszIncPaths;
/** @} */
/** @name File Name Table (0-based, dummy zero entry)
* @{ */
char **papszFileNames;
/** @} */
/** The DWARF debug info reader instance. */
/** Pointer to a DWARF line number program state. */
typedef RTDWARFLINESTATE *PRTDWARFLINESTATE;
/**
* Decodes an attribute and stores it in the specified DIE member field.
*
* @returns IPRT status code.
* @param pDie Pointer to the DIE structure.
* @param pbMember Pointer to the first byte in the member.
* @param pDesc The attribute descriptor.
* @param uForm The data form.
* @param pDataCursor The cursor to read data from.
*/
typedef DECLCALLBACK(int) FNRTDWARFATTRDECODER(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
/** Pointer to an attribute decoder callback. */
typedef FNRTDWARFATTRDECODER *PFNRTDWARFATTRDECODER;
/**
* Attribute descriptor.
*/
typedef struct RTDWARFATTRDESC
{
/** The attribute. */
/** The data member offset. */
/** The data member size and initialization method. */
/** The decoder function. */
/** Define a attribute entry. */
{ \
a_uAttr, \
{ 0, 0, 0 }, \
}
/** @name Attribute size and init methods.
* @{ */
/** @} */
/**
* DIE descriptor.
*/
typedef struct RTDWARFDIEDESC
{
/** The size of the DIE. */
/** The number of attributes. */
/** The */
typedef struct RTDWARFDIEDESC const *PCRTDWARFDIEDESC;
/** DIE descriptor initializer. */
/**
* DIE core structure, all inherits (starts with) this.
*/
typedef struct RTDWARFDIE
{
/** Pointer to the parent node. NULL if root unit. */
struct RTDWARFDIE *pParent;
/** Our node in the sibling list. */
/** List of children. */
/** The number of attributes successfully decoded. */
/** The number of unknown or otherwise unhandled attributes. */
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
/** The allocator index. */
#endif
/** The die tag, indicating which union structure to use. */
/** Offset of the abbreviation specification (within debug_abbrev). */
} RTDWARFDIE;
/**
* DWARF address structure.
*/
typedef struct RTDWARFADDR
{
/** The address. */
} RTDWARFADDR;
typedef RTDWARFADDR *PRTDWARFADDR;
typedef RTDWARFADDR const *PCRTDWARFADDR;
/**
* DWARF address range.
*/
typedef struct RTDWARFADDRRANGE
{
typedef RTDWARFADDRRANGE *PRTDWARFADDRRANGE;
typedef RTDWARFADDRRANGE const *PCRTDWARFADDRRANGE;
/** What a RTDWARFREF is relative to. */
typedef enum krtDwarfRef
{
} krtDwarfRef;
/**
* DWARF reference.
*/
typedef struct RTDWARFREF
{
/** The offset. */
/** What the offset is relative to. */
} RTDWARFREF;
typedef RTDWARFREF *PRTDWARFREF;
typedef RTDWARFREF const *PCRTDWARFREF;
/**
* DWARF Location state.
*/
typedef struct RTDWARFLOCST
{
/** The input cursor. */
/** Points to the current top of the stack. Initial value -1. */
/** The value stack. */
} RTDWARFLOCST;
/** Pointer to location state. */
typedef RTDWARFLOCST *PRTDWARFLOCST;
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** RTDWARFDIE description. */
/**
* DW_TAG_compile_unit & DW_TAG_partial_unit.
*/
typedef struct RTDWARFDIECOMPILEUNIT
{
/** The DIE core structure. */
/** The unit name. */
const char *pszName;
/** The address range of the code belonging to this unit. */
/** The language name. */
/** The identifier case. */
/** String are UTF-8 encoded. If not set, the encoding is
* unknown. */
bool fUseUtf8;
/** The unit contains main() or equivalent. */
bool fMainFunction;
/** The line numbers for this unit. */
/** The macro information for this unit. */
/** Reference to the base types. */
/** Working directory for the unit. */
const char *pszCurDir;
/** The name of the compiler or whatever that produced this unit. */
const char *pszProducer;
/** @name From the unit header.
* @{ */
/** The offset into debug_info of this unit (for references). */
/** The length of this unit. */
/** The offset into debug_abbrev of the abbreviation for this unit. */
/** The native address size. */
/** The DWARF version. */
/** @} */
typedef RTDWARFDIECOMPILEUNIT *PRTDWARFDIECOMPILEUNIT;
/** RTDWARFDIECOMPILEUNIT attributes. */
static const RTDWARFATTRDESC g_aCompileUnitAttrs[] =
{
ATTR_ENTRY(DW_AT_language, RTDWARFDIECOMPILEUNIT, uLanguage, ATTR_INIT_ZERO, rtDwarfDecode_UnsignedInt),
ATTR_ENTRY(DW_AT_macro_info, RTDWARFDIECOMPILEUNIT, MacroInfoRef, ATTR_INIT_ZERO, rtDwarfDecode_SectOff),
ATTR_ENTRY(DW_AT_stmt_list, RTDWARFDIECOMPILEUNIT, StmtListRef, ATTR_INIT_ZERO, rtDwarfDecode_SectOff),
ATTR_ENTRY(DW_AT_producer, RTDWARFDIECOMPILEUNIT, pszProducer, ATTR_INIT_ZERO, rtDwarfDecode_String),
ATTR_ENTRY(DW_AT_identifier_case, RTDWARFDIECOMPILEUNIT, uIdentifierCase,ATTR_INIT_ZERO, rtDwarfDecode_UnsignedInt),
ATTR_ENTRY(DW_AT_base_types, RTDWARFDIECOMPILEUNIT, BaseTypesRef, ATTR_INIT_ZERO, rtDwarfDecode_Reference),
ATTR_ENTRY(DW_AT_main_subprogram, RTDWARFDIECOMPILEUNIT, fMainFunction, ATTR_INIT_ZERO, rtDwarfDecode_Bool)
};
/** RTDWARFDIECOMPILEUNIT description. */
static const RTDWARFDIEDESC g_CompileUnitDesc = DIE_DESC_INIT(RTDWARFDIECOMPILEUNIT, g_aCompileUnitAttrs);
/**
* DW_TAG_subprogram.
*/
typedef struct RTDWARFDIESUBPROGRAM
{
/** The DIE core structure. */
/** The name. */
const char *pszName;
/** The linkage name. */
const char *pszLinkageName;
/** The address range of the code belonging to this unit. */
/** The first instruction in the function. */
/** Segment number (watcom). */
/** Reference to the specification. */
/** Pointer to a DW_TAG_subprogram DIE. */
typedef RTDWARFDIESUBPROGRAM *PRTDWARFDIESUBPROGRAM;
/** Pointer to a const DW_TAG_subprogram DIE. */
typedef RTDWARFDIESUBPROGRAM const *PCRTDWARFDIESUBPROGRAM;
/** RTDWARFDIESUBPROGRAM attributes. */
static const RTDWARFATTRDESC g_aSubProgramAttrs[] =
{
ATTR_ENTRY(DW_AT_linkage_name, RTDWARFDIESUBPROGRAM, pszLinkageName, ATTR_INIT_ZERO, rtDwarfDecode_String),
ATTR_ENTRY(DW_AT_MIPS_linkage_name, RTDWARFDIESUBPROGRAM, pszLinkageName, ATTR_INIT_ZERO, rtDwarfDecode_String),
ATTR_ENTRY(DW_AT_segment, RTDWARFDIESUBPROGRAM, uSegment, ATTR_INIT_ZERO, rtDwarfDecode_SegmentLoc),
ATTR_ENTRY(DW_AT_specification, RTDWARFDIESUBPROGRAM, SpecRef, ATTR_INIT_ZERO, rtDwarfDecode_Reference)
};
/** RTDWARFDIESUBPROGRAM description. */
static const RTDWARFDIEDESC g_SubProgramDesc = DIE_DESC_INIT(RTDWARFDIESUBPROGRAM, g_aSubProgramAttrs);
/** RTDWARFDIESUBPROGRAM attributes for the specification hack. */
static const RTDWARFATTRDESC g_aSubProgramSpecHackAttrs[] =
{
ATTR_ENTRY(DW_AT_linkage_name, RTDWARFDIESUBPROGRAM, pszLinkageName, ATTR_INIT_ZERO, rtDwarfDecode_String),
ATTR_ENTRY(DW_AT_MIPS_linkage_name, RTDWARFDIESUBPROGRAM, pszLinkageName, ATTR_INIT_ZERO, rtDwarfDecode_String),
};
/** RTDWARFDIESUBPROGRAM description for the specification hack. */
static const RTDWARFDIEDESC g_SubProgramSpecHackDesc = DIE_DESC_INIT(RTDWARFDIESUBPROGRAM, g_aSubProgramSpecHackAttrs);
/**
* DW_TAG_label.
*/
typedef struct RTDWARFDIELABEL
{
/** The DIE core structure. */
/** The name. */
const char *pszName;
/** The address of the first instruction. */
/** Segment number (watcom). */
/** Externally visible? */
bool fExternal;
/** Pointer to a DW_TAG_label DIE. */
typedef RTDWARFDIELABEL *PRTDWARFDIELABEL;
/** Pointer to a const DW_TAG_label DIE. */
typedef RTDWARFDIELABEL const *PCRTDWARFDIELABEL;
/** RTDWARFDIESUBPROGRAM attributes. */
static const RTDWARFATTRDESC g_aLabelAttrs[] =
{
};
/** RTDWARFDIESUBPROGRAM description. */
/**
* Tag names and descriptors.
*/
static const struct RTDWARFTAGDESC
{
/** The tag value. */
/** The tag name as string. */
const char *pszName;
/** The DIE descriptor to use. */
} g_aTagDescs[] =
{
TAGDESC_EMPTY(), /* 0x00 */
TAGDESC_EMPTY(), /* 0x0c */
TAGDESC_EMPTY(), /* 0x14 */
};
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
#if defined(LOG_ENABLED) || defined(RT_STRICT)
/**
* Turns a tag value into a string for logging purposes.
*
* @returns String name.
* @param uTag The tag.
*/
{
{
if (pszTag)
return pszTag;
}
static char s_szStatic[32];
return s_szStatic;
}
/**
* Turns an attributevalue into a string for logging purposes.
*
* @returns String name.
* @param uAttr The attribute.
*/
{
switch (uAttr)
{
}
static char s_szStatic[32];
return s_szStatic;
}
/**
* Turns a form value into a string for logging purposes.
*
* @returns String name.
* @param uForm The form.
*/
{
switch (uForm)
{
}
static char s_szStatic[32];
return s_szStatic;
}
#endif /* LOG_ENABLED || RT_STRICT */
/** @callback_method_impl{FNRTLDRENUMSEGS} */
static DECLCALLBACK(int) rtDbgModDwarfScanSegmentsCallback(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser)
{
Log(("Segment %.*s: LinkAddress=%#llx RVA=%#llx cb=%#llx\n",
/* Count relevant segments. */
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTLDRENUMSEGS} */
static DECLCALLBACK(int) rtDbgModDwarfAddSegmentsCallback(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser)
{
Log(("Segment %.*s: LinkAddress=%#llx RVA=%#llx cb=%#llx cbMapped=%#llx\n",
pSeg->cchName, pSeg->pszName, (uint64_t)pSeg->LinkAddress, (uint64_t)pSeg->RVA, pSeg->cb, pSeg->cbMapped));
/* If the segment doesn't have a mapping, just add a dummy so the indexing
works out correctly (same as for the image). */
/* The link address is 0 for all segments in a relocatable ELF image. */
}
/**
* Calls pfnSegmentAdd for each segment in the executable image.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
*/
{
int rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfScanSegmentsCallback, pThis);
if (RT_SUCCESS(rc))
{
else
{
rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfAddSegmentsCallback, pThis);
}
}
return rc;
}
/**
* Looks up a segment.
*
* @returns Pointer to the segment on success, NULL if not found.
* @param pThis The DWARF instance.
* @param uSeg The segment number / selector.
*/
{
{
}
AssertFailed();
return NULL;
}
/**
* Record a segment:offset during pass 1.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param uSeg The segment number / selector.
* @param offSeg The segment offset.
*/
{
/* Look up the segment. */
{
break;
{
/* Add */
if (!pvNew)
return VERR_NO_MEMORY;
}
}
/* Increase it's range? */
{
}
return VINF_SUCCESS;
}
/**
* Calls pfnSegmentAdd for each segment in the executable image.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
*/
{
/*
* Are the segments assigned more or less in numerical order?
*/
{
/** @todo heuristics, plase. */
}
/*
* Assume DOS segmentation.
*/
else
{
}
/*
* Add them.
*/
{
Log3(("rtDbgModDwarfAddSegmentsFromPass1: Seg#%u: %#010llx LB %#llx uSegment=%#x\n",
char szName[32];
if (RT_FAILURE(rc))
return rc;
}
return VINF_SUCCESS;
}
/**
* Loads a DWARF section from the image file.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param enmSect The section to load.
*/
{
/*
* Don't load stuff twice.
*/
return VINF_SUCCESS;
/*
* Sections that are not present cannot be loaded, treat them like they
* are empty
*/
{
return VINF_SUCCESS;
}
return VINF_SUCCESS;
/*
* Sections must be readable with the current image interface.
*/
return VERR_OUT_OF_RANGE;
/*
* Do the job.
*/
}
#ifdef SOME_UNUSED_FUNCTION
/**
* Unloads a DWARF section previously mapped by rtDbgModDwarfLoadSection.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param enmSect The section to unload.
*/
{
return VINF_SUCCESS;
int rc = pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[enmSect].cb, &pThis->aSections[enmSect].pv);
return rc;
}
#endif
/**
* Converts to UTF-8 or otherwise makes sure it's valid UTF-8.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param ppsz Pointer to the string pointer. May be
* reallocated (RTStr*).
*/
{
/** @todo DWARF & UTF-8. */
return VINF_SUCCESS;
}
/**
* Convers a link address into a segment+offset or RVA.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param uSegment The segment, 0 if not applicable.
* @param LinkAddress The address to convert..
* @param piSeg The segment index.
* @param poffSeg Where to return the segment offset.
*/
static int rtDbgModDwarfLinkAddressToSegOffset(PRTDBGMODDWARF pThis, RTSEL uSegment, uint64_t LinkAddress,
{
{
if (pSeg)
{
*poffSeg = LinkAddress;
return VINF_SUCCESS;
}
}
if (pThis->fUseLinkAddress)
return pThis->pImgMod->pImgVt->pfnLinkAddressToSegOffset(pThis->pImgMod, LinkAddress, piSeg, poffSeg);
}
/*
*
* DWARF Cursor.
* DWARF Cursor.
* DWARF Cursor.
*
*/
/**
* Reads a 8-bit unsigned integer and advances the cursor.
*
* @returns 8-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on read error.
*/
{
{
return uErrValue;
}
return u8;
}
/**
* Reads a 16-bit unsigned integer and advances the cursor.
*
* @returns 16-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on read error.
*/
{
{
pCursor->cbUnitLeft = 0;
return uErrValue;
}
if (!pCursor->fNativEndian)
return u16;
}
/**
* Reads a 32-bit unsigned integer and advances the cursor.
*
* @returns 32-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on read error.
*/
{
{
pCursor->cbUnitLeft = 0;
return uErrValue;
}
if (!pCursor->fNativEndian)
return u32;
}
/**
* Reads a 64-bit unsigned integer and advances the cursor.
*
* @returns 64-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on read error.
*/
{
{
pCursor->cbUnitLeft = 0;
return uErrValue;
}
if (!pCursor->fNativEndian)
return u64;
}
/**
* Reads an unsigned LEB128 encoded number.
*
* @returns unsigned 64-bit number. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue The value to return on error.
*/
{
{
return uErrValue;
}
/*
* Special case - single byte.
*/
if (!(b & 0x80))
{
return b;
}
/*
* Generic case.
*/
/* Decode. */
do
{
{
break;
}
off++;
} while (b & 0x80);
/* Update the cursor. */
/* Check the range. */
if (cBits > 64)
{
}
return u64Ret;
}
/**
* Reads a signed LEB128 encoded number.
*
* @returns signed 64-bit number. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param sErrValue The value to return on error.
*/
{
{
return sErrValue;
}
/*
* Special case - single byte.
*/
if (!(b & 0x80))
{
if (b & 0x40)
b |= 0x80;
return (int8_t)b;
}
/*
* Generic case.
*/
/* Decode it. */
do
{
{
break;
}
off++;
} while (b & 0x80);
/* Update cursor. */
/* Check the range. */
if (cBits > 64)
{
}
/* Sign extend the value. */
}
/**
* Reads an unsigned LEB128 encoded number, max 32-bit width.
*
* @returns unsigned 32-bit number. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue The value to return on error.
*/
{
if (u64 > UINT32_MAX)
{
return uErrValue;
}
}
/**
* Reads a signed LEB128 encoded number, max 32-bit width.
*
* @returns signed 32-bit number. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param sErrValue The value to return on error.
*/
{
{
return sErrValue;
}
}
/**
* Skips a LEB128 encoded number.
*
* @returns IPRT status code.
* @param pCursor The cursor.
*/
{
do
{
{
break;
}
}
/**
* Advances the cursor a given number of bytes.
*
* @returns IPRT status code.
* @param pCursor The cursor.
* @param offSkip The number of bytes to advance.
*/
{
return VINF_SUCCESS;
}
/**
* Reads a zero terminated string, advancing the cursor beyond the terminator.
*
* @returns Pointer to the string.
* @param pCursor The cursor.
* @param pszErrValue What to return if the string isn't terminated
* before the end of the unit.
*/
{
for (;;)
{
if (!pCursor->cbUnitLeft)
{
return pszErrValue;
}
pCursor->cbUnitLeft--;
break;
}
return pszRet;
}
/**
* Reads a 1, 2, 4 or 8 byte unsgined value.
*
* @returns 64-bit unsigned value.
* @param pCursor The cursor.
* @param cbValue The value size.
* @param uErrValue The error value.
*/
static uint64_t rtDwarfCursor_GetVarSizedU(PRTDWARFCURSOR pCursor, size_t cbValue, uint64_t uErrValue)
{
switch (cbValue)
{
default:
return uErrValue;
}
return uErrValue;
return u64Ret;
}
#if 0 /* unused */
/**
* Gets the pointer to a variable size block and advances the cursor.
*
* @returns Pointer to the block at the current cursor location. On error
* RTDWARFCURSOR::rc is set and NULL returned.
* @param pCursor The cursor.
* @param cbBlock The block size.
*/
{
{
return NULL;
}
return pb;
}
#endif
/**
* Reads an unsigned DWARF half number.
*
* @returns The number. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on error.
*/
{
}
/**
* Reads an unsigned DWARF byte number.
*
* @returns The number. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on error.
*/
{
}
/**
* Reads a signed DWARF byte number.
*
* @returns The number. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on error.
*/
{
}
/**
* Reads a unsigned DWARF offset value.
*
* @returns The value. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on error.
*/
{
if (pCursor->f64bitDwarf)
}
/**
* Reads a unsigned DWARF native offset value.
*
* @returns The value. On error RTDWARFCURSOR::rc is set and @a
* uErrValue is returned.
* @param pCursor The cursor.
* @param uErrValue What to return on error.
*/
{
switch (pCursor->cbNativeAddr)
{
default:
return uErrValue;
}
}
/**
* Gets the unit length, updating the unit length member and DWARF bitness
* members of the cursor.
*
* @returns The unit length.
* @param pCursor The cursor.
*/
{
/*
* Read the initial length.
*/
pCursor->f64bitDwarf = false;
else
{
pCursor->f64bitDwarf = true;
}
/*
* Set the unit length, quitely fixing bad lengths.
*/
return cbUnit;
}
/**
* Calculates the section offset corresponding to the current cursor position.
*
* @returns 32-bit section offset. If out of range, RTDWARFCURSOR::rc will be
* set and UINT32_MAX returned.
* @param pCursor The cursor.
*/
{
{
AssertFailed();
offRet = UINT32_MAX;
}
return offRet;
}
/**
* Calculates an absolute cursor position from one relative to the current
* cursor position.
*
* @returns The absolute cursor position.
* @param pCursor The cursor.
* @param offRelative The relative position. Must be a positive
* offset.
*/
{
{
Log(("rtDwarfCursor_CalcPos: bad position %#zx, cbUnitLeft=%#zu\n", offRelative, pCursor->cbUnitLeft));
return NULL;
}
}
/**
* Advances the cursor to the given position.
*
* @returns IPRT status code.
* @param pCursor The cursor.
* @param pbNewPos The new position - returned by
* rtDwarfCursor_CalcPos().
*/
{
{
}
{
AssertFailed();
}
}
/**
* Check if the cursor is at the end of the current DWARF unit.
*
* @retval @c true if at the end or a cursor error is pending.
* @retval @c false if not.
* @param pCursor The cursor.
*/
{
}
/**
* Skips to the end of the current unit.
*
* @returns IPRT status code.
* @param pCursor The cursor.
*/
{
pCursor->cbUnitLeft = 0;
}
/**
* Check if the cursor is at the end of the section (or whatever the cursor is
* processing).
*
* @retval @c true if at the end or a cursor error is pending.
* @retval @c false if not.
* @param pCursor The cursor.
*/
{
}
/**
* Initialize a section reader cursor.
*
* @returns IPRT status code.
* @param pCursor The cursor.
* @param pThis The dwarf module.
* @param enmSect The name of the section to read.
*/
static int rtDwarfCursor_Init(PRTDWARFCURSOR pCursor, PRTDBGMODDWARF pThis, krtDbgModDwarfSect enmSect)
{
if (RT_FAILURE(rc))
return rc;
pCursor->f64bitDwarf = false;
/** @todo ask the image about the endian used as well as the address
* width. */
pCursor->fNativEndian = true;
return VINF_SUCCESS;
}
/**
* Initialize a section reader cursor with an offset.
*
* @returns IPRT status code.
* @param pCursor The cursor.
* @param pThis The dwarf module.
* @param enmSect The name of the section to read.
* @param offSect The offset into the section.
*/
{
{
Log(("rtDwarfCursor_InitWithOffset: offSect=%#x cb=%#x enmSect=%d\n", offSect, pThis->aSections[enmSect].cb, enmSect));
return VERR_DWARF_BAD_POS;
}
if (RT_SUCCESS(rc))
{
}
return rc;
}
/**
* Initialize a cursor for a block (subsection) retrieved from the given cursor.
*
* The parent cursor will be advanced past the block.
*
* @returns IPRT status code.
* @param pCursor The cursor.
* @param pParent The parent cursor. Will be moved by @a cbBlock.
* @param cbBlock The size of the block the new cursor should
* cover.
*/
static int rtDwarfCursor_InitForBlock(PRTDWARFCURSOR pCursor, PRTDWARFCURSOR pParent, uint32_t cbBlock)
{
{
return VERR_DWARF_BAD_POS;
}
return VINF_SUCCESS;
}
/**
* Deletes a section reader initialized by rtDwarfCursor_Init.
*
* @returns @a rcOther or RTDWARCURSOR::rc.
* @param pCursor The section reader.
* @param rcOther Other error code to be returned if it indicates
* error or if the cursor status is OK.
*/
{
/* ... and a drop of poison. */
return rcOther;
}
/*
*
* DWARF Line Numbers.
* DWARF Line Numbers.
* DWARF Line Numbers.
*
*/
/**
* Defines a file name.
*
* @returns IPRT status code.
* @param pLnState The line number program state.
* @param pszFilename The name of the file.
* @param idxInc The include path index.
*/
static int rtDwarfLine_DefineFileName(PRTDWARFLINESTATE pLnState, const char *pszFilename, uint64_t idxInc)
{
/*
* Resize the array if necessary.
*/
if ((iFileName % 2) == 0)
{
void *pv = RTMemRealloc(pLnState->papszFileNames, sizeof(pLnState->papszFileNames[0]) * (iFileName + 2));
if (!pv)
return VERR_NO_MEMORY;
}
/*
* Add the file name.
*/
if ( pszFilename[0] == '/'
|| pszFilename[0] == '\\'
else
return VERR_NO_STR_MEMORY;
/*
* Sanitize the name.
*/
return rc;
}
/**
* Adds a line to the table and resets parts of the state (DW_LNS_copy).
*
* @returns IPRT status code
* @param pLnState The line number program state.
* @param offOpCode The opcode offset (for logging
* purposes).
*/
{
int rc;
else
{
: "<bad file name index>";
rc = rtDbgModDwarfLinkAddressToSegOffset(pLnState->pDwarfMod, pLnState->Regs.uSegment, pLnState->Regs.uAddress,
if (RT_SUCCESS(rc))
{
Log2(("rtDwarfLine_AddLine: %x:%08llx (%#llx) %s(%d) [offOpCode=%08x]\n", iSeg, offSeg, pLnState->Regs.uAddress, pszFile, pLnState->Regs.uLine, offOpCode));
/* Ignore address conflicts for now. */
if (rc == VERR_DBG_ADDRESS_CONFLICT)
rc = VINF_SUCCESS;
}
else
}
return rc;
}
/**
* Reset the program to the start-of-sequence state.
*
* @param pLnState The line number program state.
*/
{
}
/**
* Runs the line number program.
*
* @returns IPRT status code.
* @param pLnState The line number program state.
* @param pCursor The cursor.
*/
{
int rc = VINF_SUCCESS;
while (!rtDwarfCursor_IsAtEndOfUnit(pCursor))
{
#ifdef LOG_ENABLED
#else
#endif
{
/*
* Special opcode.
*/
Log2(("%08x: DW Special Opcode %#04x: uLine + %d => %u; uAddress + %#llx => %#llx; idxOp + %#llx => %#llx\n",
}
else
{
switch (bOpCode)
{
/*
* Standard opcode.
*/
case DW_LNS_copy:
break;
case DW_LNS_advance_pc:
{
break;
}
case DW_LNS_advance_line:
{
Log2(("%08x: DW_LNS_advance_line: uLine + %d => %u\n", offOpCode, cLineDelta, pLnState->Regs.uLine));
break;
}
case DW_LNS_set_file:
break;
case DW_LNS_set_column:
break;
case DW_LNS_negate_stmt:
break;
case DW_LNS_set_basic_block:
break;
case DW_LNS_const_add_pc:
break;
case DW_LNS_fixed_advance_pc:
break;
case DW_LNS_set_prologue_end:
break;
break;
case DW_LNS_set_isa:
break;
default:
{
Log(("rtDwarfLine_RunProgram: Unknown standard opcode %#x, %#x operands, at %08x.\n", bOpCode, cOpsToSkip, offOpCode));
while (cOpsToSkip-- > 0)
break;
}
/*
* Extended opcode.
*/
case DW_LNS_extended:
{
/* The instruction has a length prefix. */
return VERR_DWARF_BAD_LNE;
/* Get the opcode and deal with it if we know it. */
switch (bOpCode)
{
case DW_LNE_end_sequence:
#if 0 /* No need for this, I think. */
#endif
break;
case DW_LNE_set_address:
break;
case DW_LNE_define_file:
{
if (RT_SUCCESS(rc))
break;
}
/*
* Note! Was defined in DWARF 4. But... Watcom used it
* for setting the segment in DWARF 2, creating
* an incompatibility with the newer standard.
*/
case DW_LNE_set_descriminator:
{
}
else
{
Log2(("%08x: DW_LNE_set_segment: %#llx, cbInstr=%#x - Watcom Extension\n", offOpCode, uSeg, cbInstr));
}
break;
default:
Log(("rtDwarfLine_RunProgram: Unknown extended opcode %#x, length %#x at %08x\n", bOpCode, cbInstr, offOpCode));
break;
}
/* Advance the cursor to the end of the instruction . */
break;
}
}
}
/*
* Check the status before looping.
*/
if (RT_FAILURE(rc))
return rc;
}
return rc;
}
/**
* Reads the include directories for a line number unit.
*
* @returns IPRT status code
* @param pLnState The line number program state.
* @param pCursor The cursor.
*/
{
if (RT_FAILURE(rc))
return rc;
for (;;)
{
if (!*psz)
break;
if (RT_FAILURE(rc))
return rc;
}
}
/**
* Reads the include directories for a line number unit.
*
* @returns IPRT status code
* @param pLnState The line number program state.
* @param pCursor The cursor.
*/
{
for (;;)
{
{
void *pv = RTMemRealloc(pLnState->papszIncPaths, sizeof(pLnState->papszIncPaths[0]) * (pLnState->cIncPaths + 2));
if (!pv)
return VERR_NO_MEMORY;
}
if (!*psz)
break;
}
}
/**
* Explodes the line number table for a compilation unit.
*
* @returns IPRT status code
* @param pThis The DWARF instance.
* @param pCursor The cursor to read the line number information
* via.
*/
{
/*
* Parse the header.
*/
return rtDwarfCursor_SkipUnit(pCursor);
else
Log2(("DWARF Line number header:\n"
" uVer %d\n"
" offFirstOpcode %#llx\n"
" cbMinInstr %u\n"
" cMaxOpsPerInstr %u\n"
" u8DefIsStmt %u\n"
" s8LineBase %d\n"
" u8LineRange %u\n"
" u8OpcodeBase %u\n",
LnState.Hdr.u8DefIsStmt, LnState.Hdr.s8LineBase, LnState.Hdr.u8LineRange, LnState.Hdr.u8OpcodeBase));
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
/*
* Run the program....
*/
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
/*
* Clean up.
*/
while (i-- > 0)
return rc;
}
/**
* Explodes the line number table.
*
* The line numbers are insered into the debug info container.
*
* @returns IPRT status code
* @param pThis The DWARF instance.
*/
{
return VINF_SUCCESS;
if (RT_FAILURE(rc))
return rc;
while ( !rtDwarfCursor_IsAtEnd(&Cursor)
&& RT_SUCCESS(rc))
}
/*
*
* DWARF Abbreviations.
* DWARF Abbreviations.
* DWARF Abbreviations.
*
*/
/**
* Deals with a cache miss in rtDwarfAbbrev_Lookup.
*
* @returns Pointer to abbreviation cache entry (read only). May be rendered
* invalid by subsequent calls to this function.
* @param pThis The DWARF instance.
* @param uCode The abbreviation code to lookup.
*/
{
/*
* There is no entry with code zero.
*/
if (!uCode)
return NULL;
/*
* Resize the cache array if the code is considered cachable.
*/
bool fFillCache = true;
{
fFillCache = false;
else
{
if (!pv)
fFillCache = false;
else
{
}
}
}
/*
* Walk the abbreviations till we find the desired code.
*/
int rc = rtDwarfCursor_InitWithOffset(&Cursor, pThis, krtDbgModDwarfSect_abbrev, pThis->offCachedAbbrev);
if (RT_FAILURE(rc))
return NULL;
if (fFillCache)
{
/*
* Search for the entry and fill the cache while doing so.
* We assume that abbreviation codes for a unit will stop when we see
* zero code or when the code value drops.
*/
for (;;)
{
/* Read the 'header'. Skipping zero code bytes. */
break; /* probably end of unit. */
if (uCurCode != 0)
{
break;
if ( uCurTag > 0xffff
|| uChildren > 1)
{
break;
}
/* Cache it? */
{
{
{
break;
}
}
else if (pRet)
break; /* Next unit, don't cache more. */
/* else: We're growing the cache and re-reading old data. */
}
/* Skip the specification. */
do
{
} while (uAttr != 0);
}
break;
/* Done? (Maximize cache filling.) */
break;
}
}
else
{
/*
* Search for the entry with the desired code, no cache filling.
*/
for (;;)
{
/* Read the 'header'. */
break;
if ( uCurTag > 0xffff
|| uChildren > 1)
{
break;
}
/* Do we have a match? */
{
break;
}
/* Skip the specification. */
do
{
} while (uAttr != 0);
break;
}
}
return pRet;
}
/**
* Looks up an abbreviation.
*
* @returns Pointer to abbreviation cache entry (read only). May be rendered
* invalid by subsequent calls to this function.
* @param pThis The DWARF instance.
* @param uCode The abbreviation code to lookup.
*/
{
}
/**
* Sets the abbreviation offset of the current unit.
*
* @param pThis The DWARF instance.
* @param offAbbrev The offset into the abbreviation section.
*/
{
}
/*
*
* DIE Attribute Parsers.
* DIE Attribute Parsers.
* DIE Attribute Parsers.
*
*/
/**
* Gets the compilation unit a DIE belongs to.
*
* @returns The compilation unit DIE.
* @param pDie Some DIE in the unit.
*/
{
NULL);
return (PRTDWARFDIECOMPILEUNIT)pDie;
}
/**
* Resolves a string section (debug_str) reference.
*
* @returns Pointer to the string (inside the string section).
* @param pThis The DWARF instance.
* @param pCursor The cursor.
* @param pszErrValue What to return on failure (@a
* pCursor->rc is set).
*/
static const char *rtDwarfDecodeHlp_GetStrp(PRTDBGMODDWARF pThis, PRTDWARFCURSOR pCursor, const char *pszErrValue)
{
return pszErrValue;
{
/* Ugly: Exploit the cursor status field for reporting errors. */
return pszErrValue;
}
{
if (RT_FAILURE(rc))
{
/* Ugly: Exploit the cursor status field for reporting errors. */
return pszErrValue;
}
}
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_Address(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
switch (uForm)
{
default:
AssertMsgFailedReturn(("%#x (%s)\n", uForm, rtDwarfLog_FormName(uForm)), VERR_DWARF_UNEXPECTED_FORM);
}
Log4((" %-20s %#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), uAddr, rtDwarfLog_FormName(uForm)));
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_Bool(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
switch (uForm)
{
case DW_FORM_flag:
{
if (b > 1)
{
Log(("Unexpected boolean value %#x\n", b));
}
break;
}
case DW_FORM_flag_present:
*pfMember = true;
break;
default:
}
Log4((" %-20s %RTbool [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), *pfMember, rtDwarfLog_FormName(uForm)));
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_LowHighPc(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
switch (uForm)
{
default:
}
{
if (pRange->fHaveLowAddress)
{
Log(("rtDwarfDecode_LowHighPc: Duplicate DW_AT_low_pc\n"));
}
pRange->fHaveLowAddress = true;
}
else
{
if (pRange->fHaveHighAddress)
{
Log(("rtDwarfDecode_LowHighPc: Duplicate DW_AT_high_pc\n"));
}
pRange->fHaveHighAddress = true;
{
pRange->fHaveHighIsAddress = true;
}
else
}
Log4((" %-20s %#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), uAddr, rtDwarfLog_FormName(uForm)));
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_Ranges(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
/* Decode it. */
switch (uForm)
{
default:
}
/* Validate the offset and load the ranges. */
{
}
{
if (RT_FAILURE(rc))
}
/* Store the result. */
if (pRange->fHaveRanges)
{
Log(("rtDwarfDecode_Ranges: Duplicate DW_AT_ranges\n"));
}
pRange->fHaveRanges = true;
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_Reference(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
/* Decode it. */
switch (uForm)
{
case DW_FORM_ref_addr:
break;
case DW_FORM_ref_sig8:
break;
default:
}
/* Validate the offset and convert to debug_info relative offsets. */
if (enmWrt == krtDwarfRef_InfoSection)
{
{
}
}
else if (enmWrt == krtDwarfRef_SameUnit)
{
{
}
}
/* Store it */
Log4((" %-20s %d:%#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), enmWrt, off, rtDwarfLog_FormName(uForm)));
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_SectOff(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
switch (uForm)
{
default:
AssertMsgFailedReturn(("%#x (%s)\n", uForm, rtDwarfLog_FormName(uForm)), VERR_DWARF_UNEXPECTED_FORM);
}
{
default:
AssertMsgFailedReturn(("%u (%s)\n", pDesc->uAttr, rtDwarfLog_AttrName(pDesc->uAttr)), VERR_INTERNAL_ERROR_4);
}
{
/* Watcom generates offset past the end of the section, increasing the
offset by one for each compile unit. So, just fudge it. */
Log(("rtDwarfDecode_SectOff: bad off=%#llx, attr %#x (%s), enmSect=%d cb=%#llx; Assuming watcom/gcc.\n", off,
}
Log4((" %-20s %d:%#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), enmWrt, off, rtDwarfLog_FormName(uForm)));
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_String(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
const char *psz;
switch (uForm)
{
case DW_FORM_string:
break;
case DW_FORM_strp:
break;
default:
}
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_UnsignedInt(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
switch (uForm)
{
default:
}
switch (ATTR_GET_SIZE(pDesc))
{
case 1:
{
AssertFailed();
return VERR_OUT_OF_RANGE;
}
break;
case 2:
{
AssertFailed();
return VERR_OUT_OF_RANGE;
}
break;
case 4:
{
AssertFailed();
return VERR_OUT_OF_RANGE;
}
break;
case 8:
{
AssertFailed();
return VERR_OUT_OF_RANGE;
}
break;
default:
}
return VINF_SUCCESS;
}
/**
* Initialize location interpreter state from cursor & form.
*
* @returns IPRT status code.
* @retval VERR_NOT_FOUND if no location information (i.e. there is source but
* it resulted in no byte code).
* @param pLoc The location state structure to initialize.
* @param pCursor The cursor to read from.
* @param uForm The attribute form.
*/
{
switch (uForm)
{
case DW_FORM_block1:
break;
case DW_FORM_block2:
break;
case DW_FORM_block4:
break;
case DW_FORM_block:
break;
default:
}
if (!cbBlock)
return VERR_NOT_FOUND;
if (RT_FAILURE(rc))
return rc;
return VINF_SUCCESS;
}
/**
* Pushes a value onto the stack.
*
* @returns VINF_SUCCESS or VERR_DWARF_STACK_OVERFLOW.
* @param pLoc The state.
* @param uValue The value to push.
*/
{
return VINF_SUCCESS;
}
{
{
/* Read the next opcode.*/
/* Get its operands. */
switch (bOpcode)
{
case DW_OP_addr:
break;
case DW_OP_pick:
case DW_OP_const1u:
case DW_OP_deref_size:
case DW_OP_xderef_size:
break;
case DW_OP_const1s:
break;
case DW_OP_const2u:
break;
case DW_OP_skip:
case DW_OP_bra:
case DW_OP_const2s:
break;
case DW_OP_const4u:
break;
case DW_OP_const4s:
break;
case DW_OP_const8u:
break;
case DW_OP_const8s:
break;
case DW_OP_regx:
case DW_OP_piece:
case DW_OP_plus_uconst:
case DW_OP_constu:
break;
case DW_OP_consts:
case DW_OP_fbreg:
break;
case DW_OP_bregx:
break;
}
break;
/* Interpret the opcode. */
int rc;
switch (bOpcode)
{
case DW_OP_const1u:
case DW_OP_const1s:
case DW_OP_const2u:
case DW_OP_const2s:
case DW_OP_const4u:
case DW_OP_const4s:
case DW_OP_const8u:
case DW_OP_const8s:
case DW_OP_constu:
case DW_OP_consts:
case DW_OP_addr:
break;
break;
case DW_OP_nop:
break;
case DW_OP_dup: /** @todo 0 operands. */
case DW_OP_drop: /** @todo 0 operands. */
case DW_OP_over: /** @todo 0 operands. */
case DW_OP_pick: /** @todo 1 operands, a 1-byte stack index. */
case DW_OP_swap: /** @todo 0 operands. */
case DW_OP_rot: /** @todo 0 operands. */
case DW_OP_abs: /** @todo 0 operands. */
case DW_OP_and: /** @todo 0 operands. */
case DW_OP_div: /** @todo 0 operands. */
case DW_OP_minus: /** @todo 0 operands. */
case DW_OP_mod: /** @todo 0 operands. */
case DW_OP_mul: /** @todo 0 operands. */
case DW_OP_neg: /** @todo 0 operands. */
case DW_OP_not: /** @todo 0 operands. */
case DW_OP_or: /** @todo 0 operands. */
case DW_OP_plus: /** @todo 0 operands. */
case DW_OP_plus_uconst: /** @todo 1 operands, a ULEB128 addend. */
case DW_OP_shl: /** @todo 0 operands. */
case DW_OP_shr: /** @todo 0 operands. */
case DW_OP_shra: /** @todo 0 operands. */
case DW_OP_xor: /** @todo 0 operands. */
case DW_OP_skip: /** @todo 1 signed 2-byte constant. */
case DW_OP_bra: /** @todo 1 signed 2-byte constant. */
case DW_OP_eq: /** @todo 0 operands. */
case DW_OP_ge: /** @todo 0 operands. */
case DW_OP_gt: /** @todo 0 operands. */
case DW_OP_le: /** @todo 0 operands. */
case DW_OP_lt: /** @todo 0 operands. */
case DW_OP_ne: /** @todo 0 operands. */
case DW_OP_reg0 + 0: case DW_OP_reg0 + 1: case DW_OP_reg0 + 2: case DW_OP_reg0 + 3: /** @todo 0 operands - reg 0..31. */
case DW_OP_breg0+ 0: case DW_OP_breg0+ 1: case DW_OP_breg0+ 2: case DW_OP_breg0+ 3: /** @todo 1 operand, a SLEB128 offset. */
case DW_OP_piece: /** @todo 1 operand, a ULEB128 size of piece addressed. */
case DW_OP_regx: /** @todo 1 operand, a ULEB128 register. */
case DW_OP_fbreg: /** @todo 1 operand, a SLEB128 offset. */
case DW_OP_bregx: /** @todo 2 operands, a ULEB128 register followed by a SLEB128 offset. */
case DW_OP_deref: /** @todo 0 operands. */
case DW_OP_deref_size: /** @todo 1 operand, a 1-byte size of data retrieved. */
case DW_OP_xderef: /** @todo 0 operands. */
case DW_OP_xderef_size: /** @todo 1 operand, a 1-byte size of data retrieved. */
default:
}
}
}
/** @callback_method_impl{FNRTDWARFATTRDECODER} */
static DECLCALLBACK(int) rtDwarfDecode_SegmentLoc(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
{
return VINF_SUCCESS;
}
}
}
return rc;
}
/*
*
* DWARF debug_info parser
* DWARF debug_info parser
* DWARF debug_info parser
*
*/
/**
* specification reference.
*
* Since this is a hack, we ignore failure.
*
* If we want to really make use of DWARF info, we'll have to create some kind
* of lookup tree for handling this. But currently we don't, so a hack will
* suffice.
*
* @param pThis The DWARF instance.
* @param pSubProgram The subprogram which is short on names.
*/
static void rtDwarfInfo_TryGetSubProgramNameFromSpecRef(PRTDBGMODDWARF pThis, PRTDWARFDIESUBPROGRAM pSubProgram)
{
/*
* Must have a spec ref, and it must be in the info section.
*/
return;
/*
* Create a cursor for reading the info and then the abbrivation code
* starting the off the DIE.
*/
int rc = rtDwarfCursor_InitWithOffset(&InfoCursor, pThis, krtDbgModDwarfSect_info, pSubProgram->SpecRef.off);
if (RT_FAILURE(rc))
return;
if (uAbbrCode)
{
/* Only references to subprogram tags are interesting here. */
if ( pAbbrev
{
/*
* Use rtDwarfInfo_ParseDie to do the parsing, but with a different
* attribute spec than usual.
*/
pAbbrev, false /*fInitDie*/);
}
}
}
/**
* Select which name to use.
*
* @returns One of the names.
* @param pszName The DWARF name, may exclude namespace and class.
* Can also be NULL.
* @param pszLinkageName The linkage name. Can be NULL.
*/
{
if (!pszName || !pszLinkageName)
/*
* Some heuristics for selecting the link name if the normal name is missing
* namespace or class prefixes.
*/
return pszName;
return pszName;
return pszLinkageName;
}
/**
* Parse the attributes of a DIE.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param pDie The internal DIE structure to fill.
*/
{
int rc = VINF_SUCCESS;
{
case DW_TAG_subprogram:
{
/* Obtain referenced specification there is only partial info. */
&& !pSubProgram->pszName)
{
Log5(("subprogram %s (%s) <implement ranges>\n", pSubProgram->pszName, pSubProgram->pszLinkageName));
else
{
{
else
{
if (RT_SUCCESS(rc))
{
else
cb = 1;
if (RT_FAILURE(rc))
{
if ( rc == VERR_DBG_DUPLICATE_SYMBOL
|| rc == VERR_DBG_ADDRESS_CONFLICT /** @todo figure why this happens with 10.6.8 mach_kernel, 32-bit. */
)
rc = VINF_SUCCESS;
else
}
}
{
Log5(("rtDbgModDwarfLinkAddressToSegOffset: Ignoring empty range.\n"));
}
else
{
}
}
}
}
}
else
break;
}
case DW_TAG_label:
{
{
else
{
if (RT_SUCCESS(rc))
{
}
else
}
}
break;
}
}
return rc;
}
/**
* Initializes the non-core fields of an internal DIE structure.
*
* @param pDie The DIE structure.
* @param pDieDesc The DIE descriptor.
*/
{
while (i-- > 0)
{
{
case ATTR_INIT_ZERO:
/* Nothing to do (RTMemAllocZ). */
break;
case ATTR_INIT_FFFS:
{
case 1:
break;
case 2:
break;
case 4:
break;
case 8:
break;
default:
AssertFailed();
break;
}
break;
default:
AssertFailed();
}
}
}
/**
* Creates a new internal DIE structure and links it up.
*
* @returns Pointer to the new DIE structure.
* @param pThis The DWARF instance.
* @param pDieDesc The DIE descriptor (for size and init).
* @param pAbbrev The abbreviation cache entry.
* @param pParent The parent DIE (NULL if unit).
*/
{
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
#else
#endif
if (pDie)
{
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
#endif
if (pParent)
else
}
return pDie;
}
/**
* Free all children of a DIE.
*
* @param pThis The DWARF instance.
* @param pParent The parent DIE.
*/
{
{
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
#else
#endif
}
}
/**
* Free a DIE an all its children.
*
* @param pThis The DWARF instance.
* @param pDie The DIE to free.
*/
{
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
#else
#endif
}
/**
* Skips a form.
* @returns IPRT status code
* @param pCursor The cursor.
* @param uForm The form to skip.
*/
{
switch (uForm)
{
case DW_FORM_addr:
case DW_FORM_block:
case DW_FORM_exprloc:
case DW_FORM_block1:
case DW_FORM_block2:
case DW_FORM_block4:
case DW_FORM_data1:
case DW_FORM_ref1:
case DW_FORM_flag:
case DW_FORM_data2:
case DW_FORM_ref2:
case DW_FORM_data4:
case DW_FORM_ref4:
case DW_FORM_data8:
case DW_FORM_ref8:
case DW_FORM_ref_sig8:
case DW_FORM_udata:
case DW_FORM_sdata:
case DW_FORM_ref_udata:
return rtDwarfCursor_SkipLeb128(pCursor);
case DW_FORM_string:
case DW_FORM_indirect:
case DW_FORM_strp:
case DW_FORM_ref_addr:
case DW_FORM_sec_offset:
case DW_FORM_flag_present:
default:
return VERR_DWARF_UNKNOWN_FORM;
}
}
#ifdef SOME_UNUSED_FUNCTION
/**
* Skips a DIE.
*
* @returns IPRT status code.
* @param pCursor The cursor.
* @param pAbbrevCursor The abbreviation cursor.
*/
{
for (;;)
{
break;
if (RT_FAILURE(rc))
return rc;
}
}
#endif
/**
* Parse the attributes of a DIE.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param pDie The internal DIE structure to fill.
* @param pDieDesc The DIE descriptor.
* @param pCursor The debug_info cursor.
* @param pAbbrev The abbreviation cache entry.
* @param fInitDie Whether to initialize the DIE first. If not (@c
* false) it's safe to assume we're following a
* DW_AT_specification or DW_AT_abstract_origin,
* and that we shouldn't be snooping any symbols.
*/
{
int rc = rtDwarfCursor_InitWithOffset(&AbbrevCursor, pThis, krtDbgModDwarfSect_abbrev, pAbbrev->offSpec);
if (RT_FAILURE(rc))
return rc;
if (fInitDie)
for (;;)
{
if (uAttr == 0)
break;
if (uForm == DW_FORM_indirect)
/* Look up the attribute in the descriptor and invoke the decoder. */
while (i-- > 0)
{
break;
}
/* Some house keeping. */
if (pAttr)
pDie->cDecodedAttrs++;
else
{
pDie->cUnhandledAttrs++;
}
if (RT_FAILURE(rc))
break;
}
if (RT_SUCCESS(rc))
/*
* Snoop up symbols on the way out.
*/
{
/* Ignore duplicates, get work done instead. */
if (rc == VERR_DBG_DUPLICATE_SYMBOL)
rc = VINF_SUCCESS;
}
return rc;
}
/**
* Load the debug information of a unit.
*
* @returns IPRT status code.
* @param pThis The DWARF instance.
* @param pCursor The debug_info cursor.
* @param fKeepDies Whether to keep the DIEs or discard them as soon
* as possible.
*/
{
/*
* Read the compilation unit header.
*/
if ( uVer < 2
|| uVer > 4)
return rtDwarfCursor_SkipUnit(pCursor);
/*
* Set up the abbreviation cache and store the native address size in the cursor.
*/
if (offAbbrev > UINT32_MAX)
{
return VERR_DWARF_BAD_INFO;
}
/*
* The first DIE is a compile or partial unit, parse it here.
*/
if (!uAbbrCode)
{
Log(("Unexpected abbrviation code of zero\n"));
return VERR_DWARF_BAD_INFO;
}
if (!pAbbrev)
return VERR_DWARF_ABBREV_NOT_FOUND;
{
return VERR_DWARF_BAD_INFO;
}
pUnit = (PRTDWARFDIECOMPILEUNIT)rtDwarfInfo_NewDie(pThis, &g_CompileUnitDesc, pAbbrev, NULL /*pParent*/);
if (!pUnit)
return VERR_NO_MEMORY;
int rc = rtDwarfInfo_ParseDie(pThis, &pUnit->Core, &g_CompileUnitDesc, pCursor, pAbbrev, true /*fInitDie*/);
if (RT_FAILURE(rc))
return rc;
/*
* Parse DIEs.
*/
while (!rtDwarfCursor_IsAtEndOfUnit(pCursor))
{
#ifdef LOG_ENABLED
#endif
if (!uAbbrCode)
{
/* End of siblings, up one level. (Is this correct?) */
if (pParentDie->pParent)
{
cDepth--;
}
}
else
{
/*
* Look up the abbreviation and match the tag up with a descriptor.
*/
if (!pAbbrev)
return VERR_DWARF_ABBREV_NOT_FOUND;
const char *pszName;
{
}
else
{
pszName = "<unknown>";
}
/*
* Create a new internal DIE structure and parse the
* attributes.
*/
if (!pNewDie)
return VERR_NO_MEMORY;
{
cDepth++;
}
if (RT_FAILURE(rc))
return rc;
}
} /* while more DIEs */
/* Unlink and free child DIEs if told to do so. */
if (!fKeepDies)
}
/**
* Extracts the symbols.
*
* The symbols are insered into the debug info container.
*
* @returns IPRT status code
* @param pThis The DWARF instance.
*/
{
if (RT_SUCCESS(rc))
{
while ( !rtDwarfCursor_IsAtEnd(&Cursor)
&& RT_SUCCESS(rc))
}
return rc;
}
/*
*
* Public and image level symbol handling.
* Public and image level symbol handling.
* Public and image level symbol handling.
* Public and image level symbol handling.
*
*
*/
/** @callback_method_impl{FNRTLDRENUMSYMS,
* Adds missing symbols from the image symbol table.} */
static DECLCALLBACK(int) rtDwarfSyms_EnumSymbolsCallback(RTLDRMOD hLdrMod, const char *pszSymbol, unsigned uSymbol,
{
{
int rc = RTDbgModSymbolByAddr(pThis->hCnt, RTDBGSEGIDX_RVA, uRva, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDisp, &SymInfo);
if ( RT_FAILURE(rc)
|| offDisp != 0)
{
rc = RTDbgModSymbolAdd(pThis->hCnt, pszSymbol, RTDBGSEGIDX_RVA, uRva, 1, 0 /*fFlags*/, NULL /*piOrdinal*/);
}
}
else
return VINF_SUCCESS;
}
/**
* Loads additional symbols from the pubnames section and the executable image.
*
* The symbols are insered into the debug info container.
*
* @returns IPRT status code
* @param pThis The DWARF instance.
*/
{
/*
* pubnames.
*/
int rc = VINF_SUCCESS;
{
// RTDWARFCURSOR Cursor;
// int rc = rtDwarfCursor_Init(&Cursor, pThis, krtDbgModDwarfSect_info);
// if (RT_SUCCESS(rc))
// {
// while ( !rtDwarfCursor_IsAtEnd(&Cursor)
// && RT_SUCCESS(rc))
// rc = rtDwarfInfo_LoadUnit(pThis, &Cursor, false /* fKeepDies */);
//
// rc = rtDwarfCursor_Delete(&Cursor, rc);
// }
// return rc;
}
/*
* The executable image.
*/
&& RT_SUCCESS(rc))
{
pThis);
}
return rc;
}
/*
*
* DWARF Debug module implementation.
* DWARF Debug module implementation.
* DWARF Debug module implementation.
*
*/
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineByAddr} */
static DECLCALLBACK(int) rtDbgModDwarf_LineByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off,
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineByOrdinal} */
static DECLCALLBACK(int) rtDbgModDwarf_LineByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo)
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineCount} */
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineAdd} */
static DECLCALLBACK(int) rtDbgModDwarf_LineAdd(PRTDBGMODINT pMod, const char *pszFile, size_t cchFile, uint32_t uLineNo,
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByAddr} */
static DECLCALLBACK(int) rtDbgModDwarf_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByName} */
static DECLCALLBACK(int) rtDbgModDwarf_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByOrdinal} */
static DECLCALLBACK(int) rtDbgModDwarf_SymbolByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolCount} */
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolAdd} */
static DECLCALLBACK(int) rtDbgModDwarf_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentByIndex} */
static DECLCALLBACK(int) rtDbgModDwarf_SegmentByIndex(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo)
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentCount} */
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentAdd} */
static DECLCALLBACK(int) rtDbgModDwarf_SegmentAdd(PRTDBGMODINT pMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName, size_t cchName,
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnImageSize} */
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnRvaToSegOff} */
static DECLCALLBACK(RTDBGSEGIDX) rtDbgModDwarf_RvaToSegOff(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg)
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnClose} */
{
pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[iSect].cb, &pThis->aSections[iSect].pv);
if (pThis->pNestedMod)
{
}
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
while (i-- > 0)
{
}
#endif
return VINF_SUCCESS;
}
/** @callback_method_impl{FNRTLDRENUMDBG} */
static DECLCALLBACK(int) rtDbgModDwarfEnumCallback(RTLDRMOD hLdrMod, PCRTLDRDBGINFO pDbgInfo, void *pvUser)
{
/*
* Skip stuff we can't handle.
*/
return VINF_SUCCESS;
if (!pszSection || !*pszSection)
return VINF_SUCCESS;
/*
* Must have a part name starting with debug_ and possibly prefixed by dots
* or underscores.
*/
return VINF_SUCCESS; /* Ignore special watcom section for now.*/
return VINF_SUCCESS; /* Ignore special apple sections for now. */
else
/*
* Figure out which part we're talking about.
*/
if (0) { /* dummy */ }
#define ELSE_IF_STRCMP_SET(a_Name) else if (!strcmp(pszSection, #a_Name)) enmSect = krtDbgModDwarfSect_ ## a_Name
else
{
return VINF_SUCCESS;
}
/*
* Record the section.
*/
AssertMsgReturn(!pThis->aSections[enmSect].fPresent, ("duplicate %s\n", pszSection), VINF_SUCCESS /*ignore*/);
return VINF_SUCCESS;
}
static int rtDbgModDwarfTryOpenDbgFile(PRTDBGMODINT pDbgMod, PRTDBGMODDWARF pThis, RTLDRARCH enmArch)
{
if ( !pDbgMod->pszDbgFile
return VERR_DBG_NO_MATCHING_INTERPRETER;
/*
* Only open the image.
*/
if (!pDbgInfoMod)
return VERR_NO_MEMORY;
int rc;
{
{
if (RT_SUCCESS(rc))
{
return VINF_SUCCESS;
}
}
else
}
else
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */
{
/*
* DWARF is only supported when part of an image.
*/
return VERR_DBG_NO_MATCHING_INTERPRETER;
/*
* Create the module instance data.
*/
if (!pThis)
return VERR_NO_MEMORY;
/** @todo better fUseLinkAddress heuristics! */
pThis->fUseLinkAddress = true;
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
{
int rc = RTMemCacheCreate(&pThis->aDieAllocators[i].hMemCache, pThis->aDieAllocators[i].cbMax, sizeof(uint64_t),
if (RT_FAILURE(rc))
{
while (i-- > 0)
return rc;
}
}
#endif
/*
* If the debug file name is set, let's see if it's an ELF image with DWARF
* inside it. In that case we'll have to deal with two image modules, one
* for segments and address translation and one for the debug information.
*/
/*
* Enumerate the debug info in the module, looking for DWARF bits.
*/
int rc = pThis->pDbgInfoMod->pImgVt->pfnEnumDbgInfo(pThis->pDbgInfoMod, rtDbgModDwarfEnumCallback, pThis);
if (RT_SUCCESS(rc))
{
{
/*
* Extract / explode the data we want (symbols and line numbers)
* storing them in a container module.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
}
if (RT_SUCCESS(rc))
{
/*
* Free the cached abbreviations and unload all sections.
*/
pThis->cCachedAbbrevsAlloced = 0;
/** @todo Kill pThis->CompileUnitList and the alloc caches. */
return VINF_SUCCESS;
}
/* bail out. */
}
}
else
}
#ifdef RTDBGMODDWARF_WITH_MEM_CACHE
while (i-- > 0)
{
}
#endif
return rc;
}
/** Virtual function table for the DWARF debug info reader. */
{
/*.u32Magic = */ RTDBGMODVTDBG_MAGIC,
/*.fSupports = */ RT_DBGTYPE_DWARF,
/*.pszName = */ "dwarf",
/*.pfnTryOpen = */ rtDbgModDwarf_TryOpen,
/*.pfnClose = */ rtDbgModDwarf_Close,
/*.pfnRvaToSegOff = */ rtDbgModDwarf_RvaToSegOff,
/*.pfnImageSize = */ rtDbgModDwarf_ImageSize,
/*.pfnSegmentAdd = */ rtDbgModDwarf_SegmentAdd,
/*.pfnSegmentCount = */ rtDbgModDwarf_SegmentCount,
/*.pfnSegmentByIndex = */ rtDbgModDwarf_SegmentByIndex,
/*.pfnSymbolAdd = */ rtDbgModDwarf_SymbolAdd,
/*.pfnSymbolCount = */ rtDbgModDwarf_SymbolCount,
/*.pfnSymbolByOrdinal = */ rtDbgModDwarf_SymbolByOrdinal,
/*.pfnSymbolByName = */ rtDbgModDwarf_SymbolByName,
/*.pfnSymbolByAddr = */ rtDbgModDwarf_SymbolByAddr,
/*.pfnLineAdd = */ rtDbgModDwarf_LineAdd,
/*.pfnLineCount = */ rtDbgModDwarf_LineCount,
/*.pfnLineByOrdinal = */ rtDbgModDwarf_LineByOrdinal,
/*.pfnLineByAddr = */ rtDbgModDwarf_LineByAddr,
/*.u32EndMagic = */ RTDBGMODVTDBG_MAGIC
};