Package ghidra.app.util.bin.format.dwarf

# Class DWARFRegisterMappings

java.lang.Object
ghidra.app.util.bin.format.dwarf.DWARFRegisterMappings

public class DWARFRegisterMappings extends Object
Immutable mapping information between DWARF and Ghidra.

Use `DWARFRegisterMappingsManager` to get an instance for a Program's specific language.

The data held in this class is read from DWARF register mapping information contained in xml files referenced from the language *.ldefs file in an <external_name tool="DWARF.register.mapping.file" name="register_mapping_filename_here"/>

The format is:

     <dwarf>
       <register_mappings>
           <!-- Simple single mapping: -->
           <!-- NN == dwarf register number -->
           <!-- RegName == Ghidra register name string -->
           <!-- <register_mapping dwarf="NN" ghidra="RegName" /> -->

           <!-- Example: -->
         <register_mapping dwarf="0" ghidra="r0" />

           <!-- Single mapping specifying stack pointer: -->
           <!-- NN == dwarf register number -->
           <!-- RegName == Ghidra register name string -->
           <!-- <register_mapping dwarf="NN" ghidra="RegName" stackpointer="true"/> -->

           <!-- Example: -->
         <register_mapping dwarf="4" ghidra="ESP" stackpointer="true"/>

           <!-- Multiple mapping: -->
           <!-- NN == dwarf register number -->
           <!-- XX == number of times to repeat -->
           <!-- RegNameYY == Ghidra register name string with a mandatory integer suffix -->
           <!-- <register_mapping dwarf="NN" ghidra="RegNameYY" auto_count="XX"/> -->

           <!-- Example, creates mapping from 0..12 to r0..r12: -->
         <register_mapping dwarf="0" ghidra="r0" auto_count="12"/>

           <!-- Example, creates mapping from 17..32 to XMM0..XMM15: -->
         <register_mapping dwarf="17" ghidra="XMM0" auto_count="16"/>

       </register_mappings>

         <!-- Call Frame CFA Value: -->
       <call_frame_cfa value="NN"/>

         <!-- Use Formal Parameter Storage toggle: -->
       <use_formal_parameter_storage/>
     </dwarf>

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final DWARFRegisterMappings`
  `DUMMY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DWARFRegisterMappings(Map<Integer,Register> regmap, Integer callFrameCFA, int stackPointerIndex, Register stackFrameRegister, int stackFrameRegisterOffset, boolean useFPS)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCallFrameCFA()`
  'Static' value for a function's CFA value (instead of trying to extract it from the func's CIE metadata).
  `int`
  `getDWARFStackPointerRegNum()`
  `Register`
  `getGhidraReg(int dwarfRegNum)`
  `Register`
  `getStackFrameRegister()`
  `int`
  `getStackFrameRegisterOffset()`
  `Register`
  `getStackRegister()`
  `boolean`
  `hasStaticCFA()`
  `boolean`
  `isUseFormalParameterStorage()`
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### DUMMY

    public static final DWARFRegisterMappings DUMMY

- ## Constructor Details

  - ### DWARFRegisterMappings

    public DWARFRegisterMappings(Map<Integer,Register> regmap, Integer callFrameCFA, int stackPointerIndex, Register stackFrameRegister, int stackFrameRegisterOffset, boolean useFPS)

- ## Method Details

  - ### getGhidraReg

    public Register getGhidraReg(int dwarfRegNum)

  - ### getCallFrameCFA

    public int getCallFrameCFA()
    'Static' value for a function's CFA value (instead of trying to extract it from the func's CIE metadata).
    Returns:
      cfa static stack offset

  - ### hasStaticCFA

    public boolean hasStaticCFA()

  - ### getDWARFStackPointerRegNum

    public int getDWARFStackPointerRegNum()

  - ### getStackRegister

    public Register getStackRegister()

  - ### getStackFrameRegister

    public Register getStackFrameRegister()

  - ### getStackFrameRegisterOffset

    public int getStackFrameRegisterOffset()

  - ### isUseFormalParameterStorage

    public boolean isUseFormalParameterStorage()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`