dbgmoddwarf.cpp revision c895c42ff9e4863fa93d439de537c9f30dfab304
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * IPRT - Debug Info Reader For DWARF.
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync * Copyright (C) 2011-2013 Oracle Corporation
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * available from http://www.virtualbox.org. This file is free software;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * General Public License (GPL) as published by the Free Software
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * The contents of this file may alternatively be used under the terms
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * of the Common Development and Distribution License Version 1.0
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * VirtualBox OSE distribution, in which case the provisions of the
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * CDDL are applicable instead of those of the GPL.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * You may elect to license modified versions of this file under the
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * terms and conditions of either the GPL or the CDDL or both.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync/*******************************************************************************
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync* Header Files *
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync*******************************************************************************/
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync/*******************************************************************************
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync* Defined Constants And Macros *
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync*******************************************************************************/
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync/** @name Standard DWARF Line Number Opcodes
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync/** @name Extended DWARF Line Number Opcodes
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync/** @name DIE Tags.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync#define DW_TAG_imported_declaration UINT16_C(0x0008)
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync#define DW_TAG_unspecified_parameters UINT16_C(0x0018)
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync#define DW_TAG_template_type_parameter UINT16_C(0x002f)
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync#define DW_TAG_template_value_parameter UINT16_C(0x0030)
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync#define DW_TAG_rvalue_reference_type UINT16_C(0x0042)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync/** @name DIE Attributes.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync/** @name DIE Forms.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync/* What was 0x02? */
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @name Address classes.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync/** @name Location Expression Opcodes
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_addr UINT8_C(0x03) /**< 1 operand, a constant address (size target specific). */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_deref UINT8_C(0x06) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const1u UINT8_C(0x08) /**< 1 operand, a 1-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const1s UINT8_C(0x09) /**< 1 operand, a 1-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const2u UINT8_C(0x0a) /**< 1 operand, a 2-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const2s UINT8_C(0x0b) /**< 1 operand, a 2-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const4u UINT8_C(0x0c) /**< 1 operand, a 4-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const4s UINT8_C(0x0d) /**< 1 operand, a 4-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const8u UINT8_C(0x0e) /**< 1 operand, a 8-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_const8s UINT8_C(0x0f) /**< 1 operand, a 8-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_constu UINT8_C(0x10) /**< 1 operand, a ULEB128 constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_consts UINT8_C(0x11) /**< 1 operand, a SLEB128 constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_drop UINT8_C(0x13) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_over UINT8_C(0x14) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_pick UINT8_C(0x15) /**< 1 operands, a 1-byte stack index. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_swap UINT8_C(0x16) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_xderef UINT8_C(0x18) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_minus UINT8_C(0x1c) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_plus UINT8_C(0x22) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_plus_uconst UINT8_C(0x23) /**< 1 operands, a ULEB128 addend. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_shra UINT8_C(0x26) /**< 0 operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_skip UINT8_C(0x2f) /**< 1 signed 2-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_bra UINT8_C(0x28) /**< 1 signed 2-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_lit0 UINT8_C(0x30) /**< 0 operands - literals 0..31 */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_lit31 UINT8_C(0x4f) /**< last litteral. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_reg0 UINT8_C(0x50) /**< 0 operands - reg 0..31. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_reg31 UINT8_C(0x6f) /**< last register. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_breg0 UINT8_C(0x70) /**< 1 operand, a SLEB128 offset. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_breg31 UINT8_C(0x8f) /**< last branch register. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_regx UINT8_C(0x90) /**< 1 operand, a ULEB128 register. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_fbreg UINT8_C(0x91) /**< 1 operand, a SLEB128 offset. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_bregx UINT8_C(0x92) /**< 2 operands, a ULEB128 register followed by a SLEB128 offset. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_piece UINT8_C(0x93) /**< 1 operand, a ULEB128 size of piece addressed. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_deref_size UINT8_C(0x94) /**< 1 operand, a 1-byte size of data retrieved. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_xderef_size UINT8_C(0x95) /**< 1 operand, a 1-byte size of data retrieved. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_lo_user UINT8_C(0xe0) /**< First user opcode */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#define DW_OP_hi_user UINT8_C(0xff) /**< Last user opcode. */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync/*******************************************************************************
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync* Structures and Typedefs *
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync*******************************************************************************/
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** Pointer to a DWARF section reader. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** Pointer to an attribute descriptor. */
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef struct RTDWARFATTRDESC const *PCRTDWARFATTRDESC;
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** Pointer to a DIE. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** Pointer to a const DIE. */
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * DWARF sections.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /** End of valid parts (exclusive). */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Abbreviation cache entry.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** Whether this entry is filled in or not. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** Whether there are children or not. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** The tag. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** Offset into the abbrev section of the specification pairs. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync/** Pointer to an abbreviation cache entry. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync/** Pointer to a const abbreviation cache entry. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Structure for gathering segment info.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** The highest offset in the segment. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** Calculated base address. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** Estimated The segment size. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** Segment number (RTLDRSEG::Sel16bit). */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync/** Pointer to segment info. */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * The instance data of the DWARF reader.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /** The debug container containing doing the real work. */
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync /** The image module (no reference). */
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync /** The debug info module (no reference). */
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync /** Nested image module (with reference ofc). */
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /** DWARF debug info sections. */
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /** The file offset of the part. */
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /** The size of the part. */
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /** The memory mapping of the part. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync void const *pv;
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /** Set if present. */
3bb3e26b3306b9f62b18c17380bdf2ca3a98ca49vboxsync /** The debug info ordinal number in the image file. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** The offset into the abbreviation section of the current cache. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** The number of cached abbreviations we've allocated space for. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** Used for range checking cache lookups. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** Array of cached abbreviations, indexed by code. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** Used by rtDwarfAbbrev_Lookup when the result is uncachable. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The list of compilation units (RTDWARFDIE). */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** This is set to -1 if we're doing everything in one pass.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Otherwise it's 1 or 2:
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * - In pass 1, we collect segment info.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * - In pass 2, we add debug info to the container.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * The two pass parsing is necessary for watcom generated symbol files as
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * these contains no information about the code and data segments in the
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * image. So we have to figure out some approximate stuff based on the
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * segments and offsets we encounter in the debug info. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** Segment index hint. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** The number of segments in paSegs.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * (During segment copying, this is abused to count useful segments.) */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** Pointer to segments if iWatcomPass isn't -1. */
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync /** DIE allocators. */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync/** Pointer to instance data of the DWARF reader. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF cursor for reading byte data.
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync /** The current position. */
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync /** The number of bytes left to read. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /** The number of bytes left to read in the current unit. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /** The DWARF debug info reader instance. */
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync /** Set if this is 64-bit DWARF, clear if 32-bit. */
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync /** Set if the format endian is native, clear if endian needs to be
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync * inverted. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /** The size of a native address. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /** The cursor status code. This is VINF_SUCCESS until some error
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * occurs. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync /** The start of the area covered by the cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Used for repositioning the cursor relative to the start of a section. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /** The section. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF line number program state.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync /** Virtual Line Number Machine Registers. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync /** Header. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync /** @name Include Path Table (0-based)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync /** @name File Name Table (0-based, dummy zero entry)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync /** The DWARF debug info reader instance. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** Pointer to a DWARF line number program state. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync * Decodes an attribute and stores it in the specified DIE member field.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @returns IPRT status code.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pDie Pointer to the DIE structure.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pbMember Pointer to the first byte in the member.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pDesc The attribute descriptor.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param uForm The data form.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pDataCursor The cursor to read data from.
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef DECLCALLBACK(int) FNRTDWARFATTRDECODER(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** Pointer to an attribute decoder callback. */
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef FNRTDWARFATTRDECODER *PFNRTDWARFATTRDECODER;
e4bf6817370e1a71833a02285515694afcda7599vboxsync * Attribute descriptor.
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The attribute. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The data member size and initialization method. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The data member offset. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The decoder function. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** Define a attribute entry. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync#define ATTR_ENTRY(a_uAttr, a_Struct, a_Member, a_Init, a_pfnDecoder) \
e4bf6817370e1a71833a02285515694afcda7599vboxsync a_Init | ((uint8_t)RT_SIZEOFMEMB(a_Struct, a_Member) & ATTR_SIZE_MASK), \
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @name Attribute size and init methods.
e4bf6817370e1a71833a02285515694afcda7599vboxsync#define ATTR_GET_SIZE(a_pAttrDesc) ((a_pAttrDesc)->cbInit & ATTR_SIZE_MASK)
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DIE descriptor.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The size of the DIE. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The number of attributes. */
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef struct RTDWARFDIEDESC const *PCRTDWARFDIEDESC;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync/** DIE descriptor initializer. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync#define DIE_DESC_INIT(a_Type, a_aAttrs) { sizeof(a_Type), RT_ELEMENTS(a_aAttrs), &a_aAttrs[0] }
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DIE core structure, all inherits (starts with) this.
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef struct RTDWARFDIE
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** Pointer to the parent node. NULL if root unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** Our node in the sibling list. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** List of children. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The number of attributes successfully decoded. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The number of unknown or otherwise unhandled attributes. */
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync /** The allocator index. */
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync /** The die tag, indicating which union structure to use. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** Offset of the abbreviation specification (within debug_abbrev). */
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DWARF address structure.
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef struct RTDWARFADDR
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The address. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DWARF address range.
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** What a RTDWARFREF is relative to. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DWARF reference.
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef struct RTDWARFREF
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The offset. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** What the offset is relative to. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * DWARF Location state.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsynctypedef struct RTDWARFLOCST
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /** The input cursor. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /** Points to the current top of the stack. Initial value -1. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /** The value stack. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync/** Pointer to location state. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync/*******************************************************************************
e4bf6817370e1a71833a02285515694afcda7599vboxsync* Internal Functions *
e4bf6817370e1a71833a02285515694afcda7599vboxsync*******************************************************************************/
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic FNRTDWARFATTRDECODER rtDwarfDecode_LowHighPc;
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic FNRTDWARFATTRDECODER rtDwarfDecode_Reference;
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic FNRTDWARFATTRDECODER rtDwarfDecode_UnsignedInt;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic FNRTDWARFATTRDECODER rtDwarfDecode_SegmentLoc;
e4bf6817370e1a71833a02285515694afcda7599vboxsync/*******************************************************************************
e4bf6817370e1a71833a02285515694afcda7599vboxsync* Global Variables *
e4bf6817370e1a71833a02285515694afcda7599vboxsync*******************************************************************************/
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync/** RTDWARFDIE description. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic const RTDWARFDIEDESC g_CoreDieDesc = { sizeof(RTDWARFDIE), 0, NULL };
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DW_TAG_compile_unit & DW_TAG_partial_unit.
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The DIE core structure. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The unit name. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync const char *pszName;
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The address range of the code belonging to this unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The language name. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The identifier case. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** String are UTF-8 encoded. If not set, the encoding is
e4bf6817370e1a71833a02285515694afcda7599vboxsync * unknown. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The unit contains main() or equivalent. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The line numbers for this unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The macro information for this unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** Reference to the base types. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** Working directory for the unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The name of the compiler or whatever that produced this unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** @name From the unit header.
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The offset into debug_info of this unit (for references). */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The length of this unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The offset into debug_abbrev of the abbreviation for this unit. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The native address size. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /** The DWARF version. */
e4bf6817370e1a71833a02285515694afcda7599vboxsynctypedef RTDWARFDIECOMPILEUNIT *PRTDWARFDIECOMPILEUNIT;
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** RTDWARFDIECOMPILEUNIT attributes. */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic const RTDWARFATTRDESC g_aCompileUnitAttrs[] =
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_name, RTDWARFDIECOMPILEUNIT, pszName, ATTR_INIT_ZERO, rtDwarfDecode_String),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_low_pc, RTDWARFDIECOMPILEUNIT, PcRange, ATTR_INIT_ZERO, rtDwarfDecode_LowHighPc),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_high_pc, RTDWARFDIECOMPILEUNIT, PcRange, ATTR_INIT_ZERO, rtDwarfDecode_LowHighPc),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_ranges, RTDWARFDIECOMPILEUNIT, PcRange, ATTR_INIT_ZERO, rtDwarfDecode_Ranges),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_language, RTDWARFDIECOMPILEUNIT, uLanguage, ATTR_INIT_ZERO, rtDwarfDecode_UnsignedInt),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_macro_info, RTDWARFDIECOMPILEUNIT, MacroInfoRef, ATTR_INIT_ZERO, rtDwarfDecode_SectOff),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_stmt_list, RTDWARFDIECOMPILEUNIT, StmtListRef, ATTR_INIT_ZERO, rtDwarfDecode_SectOff),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_comp_dir, RTDWARFDIECOMPILEUNIT, pszCurDir, ATTR_INIT_ZERO, rtDwarfDecode_String),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_producer, RTDWARFDIECOMPILEUNIT, pszProducer, ATTR_INIT_ZERO, rtDwarfDecode_String),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_identifier_case, RTDWARFDIECOMPILEUNIT, uIdentifierCase,ATTR_INIT_ZERO, rtDwarfDecode_UnsignedInt),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_base_types, RTDWARFDIECOMPILEUNIT, BaseTypesRef, ATTR_INIT_ZERO, rtDwarfDecode_Reference),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_use_UTF8, RTDWARFDIECOMPILEUNIT, fUseUtf8, ATTR_INIT_ZERO, rtDwarfDecode_Bool),
e4bf6817370e1a71833a02285515694afcda7599vboxsync ATTR_ENTRY(DW_AT_main_subprogram, RTDWARFDIECOMPILEUNIT, fMainFunction, ATTR_INIT_ZERO, rtDwarfDecode_Bool)
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** RTDWARFDIECOMPILEUNIT description. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic const RTDWARFDIEDESC g_CompileUnitDesc = DIE_DESC_INIT(RTDWARFDIECOMPILEUNIT, g_aCompileUnitAttrs);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * DW_TAG_subprogram.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The DIE core structure. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The name. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync const char *pszName;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The linkage name. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The address range of the code belonging to this unit. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The first instruction in the function. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /** Segment number (watcom). */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync/** Pointer to a DW_TAG_subprogram DIE. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsynctypedef RTDWARFDIESUBPROGRAM *PRTDWARFDIESUBPROGRAM;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync/** Pointer to a const DW_TAG_subprogram DIE. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsynctypedef RTDWARFDIESUBPROGRAM const *PCRTDWARFDIESUBPROGRAM;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync/** RTDWARFDIESUBPROGRAM attributes. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_name, RTDWARFDIESUBPROGRAM, pszName, ATTR_INIT_ZERO, rtDwarfDecode_String),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_linkage_name, RTDWARFDIESUBPROGRAM, pszLinkageName, ATTR_INIT_ZERO, rtDwarfDecode_String),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_low_pc, RTDWARFDIESUBPROGRAM, PcRange, ATTR_INIT_ZERO, rtDwarfDecode_LowHighPc),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_high_pc, RTDWARFDIESUBPROGRAM, PcRange, ATTR_INIT_ZERO, rtDwarfDecode_LowHighPc),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_ranges, RTDWARFDIESUBPROGRAM, PcRange, ATTR_INIT_ZERO, rtDwarfDecode_Ranges),
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync ATTR_ENTRY(DW_AT_entry_pc, RTDWARFDIESUBPROGRAM, EntryPc, ATTR_INIT_ZERO, rtDwarfDecode_Address),
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync ATTR_ENTRY(DW_AT_segment, RTDWARFDIESUBPROGRAM, uSegment, ATTR_INIT_ZERO, rtDwarfDecode_SegmentLoc)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync/** RTDWARFDIESUBPROGRAM description. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic const RTDWARFDIEDESC g_SubProgramDesc = DIE_DESC_INIT(RTDWARFDIESUBPROGRAM, g_aSubProgramAttrs);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * DW_TAG_label.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** The DIE core structure. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** The name. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync const char *pszName;
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** The address of the first instruction. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** Segment number (watcom). */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** Externally visible? */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync/** Pointer to a DW_TAG_label DIE. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync/** Pointer to a const DW_TAG_label DIE. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync/** RTDWARFDIESUBPROGRAM attributes. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync ATTR_ENTRY(DW_AT_name, RTDWARFDIELABEL, pszName, ATTR_INIT_ZERO, rtDwarfDecode_String),
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync ATTR_ENTRY(DW_AT_low_pc, RTDWARFDIELABEL, Address, ATTR_INIT_ZERO, rtDwarfDecode_Address),
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync ATTR_ENTRY(DW_AT_segment, RTDWARFDIELABEL, uSegment, ATTR_INIT_ZERO, rtDwarfDecode_SegmentLoc),
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync ATTR_ENTRY(DW_AT_external, RTDWARFDIELABEL, fExternal, ATTR_INIT_ZERO, rtDwarfDecode_Bool)
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync/** RTDWARFDIESUBPROGRAM description. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsyncstatic const RTDWARFDIEDESC g_LabelDesc = DIE_DESC_INIT(RTDWARFDIELABEL, g_aLabelAttrs);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * Tag names and descriptors.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic const struct RTDWARFTAGDESC
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The tag value. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The tag name as string. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync const char *pszName;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /** The DIE descriptor to use. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync#define TAGDESC(a_Name, a_pDesc) { DW_ ## a_Name, #a_Name, a_pDesc }
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync#define TAGDESC_CORE(a_Name) TAGDESC(a_Name, &g_CoreDieDesc)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync TAGDESC_CORE(TAG_unspecified_parameters), /* 0x18 */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync TAGDESC_CORE(TAG_template_value_parameter), /* 0x30 */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * Turns a tag value into a string for logging purposes.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @returns String name.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param uTag The tag.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic const char *rtDwarfLog_GetTagName(uint32_t uTag)
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync RTStrPrintf(s_szStatic, sizeof(s_szStatic),"DW_TAG_%#x", uTag);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * Turns an attributevalue into a string for logging purposes.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @returns String name.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param uAttr The attribute.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic const char *rtDwarfLog_AttrName(uint32_t uAttr)
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync RTStrPrintf(s_szStatic, sizeof(s_szStatic),"DW_AT_%#x", uAttr);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * Turns a form value into a string for logging purposes.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @returns String name.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param uForm The form.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic const char *rtDwarfLog_FormName(uint32_t uForm)
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync RTStrPrintf(s_szStatic, sizeof(s_szStatic),"DW_FORM_%#x", uForm);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#endif /* LOG_ENABLED || RT_STRICT */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @callback_method_impl{FNRTLDRENUMSEGS} */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarfScanSegmentsCallback(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser)
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log(("Segment %.*s: LinkAddress=%#llx RVA=%#llx cb=%#llx\n",
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync pSeg->cchName, pSeg->pchName, (uint64_t)pSeg->LinkAddress, (uint64_t)pSeg->RVA, pSeg->cb));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /* Count relevant segments. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync/** @callback_method_impl{FNRTLDRENUMSEGS} */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarfAddSegmentsCallback(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync Log(("Segment %.*s: LinkAddress=%#llx RVA=%#llx cb=%#llx\n",
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync pSeg->cchName, pSeg->pchName, (uint64_t)pSeg->LinkAddress, (uint64_t)pSeg->RVA, pSeg->cb));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync AssertReturn(!pSeg->pchName[pSeg->cchName], VERR_DWARF_IPE);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /* If the segment doesn't have a mapping, just add a dummy so the indexing
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync works out correctly (same as for the image). */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync return RTDbgModSegmentAdd(pThis->hCnt, 0, 0, pSeg->pchName, 0 /*fFlags*/, NULL);
3bb3e26b3306b9f62b18c17380bdf2ca3a98ca49vboxsync /* The link address is 0 for all segments in a relocatable ELF image. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync return RTDbgModSegmentAdd(pThis->hCnt, pSeg->RVA, cb, pSeg->pchName, 0 /*fFlags*/, NULL);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Calls pfnSegmentAdd for each segment in the executable image.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns IPRT status code.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param pThis The DWARF instance.
d1e9999d55e7ac80a28692c161710be98071fc00vboxsyncstatic int rtDbgModDwarfAddSegmentsFromImage(PRTDBGMODDWARF pThis)
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync AssertReturn(pThis->pImgMod && pThis->pImgMod->pImgVt, VERR_INTERNAL_ERROR_2);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync int rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfScanSegmentsCallback, pThis);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfAddSegmentsCallback, pThis);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Looks up a segment.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @returns Pointer to the segment on success, NULL if not found.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param pThis The DWARF instance.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param uSeg The segment number / selector.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsyncstatic PRTDBGDWARFSEG rtDbgModDwarfFindSegment(PRTDBGMODDWARF pThis, RTSEL uSeg)
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Record a segment:offset during pass 1.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @returns IPRT status code.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param pThis The DWARF instance.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param uSeg The segment number / selector.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param offSeg The segment offset.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsyncstatic int rtDbgModDwarfRecordSegOffset(PRTDBGMODDWARF pThis, RTSEL uSeg, uint64_t offSeg)
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /* Look up the segment. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync void *pvNew = RTMemRealloc(paSegs, (pThis->cSegs + 1) * sizeof(paSegs[0]));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync memmove(&paSegs[iSeg + 1], &paSegs[iSeg], (cSegs - iSeg) * sizeof(paSegs[0]));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /* Increase it's range? */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log3(("rtDbgModDwarfRecordSegOffset: iSeg=%d uSeg=%#06x offSeg=%#llx\n", iSeg, uSeg, offSeg));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Calls pfnSegmentAdd for each segment in the executable image.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @returns IPRT status code.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param pThis The DWARF instance.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsyncstatic int rtDbgModDwarfAddSegmentsFromPass1(PRTDBGMODDWARF pThis)
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Are the segments assigned more or less in numerical order?
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync && paSegs[cSegs - 1].uSegment - paSegs[0].uSegment + 1U <= cSegs + 16U)
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /** @todo heuristics, plase. */
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Assume DOS segmentation.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync paSegs[iSeg].uBaseAddr = (uint32_t)paSegs[iSeg].uSegment << 16;
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Add them.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log3(("rtDbgModDwarfAddSegmentsFromPass1: Seg#%u: %#010llx LB %#llx uSegment=%#x\n",
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync iSeg, paSegs[iSeg].uBaseAddr, paSegs[iSeg].cbSegment, paSegs[iSeg].uSegment));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync RTStrPrintf(szName, sizeof(szName), "seg-%#04xh", paSegs[iSeg].uSegment);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync int rc = RTDbgModSegmentAdd(pThis->hCnt, paSegs[iSeg].uBaseAddr, paSegs[iSeg].cbSegment,
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Loads a DWARF section from the image file.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * @returns IPRT status code.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * @param pThis The DWARF instance.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * @param enmSect The section to load.
5b0a093ca572a855886faa6747ad46df859dd041vboxsyncstatic int rtDbgModDwarfLoadSection(PRTDBGMODDWARF pThis, krtDbgModDwarfSect enmSect)
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Don't load stuff twice.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Sections that are not present cannot be loaded, treat them like they
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * are empty
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Sections must be readable with the current image interface.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Do the job.
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync return pThis->pDbgInfoMod->pImgVt->pfnMapPart(pThis->pDbgInfoMod,
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Unloads a DWARF section previously mapped by rtDbgModDwarfLoadSection.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * @returns IPRT status code.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * @param pThis The DWARF instance.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * @param enmSect The section to unload.
5b0a093ca572a855886faa6747ad46df859dd041vboxsyncstatic int rtDbgModDwarfUnloadSection(PRTDBGMODDWARF pThis, krtDbgModDwarfSect enmSect)
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync int rc = pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[enmSect].cb, &pThis->aSections[enmSect].pv);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Converts to UTF-8 or otherwise makes sure it's valid UTF-8.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @returns IPRT status code.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pThis The DWARF instance.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param ppsz Pointer to the string pointer. May be
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * reallocated (RTStr*).
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int rtDbgModDwarfStringToUtf8(PRTDBGMODDWARF pThis, char **ppsz)
4e47bb772df0d04d1ded3e06354de547d52e2d06vboxsync /** @todo DWARF & UTF-8. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Convers a link address into a segment+offset or RVA.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @returns IPRT status code.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pThis The DWARF instance.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * @param uSegment The segment, 0 if not applicable.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param LinkAddress The address to convert..
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param piSeg The segment index.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param poffSeg Where to return the segment offset.
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsyncstatic int rtDbgModDwarfLinkAddressToSegOffset(PRTDBGMODDWARF pThis, RTSEL uSegment, uint64_t LinkAddress,
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync PRTDBGDWARFSEG pSeg = rtDbgModDwarfFindSegment(pThis, uSegment);
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync //return pThis->pImgMod->pImgVt->pfnRvaToSegOffset(pThis->pImgMod, LinkAddress, piSeg, poffSeg);
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync return pThis->pImgMod->pImgVt->pfnLinkAddressToSegOffset(pThis->pImgMod, LinkAddress, piSeg, poffSeg);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a 8-bit unsigned integer and advances the cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns 8-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on read error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint8_t rtDwarfCursor_GetU8(PRTDWARFCURSOR pCursor, uint8_t uErrValue)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a 16-bit unsigned integer and advances the cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns 16-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on read error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint16_t rtDwarfCursor_GetU16(PRTDWARFCURSOR pCursor, uint16_t uErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint16_t u16 = RT_MAKE_U16(pCursor->pb[0], pCursor->pb[1]);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a 32-bit unsigned integer and advances the cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns 32-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on read error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint32_t rtDwarfCursor_GetU32(PRTDWARFCURSOR pCursor, uint32_t uErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint32_t u32 = RT_MAKE_U32_FROM_U8(pCursor->pb[0], pCursor->pb[1], pCursor->pb[2], pCursor->pb[3]);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a 64-bit unsigned integer and advances the cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns 64-bit unsigned integer. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on read error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint64_t rtDwarfCursor_GetU64(PRTDWARFCURSOR pCursor, uint64_t uErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint64_t u64 = RT_MAKE_U64_FROM_U8(pCursor->pb[0], pCursor->pb[1], pCursor->pb[2], pCursor->pb[3],
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync pCursor->pb[4], pCursor->pb[5], pCursor->pb[6], pCursor->pb[7]);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads an unsigned LEB128 encoded number.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns unsigned 64-bit number. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param uErrValue The value to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint64_t rtDwarfCursor_GetULeb128(PRTDWARFCURSOR pCursor, uint64_t uErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Special case - single byte.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync if (!(b & 0x80))
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Generic case.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /* Decode. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync } while (b & 0x80);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /* Update the cursor. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /* Check the range. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a signed LEB128 encoded number.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns signed 64-bit number. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param sErrValue The value to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int64_t rtDwarfCursor_GetSLeb128(PRTDWARFCURSOR pCursor, int64_t sErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Special case - single byte.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync if (!(b & 0x80))
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync if (b & 0x40)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Generic case.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /* Decode it. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync } while (b & 0x80);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /* Update cursor. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /* Check the range. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /* Sign extend the value. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads an unsigned LEB128 encoded number, max 32-bit width.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns unsigned 32-bit number. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param uErrValue The value to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint32_t rtDwarfCursor_GetULeb128AsU32(PRTDWARFCURSOR pCursor, uint32_t uErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint64_t u64 = rtDwarfCursor_GetULeb128(pCursor, uErrValue);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a signed LEB128 encoded number, max 32-bit width.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns signed 32-bit number. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param sErrValue The value to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int32_t rtDwarfCursor_GetSLeb128AsS32(PRTDWARFCURSOR pCursor, int32_t sErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync int64_t s64 = rtDwarfCursor_GetSLeb128(pCursor, sErrValue);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Skips a LEB128 encoded number.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns IPRT status code.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int rtDwarfCursor_SkipLeb128(PRTDWARFCURSOR pCursor)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * Advances the cursor a given number of bytes.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @returns IPRT status code.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param pCursor The cursor.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param offSkip The number of bytes to advance.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsyncstatic int rtDwarfCursor_SkipBytes(PRTDWARFCURSOR pCursor, uint64_t offSkip)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Reads a zero terminated string, advancing the cursor beyond the terminator.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @returns Pointer to the string.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pszErrValue What to return if the string isn't terminated
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * before the end of the unit.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic const char *rtDwarfCursor_GetSZ(PRTDWARFCURSOR pCursor, const char *pszErrValue)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * Reads a 1, 2, 4 or 8 byte unsgined value.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @returns 64-bit unsigned value.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param pCursor The cursor.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param cbValue The value size.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param uErrValue The error value.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsyncstatic uint64_t rtDwarfCursor_GetVarSizedU(PRTDWARFCURSOR pCursor, size_t cbValue, uint64_t uErrValue)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync case 1: u64Ret = rtDwarfCursor_GetU8( pCursor, UINT8_MAX); break;
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync case 2: u64Ret = rtDwarfCursor_GetU16(pCursor, UINT16_MAX); break;
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync case 4: u64Ret = rtDwarfCursor_GetU32(pCursor, UINT32_MAX); break;
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync case 8: u64Ret = rtDwarfCursor_GetU64(pCursor, UINT64_MAX); break;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync#if 0 /* unused */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * Gets the pointer to a variable size block and advances the cursor.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @returns Pointer to the block at the current cursor location. On error
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * RTDWARFCURSOR::rc is set and NULL returned.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param pCursor The cursor.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param cbBlock The block size.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic const uint8_t *rtDwarfCursor_GetBlock(PRTDWARFCURSOR pCursor, uint32_t cbBlock)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads an unsigned DWARF half number.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns The number. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint16_t rtDwarfCursor_GetUHalf(PRTDWARFCURSOR pCursor, uint16_t uErrValue)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads an unsigned DWARF byte number.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns The number. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint8_t rtDwarfCursor_GetUByte(PRTDWARFCURSOR pCursor, uint8_t uErrValue)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a signed DWARF byte number.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns The number. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int8_t rtDwarfCursor_GetSByte(PRTDWARFCURSOR pCursor, int8_t iErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync return (int8_t)rtDwarfCursor_GetU8(pCursor, (uint8_t)iErrValue);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a unsigned DWARF offset value.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns The value. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on error.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint64_t rtDwarfCursor_GetUOff(PRTDWARFCURSOR pCursor, uint64_t uErrValue)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync return rtDwarfCursor_GetU32(pCursor, (uint32_t)uErrValue);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Reads a unsigned DWARF native offset value.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns The value. On error RTDWARFCURSOR::rc is set and @a
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * uErrValue is returned.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param uErrValue What to return on error.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic uint64_t rtDwarfCursor_GetNativeUOff(PRTDWARFCURSOR pCursor, uint64_t uErrValue)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync case 1: return rtDwarfCursor_GetU8(pCursor, (uint8_t )uErrValue);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync case 2: return rtDwarfCursor_GetU16(pCursor, (uint16_t)uErrValue);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync case 4: return rtDwarfCursor_GetU32(pCursor, (uint32_t)uErrValue);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync case 8: return rtDwarfCursor_GetU64(pCursor, uErrValue);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Gets the unit length, updating the unit length member and DWARF bitness
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * members of the cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @returns The unit length.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic uint64_t rtDwarfCursor_GetInitalLength(PRTDWARFCURSOR pCursor)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Read the initial length.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint64_t cbUnit = rtDwarfCursor_GetU32(pCursor, 0);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Set the unit length, quitely fixing bad lengths.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Calculates the section offset corresponding to the current cursor position.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @returns 32-bit section offset. If out of range, RTDWARFCURSOR::rc will be
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * set and UINT32_MAX returned.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param pCursor The cursor.
ad66a27959d7085aa31760f63ce082943be60e89vboxsyncstatic uint32_t rtDwarfCursor_CalcSectOffsetU32(PRTDWARFCURSOR pCursor)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync size_t off = pCursor->pb - (uint8_t const *)pCursor->pDwarfMod->aSections[pCursor->enmSect].pv;
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * Calculates an absolute cursor position from one relative to the current
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * cursor position.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * @returns The absolute cursor position.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * @param pCursor The cursor.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * @param offRelative The relative position. Must be a positive
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsyncstatic uint8_t const *rtDwarfCursor_CalcPos(PRTDWARFCURSOR pCursor, size_t offRelative)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log(("rtDwarfCursor_CalcPos: bad position %#zx, cbUnitLeft=%#zu\n", offRelative, pCursor->cbUnitLeft));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * Advances the cursor to the given position.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * @returns IPRT status code.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * @param pCursor The cursor.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * @param pbNewPos The new position - returned by
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * rtDwarfCursor_CalcPos().
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsyncstatic int rtDwarfCursor_AdvanceToPos(PRTDWARFCURSOR pCursor, uint8_t const *pbNewPos)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log(("rtDwarfCursor_AdvanceToPos: bad position %p, current %p\n", pbNewPos, pCursor->pb));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync uintptr_t cbAdj = (uintptr_t)pbNewPos - (uintptr_t)pCursor->pb;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Check if the cursor is at the end of the current DWARF unit.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @retval @c true if at the end or a cursor error is pending.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @retval @c false if not.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic bool rtDwarfCursor_IsAtEndOfUnit(PRTDWARFCURSOR pCursor)
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync return !pCursor->cbUnitLeft || RT_FAILURE(pCursor->rc);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Skips to the end of the current unit.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns IPRT status code.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int rtDwarfCursor_SkipUnit(PRTDWARFCURSOR pCursor)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Check if the cursor is at the end of the section (or whatever the cursor is
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * processing).
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @retval @c true if at the end or a cursor error is pending.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @retval @c false if not.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic bool rtDwarfCursor_IsAtEnd(PRTDWARFCURSOR pCursor)
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync return !pCursor->cbLeft || RT_FAILURE(pCursor->rc);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Initialize a section reader cursor.
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync * @returns IPRT status code.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor.
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync * @param pThis The dwarf module.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param enmSect The name of the section to read.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int rtDwarfCursor_Init(PRTDWARFCURSOR pCursor, PRTDBGMODDWARF pThis, krtDbgModDwarfSect enmSect)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync pCursor->pbStart = (uint8_t const *)pThis->aSections[enmSect].pv;
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync /** @todo ask the image about the endian used as well as the address
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * width. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Initialize a section reader cursor with an offset.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @returns IPRT status code.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param pCursor The cursor.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param pThis The dwarf module.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param enmSect The name of the section to read.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param offSect The offset into the section.
ad66a27959d7085aa31760f63ce082943be60e89vboxsyncstatic int rtDwarfCursor_InitWithOffset(PRTDWARFCURSOR pCursor, PRTDBGMODDWARF pThis,
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log(("rtDwarfCursor_InitWithOffset: offSect=%#x cb=%#x enmSect=%d\n", offSect, pThis->aSections[enmSect].cb, enmSect));
ad66a27959d7085aa31760f63ce082943be60e89vboxsync int rc = rtDwarfCursor_Init(pCursor, pThis, enmSect);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * Initialize a cursor for a block (subsection) retrieved from the given cursor.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * The parent cursor will be advanced past the block.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @returns IPRT status code.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param pCursor The cursor.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param pParent The parent cursor. Will be moved by @a cbBlock.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param cbBlock The size of the block the new cursor should
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic int rtDwarfCursor_InitForBlock(PRTDWARFCURSOR pCursor, PRTDWARFCURSOR pParent, uint32_t cbBlock)
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log(("rtDwarfCursor_InitForBlock: cbUnitLeft=%#x < cbBlock=%#x \n", pParent->cbUnitLeft, cbBlock));
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Deletes a section reader initialized by rtDwarfCursor_Init.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @returns @a rcOther or RTDWARCURSOR::rc.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @param pCursor The section reader.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @param rcOther Other error code to be returned if it indicates
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * error or if the cursor status is OK.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsyncstatic int rtDwarfCursor_Delete(PRTDWARFCURSOR pCursor, int rcOther)
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync /* ... and a drop of poison. */
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync if (RT_FAILURE(pCursor->rc) && RT_SUCCESS(rcOther))
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Line Numbers.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Line Numbers.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Line Numbers.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Defines a file name.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns IPRT status code.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pLnState The line number program state.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pszFilename The name of the file.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param idxInc The include path index.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic int rtDwarfLine_DefineFileName(PRTDWARFLINESTATE pLnState, const char *pszFilename, uint64_t idxInc)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Resize the array if necessary.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync void *pv = RTMemRealloc(pLnState->papszFileNames, sizeof(pLnState->papszFileNames[0]) * (iFileName + 2));
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Add the file name.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync || (RT_C_IS_ALPHA(pszFilename[0]) && pszFilename[1] == ':') )
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync pLnState->papszFileNames[iFileName] = RTStrDup(pszFilename);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync pLnState->papszFileNames[iFileName] = RTPathJoinA(pLnState->papszIncPaths[idxInc], pszFilename);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Sanitize the name.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync int rc = rtDbgModDwarfStringToUtf8(pLnState->pDwarfMod, &pLnState->papszFileNames[iFileName]);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync Log((" File #%02u = '%s'\n", iFileName, pLnState->papszFileNames[iFileName]));
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Adds a line to the table and resets parts of the state (DW_LNS_copy).
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns IPRT status code
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pLnState The line number program state.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param offOpCode The opcode offset (for logging
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * purposes).
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsyncstatic int rtDwarfLine_AddLine(PRTDWARFLINESTATE pLnState, uint32_t offOpCode)
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = rtDbgModDwarfRecordSegOffset(pThis, pLnState->Regs.uSegment, pLnState->Regs.uAddress + 1);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync const char *pszFile = pLnState->Regs.iFile < pLnState->cFileNames
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync : "<bad file name index>";
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = rtDbgModDwarfLinkAddressToSegOffset(pLnState->pDwarfMod, pLnState->Regs.uSegment, pLnState->Regs.uAddress,
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log2(("rtDwarfLine_AddLine: %x:%08llx (%#llx) %s(%d) [offOpCode=%08x]\n", iSeg, offSeg, pLnState->Regs.uAddress, pszFile, pLnState->Regs.uLine, offOpCode));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = RTDbgModLineAdd(pLnState->pDwarfMod->hCnt, pszFile, pLnState->Regs.uLine, iSeg, offSeg, NULL);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync /* Ignore address conflicts for now. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Reset the program to the start-of-sequence state.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pLnState The line number program state.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic void rtDwarfLine_ResetState(PRTDWARFLINESTATE pLnState)
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync pLnState->Regs.fIsStatement = RT_BOOL(pLnState->Hdr.u8DefIsStmt);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Runs the line number program.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @returns IPRT status code.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pLnState The line number program state.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int rtDwarfLine_RunProgram(PRTDWARFLINESTATE pLnState, PRTDWARFCURSOR pCursor)
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LogFlow(("rtDwarfLine_RunProgram: cbUnitLeft=%zu\n", pCursor->cbUnitLeft));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync uint32_t const offOpCode = rtDwarfCursor_CalcSectOffsetU32(pCursor);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync uint8_t bOpCode = rtDwarfCursor_GetUByte(pCursor, DW_LNS_extended);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Special opcode.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync uint8_t const bLogOpCode = bOpCode; NOREF(bLogOpCode);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync int32_t const cLineDelta = bOpCode % pLnState->Hdr.u8LineRange + (int32_t)pLnState->Hdr.s8LineBase;
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync uint64_t const cAddressDelta = uTmp / pLnState->Hdr.cMaxOpsPerInstr * pLnState->Hdr.cbMinInstr;
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync uint64_t const cOpIndexDelta = uTmp % pLnState->Hdr.cMaxOpsPerInstr;
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW Special Opcode %#04x: uLine + %d => %u; uAddress + %#llx => %#llx; idxOp + %#llx => %#llx\n",
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync offOpCode, bLogOpCode, cLineDelta, pLnState->Regs.uLine, cAddressDelta, pLnState->Regs.uAddress,
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Standard opcode.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint64_t u64Adv = rtDwarfCursor_GetULeb128(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync pLnState->Regs.uAddress += (pLnState->Regs.idxOp + u64Adv) / pLnState->Hdr.cMaxOpsPerInstr
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync pLnState->Regs.idxOp += (pLnState->Regs.idxOp + u64Adv) % pLnState->Hdr.cMaxOpsPerInstr;
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_advance_pc: u64Adv=%#llx (%lld) )\n", offOpCode, u64Adv, u64Adv));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync int32_t cLineDelta = rtDwarfCursor_GetSLeb128AsS32(pCursor, 0);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_advance_line: uLine + %d => %u\n", offOpCode, cLineDelta, pLnState->Regs.uLine));
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync pLnState->Regs.iFile = rtDwarfCursor_GetULeb128AsU32(pCursor, 0);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_set_file: iFile=%u\n", offOpCode, pLnState->Regs.iFile));
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync pLnState->Regs.uColumn = rtDwarfCursor_GetULeb128AsU32(pCursor, 0);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync pLnState->Regs.fIsStatement = !pLnState->Regs.fIsStatement;
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_set_basic_block\n", offOpCode));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync pLnState->Regs.uAddress += (pLnState->Regs.idxOp + 255) / pLnState->Hdr.cMaxOpsPerInstr
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync pLnState->Regs.idxOp += (pLnState->Regs.idxOp + 255) % pLnState->Hdr.cMaxOpsPerInstr;
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync pLnState->Regs.uAddress += rtDwarfCursor_GetUHalf(pCursor, 0);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_fixed_advance_pc\n", offOpCode));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_set_prologue_end\n", offOpCode));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_set_epilogue_begin\n", offOpCode));
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync pLnState->Regs.uIsa = rtDwarfCursor_GetULeb128AsU32(pCursor, 0);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNS_set_isa %#x\n", offOpCode, pLnState->Regs.uIsa));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync unsigned cOpsToSkip = pLnState->Hdr.pacStdOperands[bOpCode - 1];
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log(("rtDwarfLine_RunProgram: Unknown standard opcode %#x, %#x operands, at %08x.\n", bOpCode, cOpsToSkip, offOpCode));
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync while (cOpsToSkip-- > 0)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Extended opcode.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync /* The instruction has a length prefix. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint64_t cbInstr = rtDwarfCursor_GetULeb128(pCursor, UINT64_MAX);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync uint8_t const * const pbEndOfInstr = rtDwarfCursor_CalcPos(pCursor, cbInstr);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync /* Get the opcode and deal with it if we know it. */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync#if 0 /* No need for this, I think. */
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync pLnState->Regs.uAddress = rtDwarfCursor_GetVarSizedU(pCursor, cbInstr - 1, UINT64_MAX);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNE_set_address: %#llx\n", offOpCode, pLnState->Regs.uAddress));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync const char *pszFilename = rtDwarfCursor_GetSZ(pCursor, NULL);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync uint32_t idxInc = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNE_define_file: {%d}/%s\n", offOpCode, idxInc, pszFilename));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync rc = rtDwarfCursor_AdvanceToPos(pCursor, pbEndOfInstr);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync rc = rtDwarfLine_DefineFileName(pLnState, pszFilename, idxInc);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * Note! Was defined in DWARF 4. But... Watcom used it
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * for setting the segment in DWARF 2, creating
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * an incompatibility with the newer standard.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync pLnState->Regs.uDiscriminator = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log2(("%08x: DW_LNE_set_descriminator: %u\n", offOpCode, pLnState->Regs.uDiscriminator));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync uint64_t uSeg = rtDwarfCursor_GetVarSizedU(pCursor, cbInstr - 1, UINT64_MAX);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log2(("%08x: DW_LNE_set_segment: %#llx, cbInstr=%#x - Watcom Extension\n", offOpCode, uSeg, cbInstr));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync AssertStmt(pLnState->Regs.uSegment == uSeg, rc = VERR_DWARF_BAD_INFO);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log(("rtDwarfLine_RunProgram: Unknown extended opcode %#x, length %#x at %08x\n", bOpCode, cbInstr, offOpCode));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync /* Advance the cursor to the end of the instruction . */
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync * Check the status before looping.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Reads the include directories for a line number unit.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @returns IPRT status code
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pLnState The line number program state.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int rtDwarfLine_ReadFileNames(PRTDWARFLINESTATE pLnState, PRTDWARFCURSOR pCursor)
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync int rc = rtDwarfLine_DefineFileName(pLnState, "/<bad-zero-file-name-entry>", 0);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync const char *psz = rtDwarfCursor_GetSZ(pCursor, NULL);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync uint64_t idxInc = rtDwarfCursor_GetULeb128(pCursor, UINT64_MAX);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync rc = rtDwarfLine_DefineFileName(pLnState, psz, idxInc);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Reads the include directories for a line number unit.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @returns IPRT status code
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pLnState The line number program state.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * @param pCursor The cursor.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsyncstatic int rtDwarfLine_ReadIncludePaths(PRTDWARFLINESTATE pLnState, PRTDWARFCURSOR pCursor)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync const char *psz = ""; /* The zeroth is the unit dir. */
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync void *pv = RTMemRealloc(pLnState->papszIncPaths, sizeof(pLnState->papszIncPaths[0]) * (pLnState->cIncPaths + 2));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync Log((" Path #%02u = '%s'\n", pLnState->cIncPaths, psz));
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync pLnState->papszIncPaths[pLnState->cIncPaths] = psz;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * Explodes the line number table for a compilation unit.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @returns IPRT status code
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pThis The DWARF instance.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * @param pCursor The cursor to read the line number information
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic int rtDwarfLine_ExplodeUnit(PRTDBGMODDWARF pThis, PRTDWARFCURSOR pCursor)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Parse the header.
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.uVer = rtDwarfCursor_GetUHalf(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.offFirstOpcode = rtDwarfCursor_GetUOff(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync uint8_t const * const pbFirstOpcode = rtDwarfCursor_CalcPos(pCursor, LnState.Hdr.offFirstOpcode);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.cbMinInstr = rtDwarfCursor_GetUByte(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.cMaxOpsPerInstr = rtDwarfCursor_GetUByte(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.u8DefIsStmt = rtDwarfCursor_GetUByte(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.s8LineBase = rtDwarfCursor_GetSByte(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.u8LineRange = rtDwarfCursor_GetUByte(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.u8OpcodeBase = rtDwarfCursor_GetUByte(pCursor, 0);
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " uVer %d\n"
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " offFirstOpcode %#llx\n"
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " cbMinInstr %u\n"
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " cMaxOpsPerInstr %u\n"
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " u8DefIsStmt %u\n"
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " s8LineBase %d\n"
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " u8LineRange %u\n"
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync " u8OpcodeBase %u\n",
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.uVer, LnState.Hdr.offFirstOpcode, LnState.Hdr.cbMinInstr, LnState.Hdr.cMaxOpsPerInstr,
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync LnState.Hdr.u8DefIsStmt, LnState.Hdr.s8LineBase, LnState.Hdr.u8LineRange, LnState.Hdr.u8OpcodeBase));
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync for (uint8_t iStdOpcode = 1; iStdOpcode < LnState.Hdr.u8OpcodeBase; iStdOpcode++)
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync rc = rtDwarfLine_ReadIncludePaths(&LnState, pCursor);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Run the program....
5a5b5956f8b592c807c94785d58c25e717d430c4vboxsync rc = rtDwarfCursor_AdvanceToPos(pCursor, pbFirstOpcode);
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync * Clean up.
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync while (i-- > 0)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync Assert(rtDwarfCursor_IsAtEndOfUnit(pCursor) || RT_FAILURE(rc));
d3dea25ec07f6546715fe3af943ea863294b392evboxsync * Explodes the line number table.
d3dea25ec07f6546715fe3af943ea863294b392evboxsync * The line numbers are insered into the debug info container.
d3dea25ec07f6546715fe3af943ea863294b392evboxsync * @returns IPRT status code
d3dea25ec07f6546715fe3af943ea863294b392evboxsync * @param pThis The DWARF instance.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic int rtDwarfLine_ExplodeAll(PRTDBGMODDWARF pThis)
b26e5b503baa3dffc58048982eaf17ad1b53f207vboxsync if (!pThis->aSections[krtDbgModDwarfSect_line].fPresent)
71e045383a3316b27563b2f44b0e0e1231968bdcvboxsync int rc = rtDwarfCursor_Init(&Cursor, pThis, krtDbgModDwarfSect_line);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * DWARF Abbreviations.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * DWARF Abbreviations.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * DWARF Abbreviations.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Deals with a cache miss in rtDwarfAbbrev_Lookup.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @returns Pointer to abbreviation cache entry (read only). May be rendered
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * invalid by subsequent calls to this function.
d3dea25ec07f6546715fe3af943ea863294b392evboxsync * @param pThis The DWARF instance.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param uCode The abbreviation code to lookup.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsyncstatic PCRTDWARFABBREV rtDwarfAbbrev_LookupMiss(PRTDBGMODDWARF pThis, uint32_t uCode)
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * There is no entry with code zero.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Resize the cache array if the code is considered cachable.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync void *pv = RTMemRealloc(pThis->paCachedAbbrevs, sizeof(pThis->paCachedAbbrevs[0]) * cNew);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Walk the abbreviations till we find the desired code.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync int rc = rtDwarfCursor_InitWithOffset(&Cursor, pThis, krtDbgModDwarfSect_abbrev, pThis->offCachedAbbrev);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Search for the entry and fill the cache while doing so.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /* Read the 'header'. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint32_t const uCurCode = rtDwarfCursor_GetULeb128AsU32(&Cursor, 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint32_t const uCurTag = rtDwarfCursor_GetULeb128AsU32(&Cursor, 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint8_t const uChildren = rtDwarfCursor_GetU8(&Cursor, 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /* Cache it? */
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync PRTDWARFABBREV pEntry = &pThis->paCachedAbbrevs[uCurCode - 1];
ad66a27959d7085aa31760f63ce082943be60e89vboxsync pThis->paCachedAbbrevs[pThis->cCachedAbbrevs].fFilled = false;
ad66a27959d7085aa31760f63ce082943be60e89vboxsync pEntry->offSpec = rtDwarfCursor_CalcSectOffsetU32(&Cursor);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /* Skip the specification. */
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync } while (uAttr != 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /* Done? (Maximize cache filling.) */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Search for the entry with the desired code, no cache filling.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /* Read the 'header'. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint32_t const uCurCode = rtDwarfCursor_GetULeb128AsU32(&Cursor, 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint32_t const uCurTag = rtDwarfCursor_GetULeb128AsU32(&Cursor, 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint8_t const uChildren = rtDwarfCursor_GetU8(&Cursor, 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /* Do we have a match? */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync pRet->offSpec = rtDwarfCursor_CalcSectOffsetU32(&Cursor);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync /* Skip the specification. */
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync } while (uAttr != 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Looks up an abbreviation.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @returns Pointer to abbreviation cache entry (read only). May be rendered
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * invalid by subsequent calls to this function.
d3dea25ec07f6546715fe3af943ea863294b392evboxsync * @param pThis The DWARF instance.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param uCode The abbreviation code to lookup.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsyncstatic PCRTDWARFABBREV rtDwarfAbbrev_Lookup(PRTDBGMODDWARF pThis, uint32_t uCode)
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Sets the abbreviation offset of the current unit.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * This will flush the cached abbreviation entries if the offset differs from
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * the previous unit.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param pThis The DWARF instance.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param offAbbrev The offset into the abbreviation section.
ad66a27959d7085aa31760f63ce082943be60e89vboxsyncstatic void rtDwarfAbbrev_SetUnitOffset(PRTDBGMODDWARF pThis, uint32_t offAbbrev)
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DIE Attribute Parsers.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DIE Attribute Parsers.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DIE Attribute Parsers.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * Gets the compilation unit a DIE belongs to.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @returns The compilation unit DIE.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pDie Some DIE in the unit.
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic PRTDWARFDIECOMPILEUNIT rtDwarfDie_GetCompileUnit(PRTDWARFDIE pDie)
e4bf6817370e1a71833a02285515694afcda7599vboxsync * Resolves a string section (debug_str) reference.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @returns Pointer to the string (inside the string section).
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pThis The DWARF instance.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pCursor The cursor.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pszErrValue What to return on failure (@a
e4bf6817370e1a71833a02285515694afcda7599vboxsync * pCursor->rc is set).
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic const char *rtDwarfDecodeHlp_GetStrp(PRTDBGMODDWARF pThis, PRTDWARFCURSOR pCursor, const char *pszErrValue)
e4bf6817370e1a71833a02285515694afcda7599vboxsync uint64_t offDebugStr = rtDwarfCursor_GetUOff(pCursor, UINT64_MAX);
e4bf6817370e1a71833a02285515694afcda7599vboxsync if (offDebugStr >= pThis->aSections[krtDbgModDwarfSect_str].cb)
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Ugly: Exploit the cursor status field for reporting errors. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync int rc = rtDbgModDwarfLoadSection(pThis, krtDbgModDwarfSect_str);
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Ugly: Exploit the cursor status field for reporting errors. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync return (const char *)pThis->aSections[krtDbgModDwarfSect_str].pv + (size_t)offDebugStr;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_Address(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(RTDWARFADDR), VERR_INTERNAL_ERROR_3);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_addr: uAddr = rtDwarfCursor_GetNativeUOff(pCursor, 0); break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_data1: uAddr = rtDwarfCursor_GetU8(pCursor, 0); break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_data2: uAddr = rtDwarfCursor_GetU16(pCursor, 0); break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_data4: uAddr = rtDwarfCursor_GetU32(pCursor, 0); break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_data8: uAddr = rtDwarfCursor_GetU64(pCursor, 0); break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_udata: uAddr = rtDwarfCursor_GetULeb128(pCursor, 0); break;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertMsgFailedReturn(("%#x (%s)\n", uForm, rtDwarfLog_FormName(uForm)), VERR_DWARF_UNEXPECTED_FORM);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s %#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), uAddr, rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_Bool(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(bool), VERR_INTERNAL_ERROR_3);
e4bf6817370e1a71833a02285515694afcda7599vboxsync uint8_t b = rtDwarfCursor_GetU8(pCursor, UINT8_MAX);
e4bf6817370e1a71833a02285515694afcda7599vboxsync return RT_FAILURE(pCursor->rc) ? pCursor->rc : pCursor->rc = VERR_DWARF_BAD_INFO;
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertMsgFailedReturn(("%#x\n", uForm), VERR_DWARF_UNEXPECTED_FORM);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s %RTbool [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), *pfMember, rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_LowHighPc(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(RTDWARFADDRRANGE), VERR_INTERNAL_ERROR_3);
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertReturn(pDesc->uAttr == DW_AT_low_pc || pDesc->uAttr == DW_AT_high_pc, VERR_INTERNAL_ERROR_3);
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_addr: uAddr = rtDwarfCursor_GetNativeUOff(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data1: uAddr = rtDwarfCursor_GetU8(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data2: uAddr = rtDwarfCursor_GetU16(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data4: uAddr = rtDwarfCursor_GetU32(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data8: uAddr = rtDwarfCursor_GetU64(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_udata: uAddr = rtDwarfCursor_GetULeb128(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertMsgFailedReturn(("%#x\n", uForm), VERR_DWARF_UNEXPECTED_FORM);
e4bf6817370e1a71833a02285515694afcda7599vboxsync PRTDWARFADDRRANGE pRange = (PRTDWARFADDRRANGE)pbMember;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log(("rtDwarfDecode_LowHighPc: Duplicate DW_AT_low_pc\n"));
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log(("rtDwarfDecode_LowHighPc: Duplicate DW_AT_high_pc\n"));
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s %#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), uAddr, rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_Ranges(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(RTDWARFADDRRANGE), VERR_INTERNAL_ERROR_3);
3bb3e26b3306b9f62b18c17380bdf2ca3a98ca49vboxsync AssertReturn(pDesc->uAttr == DW_AT_ranges, VERR_INTERNAL_ERROR_3);
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Decode it. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_addr: off = rtDwarfCursor_GetNativeUOff(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data4: off = rtDwarfCursor_GetU32(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data8: off = rtDwarfCursor_GetU64(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertMsgFailedReturn(("%#x\n", uForm), VERR_DWARF_UNEXPECTED_FORM);
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Validate the offset and load the ranges. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync if (off >= pThis->aSections[krtDbgModDwarfSect_ranges].cb)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log(("rtDwarfDecode_Ranges: bad ranges off=%#llx\n", off));
e4bf6817370e1a71833a02285515694afcda7599vboxsync if (!pThis->aSections[krtDbgModDwarfSect_ranges].pv)
e4bf6817370e1a71833a02285515694afcda7599vboxsync int rc = rtDbgModDwarfLoadSection(pThis, krtDbgModDwarfSect_ranges);
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Store the result. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync PRTDWARFADDRRANGE pRange = (PRTDWARFADDRRANGE)pbMember;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log(("rtDwarfDecode_Ranges: Duplicate DW_AT_ranges\n"));
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync pRange->pbRanges = (uint8_t const *)pThis->aSections[krtDbgModDwarfSect_ranges].pv + (size_t)off;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s TODO [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_Reference(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(RTDWARFREF), VERR_INTERNAL_ERROR_3);
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Decode it. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_ref1: off = rtDwarfCursor_GetU8(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_ref2: off = rtDwarfCursor_GetU16(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_ref4: off = rtDwarfCursor_GetU32(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_ref8: off = rtDwarfCursor_GetU64(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_ref_udata: off = rtDwarfCursor_GetULeb128(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertMsgFailedReturn(("%#x\n", uForm), VERR_DWARF_UNEXPECTED_FORM);
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Validate the offset and convert to debug_info relative offsets. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync if (off >= pCursor->pDwarfMod->aSections[krtDbgModDwarfSect_info].cb)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log(("rtDwarfDecode_Reference: bad info off=%#llx\n", off));
e4bf6817370e1a71833a02285515694afcda7599vboxsync PRTDWARFDIECOMPILEUNIT pUnit = rtDwarfDie_GetCompileUnit(pDie);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log(("rtDwarfDecode_Reference: bad unit off=%#llx\n", off));
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* else: not bother verifying/resolving the indirect type reference yet. */
e4bf6817370e1a71833a02285515694afcda7599vboxsync /* Store it */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s %d:%#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), enmWrt, off, rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_SectOff(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(RTDWARFREF), VERR_INTERNAL_ERROR_3);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_data4: off = rtDwarfCursor_GetU32(pCursor, 0); break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_data8: off = rtDwarfCursor_GetU64(pCursor, 0); break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_FORM_sec_offset: off = rtDwarfCursor_GetUOff(pCursor, 0); break;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertMsgFailedReturn(("%#x (%s)\n", uForm, rtDwarfLog_FormName(uForm)), VERR_DWARF_UNEXPECTED_FORM);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_AT_stmt_list: enmSect = krtDbgModDwarfSect_line; enmWrt = krtDwarfRef_LineSection; break;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync case DW_AT_macro_info: enmSect = krtDbgModDwarfSect_loc; enmWrt = krtDwarfRef_LocSection; break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_AT_ranges: enmSect = krtDbgModDwarfSect_ranges; enmWrt = krtDwarfRef_RangesSection; break;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertMsgFailedReturn(("%u (%s)\n", pDesc->uAttr, rtDwarfLog_AttrName(pDesc->uAttr)), VERR_INTERNAL_ERROR_4);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync size_t cbSect = pCursor->pDwarfMod->aSections[enmSect].cb;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /* Watcom generates offset past the end of the section, increasing the
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync offset by one for each compile unit. So, just fudge it. */
3bb3e26b3306b9f62b18c17380bdf2ca3a98ca49vboxsync Log(("rtDwarfDecode_SectOff: bad off=%#llx, attr %#x (%s), enmSect=%d cb=%#llx; Assuming watcom/gcc.\n", off,
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync pDesc->uAttr, rtDwarfLog_AttrName(pDesc->uAttr), enmSect, cbSect));
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s %d:%#010llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), enmWrt, off, rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_String(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(const char *), VERR_INTERNAL_ERROR_3);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync const char *psz;
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync psz = rtDwarfDecodeHlp_GetStrp(pCursor->pDwarfMod, pCursor, NULL);
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertMsgFailedReturn(("%#x\n", uForm), VERR_DWARF_UNEXPECTED_FORM);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s '%s' [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr), psz, rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
e4bf6817370e1a71833a02285515694afcda7599vboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_UnsignedInt(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_udata: u64Val = rtDwarfCursor_GetULeb128(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data1: u64Val = rtDwarfCursor_GetU8(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data2: u64Val = rtDwarfCursor_GetU16(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data4: u64Val = rtDwarfCursor_GetU32(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync case DW_FORM_data8: u64Val = rtDwarfCursor_GetU64(pCursor, 0); break;
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertMsgFailedReturn(("%#x\n", uForm), VERR_DWARF_UNEXPECTED_FORM);
e4bf6817370e1a71833a02285515694afcda7599vboxsync AssertMsgFailedReturn(("%#x\n", ATTR_GET_SIZE(pDesc)), VERR_INTERNAL_ERROR_2);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * Initialize location interpreter state from cursor & form.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @returns IPRT status code.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @retval VERR_NOT_FOUND if no location information (i.e. there is source but
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * it resulted in no byte code).
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param pLoc The location state structure to initialize.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param pCursor The cursor to read from.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param uForm The attribute form.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic int rtDwarfLoc_Init(PRTDWARFLOCST pLoc, PRTDWARFCURSOR pCursor, uint32_t uForm)
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertMsgFailedReturn(("uForm=%#x\n", uForm), VERR_DWARF_UNEXPECTED_FORM);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync int rc = rtDwarfCursor_InitForBlock(&pLoc->Cursor, pCursor, cbBlock);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * Pushes a value onto the stack.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @returns VINF_SUCCESS or VERR_DWARF_STACK_OVERFLOW.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param pLoc The state.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync * @param uValue The value to push.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic int rtDwarfLoc_Push(PRTDWARFLOCST pLoc, uint64_t uValue)
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertReturn((unsigned)iTop < RT_ELEMENTS(pLoc->auStack), VERR_DWARF_STACK_OVERFLOW);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic int rtDwarfLoc_Evaluate(PRTDWARFLOCST pLoc, void *pvLater, void *pvUser)
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync while (!rtDwarfCursor_IsAtEndOfUnit(&pLoc->Cursor))
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /* Read the next opcode.*/
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uint8_t const bOpcode = rtDwarfCursor_GetU8(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /* Get its operands. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetNativeUOff(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = (int8_t)rtDwarfCursor_GetU8(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetU16(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = (int16_t)rtDwarfCursor_GetU16(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetU32(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = (int32_t)rtDwarfCursor_GetU32(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetU64(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetU64(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetULeb128(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+0: case DW_OP_breg0+1: case DW_OP_breg0+2: case DW_OP_breg0+3:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+4: case DW_OP_breg0+5: case DW_OP_breg0+6: case DW_OP_breg0+7:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+8: case DW_OP_breg0+9: case DW_OP_breg0+10: case DW_OP_breg0+11:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+12: case DW_OP_breg0+13: case DW_OP_breg0+14: case DW_OP_breg0+15:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+16: case DW_OP_breg0+17: case DW_OP_breg0+18: case DW_OP_breg0+19:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+20: case DW_OP_breg0+21: case DW_OP_breg0+22: case DW_OP_breg0+23:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+24: case DW_OP_breg0+25: case DW_OP_breg0+26: case DW_OP_breg0+27:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+28: case DW_OP_breg0+29: case DW_OP_breg0+30: case DW_OP_breg0+31:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetSLeb128(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand1 = rtDwarfCursor_GetULeb128(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uOperand2 = rtDwarfCursor_GetSLeb128(&pLoc->Cursor, 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /* Interpret the opcode. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 0: case DW_OP_lit0 + 1: case DW_OP_lit0 + 2: case DW_OP_lit0 + 3:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 4: case DW_OP_lit0 + 5: case DW_OP_lit0 + 6: case DW_OP_lit0 + 7:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 8: case DW_OP_lit0 + 9: case DW_OP_lit0 + 10: case DW_OP_lit0 + 11:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 12: case DW_OP_lit0 + 13: case DW_OP_lit0 + 14: case DW_OP_lit0 + 15:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 16: case DW_OP_lit0 + 17: case DW_OP_lit0 + 18: case DW_OP_lit0 + 19:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 20: case DW_OP_lit0 + 21: case DW_OP_lit0 + 22: case DW_OP_lit0 + 23:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 24: case DW_OP_lit0 + 25: case DW_OP_lit0 + 26: case DW_OP_lit0 + 27:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_lit0 + 28: case DW_OP_lit0 + 29: case DW_OP_lit0 + 30: case DW_OP_lit0 + 31:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_pick: /** @todo 1 operands, a 1-byte stack index. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_plus_uconst: /** @todo 1 operands, a ULEB128 addend. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_skip: /** @todo 1 signed 2-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_bra: /** @todo 1 signed 2-byte constant. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync 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. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_reg0 + 4: case DW_OP_reg0 + 5: case DW_OP_reg0 + 6: case DW_OP_reg0 + 7:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_reg0 + 8: case DW_OP_reg0 + 9: case DW_OP_reg0 + 10: case DW_OP_reg0 + 11:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_reg0 + 12: case DW_OP_reg0 + 13: case DW_OP_reg0 + 14: case DW_OP_reg0 + 15:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_reg0 + 16: case DW_OP_reg0 + 17: case DW_OP_reg0 + 18: case DW_OP_reg0 + 19:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_reg0 + 20: case DW_OP_reg0 + 21: case DW_OP_reg0 + 22: case DW_OP_reg0 + 23:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_reg0 + 24: case DW_OP_reg0 + 25: case DW_OP_reg0 + 26: case DW_OP_reg0 + 27:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_reg0 + 28: case DW_OP_reg0 + 29: case DW_OP_reg0 + 30: case DW_OP_reg0 + 31:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync 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. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+ 4: case DW_OP_breg0+ 5: case DW_OP_breg0+ 6: case DW_OP_breg0+ 7:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+ 8: case DW_OP_breg0+ 9: case DW_OP_breg0+ 10: case DW_OP_breg0+ 11:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+ 12: case DW_OP_breg0+ 13: case DW_OP_breg0+ 14: case DW_OP_breg0+ 15:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+ 16: case DW_OP_breg0+ 17: case DW_OP_breg0+ 18: case DW_OP_breg0+ 19:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+ 20: case DW_OP_breg0+ 21: case DW_OP_breg0+ 22: case DW_OP_breg0+ 23:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+ 24: case DW_OP_breg0+ 25: case DW_OP_breg0+ 26: case DW_OP_breg0+ 27:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_breg0+ 28: case DW_OP_breg0+ 29: case DW_OP_breg0+ 30: case DW_OP_breg0+ 31:
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_piece: /** @todo 1 operand, a ULEB128 size of piece addressed. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_regx: /** @todo 1 operand, a ULEB128 register. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_fbreg: /** @todo 1 operand, a SLEB128 offset. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_bregx: /** @todo 2 operands, a ULEB128 register followed by a SLEB128 offset. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_deref_size: /** @todo 1 operand, a 1-byte size of data retrieved. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync case DW_OP_xderef_size: /** @todo 1 operand, a 1-byte size of data retrieved. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertMsgFailedReturn(("bOpcode=%#x\n", bOpcode), VERR_DWARF_TODO);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertMsgFailedReturn(("bOpcode=%#x\n", bOpcode), VERR_DWARF_UNKNOWN_LOC_OPCODE);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync/** @callback_method_impl{FNRTDWARFATTRDECODER} */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsyncstatic DECLCALLBACK(int) rtDwarfDecode_SegmentLoc(PRTDWARFDIE pDie, uint8_t *pbMember, PCRTDWARFATTRDESC pDesc,
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync AssertReturn(ATTR_GET_SIZE(pDesc) == 2, VERR_DWARF_IPE);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log4((" %-20s %#06llx [%s]\n", rtDwarfLog_AttrName(pDesc->uAttr),
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync LocSt.auStack[LocSt.iTop], rtDwarfLog_FormName(uForm)));
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DWARF debug_info parser
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DWARF debug_info parser
e4bf6817370e1a71833a02285515694afcda7599vboxsync * DWARF debug_info parser
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * Parse the attributes of a DIE.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @returns IPRT status code.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pThis The DWARF instance.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pDie The internal DIE structure to fill.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic int rtDwarfInfo_SnoopSymbols(PRTDBGMODDWARF pThis, PRTDWARFDIE pDie)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync PCRTDWARFDIESUBPROGRAM pSubProgram = (PCRTDWARFDIESUBPROGRAM)pDie;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log5(("subprogram %s (%s) <implement ranges>\n", pSubProgram->pszName, pSubProgram->pszLinkageName));
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log5(("subprogram %s (%s) %#llx-%#llx%s\n", pSubProgram->pszName, pSubProgram->pszLinkageName,
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync pSubProgram->PcRange.uLowAddress, pSubProgram->PcRange.uHighAddress,
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync pSubProgram->PcRange.cAttrs == 2 ? "" : " !bad!"));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = rtDbgModDwarfRecordSegOffset(pThis, pSubProgram->uSegment, pSubProgram->PcRange.uHighAddress);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = rtDbgModDwarfLinkAddressToSegOffset(pThis, pSubProgram->uSegment,
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = RTDbgModSymbolAdd(pThis->hCnt, pSubProgram->pszName, iSeg, offSeg,
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync pSubProgram->PcRange.uHighAddress - pSubProgram->PcRange.uLowAddress,
682342827b0e80c493c820603508e79e76c42658vboxsync AssertMsg(RT_SUCCESS(rc) || rc == VERR_DBG_DUPLICATE_SYMBOL, ("%Rrc\n", rc));
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync else if ( pSubProgram->PcRange.uLowAddress == 0 /* see with vmlinux */
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync Log5(("rtDbgModDwarfLinkAddressToSegOffset: Ignoring empty range.\n"));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log5(("rtDbgModDwarfLinkAddressToSegOffset failed: %Rrc\n", rc));
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Log5(("subprogram %s (%s) external\n", pSubProgram->pszName, pSubProgram->pszLinkageName));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync PCRTDWARFDIELABEL pLabel = (PCRTDWARFDIELABEL)pDie;
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log5(("label %s %#x:%#llx\n", pLabel->pszName, pLabel->uSegment, pLabel->Address.uAddress));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = rtDbgModDwarfRecordSegOffset(pThis, pLabel->uSegment, pLabel->Address.uAddress);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = rtDbgModDwarfLinkAddressToSegOffset(pThis, pLabel->uSegment, pLabel->Address.uAddress,
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = RTDbgModSymbolAdd(pThis->hCnt, pLabel->pszName, iSeg, offSeg, 0 /*cb*/,
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync Log5(("rtDbgModDwarfLinkAddressToSegOffset failed: %Rrc\n", rc));
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * Initializes the non-core fields of an internal DIE structure.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pDie The DIE structure.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pDieDesc The DIE descriptor.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic void rtDwarfInfo_InitDie(PRTDWARFDIE pDie, PCRTDWARFDIEDESC pDieDesc)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync while (i-- > 0)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync switch (pDieDesc->paAttributes[i].cbInit & ATTR_INIT_MASK)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /* Nothing to do (RTMemAllocZ). */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync switch (pDieDesc->paAttributes[i].cbInit & ATTR_SIZE_MASK)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync *(uint8_t *)((uintptr_t)pDie + pDieDesc->paAttributes[i].off) = UINT8_MAX;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync *(uint16_t *)((uintptr_t)pDie + pDieDesc->paAttributes[i].off) = UINT16_MAX;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync *(uint32_t *)((uintptr_t)pDie + pDieDesc->paAttributes[i].off) = UINT32_MAX;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync *(uint64_t *)((uintptr_t)pDie + pDieDesc->paAttributes[i].off) = UINT64_MAX;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync memset((uint8_t *)pDie + pDieDesc->paAttributes[i].off, 0xff,
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync pDieDesc->paAttributes[i].cbInit & ATTR_SIZE_MASK);
e4bf6817370e1a71833a02285515694afcda7599vboxsync * Creates a new internal DIE structure and links it up.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @returns Pointer to the new DIE structure.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pThis The DWARF instance.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pDieDesc The DIE descriptor (for size and init).
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pAbbrev The abbreviation cache entry.
e4bf6817370e1a71833a02285515694afcda7599vboxsync * @param pParent The parent DIE (NULL if unit).
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic PRTDWARFDIE rtDwarfInfo_NewDie(PRTDBGMODDWARF pThis, PCRTDWARFDIEDESC pDieDesc,
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync uint32_t iAllocator = pDieDesc->cbDie > pThis->aDieAllocators[0].cbMax;
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync Assert(pDieDesc->cbDie <= pThis->aDieAllocators[iAllocator].cbMax);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync PRTDWARFDIE pDie = (PRTDWARFDIE)RTMemCacheAlloc(pThis->aDieAllocators[iAllocator].hMemCache);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync PRTDWARFDIE pDie = (PRTDWARFDIE)RTMemAllocZ(pDieDesc->cbDie);
e4bf6817370e1a71833a02285515694afcda7599vboxsync RTListAppend(&pParent->ChildList, &pDie->SiblingNode);
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync * Free all children of a DIE.
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync * @param pThis The DWARF instance.
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync * @param pParent The parent DIE.
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsyncstatic void rtDwarfInfo_FreeChildren(PRTDBGMODDWARF pThis, PRTDWARFDIE pParentDie)
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync RTListForEachSafe(&pParentDie->ChildList, pChild, pNextChild, RTDWARFDIE, SiblingNode)
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync RTMemCacheFree(pThis->aDieAllocators[pChild->iAllocator].hMemCache, pChild);
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync * Free a DIE an all its children.
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync * @param pThis The DWARF instance.
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync * @param pDie The DIE to free.
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsyncstatic void rtDwarfInfo_FreeDie(PRTDBGMODDWARF pThis, PRTDWARFDIE pDie)
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync RTMemCacheFree(pThis->aDieAllocators[pDie->iAllocator].hMemCache, pDie);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * Skips a form.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @returns IPRT status code
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param pCursor The cursor.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param uForm The form to skip.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsyncstatic int rtDwarfInfo_SkipForm(PRTDWARFCURSOR pCursor, uint32_t uForm)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return rtDwarfCursor_SkipBytes(pCursor, pCursor->cbNativeAddr);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return rtDwarfCursor_SkipBytes(pCursor, rtDwarfCursor_GetULeb128(pCursor, 0));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return rtDwarfCursor_SkipBytes(pCursor, rtDwarfCursor_GetU8(pCursor, 0));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return rtDwarfCursor_SkipBytes(pCursor, rtDwarfCursor_GetU16(pCursor, 0));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return rtDwarfCursor_SkipBytes(pCursor, rtDwarfCursor_GetU32(pCursor, 0));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return rtDwarfInfo_SkipForm(pCursor, rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX));
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return rtDwarfCursor_SkipBytes(pCursor, pCursor->f64bitDwarf ? 8 : 4);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * Skips a DIE.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @returns IPRT status code.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param pCursor The cursor.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync * @param pAbbrevCursor The abbreviation cursor.
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsyncstatic int rtDwarfInfo_SkipDie(PRTDWARFCURSOR pCursor, PRTDWARFCURSOR pAbbrevCursor)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync uint32_t uAttr = rtDwarfCursor_GetULeb128AsU32(pAbbrevCursor, 0);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync uint32_t uForm = rtDwarfCursor_GetULeb128AsU32(pAbbrevCursor, 0);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync return RT_FAILURE(pCursor->rc) ? pCursor->rc : pAbbrevCursor->rc;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * Parse the attributes of a DIE.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @returns IPRT status code.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @param pThis The DWARF instance.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pDie The internal DIE structure to fill.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pDieDesc The DIE descriptor.
c553cea6bfe2ce63ff5517ca4ec288502a890e99vboxsync * @param pCursor The debug_info cursor.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pAbbrev The abbreviation cache entry.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic int rtDwarfInfo_ParseDie(PRTDBGMODDWARF pThis, PRTDWARFDIE pDie, PCRTDWARFDIEDESC pDieDesc,
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync int rc = rtDwarfCursor_InitWithOffset(&AbbrevCursor, pThis, krtDbgModDwarfSect_abbrev, pAbbrev->offSpec);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync uint32_t uAttr = rtDwarfCursor_GetULeb128AsU32(&AbbrevCursor, 0);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync uint32_t uForm = rtDwarfCursor_GetULeb128AsU32(&AbbrevCursor, 0);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /* Look up the attribute in the descriptor and invoke the decoder. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync while (i-- > 0)
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync rc = pAttr->pfnDecoder(pDie, (uint8_t *)pDie + pAttr->off, pAttr, uForm, pCursor);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync /* Some house keeping. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4((" %-20s [%s]\n", rtDwarfLog_AttrName(uAttr), rtDwarfLog_FormName(uForm)));
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync * Snoop up symbols on the way out.
015d66d7947b8b6a38619a0c205842f86c832fe3vboxsync /* Ignore duplicates, get work done instead. */
015d66d7947b8b6a38619a0c205842f86c832fe3vboxsync /** @todo clean up global/static symbol mess. */
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * Load the debug information of a unit.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @returns IPRT status code.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pThis The DWARF instance.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param pCursor The debug_info cursor.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * @param fKeepDies Whether to keep the DIEs or discard them as soon
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * as possible.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsyncstatic int rtDwarfInfo_LoadUnit(PRTDBGMODDWARF pThis, PRTDWARFCURSOR pCursor, bool fKeepDies)
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log(("rtDwarfInfo_LoadUnit: %#x\n", rtDwarfCursor_CalcSectOffsetU32(pCursor)));
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Read the compilation unit header.
e4bf6817370e1a71833a02285515694afcda7599vboxsync uint64_t offUnit = rtDwarfCursor_CalcSectOffsetU32(pCursor);
e4bf6817370e1a71833a02285515694afcda7599vboxsync uint64_t cbUnit = rtDwarfCursor_GetInitalLength(pCursor);
e4bf6817370e1a71833a02285515694afcda7599vboxsync cbUnit += rtDwarfCursor_CalcSectOffsetU32(pCursor) - offUnit;
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint16_t const uVer = rtDwarfCursor_GetUHalf(pCursor, 0);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint64_t const offAbbrev = rtDwarfCursor_GetUOff(pCursor, UINT64_MAX);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync uint8_t const cbNativeAddr = rtDwarfCursor_GetU8(pCursor, UINT8_MAX);
1025ef7261a6961d07d390e85a095d806ccb88d9vboxsync Log((" uVer=%d offAbbrev=%#llx cbNativeAddr=%d\n", uVer, offAbbrev, cbNativeAddr));
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Set up the abbreviation cache and store the native address size in the cursor.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log(("Unexpected abbrviation code offset of %#llx\n", offAbbrev));
ed521f15dde29451cbdb1df104f666204e04ba65vboxsync rtDwarfAbbrev_SetUnitOffset(pThis, (uint32_t)offAbbrev);
e4bf6817370e1a71833a02285515694afcda7599vboxsync * The first DIE is a compile or partial unit, parse it here.
e4bf6817370e1a71833a02285515694afcda7599vboxsync uint32_t uAbbrCode = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX);
e4bf6817370e1a71833a02285515694afcda7599vboxsync PCRTDWARFABBREV pAbbrev = rtDwarfAbbrev_Lookup(pThis, uAbbrCode);
e4bf6817370e1a71833a02285515694afcda7599vboxsync Log(("Unexpected compile/partial unit tag %#x\n", pAbbrev->uTag));
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync pUnit = (PRTDWARFDIECOMPILEUNIT)rtDwarfInfo_NewDie(pThis, &g_CompileUnitDesc, pAbbrev, NULL /*pParent*/);
e4bf6817370e1a71833a02285515694afcda7599vboxsync RTListAppend(&pThis->CompileUnitList, &pUnit->Core.SiblingNode);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync int rc = rtDwarfInfo_ParseDie(pThis, &pUnit->Core, &g_CompileUnitDesc, pCursor, pAbbrev);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Parse DIEs.
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uint32_t offLog = rtDwarfCursor_CalcSectOffsetU32(pCursor);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync uAbbrCode = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /* End of siblings, up one level. (Is this correct?) */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync /* Padding. */
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync uAbbrCode = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log(("%08x: End of DIE stack, but still more info to parse: uAbbrCode=%#x (+%u bytes).\n",
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * Look up the abbreviation and match the tag up with a descriptor.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync const char *pszName;
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync Assert(g_aTagDescs[pAbbrev->uTag].uTag == pAbbrev->uTag || g_aTagDescs[pAbbrev->uTag].uTag == 0);
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync Log4(("%08x: %*stag=%s (%#x)%s\n", offLog, cDepth * 2, "", pszName,
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync pAbbrev->uTag, pAbbrev->fChildren ? " has children" : ""));
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * Create a new internal DIE structure and parse the
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync * attributes.
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync PRTDWARFDIE pNewDie = rtDwarfInfo_NewDie(pThis, pDieDesc, pAbbrev, pParentDie);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync rc = rtDwarfInfo_ParseDie(pThis, pNewDie, pDieDesc, pCursor, pAbbrev);
725fba5c64717677ac66072bae37e5b3686f3e6dvboxsync } /* while more DIEs */
d648458f701f69d455389e0ac6cf6a9cdee0771evboxsync /* Unlink and free child DIEs if told to do so. */
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Extracts the symbols.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * The symbols are insered into the debug info container.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @returns IPRT status code
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * @param pThis The DWARF instance.
ad66a27959d7085aa31760f63ce082943be60e89vboxsyncstatic int rtDwarfInfo_LoadAll(PRTDBGMODDWARF pThis)
ad66a27959d7085aa31760f63ce082943be60e89vboxsync int rc = rtDwarfCursor_Init(&Cursor, pThis, krtDbgModDwarfSect_info);
4b8c66482cbc69a01ac399b8588b8bc80b310523vboxsync rc = rtDwarfInfo_LoadUnit(pThis, &Cursor, false /* fKeepDies */);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Debug module implementation.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Debug module implementation.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * DWARF Debug module implementation.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnLineByAddr} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_LineByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off,
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModLineByAddr(pThis->hCnt, iSeg, off, poffDisp, pLineInfo);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnLineByOrdinal} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_LineByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModLineByOrdinal(pThis->hCnt, iOrdinal, pLineInfo);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnLineCount} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(uint32_t) rtDbgModDwarf_LineCount(PRTDBGMODINT pMod)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnLineAdd} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_LineAdd(PRTDBGMODINT pMod, const char *pszFile, size_t cchFile, uint32_t uLineNo,
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModLineAdd(pThis->hCnt, pszFile, uLineNo, iSeg, off, piOrdinal);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByAddr} */
2d8870843ff566fee9bd3a6a5942414254106479vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
2d8870843ff566fee9bd3a6a5942414254106479vboxsync return RTDbgModSymbolByAddr(pThis->hCnt, iSeg, off, fFlags, poffDisp, pSymInfo);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByName} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModSymbolByName(pThis->hCnt, pszSymbol/*, cchSymbol*/, pSymInfo);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByOrdinal} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_SymbolByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModSymbolByOrdinal(pThis->hCnt, iOrdinal, pSymInfo);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolCount} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(uint32_t) rtDbgModDwarf_SymbolCount(PRTDBGMODINT pMod)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolAdd} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync RTDBGSEGIDX iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags,
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModSymbolAdd(pThis->hCnt, pszSymbol, iSeg, off, cb, fFlags, piOrdinal);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentByIndex} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_SegmentByIndex(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModSegmentByIndex(pThis->hCnt, iSeg, pSegInfo);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentCount} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(RTDBGSEGIDX) rtDbgModDwarf_SegmentCount(PRTDBGMODINT pMod)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentAdd} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_SegmentAdd(PRTDBGMODINT pMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName, size_t cchName,
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModSegmentAdd(pThis->hCnt, uRva, cb, pszName, fFlags, piSeg);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnImageSize} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(RTUINTPTR) rtDbgModDwarf_ImageSize(PRTDBGMODINT pMod)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync RTUINTPTR cb2 = pThis->pImgMod->pImgVt->pfnImageSize(pMod);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnRvaToSegOff} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(RTDBGSEGIDX) rtDbgModDwarf_RvaToSegOff(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync return RTDbgModRvaToSegOff(pThis->hCnt, uRva, poffSeg);
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnClose} */
4bf996d915405be92dc4394b2db1395e00e14d58vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_Close(PRTDBGMODINT pMod)
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync for (unsigned iSect = 0; iSect < RT_ELEMENTS(pThis->aSections); iSect++)
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[iSect].cb, &pThis->aSections[iSect].pv);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync pThis->pNestedMod->pImgVt->pfnClose(pThis->pNestedMod);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync RTStrCacheRelease(g_hDbgModStrCache, pThis->pNestedMod->pszName);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync RTStrCacheRelease(g_hDbgModStrCache, pThis->pNestedMod->pszDbgFile);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync while (i-- > 0)
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync RTMemCacheDestroy(pThis->aDieAllocators[i].hMemCache);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync pThis->aDieAllocators[i].hMemCache = NIL_RTMEMCACHE;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync/** @callback_method_impl{FNRTLDRENUMDBG} */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncstatic DECLCALLBACK(int) rtDbgModDwarfEnumCallback(RTLDRMOD hLdrMod, PCRTLDRDBGINFO pDbgInfo, void *pvUser)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Skip stuff we can't handle.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync const char *pszSection = pDbgInfo->u.Dwarf.pszSection;
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Must have a part name starting with debug_ and possibly prefixed by dots
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * or underscores.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (!strncmp(pszSection, RT_STR_TUPLE(".debug_"))) /* ELF */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else if (!strncmp(pszSection, RT_STR_TUPLE("__debug_"))) /* Mach-O */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else if (!strcmp(pszSection, ".WATCOM_references"))
113a43aca041000560f93f9a8ee23dfcf01a9e7cvboxsync return VINF_SUCCESS; /* Ignore special watcom section for now.*/
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertMsgFailedReturn(("%s\n", pszSection), VINF_SUCCESS /*ignore*/);
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Figure out which part we're talking about.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync if (0) { /* dummy */ }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync#define ELSE_IF_STRCMP_SET(a_Name) else if (!strcmp(pszSection, #a_Name)) enmSect = krtDbgModDwarfSect_ ## a_Name
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Record the section.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertMsgReturn(!pThis->aSections[enmSect].fPresent, ("duplicate %s\n", pszSection), VINF_SUCCESS /*ignore*/);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pThis->aSections[enmSect].offFile = pDbgInfo->offFile;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pThis->aSections[enmSect].cb = (size_t)pDbgInfo->cb;
3bb3e26b3306b9f62b18c17380bdf2ca3a98ca49vboxsync pThis->aSections[enmSect].iDbgInfo = pDbgInfo->iDbgInfo;
d1e9999d55e7ac80a28692c161710be98071fc00vboxsyncstatic int rtDbgModDwarfTryOpenDbgFile(PRTDBGMODINT pDbgMod, PRTDBGMODDWARF pThis, RTLDRARCH enmArch)
245e74fad1cf613e77302d69c57e215b8a3e17f9vboxsync || RTPathIsSame(pDbgMod->pszDbgFile, pDbgMod->pszImgFile) == (int)true /* returns VERR too */)
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync * Only open the image.
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync PRTDBGMODINT pDbgInfoMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgInfoMod));
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync if (RTStrCacheRetain(pDbgMod->pszDbgFile) != UINT32_MAX)
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync if (RTStrCacheRetain(pDbgMod->pszName) != UINT32_MAX)
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync rc = pDbgInfoMod->pImgVt->pfnTryOpen(pDbgInfoMod, enmArch);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgInfoMod->pszName);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgInfoMod->pszImgFile);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync/** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */
d1e9999d55e7ac80a28692c161710be98071fc00vboxsyncstatic DECLCALLBACK(int) rtDbgModDwarf_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * DWARF is only supported when part of an image.
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync * Create the module instance data.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)RTMemAllocZ(sizeof(*pThis));
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync AssertCompile(RT_ELEMENTS(pThis->aDieAllocators) == 2);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync pThis->aDieAllocators[0].cbMax = sizeof(RTDWARFDIE);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync pThis->aDieAllocators[1].cbMax = sizeof(RTDWARFDIECOMPILEUNIT);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync for (uint32_t i = 0; i < RT_ELEMENTS(g_aTagDescs); i++)
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync if (g_aTagDescs[i].pDesc && g_aTagDescs[i].pDesc->cbDie > pThis->aDieAllocators[1].cbMax)
a4a975fd10df2483568b3695eb010798a9ac2fccvboxsync pThis->aDieAllocators[1].cbMax = (uint32_t)g_aTagDescs[i].pDesc->cbDie;
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync pThis->aDieAllocators[1].cbMax = RT_ALIGN_32(pThis->aDieAllocators[1].cbMax, sizeof(uint64_t));
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aDieAllocators); i++)
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync int rc = RTMemCacheCreate(&pThis->aDieAllocators[i].hMemCache, pThis->aDieAllocators[i].cbMax, sizeof(uint64_t),
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync UINT32_MAX, NULL /*pfnCtor*/, NULL /*pfnDtor*/, NULL /*pvUser*/, 0 /*fFlags*/);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync while (i-- > 0)
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync RTMemCacheDestroy(pThis->aDieAllocators[i].hMemCache);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync * If the debug file name is set, let's see if it's an ELF image with DWARF
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync * inside it. In that case we'll have to deal with two image modules, one
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync * for segments and address translation and one for the debug information.
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync * Enumerate the debug info in the module, looking for DWARF bits.
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync int rc = pThis->pDbgInfoMod->pImgVt->pfnEnumDbgInfo(pThis->pDbgInfoMod, rtDbgModDwarfEnumCallback, pThis);
5b0a093ca572a855886faa6747ad46df859dd041vboxsync if (pThis->aSections[krtDbgModDwarfSect_info].fPresent)
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * Extract / explode the data we want (symbols and line numbers)
5b0a093ca572a855886faa6747ad46df859dd041vboxsync * storing them in a container module.
5b0a093ca572a855886faa6747ad46df859dd041vboxsync rc = RTDbgModCreate(&pThis->hCnt, pMod->pszName, 0 /*cbSeg*/, 0 /*fFlags*/);
ad66a27959d7085aa31760f63ce082943be60e89vboxsync * Free the cached abbreviations and unload all sections.
ad66a27959d7085aa31760f63ce082943be60e89vboxsync pThis->cCachedAbbrevs = pThis->cCachedAbbrevsAlloced = 0;
ad66a27959d7085aa31760f63ce082943be60e89vboxsync for (unsigned iSect = 0; iSect < RT_ELEMENTS(pThis->aSections); iSect++)
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[iSect].cb,
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync /** @todo Kill pThis->CompileUnitList and the alloc caches. */
5b0a093ca572a855886faa6747ad46df859dd041vboxsync /* bail out. */
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync while (i-- > 0)
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync RTMemCacheDestroy(pThis->aDieAllocators[i].hMemCache);
7c4a90169768dcfac3c355a4c1f98b3ef0193641vboxsync pThis->aDieAllocators[i].hMemCache = NIL_RTMEMCACHE;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync/** Virtual function table for the DWARF debug info reader. */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsyncDECL_HIDDEN_CONST(RTDBGMODVTDBG) const g_rtDbgModVtDbgDwarf =
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*.pfnSegmentCount = */ rtDbgModDwarf_SegmentCount,
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*.pfnSegmentByIndex = */ rtDbgModDwarf_SegmentByIndex,
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*.pfnSymbolByOrdinal = */ rtDbgModDwarf_SymbolByOrdinal,
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*.pfnSymbolByName = */ rtDbgModDwarf_SymbolByName,
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*.pfnSymbolByAddr = */ rtDbgModDwarf_SymbolByAddr,
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*.pfnLineByOrdinal = */ rtDbgModDwarf_LineByOrdinal,