diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfARangesSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfARangesSectionImpl.java
index 25198d29b318..35fd9fd99ff9 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfARangesSectionImpl.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfARangesSectionImpl.java
@@ -29,6 +29,8 @@
import java.util.Map;
import com.oracle.objectfile.debugentry.ClassEntry;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfVersion;
import org.graalvm.compiler.debug.DebugContext;
import com.oracle.objectfile.LayoutDecision;
@@ -42,16 +44,11 @@
*/
public class DwarfARangesSectionImpl extends DwarfSectionImpl {
/* Headers have a fixed size but must align up to 2 * address size. */
- private static final int DW_AR_HEADER_SIZE = 12;
- private static final int DW_AR_HEADER_PAD_SIZE = 4;
+ private static final int AR_HEADER_SIZE = 12;
+ private static final int AR_HEADER_PAD_SIZE = 4;
public DwarfARangesSectionImpl(DwarfDebugInfo dwarfSections) {
- super(dwarfSections);
- }
-
- @Override
- public String getSectionName() {
- return DwarfDebugInfo.DW_ARANGES_SECTION_NAME;
+ super(dwarfSections, DwarfSectionName.DW_ARANGES_SECTION, DwarfSectionName.DW_FRAME_SECTION);
}
@Override
@@ -104,9 +101,9 @@ public void createContent() {
private static int entrySize(int methodCount) {
int size = 0;
// allow for header data
- size += DW_AR_HEADER_SIZE;
+ size += AR_HEADER_SIZE;
// align to 2 * address size.
- size += DW_AR_HEADER_PAD_SIZE;
+ size += AR_HEADER_PAD_SIZE;
// count 16 bytes for each deopt compiled method
size += methodCount * (2 * 8);
// allow for two trailing zeroes to terminate
@@ -161,17 +158,17 @@ private int writeHeader(int cuIndex, byte[] buffer, int p) {
// write dummy length for now
pos = writeInt(0, buffer, pos);
/* DWARF version is always 2. */
- pos = writeShort(DwarfDebugInfo.DW_VERSION_2, buffer, pos);
+ pos = writeDwarfVersion(DwarfVersion.DW_VERSION_2, buffer, pos);
pos = writeInfoSectionOffset(cuIndex, buffer, pos);
/* Address size is always 8. */
pos = writeByte((byte) 8, buffer, pos);
/* Segment size is always 0. */
pos = writeByte((byte) 0, buffer, pos);
- assert (pos - p) == DW_AR_HEADER_SIZE;
+ assert (pos - p) == AR_HEADER_SIZE;
/*
* Align to 2 * address size.
*/
- for (int i = 0; i < DW_AR_HEADER_PAD_SIZE; i++) {
+ for (int i = 0; i < AR_HEADER_PAD_SIZE; i++) {
pos = writeByte((byte) 0, buffer, pos);
}
return pos;
@@ -185,24 +182,4 @@ int writeARange(DebugContext context, CompiledMethodEntry compiledMethod, byte[]
pos = writeLong(primary.getHi() - primary.getLo(), buffer, pos);
return pos;
}
-
- /*
- * The debug_aranges section depends on debug_frame section.
- */
- private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_FRAME_SECTION_NAME;
-
- @Override
- public String targetSectionName() {
- return TARGET_SECTION_NAME;
- }
-
- private final LayoutDecision.Kind[] targetSectionKinds = {
- LayoutDecision.Kind.CONTENT,
- LayoutDecision.Kind.SIZE
- };
-
- @Override
- public LayoutDecision.Kind[] targetSectionKinds() {
- return targetSectionKinds;
- }
}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfAbbrevSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfAbbrevSectionImpl.java
index 4a2c4c971188..9abf63c0f459 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfAbbrevSectionImpl.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfAbbrevSectionImpl.java
@@ -26,8 +26,13 @@
package com.oracle.objectfile.elf.dwarf;
-import com.oracle.objectfile.LayoutDecision;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfForm;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfHasChildren;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfTag;
import org.graalvm.compiler.debug.DebugContext;
+import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo.AbbrevCode;
/**
* Section generator for debug_abbrev section. That section defines the layout of the
@@ -77,9 +82,9 @@
*
*
* For the moment we only use one abbrev table with two types of CU. There is one occurrence of the
- * builtin_unit CU which includes definitions of Java primitive value types and the
+ * BUILTIN_UNIT CU which includes definitions of Java primitive value types and the
* struct type used to model a Java object header. There are multiple occurrences of the
- * class_unit CU, one for each Java class, interface or array class included in the
+ * CLASS_UNIT CU, one for each Java class, interface or array class included in the
* generated native image binary. The latter describes the class, array or interface layout and
* defines a class, interface or array reference pointer type. It provides declarations for instance
* and static methods and static fields of a class, and methods of an interface. In the case of a
@@ -95,13 +100,13 @@
*
*
code = null, tag == null - empty terminator
+ * abbrev_code == null, tag == null - empty terminator
*
- * code = builtin_unit, tag == class_unit - CU that defines the Java object header
- * struct and all Java primitive types.
+ * abbrev_code == BUILTIN_UNIT, tag == DW_TAG_compilation_unit - CU that defines
+ * the Java object header struct and all Java primitive types.
*
- * code = class_unit, tag == class_unit - CU that defines a specific Java object,
- * interface or array type.
+ * abbrev_code == CLASS_UNIT, tag == DW_TAG_compilation_unit - CU that defines a
+ * specific Java object, interface or array type.
*
* code = primitive_type, tag == base_type, parent = builtin_unit - Java primitive
- * type (non-void)
+ * abbrev_code == PRIMITIVE_TYPE, tag == DW_TAG_base_type, parent = BUILTIN_UNIT -
+ * Java primitive type (non-void)
*
- * code = void_type, tag == unspecified_type, parent = builtin_unit - Java void
- * type
+ * abbrev_code == VOID_TYPE, tag == DW_TAG_unspecified_type, parent = BUILTIN_UNIT
+ * - Java void type
*
- * code = object_header, tag == structure_type, parent = builtin_unit - Java object
- * header
+ * abbrev_code == OBJECT_HEADER, tag == DW_TAG_structure_type, parent = BUILTIN_UNIT
+ * - Java object header
*
- * code = class_layout, tag == class_type, parent = class_unit - Java instance type
- * structure definition
+ * abbrev_code == CLASS_LAYOUT, tag == DW_TAG_class_type, parent = CLASS_UNIT -
+ * Java instance type structure definition
*
- * code = class_pointer, tag == pointer_type, parent = class_unit - Java instance
- * ref type
+ * abbrev_code == CLASS_POINTER, tag == DW_TAG_pointer_type, parent = CLASS_UNIT -
+ * Java instance ref type
*
- * code = method_location, tag == subprogram , parent = class_unit - Java method
- * code definition (i.e. location of code)
+ * abbrev_code == METHOD_LOCATION, tag == DW_TAG_subprogram , parent = CLASS_UNIT -
+ * Java method code definition (i.e. location of code)
*
- * code = static_field_location, tag == variable, parent = class_unit - Java static
- * field definition (i.e. location of data)
+ * abbrev_code == STATIC_FIELD_LOCATION, tag == DW_TAG_variable, parent = CLASS_UNIT
+ * - Java static field definition (i.e. location of data)
*
- * code = array_layout, tag == structure_type, parent = class_unit - Java array
- * type structure definition
+ * abbrev_code == ARRAY_LAYOUT, tag == DW_TAG_structure_type, parent = CLASS_UNIT -
+ * Java array type structure definition
*
- * code = array_pointer, tag == pointer_type, parent = class_unit - Java array ref
- * type
+ * abbrev_code == ARRAY_POINTER, tag == DW_TAG_pointer_type, parent = CLASS_UNIT -
+ * Java array ref type
*
- * code = interface_layout, tag == union_type, parent = class_unit - Java array
- * type structure definition
+ * abbrev_code == INTERFACE_LAYOUT, tag == DW_TAG_union_type, parent = CLASS_UNIT -
+ * Java array type structure definition
*
- * code = interface_pointer, tag == pointer_type, parent = class_unit - Java
- * interface ref type
+ * abbrev_code == INTERFACE_POINTER, tag == DW_TAG_pointer_type, parent = CLASS_UNIT
+ * - Java interface ref type
*
- * code = indirect_layout, tag == class_type, parent = class_unit - wrapper layout
- * attaches address rewriting logic to the layout types that it wraps using a
+ * abbrev_code == INDIRECT_LAYOUT, tag == DW_TAG_class_type, parent = CLASS_UNIT -
+ * wrapper layout attaches address rewriting logic to the layout types that it wraps using a
* data_location attribute
*
- * code = indirect_pointer, tag == pointer_type, parent = class_unit - indirect ref
- * type used to type indirect oops that encode the address of an object, whether by adding tag bits
- * or representing the address as an offset from some base address. these are used to type object
- * references stored in static and instance fields. They are not needed when typing local vars and
- * parameters held in registers or on the stack as they appear as raw addresses.
+ * abbrev_code == INDIRECT_POINTER, tag == DW_TAG_pointer_type, parent = CLASS_UNIT
+ * - indirect ref type used to type indirect oops that encode the address of an object, whether by
+ * adding tag bits or representing the address as an offset from some base address. these are used
+ * to type object references stored in static and instance fields. They are not needed when typing
+ * local vars and parameters held in registers or on the stack as they appear as raw addresses.
*
- * code = namespace, tag == namespace, parent = class_unit - a wrap-around DIE that
- * is used to embed all the normal level 1 DIEs of a class_unit in a namespace. This is
- * needed when the corresponding class/interface or array base element type have been loaded by a
- * loader with a non-empty loader in order to ensure that mangled names for the class and its
- * members can legitimately employ the loader id as a namespace prefix. Note that use of a namespace
- * wrapper DIE causes all the embedded level 1+ DIEs documented above and all their children to be
- * generated at a level one greater than documented here.
+ * abbrev_code == NAMESPACE, tag == DW_TAG_namespace, parent = CLASS_UNIT - a
+ * wrap-around DIE that is used to embed all the normal level 1 DIEs of a CLASS_UNIT in
+ * a namespace. This is needed when the corresponding class/interface or array base element type
+ * have been loaded by a loader with a non-empty loader in order to ensure that mangled names for
+ * the class and its members can legitimately employ the loader id as a namespace prefix. Note that
+ * use of a namespace wrapper DIE causes all the embedded level 1+ DIEs documented above and all
+ * their children to be generated at a level one greater than documented here.
*
* code = header_field, tag == member, parent = object_header - object/array header
- * field
+ * abbrev_code == HEADER_FIELD, tag == DW_TAG_member, parent = OBJECT_HEADER -
+ * object/array header field
*
- * code == method_declaration1/2, tag == subprogram, parent = class_layout, interface_layout
+ * abbrev_code == METHOD_DECLARATION/METHOD_DECLARATION_STATIC, tag == DW_TAG_subprogram,
+ * parent = CLASS_LAYOUT, INTERFACE_LAYOUT
*
- * code = field_declaration1/2/3/4, tag == member, parent = class_layout - instance
- * field declaration (i.e. specification of properties)
+ * abbrev_code == FIELD_DECLARATION_1/2/3/4, tag == DW_TAG_member, parent = CLASS_LAYOUT
+ * - instance field declaration (i.e. specification of properties)
*
- * code == super_reference, tag == inheritance, parent = class_layout,
- * array_layout - reference to super class layout or to appropriate header struct for {code
+ * abbrev_code == SUPER_REFERENCE, tag == DW_TAG_inheritance, parent = CLASS_LAYOUT,
+ * ARRAY_LAYOUT - reference to super class layout or to appropriate header struct for {code
* java.lang.Object} or arrays.
*
- * code == interface_implementor, tag == member, parent = interface_layout - union
- * member typed using class layout of a given implementing class
+ * abbrev_code == INTERFACE_IMPLEMENTOR, tag == DW_TAG_member, parent = INTERFACE_LAYOUT
+ * - union member typed using class layout of a given implementing class
*
- * code = inlined_subroutine/inlined_subroutine_with_children, tag == subprogram,
- * parent = method_location/inlined_subroutine_with_children - provides range and
- * abstract origin for a concrete inline method
+ * abbrev_code == INLINED_SUBROUTINE/INLINED_SUBROUTINE_WITH_CHILDREN, tag == DW_TAG_subprogram,
+ * parent = METHOD_LOCATION/INLINED_SUBROUTINE_WITH_CHILDREN - provides range and
+ * abstract origin for an inlined subroutine
*
- * code == method_parameter_declaration1/2/3, tag == formal_parameter, parent =
- * method_declaration1/2 - details of method parameters
+ * abbrev_code == METHOD_PARAMETER_DECLARATION_1/2/3, tag == DW_TAG_formal_parameter, parent =
+ * METHOD_DECLARATION/METHOD_DECLARATION_STATIC - details of method parameters
*
- * code == method_local_declaration1/2, tag == variable, parent =
- * method_declaration1/2 - details of method local vars
+ * abbrev_code == METHOD_LOCAL_DECLARATION_1/2, tag == DW_TAG_variable, parent =
+ * METHOD_DECLARATION/METHOD_DECLARATION_STATIC - details of method local vars
*
* code == method_local_location, tag == formal_parameter, parent =
- * method_location, concrete_inline_method - details of method parameter or local locations
+ * abbrev_code == METHOD_LOCAL_LOCATION, tag == DW_TAG_formal_parameter, parent =
+ * METHOD_LOCATION - details of method parameter or local locations
*
*
*
- * A single instance of the level 0 builtin_unit compile unit provide details of all
+ * A single instance of the level 0 BUILTIN_UNIT compile unit provide details of all
* Java primitive types and the struct type used to model a Java object header
*
*
abbrev_code == built_unit, tag == DW_TAG_compilation_unit,
+ * abbrev_code == BUILTIN_UNIT, tag == DW_TAG_compilation_unit,
* has_children
*
* DW_AT_language : ... DW_FORM_data1
@@ -221,12 +227,12 @@
*
* class_unit compile unit provide details of all Java object
+ * Instances of the level 0 CLASS_UNIT compile unit provide details of all Java object
* types and compiled code.
*
* abbrev_code == class_unit1/2, tag == DW_TAG_compilation_unit,
+ * abbrev_code == CLASS_UNIT1/2, tag == DW_TAG_compilation_unit,
* has_children
*
* DW_AT_language : ... DW_FORM_data1
@@ -235,9 +241,9 @@
*
* DW_AT_comp_dir : ... DW_FORM_strp
*
- * DW_AT_low_pc : ..... DW_FORM_address only for class_unit1
+ * DW_AT_low_pc : ..... DW_FORM_address only for CLASS_UNIT1
*
- * DW_AT_hi_pc : ...... DW_FORM_address only for class_unit1
+ * DW_AT_hi_pc : ...... DW_FORM_address only for CLASS_UNIT1
*
* DW_AT_use_UTF8 : ... DW_FORM_flag
*
@@ -254,7 +260,7 @@
*
* DW_AT_byte_size : ... DW_FORM_data1 (or data2 ???)
*
- * DW_AT_bit_size : ... DW_FORM_data1 (or data2 ???)
+ * DW_AT_bit_size : .... DW_FORM_data1 (or data2 ???)
*
* DW_AT_encoding : .... DW_FORM_data1
*
@@ -266,7 +272,7 @@
*
* The void type is defined as an unspecified type
*
- * abbrev_code == void_type, tag == DW_TAG_unspecified_type, no_children
+ * abbrev_code == VOID_TYPE, tag == DW_TAG_unspecified_type, no_children
*
* DW_AT_name : ........ DW_FORM_strp
*
@@ -278,9 +284,9 @@
*
*
*
- * abbrev_code == object_header, tag == DW_TAG_structure_type, has_children
+ * abbrev_code == OBJECT_HEADER, tag == DW_TAG_structure_type, has_children
*
- * DW_AT_name : ......... DW_FORM_strp "oop"
+ * DW_AT_name : ........ DW_FORM_strp "oop"
*
* DW_AT_byte_size : ... DW_FORM_data1 "oop"
*
@@ -292,7 +298,7 @@
*
*
*
- * abbrev_code = header_field, tag == DW_TAG_member, no_children
+ * abbrev_code = HEADER_FIELD, tag == DW_TAG_member, no_children
*
* Dw_AT_name : ................... DW_FORM_strp
*
@@ -313,7 +319,7 @@
* compile unit. The namespace DIE has a single attribute defining the namespace's name as the
* loader id string.
*
- * abbrev_code == namespace, tag == DW_TAG_namespace, parent = class_unit, has_children
+ * abbrev_code == NAMESPACE, tag == DW_TAG_namespace, parent = CLASS_UNIT, has_children
*
* DW_AT_name : ....... DW_FORM_strp
*
@@ -335,7 +341,7 @@
*
*
*
- * abbrev_code == class_layout1/class_layout2, tag == DW_TAG_class_type,
+ * abbrev_code == CLASS_LAYOUT1/CLASS_LAYOUT2, tag == DW_TAG_class_type,
* has_children
*
* Dw_AT_name : ........ DW_FORM_strp
@@ -346,28 +352,28 @@
*
* Dw_AT_decl_line : ... DW_FORM_data1/2
*
- * Dw_AT_data_location : ... DW_FORM_expr_loc n.b. only for class_layout2
+ * Dw_AT_data_location : ... DW_FORM_expr_loc n.b. only for CLASS_LAYOUT2
*
*
*
- * Instance Class members: A level 1 class_layout DIE includes a level 2 child for each
+ * Instance Class members: A level 1 CLASS_LAYOUT DIE includes a level 2 child for each
* of the class's methods and fields. The first type declares a method but omits details of
* the location of the code that implements the method. The second type declares an
- * instance or static field. A class_layout DIE also contains a level 2 DIE specifying the type from
+ * instance or static field. A CLASS_LAYOUT DIE also contains a level 2 DIE specifying the type from
* which it inherits superclass structure. In the case of class Object structure is
* inherited from the object header structure type.
*
* n.b. Code implementation details for each method (i.e. the method definition) are
- * provided in an auxiliary level 1 method_location DIE that follows the
- * class_layout DIE. Instance field declarations need no auxiliary level 1 DIE as all
+ * provided in an auxiliary level 1 METHOD_LOCATION DIE that follows the
+ * CLASS_LAYOUT DIE. Instance field declarations need no auxiliary level 1 DIE as all
* relevant details, including size and offset in the instance, are specified in the field
* declaration DIE. Static field locations (i.e. the field definition) are provided in an
- * auxiliary level 1 static_field_location DIE that follows the
- * class_layout DIE.
+ * auxiliary level 1 STATIC_FIELD_LOCATION DIE that follows the
+ * CLASS_LAYOUT DIE.
*
*
*
- * abbrev_code == method_declaration1/2, tag == DW_TAG_subprogram,
+ * abbrev_code == METHOD_DECLARATION/METHOD_DECLARATION_STATIC, tag == DW_TAG_subprogram,
* has_children
*
* DW_AT_external : .......... DW_FORM_flag
@@ -388,7 +394,7 @@
*
* DW_AT_declaration : ....... DW_FORM_flag
*
- * Dw_AT_object_pointer : .... DW_FORM_ref4 n.b. only for method_declaration1,
+ * Dw_AT_object_pointer : .... DW_FORM_ref4 n.b. only for METHOD_DECLARATION,
* points to param 0 DIE
*
* DW_AT_virtuality : ........ DW_FORM_data1 (for override methods)
@@ -399,36 +405,36 @@
*
*
*
- * abbrev_code == field_declaration1/2/3/4, tag == DW_TAG_member, no_children
+ * abbrev_code == FIELD_DECLARATION_1/2/3/4, tag == DW_TAG_member, no_children
*
* Dw_AT_name : ................... DW_FORM_strp
*
* DW_AT_decl_file : .............. DW_FORM_data1/2 n.b. only for
- * field_declaration2/4
+ * FIELD_DECLARATION_2/4
*
* DW_AT_decl_line : .............. DW_FORM_data1/2 n.b. only for
- * field_declaration2/4
+ * FIELD_DECLARATION_2/4
*
* Dw_AT_type : ................... DW_FORM_ref_addr
*
* Dw_AT_data_member_location : ... DW_FORM_data1/2 (n.b. nly for
- * field_declaration1/2 instance
+ * FIELD_DECLARATION_1/2 instance
*
* Dw_AT_artificial : ............. DW_FORM_flag
*
* Dw_AT_accessibility : .......... DW_FORM_data1
*
* Dw_AT_external : ............... DW_FORM_flag (n.b. only for
- * field_declaration3/4 static
+ * FIELD_DECLARATION_3/4 static
*
- * Dw_AT_declaration : ............ DW_FORM_flag n.b. only for field_declaration3/4
- * static
+ * Dw_AT_declaration : ............ DW_FORM_flag n.b. only for
+ * FIELD_DECLARATION_3/4 static
*
*
*
*
*
- * abbrev_code == super_reference, tag == DW_TAG_inheritance, no_children
+ * abbrev_code == SUPER_REFERENCE, tag == DW_TAG_inheritance, no_children
*
* Dw_AT_type : ................... DW_FORM_ref_addr
*
@@ -438,38 +444,38 @@
*
*
*
- * Method Parameters: Level 2 method_declaration DIEs may include level 3 DIEs that describe their
- * parameters and/or their local variables. n.b. these two DIEs only differ in the value of their
- * tag.
+ * Method Parameters: Level 2 METHOD_DECLARATION/METHOD_DECLARATION_STATIC DIEs may include level 3
+ * DIEs that describe their parameters and/or their local variables. n.b. these two DIEs only differ
+ * in the value of their tag.
*
*
*
- * abbrev_code == method_parameter_declaration1/2/3, tag ==
+ * abbrev_code == METHOD_PARAMETER_DECLARATION_1/2/3, tag ==
* DW_TAG_formal_parameter, no_children
*
* Dw_AT_name : ... DW_FORM_strp (may be empty string)
*
- * Dw_AT_file : ... DW_FORM_data1/2 n.b. only for method_parameter_declaration2
+ * Dw_AT_file : ... DW_FORM_data1/2 n.b. only for METHOD_PARAMETER_DECLARATION_2
*
- * Dw_AT_line : ... DW_FORM_data1/2 n.b. only for method_parameter_declaration2
+ * Dw_AT_line : ... DW_FORM_data1/2 n.b. only for METHOD_PARAMETER_DECLARATION_2
*
* Dw_AT_type : ... DW_FORM_ref_addr
*
- * Dw_AT_artificial : ... DW_FORM_flag n.b. only for method_parameter_declaration1
+ * Dw_AT_artificial : ... DW_FORM_flag n.b. only for METHOD_PARAMETER_DECLARATION_1
* used for this and access vars
*
* Dw_AT_declaration : ... DW_FORM_flag
*
*
*
- * abbrev_code == method_local_declaration1/2, tag == DW_TAG_variable,
+ * abbrev_code == METHOD_LOCAL_DECLARATION_1/2, tag == DW_TAG_variable,
* no_children
*
* Dw_AT_name : ... DW_FORM_strp (may be empty string)
*
- * Dw_AT_file : ... DW_FORM_data1/2 n.b. only for method_parameter_declaration1
+ * Dw_AT_file : ... DW_FORM_data1/2 n.b. only for METHOD_PARAMETER_DECLARATION_1
*
- * Dw_AT_line : ... DW_FORM_data1/2 n.b. only for method_parameter_declaration1
+ * Dw_AT_line : ... DW_FORM_data1/2 n.b. only for METHOD_PARAMETER_DECLARATION_1
*
* Dw_AT_type : ... DW_FORM_ref_addr
*
@@ -478,20 +484,20 @@
*
*
* Indirect Instance Class Structure: The level 1 class layout DIE may be followed by a level 1
- * indirect_layout DIE. The indirect layout is only needed when a heapbase register is
+ * INDIRECT_LAYOUT DIE. The indirect layout is only needed when a heapbase register is
* in use (isolates or compressed oops are enabled). This means that oop fields will hold encoded
* oops. The indirect layout defines an empty wrapper class which declares the previous layout as
* its super class. This wrapper type also supplies a data_location attribute, ensuring
* that indirect pointers to the class (see next item) are translated to raw addresses. The name of
* the indirect type is constructed by prefixing the class name with
* DwarfDebugInfo.INDIRECT_PREFIX. This DIE has only one child DIE with type
- * super_reference (see above). This effectively embeds the standard layout type in the indirect
+ * SUPER_REFERENCE (see above). This effectively embeds the standard layout type in the indirect
* layout as a type compatible referent for the Java oop. The size of the indirect layout is the
* same as the size of the class layout.
*
*
*
- * abbrev_code == indirect_layout, tag == DW_TAG_class_type, has_children
+ * abbrev_code == INDIRECT_LAYOUT, tag == DW_TAG_class_type, has_children
*
* Dw_AT_name : ........ DW_FORM_strp
*
@@ -501,21 +507,21 @@
*
*
*
- * Instance Class Reference Types: The level 1 class_layout and
- * indirect_layout DIEs are followed by level 1 DIEs defining pointers to the
- * respective class layouts. A class_pointer DIE defines a pointer type for the
- * class_layout type and is used to type pointers which directly address an instance.
+ * Instance Class Reference Types: The level 1 CLASS_LAYOUT and
+ * INDIRECT_LAYOUT DIEs are followed by level 1 DIEs defining pointers to the
+ * respective class layouts. A CLASS_POINTER DIE defines a pointer type for the
+ * CLASS_LAYOUT type and is used to type pointers which directly address an instance.
* It is used to type local and parameter var references whether located in a register or on the
- * stack. It may be followed by an indirect_pointer DIE which defines a pointer type
- * for the class's indirect_layout type. This is used to type references to instances
+ * stack. It may be followed by an INDIRECT_POINTER DIE which defines a pointer type
+ * for the class's INDIRECT_LAYOUT type. This is used to type references to instances
* of the class located in a static or instance field. These latter references require address
* translation by masking off tag bits and/or rebasing from an offset to a raw address. The logic
* for this translation is encoded in the data_location attribute of the corresponding
- * indirect_layout DIE.
+ * INDIRECT_LAYOUT DIE.
*
*
*
- * abbrev_code == class_pointer, tag == DW_TAG_pointer_type, no_children
+ * abbrev_code == CLASS_POINTER, tag == DW_TAG_pointer_type, no_children
*
* Dw_AT_byte_size : ... DW_FORM_data1
*
@@ -525,7 +531,7 @@
*
*
*
- * abbrev_code == indirect_pointer, tag == DW_TAG_pointer_type, no_children
+ * abbrev_code == INDIRECT_POINTER, tag == DW_TAG_pointer_type, no_children
*
* Dw_AT_byte_size : ... DW_FORM_data1
*
@@ -533,7 +539,7 @@
*
*
*
- * n.b. the name used in the class_layout DIE is the Java class name. This is
+ * n.b. the name used in the CLASS_LAYOUT DIE is the Java class name. This is
* deliberately inconsistent with the Java naming where the name refers to the pointer
* type. In consequence when gdb displays Java types and signatures oop references appear as pointer
* types. So, for example the Java String class looks like
@@ -560,7 +566,7 @@
*
*
*
- * abbrev_code == DW_ABBREV_CODE_method_location, tag == DW_TAG_subprogram,
+ * abbrev_code == DW_ABBREV_CODE_METHOD_LOCATION, tag == DW_TAG_subprogram,
* has_children
*
* DW_AT_low_pc : .......... DW_FORM_addr
@@ -574,24 +580,24 @@
*
*
* Method local locations: A method location may be followed by zero or more
- * method_local_location DIEs which identify the in-memory location of parameter and/or
- * local values during execution of the compiled code. A method_local_location DIE
- * references the corresponding method_parameter_declaration or
- * method_local_declaration. It also specifies a location list which defines address
+ * METHOD_LOCAL_LOCATION DIEs which identify the in-memory location of parameter and/or
+ * local values during execution of the compiled code. A METHOD_LOCAL_LOCATION DIE
+ * references the corresponding METHOD_PARAMETER_DECLARATION or *
+ * METHOD_LOCAL_DECLARATION. It also specifies a location list which defines address
* ranges where the parameter or local is valid and provides details of where to find the value of
- * the parameter or local in memory. Likewise, an inline concrete method DIE is followed by zero or
- * more method_local_location DIEs, providing details of where to find the
- * specification of inlined parameters or locals and their value in memory.
+ * the parameter or local in memory. Likewise, an inlined subroutine DIE is followed by zero or more
+ * METHOD_LOCAL_LOCATION DIEs, providing details of where to find the specification of
+ * inlined parameters or locals and their value in memory.
*
*
*
- * abbrev_code == DW_ABBREV_CODE_method_local_location1/2, tag ==
+ * abbrev_code == DW_ABBREV_CODE_METHOD_LOCAL_LOCATION1/2, tag ==
* DW_TAG_formal_parameter, no_children
*
* DW_AT_specification : .......... DW_FORM_ref4
*
* DW_AT_location: ................ DW_FORM_sec_offset n.b. only for
- * method_local_location2
+ * METHOD_LOCAL_LOCATION2
*
*
*
@@ -603,13 +609,12 @@
* including attributes specified in child DIEs of the method_definition. However, it is actually
* necessary to replicate the method_parameter/local_declaration DIEs of the specification as
* children of the abstract_inline_method DIE. This provides a CU-local target for references from
- * the corresponding method_parameter/local_location DIEs that sit below the inlined_subroutine DIEs
- * in the concrete inlined subroutine tree. This is needed because some tools require the location
- * DIEs abstract_origin attribute that links the location to specification to be a CU-relative
- * offset (FORM_Ref4) rather than a relcoatabel cross-CU info section offset. This has the added
- * benefit that repeated reference to abstract inline methods or parameters from concrete inline
- * method DIEs or parameter or local location DIES only avoids the cost of tracking separate
- * relocatable reference.
+ * the corresponding method_parameter/local_location DIEs that sit below the INLINED_SUBROUTINE DIEs
+ * in the inlined subroutine tree. This is needed because some tools require the location DIEs
+ * abstract_origin attribute that links the location to specification to be a CU-relative offset
+ * (FORM_Ref4) rather than a relocatable cross-CU info section offset. This has the added benefit
+ * that repeated reference to abstract inline methods or parameters from inlined subroutine DIEs or
+ * parameter or local location DIES only avoids the cost of tracking separate relocatable reference.
*
*
*
@@ -624,27 +629,26 @@
*
*
*
- * Concrete Inlined Methods: Concrete inlined method DIEs are nested as a tree of children under the
- * method_location DIE for the method into which they have been inlined. Each inlined method DIE
- * defines an address range that is a subrange of its parent DIE. A method_location DIE occurs at
- * depth 1 in a compile unit (class_unit). So, this means that for any method which has been inlined
- * into a compiled method at depth K in the inline frame stack there will be a corresponding level
- * 2+K DIE that identifies the method that was inlined (by referencing the corresponding method
- * declaration DIE) and locates the call point by citing the file index and line number of its
- * caller. So, if compiled method M inlines a call to m1 at source position f0:l0, m1 inlines a call
- * to method m2 at source position f1:l1 and m2 inlines a call to m3 at source position f2:l2 then
- * there will be a level 2 DIE for the inline code range derived from m1 referencing the declaration
- * DIE for m1 with f0 and l0 as file and line, a level 3 DIE for the inline code range derived from
- * m2 referencing the declaration DIE for m2 with f1 and l1 as file and line and a level 3 DIE for
- * the inline code range derived from m3 referencing the declaration DIE for m3 with f2 and l2 as
- * file and line.
+ * Inlined subroutine DIEs are nested as a tree of children under the METHOD_LOCATION DIE for the
+ * method into which they have been inlined. Each inlined subroutine DIE defines an address range
+ * that is a subrange of its parent DIE. A METHOD_LOCATION DIE occurs at depth 1 in a compile unit
+ * (CLASS_UNIT). So, this means that for any method which has been inlined into a compiled method at
+ * depth K in the inline frame stack there will be a corresponding level 2+K DIE that identifies the
+ * method that was inlined (by referencing the corresponding method declaration DIE) and locates the
+ * call point by citing the file index and line number of its caller. So, if compiled method M
+ * inlines a call to m1 at source position f0:l0, m1 inlines a call to method m2 at source position
+ * f1:l1 and m2 inlines a call to m3 at source position f2:l2 then there will be a level 2 DIE for
+ * the inline code range derived from m1 referencing the declaration DIE for m1 with f0 and l0 as
+ * file and line, a level 3 DIE for the inline code range derived from m2 referencing the
+ * declaration DIE for m2 with f1 and l1 as file and line and a level 3 DIE for the inline code
+ * range derived from m3 referencing the declaration DIE for m3 with f2 and l2 as file and line.
*
*
*
- * abbrev_code == DW_ABBREV_CODE_inlined_subroutine, tag == DW_TAG_subprogram,
+ * abbrev_code == DW_ABBREV_CODE_INLINED_SUBROUTINE, tag == DW_TAG_subprogram,
* no_children
*
- * abbrev_code == DW_ABBREV_CODE_inlined_subroutine_with_children, tag ==
+ * abbrev_code == DW_ABBREV_CODE_INLINED_SUBROUTINE_WITH_CHILDREN, tag ==
* DW_TAG_subprogram, has_children
*
* DW_AT_abstract_origin : ... DW_FORM_ref4
@@ -664,7 +668,7 @@
*
*
*
- * abbrev_code == static_field_location, tag == DW_TAG_variable,
+ * abbrev_code == STATIC_FIELD_LOCATION, tag == DW_TAG_variable,
* no_children
*
* DW_AT_specification : ... DW_FORM_ref4
@@ -679,7 +683,7 @@
*
*
* Array Layout: The first array DIE describes the array layout. It has three children. The first is
- * a super_reference DIE (see above) to class java.lang.Object. The other
+ * a SUPER_REFERENCE DIE (see above) to class java.lang.Object. The other
* two children are field declarations, a length field that overlays the Java array length field and
* an array data field which aligns with the element 0 of the Java array's data area. The data field
* type is typed (via a later level 1 DIE) as a DWARF array, i.e. it is a data block embedded
@@ -697,7 +701,7 @@
*
*
*
- * abbrev_code == array_layout, tag == DW_TAG_class_type, has_children
+ * abbrev_code == ARRAY_LAYOUT, tag == DW_TAG_class_type, has_children
*
* Dw_AT_name : ........ DW_FORM_strp
*
@@ -705,24 +709,24 @@
*
*
*
- * The immediately following DIE is an indirect_layout (see above) that wraps the array layout as
+ * The immediately following DIE is an INDIRECT_LAYOUT (see above) that wraps the array layout as
* its super type (just as with class layouts). The wrapper type supplies a data_location attribute,
* allowing indirect pointers to the array to be translated to raw addresses. The name of the
* indirect array type is constructed by prefixing the array name with
* DwarfDebugInfo.INDIRECT_PREFIX. This DIE has only one child DIE with type
- * super_reference (see above). The latter references the array layout DIE, effectively
+ * SUPER_REFERENCE (see above). The latter references the array layout DIE, effectively
* embedding the standard array layout type in the indirect layout. The size of the indirect layout
* is the same as the size of the array layout.
*
*
* The third and fourth DIEs define array reference types as a pointers to the underlying structure
- * layout types. As with classes, there is an array_pointer type for raw address references used to
- * type local and param vars and an indirect_pointer type (see above) for array references stored in
+ * layout types. As with classes, there is an ARRAY_POINTER type for raw address references used to
+ * type local and param vars and an INDIRECT_POINTER type (see above) for array references stored in
* static and instance fields.
*
*
*
- * abbrev_code == array_pointer, tag == DW_TAG_pointer_type, no_children
+ * abbrev_code == ARRAY_POINTER, tag == DW_TAG_pointer_type, no_children
*
* Dw_AT_byte_size : ... DW_FORM_data1
*
@@ -730,12 +734,12 @@
*
*
*
- * n.b. the name used in the array_layout DIE is the Java array name. This is deliberately
+ * n.b. the name used in the ARRAY_LAYOUT DIE is the Java array name. This is deliberately
* inconsistent with the Java naming where the name refers to the pointer type. As with normal
* objects an array reference in a Java signature appears as a pointer to an array layout when
* printed by gdb.
*
- * Array members: The level 1 array_layout DIE includes a member field DIE that defines the layout
+ * Array members: The level 1 ARRAY_LAYOUT DIE includes a member field DIE that defines the layout
* of the array data. The type of this embedded field is declared by a fifth level 1 DIE, a
* array_data_type DIE (with DWARF tag array_type).
*
@@ -761,7 +765,7 @@
*
*
*
- * abbrev_code == interface_layout, tag == union_type, has_children
+ * abbrev_code == INTERFACE_LAYOUT, DW_TAG_union_type, has_children
*
* Dw_AT_name : ....... DW_FORM_strp
*
@@ -777,20 +781,20 @@
* indirect layout is the same as the size of the interface layout.
*
* The third and fourth DIEs define interface reference types as a pointers to the underlying
- * structure layout types. As with classes, there is an interface_pointer type for raw address
- * references used to type local and param vars and an indirect_pointer type (see above) for
+ * structure layout types. As with classes, there is an INTERFACE_POINTER type for raw address
+ * references used to type local and param vars and an INDIRECT_POINTER type (see above) for
* interface references stored in static and instance fields.
*
* A second level 1 defines a pointer to this layout type.
*
- * n.b. the name used in the interface_layout DIE is the Java array name. This is
+ * n.b. the name used in the INTERFACE_LAYOUT DIE is the Java array name. This is
* deliberately inconsistent with the Java naming where the name refers to the pointer type. As with
* normal objects an interface reference in a Java signature appears as a pointer to an interface
* layout when printed by gdb.
*
*
*
- * abbrev_code == interface_pointer, tag == pointer_type, has_children
+ * abbrev_code == INTERFACE_POINTER, tag == DW_TAG_pointer_type, has_children
*
* Dw_AT_byte_size : ... DW_FORM_data1
*
@@ -803,7 +807,7 @@
*
*
*
- * abbrev_code == interface_implementor, tag == member, no_children
+ * abbrev_code == INTERFACE_IMPLEMENTOR, tag == DW_TAG_member, no_children
*
* Dw_AT_name : ................... DW_FORM_strp
*
@@ -829,12 +833,8 @@
public class DwarfAbbrevSectionImpl extends DwarfSectionImpl {
public DwarfAbbrevSectionImpl(DwarfDebugInfo dwarfSections) {
- super(dwarfSections);
- }
-
- @Override
- public String getSectionName() {
- return DwarfDebugInfo.DW_ABBREV_SECTION_NAME;
+ // abbrev section depends on ranges section
+ super(dwarfSections, DwarfSectionName.DW_ABBREV_SECTION, DwarfSectionName.DW_RANGES_SECTION);
}
@Override
@@ -928,154 +928,158 @@ public int writeAbbrevs(DebugContext context, byte[] buffer, int p) {
return pos;
}
- private int writeAttrType(long code, byte[] buffer, int pos) {
- return writeSLEB(code, buffer, pos);
+ private int writeAttrType(DwarfAttribute attribute, byte[] buffer, int pos) {
+ return writeULEB(attribute.value(), buffer, pos);
+ }
+
+ private int writeAttrForm(DwarfForm dwarfForm, byte[] buffer, int pos) {
+ return writeULEB(dwarfForm.value(), buffer, pos);
}
- private int writeAttrForm(long code, byte[] buffer, int pos) {
- return writeSLEB(code, buffer, pos);
+ private int writeHasChildren(DwarfHasChildren hasChildren, byte[] buffer, int pos) {
+ return writeByte(hasChildren.value(), buffer, pos);
}
private int writeCompileUnitAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_builtin_unit, buffer, pos);
- pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_class_unit1, buffer, pos);
- pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_class_unit2, buffer, pos);
+ pos = writeCompileUnitAbbrev(context, AbbrevCode.BUILTIN_UNIT, buffer, pos);
+ pos = writeCompileUnitAbbrev(context, AbbrevCode.CLASS_UNIT_1, buffer, pos);
+ pos = writeCompileUnitAbbrev(context, AbbrevCode.CLASS_UNIT_2, buffer, pos);
return pos;
}
- private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_compile_unit, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_language, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_use_UTF8, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_comp_dir, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_class_unit2) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_ranges, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_sec_offset, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_low_pc, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_stmt_list, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_sec_offset, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_compile_unit, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_language, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_use_UTF8, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_comp_dir, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ if (abbrevCode == AbbrevCode.CLASS_UNIT_2) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_ranges, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_sec_offset, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_low_pc, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_stmt_list, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_sec_offset, buffer, pos);
}
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writePrimitiveTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_primitive_type, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_base_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_bit_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_encoding, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.PRIMITIVE_TYPE, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_base_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_bit_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_encoding, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeVoidTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_void_type, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_unspecified_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.VOID_TYPE, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_unspecified_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeObjectHeaderAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_object_header, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_structure_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.OBJECT_HEADER, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_structure_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeNamespaceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_namespace, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_namespace, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.NAMESPACE, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_namespace, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeClassLayoutAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeClassLayoutAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_class_layout1, buffer, pos);
+ pos = writeClassLayoutAbbrev(context, AbbrevCode.CLASS_LAYOUT_1, buffer, pos);
if (!dwarfSections.useHeapBase()) {
- pos = writeClassLayoutAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_class_layout2, buffer, pos);
+ pos = writeClassLayoutAbbrev(context, AbbrevCode.CLASS_LAYOUT_2, buffer, pos);
}
return pos;
}
- private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_class_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_file, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_class_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_file, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
/*-
* At present we definitely don't have a line number for the class itself.
pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
*/
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_class_layout2) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_data_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_expr_loc, buffer, pos);
+ if (abbrevCode == AbbrevCode.CLASS_LAYOUT_2) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_data_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_expr_loc, buffer, pos);
}
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
@@ -1084,233 +1088,233 @@ private int writeClassReferenceAbbrev(@SuppressWarnings("unused") DebugContext c
int pos = p;
/* A pointer to the class struct type. */
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_class_pointer, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_pointer_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.CLASS_POINTER, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_pointer_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeMethodDeclarationAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeMethodDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_declaration, buffer, pos);
- pos = writeMethodDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_declaration_static, buffer, pos);
+ pos = writeMethodDeclarationAbbrev(context, AbbrevCode.METHOD_DECLARATION, buffer, pos);
+ pos = writeMethodDeclarationAbbrev(context, AbbrevCode.METHOD_DECLARATION_STATIC, buffer, pos);
return pos;
}
- private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_subprogram, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_external, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_file, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_linkage_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_artificial, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_declaration, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_subprogram, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_external, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_file, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_line, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_linkage_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_artificial, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_accessibility, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_declaration, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
/* This is not in DWARF2 */
- // pos = writeAttrType(DwarfDebugInfo.DW_AT_virtuality, buffer, pos);
- // pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_containing_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_declaration) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_object_pointer, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ // pos = writeAttrType(DW_AT_virtuality, buffer, pos);
+ // pos = writeAttrForm(DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_containing_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
+ if (abbrevCode == AbbrevCode.METHOD_DECLARATION) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_object_pointer, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
}
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeFieldDeclarationAbbrevs(DebugContext context, byte[] buffer, int p) {
int pos = p;
/* An instance field no line and file. */
- pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_field_declaration1, buffer, pos);
+ pos = writeFieldDeclarationAbbrev(context, AbbrevCode.FIELD_DECLARATION_1, buffer, pos);
/* An instance field with line and file. */
- pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_field_declaration2, buffer, pos);
+ pos = writeFieldDeclarationAbbrev(context, AbbrevCode.FIELD_DECLARATION_2, buffer, pos);
/* A static field no line and file. */
- pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_field_declaration3, buffer, pos);
+ pos = writeFieldDeclarationAbbrev(context, AbbrevCode.FIELD_DECLARATION_3, buffer, pos);
/* A static field with line and file. */
- pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_field_declaration4, buffer, pos);
+ pos = writeFieldDeclarationAbbrev(context, AbbrevCode.FIELD_DECLARATION_4, buffer, pos);
return pos;
}
- private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_member, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_member, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
/* We may not have a file and line for a field. */
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_field_declaration2 || abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_field_declaration4) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_file, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
+ if (abbrevCode == AbbrevCode.FIELD_DECLARATION_2 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_file, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
/* At present we definitely don't have line numbers. */
// pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
// pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
}
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_field_declaration1 || abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_field_declaration2) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ if (abbrevCode == AbbrevCode.FIELD_DECLARATION_1 || abbrevCode == AbbrevCode.FIELD_DECLARATION_2) {
/* Instance fields have a member offset relocated relative to the heap base register. */
- pos = writeAttrType(DwarfDebugInfo.DW_AT_data_member_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_data_member_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
}
- pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_accessibility, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
/* Static fields are only declared here and are external. */
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_field_declaration3 || abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_field_declaration4) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_external, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_declaration, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
+ if (abbrevCode == AbbrevCode.FIELD_DECLARATION_3 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_external, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_declaration, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
}
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeClassConstantAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_class_constant, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_constant, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.CLASS_CONSTANT, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_constant, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
/* We may not have a file and line for a field. */
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_external, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_declaration, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_expr_loc, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_accessibility, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_external, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_declaration, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_expr_loc, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeArrayLayoutAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_array_layout, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_class_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.ARRAY_LAYOUT, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_class_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeArrayReferenceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_array_pointer, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_pointer_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.ARRAY_POINTER, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_pointer_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeInterfaceLayoutAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_interface_layout, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_union_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.INTERFACE_LAYOUT, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_union_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeInterfaceReferenceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_interface_pointer, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_pointer_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.INTERFACE_POINTER, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_pointer_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeInterfaceImplementorAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_interface_implementor, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_member, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.INTERFACE_IMPLEMENTOR, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_member, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_accessibility, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
@@ -1318,21 +1322,21 @@ private int writeForeignReferenceAbbrev(@SuppressWarnings("unused") DebugContext
int pos = p;
/* A pointer to the class struct type. */
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_foreign_pointer, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_pointer_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.FOREIGN_POINTER, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_pointer_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
// n.b we use a (relocatable) ref_addr here rather than a (CU-relative) ref4
// because an unknown foreign pointer type will reference void which is not
// local to the current CU.
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
@@ -1340,18 +1344,18 @@ private int writeForeignTypedefAbbrev(@SuppressWarnings("unused") DebugContext c
int pos = p;
/* A pointer to the class struct type. */
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_foreign_typedef, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_typedef, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.FOREIGN_TYPEDEF, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_typedef, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
@@ -1359,71 +1363,71 @@ private int writeForeignStructAbbrev(@SuppressWarnings("unused") DebugContext co
int pos = p;
/* A pointer to the class struct type. */
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_foreign_struct, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_structure_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.FOREIGN_STRUCT, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_structure_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeHeaderFieldAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_header_field, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_member, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_data_member_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.HEADER_FIELD, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_member, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_data_member_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_accessibility, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeArrayDataTypeAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeArrayDataTypeAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_array_data_type1, buffer, pos);
- pos = writeArrayDataTypeAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_array_data_type2, buffer, pos);
+ pos = writeArrayDataTypeAbbrev(context, AbbrevCode.ARRAY_DATA_TYPE_1, buffer, pos);
+ pos = writeArrayDataTypeAbbrev(context, AbbrevCode.ARRAY_DATA_TYPE_2, buffer, pos);
return pos;
}
- private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_array_type, buffer, pos);
- boolean hasChildren = (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_array_data_type2);
- pos = writeFlag((hasChildren ? DwarfDebugInfo.DW_CHILDREN_yes : DwarfDebugInfo.DW_CHILDREN_no), buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_array_data_type2) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data4, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_array_type, buffer, pos);
+ boolean hasChildren = (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2);
+ pos = writeHasChildren((hasChildren ? DwarfHasChildren.DW_CHILDREN_yes : DwarfHasChildren.DW_CHILDREN_no), buffer, pos);
+ if (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data4, buffer, pos);
}
// n.b we use a (relocatable) ref_addr here rather than a (CU-relative) ref4
// because a foreign array type can reference another foreign type which is
// not in the current CU.
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
@@ -1431,96 +1435,96 @@ private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext co
private int writeArraySubrangeTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_array_subrange, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_subrange_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_count, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.ARRAY_SUBRANGE, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_subrange_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_count, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data4, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeMethodLocationAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_method_location, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_subprogram, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_low_pc, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_hi_pc, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_external, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_specification, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.METHOD_LOCATION, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_subprogram, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_low_pc, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_hi_pc, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_external, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_specification, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeAbstractInlineMethodAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_abstract_inline_method, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_subprogram, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_inline, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_external, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_specification, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.ABSTRACT_INLINE_METHOD, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_subprogram, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_inline, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_external, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_specification, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeStaticFieldLocationAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_static_field_location, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_variable, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_specification, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.STATIC_FIELD_LOCATION, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_variable, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_specification, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
// pos = writeAttrType(DwarfDebugInfo.DW_AT_linkage_name, buffer, pos);
// pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_expr_loc, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_expr_loc, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeSuperReferenceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_super_reference, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_inheritance, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_data_member_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.SUPER_REFERENCE, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_inheritance, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_data_member_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_accessibility, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
@@ -1535,21 +1539,21 @@ private int writeIndirectLayoutAbbrev(@SuppressWarnings("unused") DebugContext c
* values stored in static and instance fields.
*/
/* the type for an indirect layout that includes address translation info */
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_indirect_layout, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_class_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_yes, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.INDIRECT_LAYOUT, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_class_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_yes, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
/* Add a data location expression to rebase oop pointers stored as offsets. */
- pos = writeAttrType(DwarfDebugInfo.DW_AT_data_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_expr_loc, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_data_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_expr_loc, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
@@ -1558,189 +1562,169 @@ private int writeIndirectReferenceAbbrev(@SuppressWarnings("unused") DebugContex
int pos = p;
/* The type for a pointer to the indirect layout type. */
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_indirect_pointer, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_pointer_type, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_byte_size, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.INDIRECT_POINTER, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_pointer_type, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_byte_size, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data1, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeParameterDeclarationAbbrevs(DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration1, buffer, pos);
- pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration2, buffer, pos);
- pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration3, buffer, pos);
+ pos = writeParameterDeclarationAbbrev(context, AbbrevCode.METHOD_PARAMETER_DECLARATION_1, buffer, pos);
+ pos = writeParameterDeclarationAbbrev(context, AbbrevCode.METHOD_PARAMETER_DECLARATION_2, buffer, pos);
+ pos = writeParameterDeclarationAbbrev(context, AbbrevCode.METHOD_PARAMETER_DECLARATION_3, buffer, pos);
return pos;
}
- private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_formal_parameter, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration2) {
+ pos = writeTag(DwarfTag.DW_TAG_formal_parameter, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_2) {
/* Line numbers for parameter declarations are not (yet?) available. */
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_file, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_file, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_line, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
}
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration1) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_1) {
/* Only this parameter is artificial and it has no line. */
- pos = writeAttrType(DwarfDebugInfo.DW_AT_artificial, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_artificial, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
}
- pos = writeAttrType(DwarfDebugInfo.DW_AT_declaration, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_declaration, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeLocalDeclarationAbbrevs(DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeLocalDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration1, buffer, pos);
- pos = writeLocalDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration2, buffer, pos);
+ pos = writeLocalDeclarationAbbrev(context, AbbrevCode.METHOD_LOCAL_DECLARATION_1, buffer, pos);
+ pos = writeLocalDeclarationAbbrev(context, AbbrevCode.METHOD_LOCAL_DECLARATION_2, buffer, pos);
return pos;
}
- private int writeLocalDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeLocalDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_variable, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_name, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration1) {
+ pos = writeTag(DwarfTag.DW_TAG_variable, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_name, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_strp, buffer, pos);
+ if (abbrevCode == AbbrevCode.METHOD_LOCAL_DECLARATION_1) {
/* Line numbers for parameter declarations are not (yet?) available. */
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_file, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_file, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_decl_line, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data2, buffer, pos);
}
- pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_declaration, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_type, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_declaration, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos);
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeParameterLocationAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeParameterLocationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location1, buffer, pos);
- pos = writeParameterLocationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location2, buffer, pos);
+ pos = writeParameterLocationAbbrev(context, AbbrevCode.METHOD_PARAMETER_LOCATION_1, buffer, pos);
+ pos = writeParameterLocationAbbrev(context, AbbrevCode.METHOD_PARAMETER_LOCATION_2, buffer, pos);
return pos;
}
private int writeLocalLocationAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeLocalLocationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_local_location1, buffer, pos);
- pos = writeLocalLocationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_method_local_location2, buffer, pos);
+ pos = writeLocalLocationAbbrev(context, AbbrevCode.METHOD_LOCAL_LOCATION_1, buffer, pos);
+ pos = writeLocalLocationAbbrev(context, AbbrevCode.METHOD_LOCAL_LOCATION_2, buffer, pos);
return pos;
}
- private int writeParameterLocationAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeParameterLocationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_formal_parameter, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_abstract_origin, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location2) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_sec_offset, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_formal_parameter, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_abstract_origin, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
+ if (abbrevCode == AbbrevCode.METHOD_PARAMETER_LOCATION_2) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_sec_offset, buffer, pos);
}
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
- private int writeLocalLocationAbbrev(@SuppressWarnings("unused") DebugContext context, int abbrevCode, byte[] buffer, int p) {
+ private int writeLocalLocationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) {
int pos = p;
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_variable, buffer, pos);
- pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_abstract_origin, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_local_location2) {
- pos = writeAttrType(DwarfDebugInfo.DW_AT_location, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_sec_offset, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_variable, buffer, pos);
+ pos = writeHasChildren(DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_abstract_origin, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
+ if (abbrevCode == AbbrevCode.METHOD_LOCAL_LOCATION_2) {
+ pos = writeAttrType(DwarfAttribute.DW_AT_location, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_sec_offset, buffer, pos);
}
/*
* Now terminate.
*/
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
private int writeNullAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) {
int pos = p;
- pos = writeAbbrevCode(DwarfDebugInfo.DW_ABBREV_CODE_null, buffer, pos);
+ pos = writeAbbrevCode(AbbrevCode.NULL, buffer, pos);
return pos;
}
private int writeInlinedSubroutineAbbrev(byte[] buffer, int p, boolean withChildren) {
int pos = p;
- pos = writeAbbrevCode(withChildren ? DwarfDebugInfo.DW_ABBREV_CODE_inlined_subroutine_with_children : DwarfDebugInfo.DW_ABBREV_CODE_inlined_subroutine, buffer, pos);
- pos = writeTag(DwarfDebugInfo.DW_TAG_inlined_subroutine, buffer, pos);
- pos = writeFlag(withChildren ? DwarfDebugInfo.DW_CHILDREN_yes : DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_abstract_origin, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref4, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_low_pc, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_hi_pc, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_addr, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_call_file, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data4, buffer, pos);
- pos = writeAttrType(DwarfDebugInfo.DW_AT_call_line, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data4, buffer, pos);
+ pos = writeAbbrevCode(withChildren ? AbbrevCode.INLINED_SUBROUTINE_WITH_CHILDREN : AbbrevCode.INLINED_SUBROUTINE, buffer, pos);
+ pos = writeTag(DwarfTag.DW_TAG_inlined_subroutine, buffer, pos);
+ pos = writeHasChildren(withChildren ? DwarfHasChildren.DW_CHILDREN_yes : DwarfHasChildren.DW_CHILDREN_no, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_abstract_origin, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_low_pc, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_hi_pc, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_addr, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_call_file, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data4, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_call_line, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_data4, buffer, pos);
/* Now terminate. */
- pos = writeAttrType(DwarfDebugInfo.DW_AT_null, buffer, pos);
- pos = writeAttrForm(DwarfDebugInfo.DW_FORM_null, buffer, pos);
+ pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos);
+ pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos);
return pos;
}
-
- /**
- * The debug_abbrev section depends on debug_ranges section.
- */
- private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_RANGES_SECTION_NAME;
-
- @Override
- public String targetSectionName() {
- return TARGET_SECTION_NAME;
- }
-
- private final LayoutDecision.Kind[] targetSectionKinds = {
- LayoutDecision.Kind.CONTENT,
- LayoutDecision.Kind.SIZE
- };
-
- @Override
- public LayoutDecision.Kind[] targetSectionKinds() {
- return targetSectionKinds;
- }
}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfDebugInfo.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfDebugInfo.java
index 05afa09b251f..aee6600eeb85 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfDebugInfo.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfDebugInfo.java
@@ -37,6 +37,7 @@
import com.oracle.objectfile.debugentry.TypeEntry;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalInfo;
import com.oracle.objectfile.elf.ELFMachine;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfLanguage;
import org.graalvm.collections.EconomicMap;
/**
@@ -46,265 +47,72 @@
*/
public class DwarfDebugInfo extends DebugInfoBase {
- /*
- * Names of the different ELF sections we create or reference in reverse dependency order.
- */
- public static final String TEXT_SECTION_NAME = ".text";
public static final String HEAP_BEGIN_NAME = "__svm_heap_begin";
- public static final String DW_STR_SECTION_NAME = ".debug_str";
- public static final String DW_LINE_SECTION_NAME = ".debug_line";
- public static final String DW_FRAME_SECTION_NAME = ".debug_frame";
- public static final String DW_ABBREV_SECTION_NAME = ".debug_abbrev";
- public static final String DW_INFO_SECTION_NAME = ".debug_info";
- public static final String DW_LOC_SECTION_NAME = ".debug_loc";
- public static final String DW_ARANGES_SECTION_NAME = ".debug_aranges";
- public static final String DW_RANGES_SECTION_NAME = ".debug_ranges";
-
- /**
- * Currently generated debug info relies on DWARF spec version 4.
- */
- public static final short DW_VERSION_2 = 2;
- public static final short DW_VERSION_4 = 4;
/*
* Define all the abbrev section codes we need for our DIEs.
*/
- @SuppressWarnings("unused") public static final int DW_ABBREV_CODE_null = 0;
- /* Level 0 DIEs. */
- public static final int DW_ABBREV_CODE_builtin_unit = 1;
- public static final int DW_ABBREV_CODE_class_unit1 = 2;
- public static final int DW_ABBREV_CODE_class_unit2 = 3;
- /* Level 1 DIEs. */
- public static final int DW_ABBREV_CODE_primitive_type = 4;
- public static final int DW_ABBREV_CODE_void_type = 5;
- public static final int DW_ABBREV_CODE_object_header = 6;
- public static final int DW_ABBREV_CODE_namespace = 7;
- public static final int DW_ABBREV_CODE_class_layout1 = 8;
- public static final int DW_ABBREV_CODE_class_layout2 = 9;
- public static final int DW_ABBREV_CODE_class_pointer = 10;
- public static final int DW_ABBREV_CODE_foreign_pointer = 11;
- public static final int DW_ABBREV_CODE_foreign_typedef = 12;
- public static final int DW_ABBREV_CODE_foreign_struct = 13;
- public static final int DW_ABBREV_CODE_method_location = 14;
- public static final int DW_ABBREV_CODE_static_field_location = 15;
- public static final int DW_ABBREV_CODE_array_layout = 16;
- public static final int DW_ABBREV_CODE_array_pointer = 17;
- public static final int DW_ABBREV_CODE_interface_layout = 18;
- public static final int DW_ABBREV_CODE_interface_pointer = 19;
- public static final int DW_ABBREV_CODE_indirect_layout = 20;
- public static final int DW_ABBREV_CODE_indirect_pointer = 21;
- /* Level 2 DIEs. */
- public static final int DW_ABBREV_CODE_method_declaration = 22;
- public static final int DW_ABBREV_CODE_method_declaration_static = 23;
- public static final int DW_ABBREV_CODE_field_declaration1 = 24;
- public static final int DW_ABBREV_CODE_field_declaration2 = 25;
- public static final int DW_ABBREV_CODE_field_declaration3 = 26;
- public static final int DW_ABBREV_CODE_field_declaration4 = 27;
- public static final int DW_ABBREV_CODE_class_constant = 28;
- public static final int DW_ABBREV_CODE_header_field = 29;
- public static final int DW_ABBREV_CODE_array_data_type1 = 30;
- public static final int DW_ABBREV_CODE_array_data_type2 = 31;
- public static final int DW_ABBREV_CODE_array_subrange = 32;
- public static final int DW_ABBREV_CODE_super_reference = 33;
- public static final int DW_ABBREV_CODE_interface_implementor = 34;
- /* Level 2+K DIEs (where inline depth K >= 0) */
- public static final int DW_ABBREV_CODE_inlined_subroutine = 35;
- public static final int DW_ABBREV_CODE_inlined_subroutine_with_children = 36;
- public static final int DW_ABBREV_CODE_abstract_inline_method = 37;
- /* Level 2 DIEs. */
- public static final int DW_ABBREV_CODE_method_parameter_declaration1 = 38;
- public static final int DW_ABBREV_CODE_method_parameter_declaration2 = 39;
- public static final int DW_ABBREV_CODE_method_parameter_declaration3 = 40;
- public static final int DW_ABBREV_CODE_method_local_declaration1 = 41;
- public static final int DW_ABBREV_CODE_method_local_declaration2 = 42;
- /* Level 3 DIEs. */
- public static final int DW_ABBREV_CODE_method_parameter_location1 = 43;
- public static final int DW_ABBREV_CODE_method_parameter_location2 = 44;
- public static final int DW_ABBREV_CODE_method_local_location1 = 45;
- public static final int DW_ABBREV_CODE_method_local_location2 = 46;
-
- /*
- * Define all the Dwarf tags we need for our DIEs.
- */
- public static final int DW_TAG_array_type = 0x01;
- public static final int DW_TAG_class_type = 0x02;
- public static final int DW_TAG_formal_parameter = 0x05;
- public static final int DW_TAG_member = 0x0d;
- public static final int DW_TAG_pointer_type = 0x0f;
- public static final int DW_TAG_compile_unit = 0x11;
- public static final int DW_TAG_structure_type = 0x13;
- public static final int DW_TAG_typedef = 0x16;
- public static final int DW_TAG_union_type = 0x17;
- public static final int DW_TAG_inheritance = 0x1c;
- public static final int DW_TAG_subrange_type = 0x21;
- public static final int DW_TAG_base_type = 0x24;
- public static final int DW_TAG_constant = 0x27;
- public static final int DW_TAG_subprogram = 0x2e;
- public static final int DW_TAG_variable = 0x34;
- public static final int DW_TAG_namespace = 0x39;
- public static final int DW_TAG_unspecified_type = 0x3b;
- public static final int DW_TAG_inlined_subroutine = 0x1d;
-
- /*
- * Define all the Dwarf attributes we need for our DIEs.
- */
- public static final int DW_AT_null = 0x0;
- public static final int DW_AT_location = 0x02;
- public static final int DW_AT_name = 0x3;
- public static final int DW_AT_byte_size = 0x0b;
- public static final int DW_AT_bit_size = 0x0d;
- public static final int DW_AT_stmt_list = 0x10;
- public static final int DW_AT_low_pc = 0x11;
- public static final int DW_AT_hi_pc = 0x12;
- public static final int DW_AT_language = 0x13;
- public static final int DW_AT_comp_dir = 0x1b;
- public static final int DW_AT_containing_type = 0x1d;
- @SuppressWarnings("unused") public static final int DW_AT_inline = 0x20;
- public static final int DW_AT_abstract_origin = 0x31;
- public static final int DW_AT_accessibility = 0x32;
- public static final int DW_AT_artificial = 0x34;
- public static final int DW_AT_count = 0x37;
- public static final int DW_AT_data_member_location = 0x38;
- @SuppressWarnings("unused") public static final int DW_AT_decl_column = 0x39;
- public static final int DW_AT_decl_file = 0x3a;
- @SuppressWarnings("unused") public static final int DW_AT_decl_line = 0x3b;
- public static final int DW_AT_declaration = 0x3c;
- public static final int DW_AT_encoding = 0x3e;
- public static final int DW_AT_external = 0x3f;
- @SuppressWarnings("unused") public static final int DW_AT_return_addr = 0x2a;
- @SuppressWarnings("unused") public static final int DW_AT_frame_base = 0x40;
- public static final int DW_AT_specification = 0x47;
- public static final int DW_AT_type = 0x49;
- public static final int DW_AT_data_location = 0x50;
- public static final int DW_AT_use_UTF8 = 0x53;
- public static final int DW_AT_ranges = 0x55;
- public static final int DW_AT_call_file = 0x58;
- public static final int DW_AT_call_line = 0x59;
- public static final int DW_AT_object_pointer = 0x64;
- public static final int DW_AT_linkage_name = 0x6e;
-
- /*
- * Define all the Dwarf attribute forms we need for our DIEs.
- */
- public static final int DW_FORM_null = 0x0;
- public static final int DW_FORM_addr = 0x1;
- public static final int DW_FORM_data2 = 0x05;
- public static final int DW_FORM_data4 = 0x6;
- @SuppressWarnings("unused") public static final int DW_FORM_data8 = 0x7;
- @SuppressWarnings("unused") private static final int DW_FORM_string = 0x8;
- @SuppressWarnings("unused") public static final int DW_FORM_block1 = 0x0a;
- public static final int DW_FORM_ref_addr = 0x10;
- @SuppressWarnings("unused") public static final int DW_FORM_ref1 = 0x11;
- @SuppressWarnings("unused") public static final int DW_FORM_ref2 = 0x12;
- @SuppressWarnings("unused") public static final int DW_FORM_ref4 = 0x13;
- @SuppressWarnings("unused") public static final int DW_FORM_ref8 = 0x14;
- public static final int DW_FORM_sec_offset = 0x17;
- public static final int DW_FORM_data1 = 0x0b;
- public static final int DW_FORM_flag = 0xc;
- public static final int DW_FORM_strp = 0xe;
- public static final int DW_FORM_expr_loc = 0x18;
+ enum AbbrevCode {
+ /* null marker which must come first as its ordinal has to equal zero */
+ NULL,
+ /* Level 0 DIEs. */
+ BUILTIN_UNIT,
+ CLASS_UNIT_1,
+ CLASS_UNIT_2,
+ /* Level 1 DIEs. */
+ PRIMITIVE_TYPE,
+ VOID_TYPE,
+ OBJECT_HEADER,
+ NAMESPACE,
+ CLASS_LAYOUT_1,
+ CLASS_LAYOUT_2,
+ CLASS_POINTER,
+ FOREIGN_POINTER,
+ FOREIGN_TYPEDEF,
+ FOREIGN_STRUCT,
+ METHOD_LOCATION,
+ STATIC_FIELD_LOCATION,
+ ARRAY_LAYOUT,
+ ARRAY_POINTER,
+ INTERFACE_LAYOUT,
+ INTERFACE_POINTER,
+ INDIRECT_LAYOUT,
+ INDIRECT_POINTER,
+ /* Level 2 DIEs. */
+ METHOD_DECLARATION,
+ METHOD_DECLARATION_STATIC,
+ FIELD_DECLARATION_1,
+ FIELD_DECLARATION_2,
+ FIELD_DECLARATION_3,
+ FIELD_DECLARATION_4,
+ CLASS_CONSTANT,
+ HEADER_FIELD,
+ ARRAY_DATA_TYPE_1,
+ ARRAY_DATA_TYPE_2,
+ ARRAY_SUBRANGE,
+ SUPER_REFERENCE,
+ INTERFACE_IMPLEMENTOR,
+ /* Level 2+K DIEs (where inline depth K >= 0) */
+ INLINED_SUBROUTINE,
+ INLINED_SUBROUTINE_WITH_CHILDREN,
+ ABSTRACT_INLINE_METHOD,
+ /* Level 3 DIEs. */
+ METHOD_PARAMETER_DECLARATION_1,
+ METHOD_PARAMETER_DECLARATION_2,
+ METHOD_PARAMETER_DECLARATION_3,
+ METHOD_LOCAL_DECLARATION_1,
+ METHOD_LOCAL_DECLARATION_2,
+ METHOD_PARAMETER_LOCATION_1,
+ METHOD_PARAMETER_LOCATION_2,
+ METHOD_LOCAL_LOCATION_1,
+ METHOD_LOCAL_LOCATION_2,
+ }
- /*
- * Define specific attribute values for given attribute or form types.
- */
- /*
- * DIE header has_children attribute values.
- */
- public static final byte DW_CHILDREN_no = 0;
- public static final byte DW_CHILDREN_yes = 1;
- /*
- * DW_FORM_flag attribute values.
- */
- @SuppressWarnings("unused") public static final byte DW_FLAG_false = 0;
- public static final byte DW_FLAG_true = 1;
- /*
- * Value for DW_AT_language attribute with form DATA1.
- */
- public static final byte DW_LANG_Java = 0xb;
/**
* This field defines the value used for the DW_AT_language attribute of compile units.
*
*/
- public static final byte LANG_ENCODING = DW_LANG_Java;
- /*
- * Values for {@link DW_AT_inline} attribute with form DATA1.
- */
- @SuppressWarnings("unused") public static final byte DW_INL_not_inlined = 0;
- public static final byte DW_INL_inlined = 1;
- @SuppressWarnings("unused") public static final byte DW_INL_declared_not_inlined = 2;
- @SuppressWarnings("unused") public static final byte DW_INL_declared_inlined = 3;
-
- /*
- * DW_AT_Accessibility attribute values.
- *
- * These are not needed until we make functions members.
- */
- @SuppressWarnings("unused") public static final byte DW_ACCESS_public = 1;
- @SuppressWarnings("unused") public static final byte DW_ACCESS_protected = 2;
- @SuppressWarnings("unused") public static final byte DW_ACCESS_private = 3;
-
- /*
- * DW_AT_encoding attribute values
- */
- public static final byte DW_ATE_address = 0x1;
- public static final byte DW_ATE_boolean = 0x2;
- public static final byte DW_ATE_float = 0x4;
- public static final byte DW_ATE_signed = 0x5;
- public static final byte DW_ATE_signed_char = 0x6;
- public static final byte DW_ATE_unsigned = 0x7;
- public static final byte DW_ATE_unsigned_char = 0x8;
-
- /*
- * CIE and FDE entries.
- */
-
- /* Full byte/word values. */
- public static final int DW_CFA_CIE_id = -1;
- @SuppressWarnings("unused") public static final int DW_CFA_FDE_id = 0;
-
- public static final byte DW_CFA_CIE_version = 1;
-
- /* Values encoded in high 2 bits. */
- public static final byte DW_CFA_advance_loc = 0x1;
- public static final byte DW_CFA_offset = 0x2;
- public static final byte DW_CFA_restore = 0x3;
-
- /* Values encoded in low 6 bits. */
- public static final byte DW_CFA_nop = 0x0;
- @SuppressWarnings("unused") public static final byte DW_CFA_set_loc1 = 0x1;
- public static final byte DW_CFA_advance_loc1 = 0x2;
- public static final byte DW_CFA_advance_loc2 = 0x3;
- public static final byte DW_CFA_advance_loc4 = 0x4;
- @SuppressWarnings("unused") public static final byte DW_CFA_offset_extended = 0x5;
- @SuppressWarnings("unused") public static final byte DW_CFA_restore_extended = 0x6;
- @SuppressWarnings("unused") public static final byte DW_CFA_undefined = 0x7;
- @SuppressWarnings("unused") public static final byte DW_CFA_same_value = 0x8;
- public static final byte DW_CFA_register = 0x9;
- public static final byte DW_CFA_def_cfa = 0xc;
- @SuppressWarnings("unused") public static final byte DW_CFA_def_cfa_register = 0xd;
- public static final byte DW_CFA_def_cfa_offset = 0xe;
-
- /*
- * Values used to build DWARF expressions and locations
- */
- public static final byte DW_OP_addr = 0x03;
- @SuppressWarnings("unused") public static final byte DW_OP_deref = 0x06;
- public static final byte DW_OP_dup = 0x12;
- public static final byte DW_OP_and = 0x1a;
- public static final byte DW_OP_not = 0x20;
- public static final byte DW_OP_plus = 0x22;
- public static final byte DW_OP_shl = 0x24;
- public static final byte DW_OP_shr = 0x25;
- public static final byte DW_OP_bra = 0x28;
- public static final byte DW_OP_eq = 0x29;
- public static final byte DW_OP_lit0 = 0x30;
- public static final byte DW_OP_reg0 = 0x50;
- public static final byte DW_OP_breg0 = 0x70;
- public static final byte DW_OP_regx = (byte) 0x90;
- public static final byte DW_OP_bregx = (byte) 0x92;
- public static final byte DW_OP_push_object_address = (byte) 0x97;
- public static final byte DW_OP_implicit_value = (byte) 0x9e;
- public static final byte DW_OP_stack_value = (byte) 0x9f;
+ public static final DwarfLanguage LANG_ENCODING = DwarfLanguage.DW_LANG_Java;
/* Register constants for AArch64. */
public static final byte rheapbase_aarch64 = (byte) 27;
@@ -323,6 +131,7 @@ public class DwarfDebugInfo extends DebugInfoBase {
* bits
*/
public static final String HUB_TYPE_NAME = "java.lang.Class";
+ /* Full byte/word values. */
private final DwarfStrSectionImpl dwarfStrSection;
private final DwarfAbbrevSectionImpl dwarfAbbrevSection;
private final DwarfInfoSectionImpl dwarfInfoSection;
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImpl.java
index fda78c22feb4..d797c64d511f 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImpl.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImpl.java
@@ -26,10 +26,11 @@
package com.oracle.objectfile.elf.dwarf;
-import com.oracle.objectfile.LayoutDecision;
import com.oracle.objectfile.debugentry.CompiledMethodEntry;
import com.oracle.objectfile.debugentry.range.Range;
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfFrameValue;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName;
import org.graalvm.compiler.debug.DebugContext;
import java.util.List;
@@ -41,13 +42,11 @@ public abstract class DwarfFrameSectionImpl extends DwarfSectionImpl {
private static final int PADDING_NOPS_ALIGNMENT = 8;
- public DwarfFrameSectionImpl(DwarfDebugInfo dwarfSections) {
- super(dwarfSections);
- }
+ private static final int CFA_CIE_id_default = -1;
- @Override
- public String getSectionName() {
- return DwarfDebugInfo.DW_FRAME_SECTION_NAME;
+ public DwarfFrameSectionImpl(DwarfDebugInfo dwarfSections) {
+ // debug_frame section depends on debug_line section
+ super(dwarfSections, DwarfSectionName.DW_FRAME_SECTION, DwarfSectionName.DW_LINE_SECTION);
}
@Override
@@ -100,7 +99,7 @@ private int writeCIE(byte[] buffer, int p) {
*
* uint32 : length ............... length of remaining fields in this CIE
*
- * uint32 : CIE_id ................ unique id for CIE == 0xffffff
+ * uint32 : CIE_id ................ unique id for CIE == 0xffffffff
*
* uint8 : version ................ == 1
*
@@ -119,8 +118,8 @@ private int writeCIE(byte[] buffer, int p) {
int pos = p;
int lengthPos = pos;
pos = writeInt(0, buffer, pos);
- pos = writeInt(DwarfDebugInfo.DW_CFA_CIE_id, buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_CFA_CIE_version, buffer, pos);
+ pos = writeInt(CFA_CIE_id_default, buffer, pos);
+ pos = writeCIEVersion(buffer, pos);
pos = writeByte((byte) 0, buffer, pos);
pos = writeULEB(1, buffer, pos);
pos = writeSLEB(-8, buffer, pos);
@@ -137,6 +136,10 @@ private int writeCIE(byte[] buffer, int p) {
return pos;
}
+ private int writeCIEVersion(byte[] buffer, int pos) {
+ return writeByte(DwarfFrameValue.DW_CFA_CIE_version.value(), buffer, pos);
+ }
+
private int writeMethodFrame(CompiledMethodEntry compiledEntry, byte[] buffer, int p) {
int pos = p;
int lengthPos = pos;
@@ -194,21 +197,22 @@ private int writeFDEHeader(int lo, int hi, byte[] buffer, int p) {
private int writePaddingNops(byte[] buffer, int p) {
int pos = p;
while ((pos & (PADDING_NOPS_ALIGNMENT - 1)) != 0) {
- pos = writeByte(DwarfDebugInfo.DW_CFA_nop, buffer, pos);
+ pos = writeByte(DwarfFrameValue.DW_CFA_nop.value(), buffer, pos);
}
return pos;
}
protected int writeDefCFA(int register, int offset, byte[] buffer, int p) {
int pos = p;
- pos = writeByte(DwarfDebugInfo.DW_CFA_def_cfa, buffer, pos);
+ pos = writeByte(DwarfFrameValue.DW_CFA_def_cfa.value(), buffer, pos);
pos = writeULEB(register, buffer, pos);
return writeULEB(offset, buffer, pos);
}
protected int writeDefCFAOffset(int offset, byte[] buffer, int p) {
int pos = p;
- pos = writeByte(DwarfDebugInfo.DW_CFA_def_cfa_offset, buffer, pos);
+ byte op = DwarfFrameValue.DW_CFA_def_cfa_offset.value();
+ pos = writeByte(op, buffer, pos);
return writeULEB(offset, buffer, pos);
}
@@ -231,20 +235,20 @@ protected int writeAdvanceLoc0(byte offset, byte[] buffer, int pos) {
protected int writeAdvanceLoc1(byte offset, byte[] buffer, int p) {
int pos = p;
- byte op = DwarfDebugInfo.DW_CFA_advance_loc1;
+ byte op = DwarfFrameValue.DW_CFA_advance_loc1.value();
pos = writeByte(op, buffer, pos);
return writeByte(offset, buffer, pos);
}
protected int writeAdvanceLoc2(short offset, byte[] buffer, int p) {
- byte op = DwarfDebugInfo.DW_CFA_advance_loc2;
+ byte op = DwarfFrameValue.DW_CFA_advance_loc2.value();
int pos = p;
pos = writeByte(op, buffer, pos);
return writeShort(offset, buffer, pos);
}
protected int writeAdvanceLoc4(int offset, byte[] buffer, int p) {
- byte op = DwarfDebugInfo.DW_CFA_advance_loc4;
+ byte op = DwarfFrameValue.DW_CFA_advance_loc4.value();
int pos = p;
pos = writeByte(op, buffer, pos);
return writeInt(offset, buffer, pos);
@@ -266,7 +270,8 @@ protected int writeRestore(int register, byte[] buffer, int p) {
@SuppressWarnings("unused")
protected int writeRegister(int savedReg, int savedToReg, byte[] buffer, int p) {
int pos = p;
- pos = writeByte(DwarfDebugInfo.DW_CFA_register, buffer, pos);
+ byte op = DwarfFrameValue.DW_CFA_register.value();
+ pos = writeByte(op, buffer, pos);
pos = writeULEB(savedReg, buffer, pos);
return writeULEB(savedToReg, buffer, pos);
}
@@ -278,38 +283,23 @@ protected int writeRegister(int savedReg, int savedToReg, byte[] buffer, int p)
protected abstract int writeInitialInstructions(byte[] buffer, int pos);
- /**
- * The debug_frame section depends on debug_line section.
- */
- private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_LINE_SECTION_NAME;
-
- @Override
- public String targetSectionName() {
- return TARGET_SECTION_NAME;
- }
-
- private final LayoutDecision.Kind[] targetSectionKinds = {
- LayoutDecision.Kind.CONTENT,
- LayoutDecision.Kind.SIZE
- };
-
- @Override
- public LayoutDecision.Kind[] targetSectionKinds() {
- return targetSectionKinds;
- }
-
private static byte offsetOp(int register) {
- assert (register >> 6) == 0;
- return (byte) ((DwarfDebugInfo.DW_CFA_offset << 6) | register);
+ byte op = DwarfFrameValue.DW_CFA_offset.value();
+ return encodeOp(op, register);
}
private static byte restoreOp(int register) {
- assert (register >> 6) == 0;
- return (byte) ((DwarfDebugInfo.DW_CFA_restore << 6) | register);
+ byte op = DwarfFrameValue.DW_CFA_restore.value();
+ return encodeOp(op, register);
}
private static byte advanceLoc0Op(int offset) {
- assert (offset >= 0 && offset <= 0x3f);
- return (byte) ((DwarfDebugInfo.DW_CFA_advance_loc << 6) | offset);
+ byte op = DwarfFrameValue.DW_CFA_advance_loc.value();
+ return encodeOp(op, offset);
+ }
+
+ private static byte encodeOp(byte op, int value) {
+ assert (value >> 6) == 0;
+ return (byte) ((op << 6) | value);
}
}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImplAArch64.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImplAArch64.java
index 73dc13e94239..b568d396c919 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImplAArch64.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfFrameSectionImplAArch64.java
@@ -35,10 +35,10 @@
* registers and frame layout.
*/
public class DwarfFrameSectionImplAArch64 extends DwarfFrameSectionImpl {
- public static final int DW_CFA_FP_IDX = 29;
- private static final int DW_CFA_LR_IDX = 30;
- private static final int DW_CFA_SP_IDX = 31;
- @SuppressWarnings("unused") private static final int DW_CFA_PC_IDX = 32;
+ public static final int CFA_FP_IDX = 29;
+ private static final int CFA_LR_IDX = 30;
+ private static final int CFA_SP_IDX = 31;
+ @SuppressWarnings("unused") private static final int CFA_PC_IDX = 32;
public DwarfFrameSectionImplAArch64(DwarfDebugInfo dwarfSections) {
super(dwarfSections);
@@ -46,12 +46,12 @@ public DwarfFrameSectionImplAArch64(DwarfDebugInfo dwarfSections) {
@Override
public int getReturnPCIdx() {
- return DW_CFA_LR_IDX;
+ return CFA_LR_IDX;
}
@Override
public int getSPIdx() {
- return DW_CFA_SP_IDX;
+ return CFA_SP_IDX;
}
@Override
@@ -68,7 +68,7 @@ public int writeInitialInstructions(byte[] buffer, int p) {
*
*
*/
- pos = writeDefCFA(DW_CFA_SP_IDX, 0, buffer, pos);
+ pos = writeDefCFA(CFA_SP_IDX, 0, buffer, pos);
return pos;
}
@@ -92,8 +92,8 @@ protected int writeFDEs(int frameSize, List
*/
- pos = writeDefCFA(DW_CFA_RSP_IDX, 8, buffer, pos);
+ pos = writeDefCFA(CFA_RSP_IDX, 8, buffer, pos);
/*
* Register rip is saved in slot 1.
*
@@ -79,7 +79,7 @@ public int writeInitialInstructions(byte[] buffer, int p) {
*
*
*/
- pos = writeOffset(DW_CFA_RIP_IDX, 1, buffer, pos);
+ pos = writeOffset(CFA_RIP_IDX, 1, buffer, pos);
return pos;
}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfInfoSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfInfoSectionImpl.java
index e49ba150e213..251b7c340a7d 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfInfoSectionImpl.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfInfoSectionImpl.java
@@ -33,10 +33,17 @@
import java.util.List;
import java.util.stream.Stream;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfAccess;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfEncoding;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfFlag;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfInline;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfLanguage;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfVersion;
import org.graalvm.collections.EconomicSet;
import org.graalvm.compiler.debug.DebugContext;
-import com.oracle.objectfile.LayoutDecision;
import com.oracle.objectfile.debugentry.ArrayTypeEntry;
import com.oracle.objectfile.debugentry.ClassEntry;
import com.oracle.objectfile.debugentry.CompiledMethodEntry;
@@ -54,6 +61,7 @@
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo;
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo;
+import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo.AbbrevCode;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
@@ -71,7 +79,7 @@ public class DwarfInfoSectionImpl extends DwarfSectionImpl {
/**
* An info header section always contains a fixed number of bytes.
*/
- private static final int DW_DIE_HEADER_SIZE = 11;
+ private static final int DIE_HEADER_SIZE = 11;
/**
* Normally the offset of DWARF type declarations are tracked using the type/class entry
* properties but that means they are only available to be read during the second pass when
@@ -83,18 +91,14 @@ public class DwarfInfoSectionImpl extends DwarfSectionImpl {
private int cuStart;
public DwarfInfoSectionImpl(DwarfDebugInfo dwarfSections) {
- super(dwarfSections);
+ // debug_info section depends on loc section
+ super(dwarfSections, DwarfSectionName.DW_INFO_SECTION, DwarfSectionName.DW_LOC_SECTION);
// initialize to an invalid value
voidOffset = -1;
// initialize CU start to an invalid value
cuStart = -1;
}
- @Override
- public String getSectionName() {
- return DwarfDebugInfo.DW_INFO_SECTION_NAME;
- }
-
@Override
public void createContent() {
assert !contentByteArrayCreated();
@@ -122,29 +126,29 @@ public void writeContent(DebugContext context) {
assert pos == size;
}
- byte computeEncoding(int flags, int bitCount) {
+ DwarfEncoding computeEncoding(int flags, int bitCount) {
assert bitCount > 0;
if ((flags & DebugPrimitiveTypeInfo.FLAG_NUMERIC) != 0) {
if (((flags & DebugPrimitiveTypeInfo.FLAG_INTEGRAL) != 0)) {
if ((flags & DebugPrimitiveTypeInfo.FLAG_SIGNED) != 0) {
switch (bitCount) {
case 8:
- return DwarfDebugInfo.DW_ATE_signed_char;
+ return DwarfEncoding.DW_ATE_signed_char;
default:
assert bitCount == 16 || bitCount == 32 || bitCount == 64;
- return DwarfDebugInfo.DW_ATE_signed;
+ return DwarfEncoding.DW_ATE_signed;
}
} else {
assert bitCount == 16;
- return DwarfDebugInfo.DW_ATE_unsigned;
+ return DwarfEncoding.DW_ATE_unsigned;
}
} else {
assert bitCount == 32 || bitCount == 64;
- return DwarfDebugInfo.DW_ATE_float;
+ return DwarfEncoding.DW_ATE_float;
}
} else {
assert bitCount == 1;
- return DwarfDebugInfo.DW_ATE_boolean;
+ return DwarfEncoding.DW_ATE_boolean;
}
}
@@ -175,14 +179,14 @@ private int writeBuiltInTypes(DebugContext context, byte[] buffer, int p) {
log(context, " [0x%08x] <0> Java Builtin Compile Unit", pos);
cuStart = p;
pos = writeCUHeader(buffer, pos);
- assert pos == lengthPos + DW_DIE_HEADER_SIZE;
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_builtin_unit;
+ assert pos == lengthPos + DIE_HEADER_SIZE;
+ AbbrevCode abbrevCode = AbbrevCode.BUILTIN_UNIT;
log(context, " [0x%08x] <0> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] language %s", pos, "DW_LANG_Java");
- pos = writeAttrData1(DwarfDebugInfo.LANG_ENCODING, buffer, pos);
+ pos = writeAttrLanguage(DwarfDebugInfo.LANG_ENCODING, buffer, pos);
log(context, " [0x%08x] use_UTF8", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
String name = uniqueDebugString("JAVA");
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
pos = writeStrSectionOffset(name, buffer, pos);
@@ -233,7 +237,7 @@ public int writePrimitiveType(DebugContext context, PrimitiveTypeEntry primitive
* might want an indirect type
*/
setIndirectTypeIndex(primitiveTypeEntry, pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_primitive_type;
+ AbbrevCode abbrevCode = AbbrevCode.PRIMITIVE_TYPE;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
byte byteSize = (byte) primitiveTypeEntry.getSize();
@@ -242,9 +246,9 @@ public int writePrimitiveType(DebugContext context, PrimitiveTypeEntry primitive
byte bitCount = (byte) primitiveTypeEntry.getBitCount();
log(context, " [0x%08x] bitCount %d", pos, bitCount);
pos = writeAttrData1(bitCount, buffer, pos);
- byte encoding = computeEncoding(primitiveTypeEntry.getFlags(), bitCount);
- log(context, " [0x%08x] encoding 0x%x", pos, encoding);
- pos = writeAttrData1(encoding, buffer, pos);
+ DwarfEncoding encoding = computeEncoding(primitiveTypeEntry.getFlags(), bitCount);
+ log(context, " [0x%08x] encoding 0x%x", pos, encoding.value());
+ pos = writeAttrEncoding(encoding, buffer, pos);
String name = primitiveTypeEntry.getTypeName();
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
return writeStrSectionOffset(name, buffer, pos);
@@ -265,7 +269,7 @@ public int writeVoidType(DebugContext context, PrimitiveTypeEntry primitiveTypeE
// we need to use it as the base layout for foreign types
assert voidOffset == -1 || voidOffset == pos;
voidOffset = pos;
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_void_type;
+ AbbrevCode abbrevCode = AbbrevCode.VOID_TYPE;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String name = primitiveTypeEntry.getTypeName();
@@ -285,7 +289,7 @@ public int writeHeaderType(DebugContext context, HeaderTypeEntry headerTypeEntry
* want an indirect type.
*/
setIndirectTypeIndex(headerTypeEntry, pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_object_header;
+ AbbrevCode abbrevCode = AbbrevCode.OBJECT_HEADER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
@@ -349,7 +353,7 @@ private int writeStructField(DebugContext context, FieldEntry fieldEntry, byte[]
valueTypeIdx = getIndirectTypeIndex(valueType);
}
log(context, " [0x%08x] struct field", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_header_field;
+ AbbrevCode abbrevCode = AbbrevCode.HEADER_FIELD;
log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(fieldName), fieldName);
@@ -383,14 +387,14 @@ private int writeInstanceClassInfo(DebugContext context, ClassEntry classEntry,
int lengthPos = pos;
log(context, " [0x%08x] Instance class unit", pos);
pos = writeCUHeader(buffer, pos);
- assert pos == lengthPos + DW_DIE_HEADER_SIZE;
- int abbrevCode = (classEntry.hasCompiledEntries() ? DwarfDebugInfo.DW_ABBREV_CODE_class_unit2 : DwarfDebugInfo.DW_ABBREV_CODE_class_unit1);
+ assert pos == lengthPos + DIE_HEADER_SIZE;
+ AbbrevCode abbrevCode = (classEntry.hasCompiledEntries() ? AbbrevCode.CLASS_UNIT_2 : AbbrevCode.CLASS_UNIT_1);
log(context, " [0x%08x] <0> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] language %s", pos, "DW_LANG_Java");
- pos = writeAttrData1(DwarfDebugInfo.LANG_ENCODING, buffer, pos);
+ pos = writeAttrLanguage(DwarfDebugInfo.LANG_ENCODING, buffer, pos);
log(context, " [0x%08x] use_UTF8", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
String name = classEntry.getFullFileName();
if (name == null) {
name = classEntry.getTypeName().replace('.', '/') + ".java";
@@ -400,7 +404,7 @@ private int writeInstanceClassInfo(DebugContext context, ClassEntry classEntry,
String compilationDirectory = dwarfSections.getCachePath();
log(context, " [0x%08x] comp_dir 0x%x (%s)", pos, debugStringIndex(compilationDirectory), compilationDirectory);
pos = writeStrSectionOffset(compilationDirectory, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_class_unit2) {
+ if (abbrevCode == AbbrevCode.CLASS_UNIT_2) {
int codeRangesIndex = getCodeRangesIndex(classEntry);
log(context, " [0x%08x] ranges 0x%x", pos, codeRangesIndex);
pos = writeRangesSectionOffset(codeRangesIndex, buffer, pos);
@@ -470,7 +474,7 @@ private int writeNameSpace(DebugContext context, String id, byte[] buffer, int p
String name = uniqueDebugString(id);
assert !id.isEmpty();
log(context, " [0x%08x] namespace %s", pos, name);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_namespace;
+ AbbrevCode abbrevCode = AbbrevCode.NAMESPACE;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
@@ -487,7 +491,7 @@ private int writeClassConstantDeclaration(DebugContext context, TypeEntry typeEn
}
// Write a special static field declaration for the class object
// we use the abbrev code for a static field with no file or line location
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_class_constant;
+ AbbrevCode abbrevCode = AbbrevCode.CLASS_CONSTANT;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
@@ -505,9 +509,9 @@ private int writeClassConstantDeclaration(DebugContext context, TypeEntry typeEn
log(context, " [0x%08x] accessibility public static final", pos);
pos = writeAttrAccessibility(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL, buffer, pos);
log(context, " [0x%08x] external(true)", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
log(context, " [0x%08x] definition(true)", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
/*
* We need to force encoding of this location as a heap base relative relocatable address
* rather than an offset from the heapbase register.
@@ -522,13 +526,13 @@ private int writeClassLayout(DebugContext context, ClassEntry classEntry, byte[]
int layoutIndex = pos;
setLayoutIndex(classEntry, layoutIndex);
log(context, " [0x%08x] class layout", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_class_layout1;
+ AbbrevCode abbrevCode = AbbrevCode.CLASS_LAYOUT_1;
/*
* when we don't have a separate indirect type then hub layouts need an extra data_location
* attribute
*/
if (!dwarfSections.useHeapBase() && dwarfSections.isHubClassEntry(classEntry)) {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_class_layout2;
+ abbrevCode = AbbrevCode.CLASS_LAYOUT_2;
}
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
@@ -541,7 +545,7 @@ private int writeClassLayout(DebugContext context, ClassEntry classEntry, byte[]
int fileIdx = classEntry.getFileIdx();
log(context, " [0x%08x] file 0x%x (%s)", pos, fileIdx, classEntry.getFileName());
pos = writeAttrData2((short) fileIdx, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_class_layout2) {
+ if (abbrevCode == AbbrevCode.CLASS_LAYOUT_2) {
/* Write a data location expression to mask and/or rebase oop pointers. */
log(context, " [0x%08x] data_location", pos);
pos = writeIndirectOopConversionExpression(true, buffer, pos);
@@ -575,7 +579,7 @@ private int writeClassLayout(DebugContext context, ClassEntry classEntry, byte[]
*/
setIndirectLayoutIndex(classEntry, pos);
log(context, " [0x%08x] indirect class layout", pos);
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_layout;
+ abbrevCode = AbbrevCode.INDIRECT_LAYOUT;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String indirectName = uniqueDebugString(DwarfDebugInfo.INDIRECT_PREFIX + classEntry.getTypeName());
@@ -604,7 +608,7 @@ private int writeClassLayout(DebugContext context, ClassEntry classEntry, byte[]
private int writeSuperReference(DebugContext context, int superTypeOffset, String superName, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] super reference", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_super_reference;
+ AbbrevCode abbrevCode = AbbrevCode.SUPER_REFERENCE;
log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] type 0x%x (%s)", pos, superTypeOffset, superName);
@@ -633,19 +637,19 @@ private int writeField(DebugContext context, StructureTypeEntry entry, FieldEntr
int modifiers = fieldEntry.getModifiers();
boolean hasFile = fieldEntry.getFileName().length() > 0;
log(context, " [0x%08x] field definition", pos);
- int abbrevCode;
+ AbbrevCode abbrevCode;
boolean isStatic = Modifier.isStatic(modifiers);
if (!isStatic) {
if (!hasFile) {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration1;
+ abbrevCode = AbbrevCode.FIELD_DECLARATION_1;
} else {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration2;
+ abbrevCode = AbbrevCode.FIELD_DECLARATION_2;
}
} else {
if (!hasFile) {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration3;
+ abbrevCode = AbbrevCode.FIELD_DECLARATION_3;
} else {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration4;
+ abbrevCode = AbbrevCode.FIELD_DECLARATION_4;
}
/* Record the position of the declaration to use when we write the definition. */
setFieldDeclarationIndex(entry, fieldEntry.fieldName(), pos);
@@ -680,9 +684,9 @@ private int writeField(DebugContext context, StructureTypeEntry entry, FieldEntr
/* Static fields are only declared here and are external. */
if (isStatic) {
log(context, " [0x%08x] external(true)", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
log(context, " [0x%08x] definition(true)", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
}
return pos;
}
@@ -709,11 +713,11 @@ private int writeMethodDeclaration(DebugContext context, ClassEntry classEntry,
int modifiers = method.getModifiers();
boolean isStatic = Modifier.isStatic(modifiers);
log(context, " [0x%08x] method declaration %s::%s", pos, classEntry.getTypeName(), method.methodName());
- int abbrevCode = (isStatic ? DwarfDebugInfo.DW_ABBREV_CODE_method_declaration_static : DwarfDebugInfo.DW_ABBREV_CODE_method_declaration);
+ AbbrevCode abbrevCode = (isStatic ? AbbrevCode.METHOD_DECLARATION_STATIC : AbbrevCode.METHOD_DECLARATION);
log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] external true", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
String name = uniqueDebugString(method.methodName());
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
pos = writeStrSectionOffset(name, buffer, pos);
@@ -735,15 +739,15 @@ private int writeMethodDeclaration(DebugContext context, ClassEntry classEntry,
log(context, " [0x%08x] type 0x%x (%s)", pos, retTypeIdx, returnType.getTypeName());
pos = writeInfoSectionOffset(retTypeIdx, buffer, pos);
log(context, " [0x%08x] artificial %s", pos, method.isDeopt() ? "true" : "false");
- pos = writeFlag((method.isDeopt() ? (byte) 1 : (byte) 0), buffer, pos);
+ pos = writeFlag((method.isDeopt() ? DwarfFlag.DW_FLAG_true : DwarfFlag.DW_FLAG_false), buffer, pos);
log(context, " [0x%08x] accessibility %s", pos, "public");
pos = writeAttrAccessibility(modifiers, buffer, pos);
log(context, " [0x%08x] declaration true", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
int typeIdx = getLayoutIndex(classEntry);
log(context, " [0x%08x] containing_type 0x%x (%s)", pos, typeIdx, classEntry.getTypeName());
pos = writeAttrRef4(typeIdx, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_declaration) {
+ if (abbrevCode == AbbrevCode.METHOD_DECLARATION) {
/* Record the current position so we can back patch the object pointer. */
int objectPointerIndex = pos;
/*
@@ -788,22 +792,22 @@ private int writeMethodParameterDeclaration(DebugContext context, DebugLocalInfo
int p) {
int pos = p;
log(context, " [0x%08x] method parameter declaration", pos);
- int abbrevCode;
+ AbbrevCode abbrevCode;
String paramName = paramInfo.name();
TypeEntry paramType = lookupType(paramInfo.valueType());
int line = paramInfo.line();
if (artificial) {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration1;
+ abbrevCode = AbbrevCode.METHOD_PARAMETER_DECLARATION_1;
} else if (line >= 0) {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration2;
+ abbrevCode = AbbrevCode.METHOD_PARAMETER_DECLARATION_2;
} else {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration3;
+ abbrevCode = AbbrevCode.METHOD_PARAMETER_DECLARATION_3;
}
log(context, " [0x%08x] <%d> Abbrev Number %d", pos, level, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] name %s", pos, paramName);
pos = writeStrSectionOffset(uniqueDebugString(paramName), buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration2) {
+ if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_2) {
log(context, " [0x%08x] file 0x%x", pos, fileIdx);
pos = writeAttrData2((short) fileIdx, buffer, pos);
log(context, " [0x%08x] line 0x%x", pos, line);
@@ -812,12 +816,12 @@ private int writeMethodParameterDeclaration(DebugContext context, DebugLocalInfo
int typeIdx = getTypeIndex(paramType);
log(context, " [0x%08x] type 0x%x (%s)", pos, typeIdx, paramType.getTypeName());
pos = writeInfoSectionOffset(typeIdx, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration1) {
+ if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_1) {
log(context, " [0x%08x] artificial true", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
}
log(context, " [0x%08x] declaration true", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
return pos;
}
@@ -837,20 +841,20 @@ private int writeMethodLocalDeclaration(DebugContext context, DebugLocalInfo par
int p) {
int pos = p;
log(context, " [0x%08x] method local declaration", pos);
- int abbrevCode;
+ AbbrevCode abbrevCode;
String paramName = paramInfo.name();
TypeEntry paramType = lookupType(paramInfo.valueType());
int line = paramInfo.line();
if (line >= 0) {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration1;
+ abbrevCode = AbbrevCode.METHOD_LOCAL_DECLARATION_1;
} else {
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration2;
+ abbrevCode = AbbrevCode.METHOD_LOCAL_DECLARATION_2;
}
log(context, " [0x%08x] <%d> Abbrev Number %d", pos, level, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] name %s", pos, paramName);
pos = writeStrSectionOffset(uniqueDebugString(paramName), buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration1) {
+ if (abbrevCode == AbbrevCode.METHOD_LOCAL_DECLARATION_1) {
log(context, " [0x%08x] file 0x%x", pos, fileIdx);
pos = writeAttrData2((short) fileIdx, buffer, pos);
log(context, " [0x%08x] line 0x%x", pos, line);
@@ -860,7 +864,7 @@ private int writeMethodLocalDeclaration(DebugContext context, DebugLocalInfo par
log(context, " [0x%08x] type 0x%x (%s)", pos, typeIdx, paramType.getTypeName());
pos = writeInfoSectionOffset(typeIdx, buffer, pos);
log(context, " [0x%08x] declaration true", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
return pos;
}
@@ -869,7 +873,7 @@ private int writeInterfaceLayout(DebugContext context, InterfaceClassEntry inter
int layoutOffset = pos;
setLayoutIndex(interfaceClassEntry, layoutOffset);
log(context, " [0x%08x] interface layout", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_interface_layout;
+ AbbrevCode abbrevCode = AbbrevCode.INTERFACE_LAYOUT;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String name = interfaceClassEntry.getTypeName();
@@ -893,7 +897,7 @@ private int writeInterfaceLayout(DebugContext context, InterfaceClassEntry inter
*/
setIndirectLayoutIndex(interfaceClassEntry, pos);
log(context, " [0x%08x] indirect class layout", pos);
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_layout;
+ abbrevCode = AbbrevCode.INDIRECT_LAYOUT;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String indirectName = uniqueDebugString(DwarfDebugInfo.INDIRECT_PREFIX + interfaceClassEntry.getTypeName());
@@ -927,7 +931,7 @@ private int writeInterfaceImplementors(DebugContext context, InterfaceClassEntry
private int writeInterfaceImplementor(DebugContext context, ClassEntry classEntry, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] interface implementor", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_interface_implementor;
+ AbbrevCode abbrevCode = AbbrevCode.INTERFACE_IMPLEMENTOR;
log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String name = uniqueDebugString("_" + classEntry.getTypeName());
@@ -993,7 +997,7 @@ private int writeForeignLayout(DebugContext context, ForeignTypeEntry foreignTyp
private int writeForeignStructLayout(DebugContext context, ForeignTypeEntry foreignTypeEntry, int size, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] foreign struct type for %s", pos, foreignTypeEntry.getTypeName());
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_foreign_struct;
+ AbbrevCode abbrevCode = AbbrevCode.FOREIGN_STRUCT;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String typedefName = foreignTypeEntry.getTypedefName();
@@ -1028,7 +1032,7 @@ private int writeForeignWordLayout(DebugContext context, ForeignTypeEntry foreig
int pos = p;
log(context, " [0x%08x] foreign primitive word type for %s", pos, foreignTypeEntry.getTypeName());
/* Record the location of this type entry. */
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_primitive_type;
+ AbbrevCode abbrevCode = AbbrevCode.PRIMITIVE_TYPE;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
assert size >= 0;
@@ -1039,9 +1043,9 @@ private int writeForeignWordLayout(DebugContext context, ForeignTypeEntry foreig
log(context, " [0x%08x] bitCount %d", pos, bitCount);
pos = writeAttrData1(bitCount, buffer, pos);
// treat the layout as a signed or unsigned word of the relevant size
- byte encoding = (isSigned ? DwarfDebugInfo.DW_ATE_signed : DwarfDebugInfo.DW_ATE_unsigned);
- log(context, " [0x%08x] encoding 0x%x", pos, encoding);
- pos = writeAttrData1(encoding, buffer, pos);
+ DwarfEncoding encoding = (isSigned ? DwarfEncoding.DW_ATE_signed : DwarfEncoding.DW_ATE_unsigned);
+ log(context, " [0x%08x] encoding 0x%x", pos, encoding.value());
+ pos = writeAttrEncoding(encoding, buffer, pos);
String name = uniqueDebugString(integralTypeName(byteSize, isSigned));
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
return writeStrSectionOffset(name, buffer, pos);
@@ -1051,7 +1055,7 @@ private int writeForeignIntegerLayout(DebugContext context, ForeignTypeEntry for
int pos = p;
log(context, " [0x%08x] foreign primitive integral type for %s", pos, foreignTypeEntry.getTypeName());
/* Record the location of this type entry. */
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_primitive_type;
+ AbbrevCode abbrevCode = AbbrevCode.PRIMITIVE_TYPE;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
assert size > 0;
@@ -1062,9 +1066,9 @@ private int writeForeignIntegerLayout(DebugContext context, ForeignTypeEntry for
log(context, " [0x%08x] bitCount %d", pos, bitCount);
pos = writeAttrData1(bitCount, buffer, pos);
// treat the layout as a signed or unsigned word of the relevant size
- byte encoding = (isSigned ? DwarfDebugInfo.DW_ATE_signed : DwarfDebugInfo.DW_ATE_unsigned);
- log(context, " [0x%08x] encoding 0x%x", pos, encoding);
- pos = writeAttrData1(encoding, buffer, pos);
+ DwarfEncoding encoding = (isSigned ? DwarfEncoding.DW_ATE_signed : DwarfEncoding.DW_ATE_unsigned);
+ log(context, " [0x%08x] encoding 0x%x", pos, encoding.value());
+ pos = writeAttrEncoding(encoding, buffer, pos);
String name = uniqueDebugString(integralTypeName(byteSize, isSigned));
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
return writeStrSectionOffset(name, buffer, pos);
@@ -1074,7 +1078,7 @@ private int writeForeignFloatLayout(DebugContext context, ForeignTypeEntry forei
int pos = p;
log(context, " [0x%08x] foreign primitive float type for %s", pos, foreignTypeEntry.getTypeName());
/* Record the location of this type entry. */
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_primitive_type;
+ AbbrevCode abbrevCode = AbbrevCode.PRIMITIVE_TYPE;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
assert size > 0;
@@ -1085,9 +1089,9 @@ private int writeForeignFloatLayout(DebugContext context, ForeignTypeEntry forei
log(context, " [0x%08x] bitCount %d", pos, bitCount);
pos = writeAttrData1(bitCount, buffer, pos);
// treat the layout as a float of the relevant size
- byte encoding = DwarfDebugInfo.DW_ATE_float;
- log(context, " [0x%08x] encoding 0x%x", pos, encoding);
- pos = writeAttrData1(encoding, buffer, pos);
+ DwarfEncoding encoding = DwarfEncoding.DW_ATE_float;
+ log(context, " [0x%08x] encoding 0x%x", pos, encoding.value());
+ pos = writeAttrEncoding(encoding, buffer, pos);
String name = uniqueDebugString(size == 4 ? "float" : (size == 8 ? "double" : "long double"));
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
return writeStrSectionOffset(name, buffer, pos);
@@ -1112,7 +1116,7 @@ private int writeClassType(DebugContext context, ClassEntry classEntry, byte[] b
int typeIdx = pos;
setTypeIndex(classEntry, typeIdx);
log(context, " [0x%08x] class pointer type", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_class_pointer;
+ AbbrevCode abbrevCode = AbbrevCode.CLASS_POINTER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int pointerSize = dwarfSections.pointerSize();
@@ -1126,7 +1130,7 @@ private int writeClassType(DebugContext context, ClassEntry classEntry, byte[] b
/* Define an indirect pointer type referring to the indirect layout. */
setIndirectTypeIndex(classEntry, pos);
log(context, " [0x%08x] class indirect pointer type", pos);
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_pointer;
+ abbrevCode = AbbrevCode.INDIRECT_POINTER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int oopReferenceSize = dwarfSections.oopReferenceSize();
@@ -1149,7 +1153,7 @@ private int writeInterfaceType(DebugContext context, InterfaceClassEntry interfa
int typeIdx = pos;
setTypeIndex(interfaceClassEntry, typeIdx);
log(context, " [0x%08x] interface pointer type", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_interface_pointer;
+ AbbrevCode abbrevCode = AbbrevCode.INTERFACE_POINTER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int pointerSize = dwarfSections.pointerSize();
@@ -1163,7 +1167,7 @@ private int writeInterfaceType(DebugContext context, InterfaceClassEntry interfa
/* Define an indirect pointer type referring to the indirect layout. */
setIndirectTypeIndex(interfaceClassEntry, pos);
log(context, " [0x%08x] interface indirect pointer type", pos);
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_pointer;
+ abbrevCode = AbbrevCode.INDIRECT_POINTER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int byteSize = dwarfSections.oopReferenceSize();
@@ -1190,7 +1194,7 @@ private int writeForeignType(DebugContext context, ForeignTypeEntry foreignTypeE
/* Define a pointer type referring to the base type */
int refTypeIdx = pos;
log(context, " [0x%08x] foreign pointer type", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_foreign_pointer;
+ AbbrevCode abbrevCode = AbbrevCode.FOREIGN_POINTER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int pointerSize = dwarfSections.pointerSize();
@@ -1204,7 +1208,7 @@ private int writeForeignType(DebugContext context, ForeignTypeEntry foreignTypeE
/* Define a typedef for the layout type using the Java name. */
int typedefIdx = pos;
log(context, " [0x%08x] foreign typedef", pos);
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_foreign_typedef;
+ abbrevCode = AbbrevCode.FOREIGN_TYPEDEF;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String name = uniqueDebugString(foreignTypeEntry.getTypeName());
@@ -1242,7 +1246,7 @@ private int writeClassStaticFieldLocation(DebugContext context, ClassEntry class
String fieldName = fieldEntry.fieldName();
int fieldDefinitionOffset = getFieldDeclarationIndex(classEntry, fieldName);
log(context, " [0x%08x] static field location %s.%s", pos, classEntry.getTypeName(), fieldName);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_static_field_location;
+ AbbrevCode abbrevCode = AbbrevCode.STATIC_FIELD_LOCATION;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
// n.b. field definition offset gets written as a Ref4, relative to CU start
@@ -1271,14 +1275,14 @@ private int writeArray(DebugContext context, ArrayTypeEntry arrayTypeEntry, byte
int lengthPos = pos;
log(context, " [0x%08x] Array class unit", pos);
pos = writeCUHeader(buffer, pos);
- assert pos == lengthPos + DW_DIE_HEADER_SIZE;
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_class_unit1;
+ assert pos == lengthPos + DIE_HEADER_SIZE;
+ AbbrevCode abbrevCode = AbbrevCode.CLASS_UNIT_1;
log(context, " [0x%08x] <0> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] language %s", pos, "DW_LANG_Java");
- pos = writeAttrData1(DwarfDebugInfo.LANG_ENCODING, buffer, pos);
+ pos = writeAttrLanguage(DwarfDebugInfo.LANG_ENCODING, buffer, pos);
log(context, " [0x%08x] use_UTF8", pos);
- pos = writeFlag((byte) 1, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
String name = uniqueDebugString("JAVA");
log(context, " [0x%08x] name 0x%x (%s)", pos, debugStringIndex(name), name);
pos = writeStrSectionOffset(name, buffer, pos);
@@ -1325,7 +1329,7 @@ private int writeArray(DebugContext context, ArrayTypeEntry arrayTypeEntry, byte
private int writeArrayLayout(DebugContext context, ArrayTypeEntry arrayTypeEntry, TypeEntry elementType, int size, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] array layout", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_array_layout;
+ AbbrevCode abbrevCode = AbbrevCode.ARRAY_LAYOUT;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String name = arrayTypeEntry.getTypeName();
@@ -1366,7 +1370,7 @@ private int writeIndirectArrayLayout(DebugContext context, ArrayTypeEntry arrayT
* indirect pointer
*/
log(context, " [0x%08x] indirect class layout", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_layout;
+ AbbrevCode abbrevCode = AbbrevCode.INDIRECT_LAYOUT;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String name = arrayTypeEntry.getTypeName();
@@ -1389,7 +1393,7 @@ private int writeIndirectArrayLayout(DebugContext context, ArrayTypeEntry arrayT
private int writeArrayDataType(DebugContext context, TypeEntry elementType, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] array element data type", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_array_data_type1;
+ AbbrevCode abbrevCode = AbbrevCode.ARRAY_DATA_TYPE_1;
log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
// Java arrays don't have a fixed byte_size
@@ -1404,7 +1408,7 @@ private int writeArrayDataType(DebugContext context, TypeEntry elementType, byte
private int writeEmbeddedArrayDataType(DebugContext context, ForeignTypeEntry foreignValueType, int valueSize, int arraySize, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] embedded array element data type", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_array_data_type2;
+ AbbrevCode abbrevCode = AbbrevCode.ARRAY_DATA_TYPE_2;
log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
// Foreign arrays have a fixed byte_size
@@ -1434,7 +1438,7 @@ private int writeEmbeddedArrayDataType(DebugContext context, ForeignTypeEntry fo
pos = writeInfoSectionOffset(elementTypeIdx, buffer, pos);
// write subrange child DIE
log(context, " [0x%08x] embedded array element range", pos);
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_array_subrange;
+ abbrevCode = AbbrevCode.ARRAY_SUBRANGE;
log(context, " [0x%08x] <3> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] count 0x%x", pos, arraySize);
@@ -1448,7 +1452,7 @@ private int writeEmbeddedArrayDataType(DebugContext context, ForeignTypeEntry fo
private int writeArrayElementField(DebugContext context, int offset, int arrayDataTypeIdx, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] array element data field", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_header_field;
+ AbbrevCode abbrevCode = AbbrevCode.HEADER_FIELD;
log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
String fieldName = uniqueDebugString("data");
@@ -1484,7 +1488,7 @@ private int writeArrayTypes(DebugContext context, ArrayTypeEntry arrayTypeEntry,
setTypeIndex(arrayTypeEntry, pos);
/* Define a pointer type referring to the underlying layout. */
log(context, " [0x%08x] array pointer type", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_array_pointer;
+ AbbrevCode abbrevCode = AbbrevCode.ARRAY_POINTER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int pointerSize = dwarfSections.pointerSize();
@@ -1497,7 +1501,7 @@ private int writeArrayTypes(DebugContext context, ArrayTypeEntry arrayTypeEntry,
setIndirectTypeIndex(arrayTypeEntry, pos);
/* Define an indirect pointer type referring to the underlying indirect layout. */
log(context, " [0x%08x] array indirect pointer type", pos);
- abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_indirect_pointer;
+ abbrevCode = AbbrevCode.INDIRECT_POINTER;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
int byteSize = dwarfSections.oopReferenceSize();
@@ -1524,7 +1528,7 @@ private int writeMethodLocation(DebugContext context, ClassEntry classEntry, Com
int pos = p;
Range primary = compiledEntry.getPrimary();
log(context, " [0x%08x] method location", pos);
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_location;
+ AbbrevCode abbrevCode = AbbrevCode.METHOD_LOCATION;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] lo_pc 0x%08x", pos, primary.getLo());
@@ -1535,7 +1539,7 @@ private int writeMethodLocation(DebugContext context, ClassEntry classEntry, Com
* Should pass true only if method is non-private.
*/
log(context, " [0x%08x] external true", pos);
- pos = writeFlag(DwarfDebugInfo.DW_FLAG_true, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
String methodKey = primary.getSymbolName();
int methodSpecOffset = getMethodDeclarationIndex(primary.getMethodEntry());
log(context, " [0x%08x] specification 0x%x (%s)", pos, methodSpecOffset, methodKey);
@@ -1625,18 +1629,18 @@ private int writeMethodLocalLocation(DebugContext context, Range range, DebugLoc
}
}
}
- int abbrevCode;
+ AbbrevCode abbrevCode;
if (localValues.isEmpty()) {
- abbrevCode = (isParam ? DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location1 : DwarfDebugInfo.DW_ABBREV_CODE_method_local_location1);
+ abbrevCode = (isParam ? AbbrevCode.METHOD_PARAMETER_LOCATION_1 : AbbrevCode.METHOD_LOCAL_LOCATION_1);
} else {
- abbrevCode = (isParam ? DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location2 : DwarfDebugInfo.DW_ABBREV_CODE_method_local_location2);
+ abbrevCode = (isParam ? AbbrevCode.METHOD_PARAMETER_LOCATION_2 : AbbrevCode.METHOD_LOCAL_LOCATION_2);
}
log(context, " [0x%08x] <%d> Abbrev Number %d", pos, depth, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] specification 0x%x", pos, refAddr);
pos = writeAttrRef4(refAddr, buffer, pos);
- if (abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_local_location2 ||
- abbrevCode == DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location2) {
+ if (abbrevCode == AbbrevCode.METHOD_LOCAL_LOCATION_2 ||
+ abbrevCode == AbbrevCode.METHOD_PARAMETER_LOCATION_2) {
int locRefAddr = getRangeLocalIndex(range, localInfo);
log(context, " [0x%08x] loc list 0x%x", pos, locRefAddr);
pos = writeLocSectionOffset(locRefAddr, buffer, pos);
@@ -1715,10 +1719,9 @@ private int writeInlineSubroutine(DebugContext context, ClassEntry classEntry, S
fileIndex = classEntry.getFileIdx();
}
}
- final int code;
- code = DwarfDebugInfo.DW_ABBREV_CODE_inlined_subroutine_with_children;
- log(context, " [0x%08x] <%d> Abbrev Number %d", pos, depth, code);
- pos = writeAbbrevCode(code, buffer, pos);
+ final AbbrevCode abbrevCode = AbbrevCode.INLINED_SUBROUTINE_WITH_CHILDREN;
+ log(context, " [0x%08x] <%d> Abbrev Number %d", pos, depth, abbrevCode);
+ pos = writeAbbrevCode(abbrevCode, buffer, pos);
log(context, " [0x%08x] abstract_origin 0x%x", pos, abstractOriginIndex);
pos = writeAttrRef4(abstractOriginIndex, buffer, pos);
log(context, " [0x%08x] lo_pc 0x%08x", pos, caller.getLo());
@@ -1778,16 +1781,16 @@ private void addInlinedMethods(DebugContext context, CompiledMethodEntry compile
private int writeAbstractInlineMethod(DebugContext context, ClassEntry classEntry, MethodEntry method, byte[] buffer, int p) {
int pos = p;
log(context, " [0x%08x] abstract inline method %s::%s", pos, classEntry.getTypeName(), method.methodName());
- int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_abstract_inline_method;
+ AbbrevCode abbrevCode = AbbrevCode.ABSTRACT_INLINE_METHOD;
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);
pos = writeAbbrevCode(abbrevCode, buffer, pos);
- log(context, " [0x%08x] inline 0x%x", pos, DwarfDebugInfo.DW_INL_inlined);
- pos = writeAttrData1(DwarfDebugInfo.DW_INL_inlined, buffer, pos);
+ log(context, " [0x%08x] inline 0x%x", pos, DwarfInline.DW_INL_inlined.value());
+ pos = writeAttrInline(DwarfInline.DW_INL_inlined, buffer, pos);
/*
* Should pass true only if method is non-private.
*/
log(context, " [0x%08x] external true", pos);
- pos = writeFlag(DwarfDebugInfo.DW_FLAG_true, buffer, pos);
+ pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos);
int methodSpecOffset = getMethodDeclarationIndex(method);
log(context, " [0x%08x] specification 0x%x", pos, methodSpecOffset);
pos = writeInfoSectionOffset(methodSpecOffset, buffer, pos);
@@ -1826,7 +1829,7 @@ private int writeCUHeader(byte[] buffer, int p) {
/* CU length. */
pos = writeInt(0, buffer, pos);
/* DWARF version. */
- pos = writeShort(DwarfDebugInfo.DW_VERSION_4, buffer, pos);
+ pos = writeDwarfVersion(DwarfVersion.DW_VERSION_4, buffer, pos);
/* Abbrev offset. */
pos = writeAbbrevSectionOffset(0, buffer, pos);
/* Address size. */
@@ -1839,19 +1842,32 @@ public int writeAttrString(String value, byte[] buffer, int p) {
return writeUTF8StringBytes(value, buffer, pos);
}
+ public int writeAttrLanguage(DwarfLanguage language, byte[] buffer, int p) {
+ int pos = p;
+ return writeByte(language.value(), buffer, pos);
+ }
+
+ public int writeAttrEncoding(DwarfEncoding encoding, byte[] buffer, int p) {
+ return writeByte(encoding.value(), buffer, p);
+ }
+
+ public int writeAttrInline(DwarfInline inline, byte[] buffer, int p) {
+ return writeByte(inline.value(), buffer, p);
+ }
+
public int writeAttrAccessibility(int modifiers, byte[] buffer, int p) {
- byte access;
+ DwarfAccess access;
if (Modifier.isPublic(modifiers)) {
- access = DwarfDebugInfo.DW_ACCESS_public;
+ access = DwarfAccess.DW_ACCESS_public;
} else if (Modifier.isProtected(modifiers)) {
- access = DwarfDebugInfo.DW_ACCESS_protected;
+ access = DwarfAccess.DW_ACCESS_protected;
} else if (Modifier.isPrivate(modifiers)) {
- access = DwarfDebugInfo.DW_ACCESS_private;
+ access = DwarfAccess.DW_ACCESS_private;
} else {
/* Actually package private -- make it public for now. */
- access = DwarfDebugInfo.DW_ACCESS_public;
+ access = DwarfAccess.DW_ACCESS_public;
}
- return writeAttrData1(access, buffer, p);
+ return writeByte(access.value(), buffer, p);
}
public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, int p) {
@@ -1954,40 +1970,39 @@ public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, in
pos = writeULEB(exprSize, buffer, pos);
int exprStart = pos;
if (!useHeapBase) {
- pos = writeByte(DwarfDebugInfo.DW_OP_push_object_address, buffer, pos);
- pos = writeByte((byte) (DwarfDebugInfo.DW_OP_lit0 + mask), buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_not, buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_and, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_push_object_address, buffer, pos);
+ pos = writeExprOpcodeLiteral(mask, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_not, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_and, buffer, pos);
} else {
- pos = writeByte(DwarfDebugInfo.DW_OP_push_object_address, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_push_object_address, buffer, pos);
/* skip to end if oop is null */
- pos = writeByte(DwarfDebugInfo.DW_OP_dup, buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_lit0, buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_eq, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_dup, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_lit0, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_eq, buffer, pos);
int skipStart = pos + 3; /* offset excludes BR op + 2 operand bytes */
short offsetToEnd = (short) (exprSize - (skipStart - exprStart));
- pos = writeByte(DwarfDebugInfo.DW_OP_bra, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_bra, buffer, pos);
pos = writeShort(offsetToEnd, buffer, pos);
/* insert mask or shifts as necessary */
if (mask != 0) {
- pos = writeByte((byte) (DwarfDebugInfo.DW_OP_lit0 + mask), buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_not, buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_and, buffer, pos);
+ pos = writeExprOpcodeLiteral(mask, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_not, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_and, buffer, pos);
} else {
if (rightShift != 0) {
- pos = writeByte((byte) (DwarfDebugInfo.DW_OP_lit0 + rightShift), buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_shr, buffer, pos);
+ pos = writeExprOpcodeLiteral(rightShift, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_shr, buffer, pos);
}
if (leftShift != 0) {
- pos = writeByte((byte) (DwarfDebugInfo.DW_OP_lit0 + leftShift), buffer, pos);
- pos = writeByte(DwarfDebugInfo.DW_OP_shl, buffer, pos);
+ pos = writeExprOpcodeLiteral(leftShift, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_shl, buffer, pos);
}
}
/* add the resulting offset to the heapbase register */
- byte regOp = (byte) (DwarfDebugInfo.DW_OP_breg0 + dwarfSections.getHeapbaseRegister());
- pos = writeByte(regOp, buffer, pos);
+ pos = writeExprOpcodeBReg(dwarfSections.getHeapbaseRegister(), buffer, pos);
pos = writeSLEB(0, buffer, pos); /* 1 byte. */
- pos = writeByte(DwarfDebugInfo.DW_OP_plus, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_plus, buffer, pos);
assert pos == skipStart + offsetToEnd;
/* make sure we added up correctly */
@@ -1995,24 +2010,4 @@ public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, in
}
return pos;
}
-
- /**
- * The debug_info section depends on loc section.
- */
- protected static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_LOC_SECTION_NAME;
-
- @Override
- public String targetSectionName() {
- return TARGET_SECTION_NAME;
- }
-
- private final LayoutDecision.Kind[] targetSectionKinds = {
- LayoutDecision.Kind.CONTENT,
- LayoutDecision.Kind.SIZE
- };
-
- @Override
- public LayoutDecision.Kind[] targetSectionKinds() {
- return targetSectionKinds;
- }
}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLineSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLineSectionImpl.java
index e5b552782351..9c8a02b48ccb 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLineSectionImpl.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLineSectionImpl.java
@@ -30,6 +30,9 @@
import java.util.Map;
import com.oracle.objectfile.debugentry.ClassEntry;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfVersion;
import org.graalvm.compiler.debug.DebugContext;
import com.oracle.objectfile.LayoutDecision;
@@ -44,108 +47,31 @@
* Section generator for debug_line section.
*/
public class DwarfLineSectionImpl extends DwarfSectionImpl {
+ /**
+ * 0 is used to indicate an invalid opcode.
+ */
+ private static final int LN_undefined = 0;
+
/**
* Line header section always contains fixed number of bytes.
*/
- private static final int DW_LN_HEADER_SIZE = 28;
+ private static final int LN_HEADER_SIZE = 28;
/**
* Current generator follows C++ with line base -5.
*/
- private static final int DW_LN_LINE_BASE = -5;
+ private static final int LN_LINE_BASE = -5;
/**
* Current generator follows C++ with line range 14 giving full range -5 to 8.
*/
- private static final int DW_LN_LINE_RANGE = 14;
+ private static final int LN_LINE_RANGE = 14;
/**
* Current generator uses opcode base of 13 which must equal DW_LNS_set_isa + 1.
*/
- private static final int DW_LN_OPCODE_BASE = 13;
-
- /*
- * Standard opcodes defined by Dwarf 2
- */
- /*
- * 0 can be returned to indicate an invalid opcode.
- */
- private static final byte DW_LNS_undefined = 0;
- /*
- * 0 can be inserted as a prefix for extended opcodes.
- */
- private static final byte DW_LNS_extended_prefix = 0;
- /*
- * Append current state as matrix row 0 args.
- */
- private static final byte DW_LNS_copy = 1;
- /*
- * Increment address 1 uleb arg.
- */
- private static final byte DW_LNS_advance_pc = 2;
- /*
- * Increment line 1 sleb arg.
- */
- private static final byte DW_LNS_advance_line = 3;
- /*
- * Set file 1 uleb arg.
- */
- private static final byte DW_LNS_set_file = 4;
- /*
- * sSet column 1 uleb arg.
- */
- private static final byte DW_LNS_set_column = 5;
- /*
- * Flip is_stmt 0 args.
- */
- private static final byte DW_LNS_negate_stmt = 6;
- /*
- * Set end sequence and copy row 0 args.
- */
- private static final byte DW_LNS_set_basic_block = 7;
- /*
- * Increment address as per opcode 255 0 args.
- */
- private static final byte DW_LNS_const_add_pc = 8;
- /*
- * Increment address 1 ushort arg.
- */
- private static final byte DW_LNS_fixed_advance_pc = 9;
-
- /*
- * Increment address 1 ushort arg.
- */
- @SuppressWarnings("unused") private static final byte DW_LNS_set_prologue_end = 10;
-
- /*
- * Increment address 1 ushort arg.
- */
- @SuppressWarnings("unused") private static final byte DW_LNS_set_epilogue_begin = 11;
-
- /*
- * Extended opcodes defined by DWARF 2.
- */
- /*
- * There is no extended opcode 0.
- */
- @SuppressWarnings("unused") private static final byte DW_LNE_undefined = 0;
- /*
- * End sequence of addresses.
- */
- private static final byte DW_LNE_end_sequence = 1;
- /*
- * Set address as explicit long argument.
- */
- private static final byte DW_LNE_set_address = 2;
- /*
- * Set file as explicit string argument.
- */
- private static final byte DW_LNE_define_file = 3;
+ private static final int LN_OPCODE_BASE = 13;
DwarfLineSectionImpl(DwarfDebugInfo dwarfSections) {
- super(dwarfSections);
- }
-
- @Override
- public String getSectionName() {
- return DwarfDebugInfo.DW_LINE_SECTION_NAME;
+ // line section depends on string section
+ super(dwarfSections, DwarfSectionName.DW_LINE_SECTION, DwarfSectionName.DW_STR_SECTION);
}
@Override
@@ -203,7 +129,7 @@ private static int headerSize() {
*
*/
- return DW_LN_HEADER_SIZE;
+ return LN_HEADER_SIZE;
}
private int computeDirTableSize(ClassEntry classEntry) {
@@ -318,7 +244,7 @@ private int writeHeader(ClassEntry classEntry, byte[] buffer, int p) {
/*
* 2 ubyte version is always 2.
*/
- pos = writeShort(DwarfDebugInfo.DW_VERSION_4, buffer, pos);
+ pos = writeDwarfVersion(DwarfVersion.DW_VERSION_4, buffer, pos);
/*
* 4 ubyte prologue length includes rest of header and dir + file table section.
*/
@@ -339,15 +265,15 @@ private int writeHeader(ClassEntry classEntry, byte[] buffer, int p) {
/*
* 1 byte line base is always -5.
*/
- pos = writeByte((byte) DW_LN_LINE_BASE, buffer, pos);
+ pos = writeByte((byte) LN_LINE_BASE, buffer, pos);
/*
* 1 ubyte line range is always 14 giving range -5 to 8.
*/
- pos = writeByte((byte) DW_LN_LINE_RANGE, buffer, pos);
+ pos = writeByte((byte) LN_LINE_RANGE, buffer, pos);
/*
* 1 ubyte opcode base is always 13.
*/
- pos = writeByte((byte) DW_LN_OPCODE_BASE, buffer, pos);
+ pos = writeByte((byte) LN_OPCODE_BASE, buffer, pos);
/*
* specify opcode arg sizes for the standard opcodes.
*/
@@ -548,7 +474,7 @@ private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEn
* Check if we can advance line and/or address in one byte with a special opcode.
*/
byte opcode = isSpecialOpcode(addressDelta, lineDelta);
- if (opcode != DW_LNS_undefined) {
+ if (opcode != LN_undefined) {
/*
* Ignore pointless write when addressDelta == lineDelta == 0.
*/
@@ -567,7 +493,7 @@ private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEn
* line delta.
*/
opcode = isSpecialOpcode(remainder, lineDelta);
- if (opcode != DW_LNS_undefined) {
+ if (opcode != LN_undefined) {
/*
* Address remainder and line now fit.
*/
@@ -578,7 +504,7 @@ private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEn
* remainder.
*/
opcode = isSpecialOpcode(remainder, 0);
- assert opcode != DW_LNS_undefined;
+ assert opcode != LN_undefined;
pos = writeAdvanceLineOp(context, lineDelta, buffer, pos);
pos = writeSpecialOpcode(context, opcode, buffer, pos);
}
@@ -652,111 +578,111 @@ private static SubRange prologueLeafRange(CompiledMethodEntry compiledEntry) {
}
private int writeCopyOp(DebugContext context, byte[] buffer, int p) {
- byte opcode = DW_LNS_copy;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_copy;
int pos = p;
debugCopyCount++;
verboseLog(context, " [0x%08x] Copy %d", pos, debugCopyCount);
- return writeByte(opcode, buffer, pos);
+ return writeLineOpcode(opcode, buffer, pos);
}
private int writeAdvancePCOp(DebugContext context, long uleb, byte[] buffer, int p) {
- byte opcode = DW_LNS_advance_pc;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_advance_pc;
int pos = p;
debugAddress += uleb;
verboseLog(context, " [0x%08x] Advance PC by %d to 0x%08x", pos, uleb, debugAddress);
- pos = writeByte(opcode, buffer, pos);
+ pos = writeLineOpcode(opcode, buffer, pos);
return writeULEB(uleb, buffer, pos);
}
private int writeAdvanceLineOp(DebugContext context, long sleb, byte[] buffer, int p) {
- byte opcode = DW_LNS_advance_line;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_advance_line;
int pos = p;
debugLine += sleb;
verboseLog(context, " [0x%08x] Advance Line by %d to %d", pos, sleb, debugLine);
- pos = writeByte(opcode, buffer, pos);
+ pos = writeLineOpcode(opcode, buffer, pos);
return writeSLEB(sleb, buffer, pos);
}
private int writeSetFileOp(DebugContext context, String file, long uleb, byte[] buffer, int p) {
- byte opcode = DW_LNS_set_file;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_set_file;
int pos = p;
verboseLog(context, " [0x%08x] Set File Name to entry %d in the File Name Table (%s)", pos, uleb, file);
- pos = writeByte(opcode, buffer, pos);
+ pos = writeLineOpcode(opcode, buffer, pos);
return writeULEB(uleb, buffer, pos);
}
@SuppressWarnings("unused")
private int writeSetColumnOp(DebugContext context, long uleb, byte[] buffer, int p) {
- byte opcode = DW_LNS_set_column;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_set_column;
int pos = p;
- pos = writeByte(opcode, buffer, pos);
+ pos = writeLineOpcode(opcode, buffer, pos);
return writeULEB(uleb, buffer, pos);
}
@SuppressWarnings("unused")
private int writeNegateStmtOp(DebugContext context, byte[] buffer, int p) {
- byte opcode = DW_LNS_negate_stmt;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_negate_stmt;
int pos = p;
- return writeByte(opcode, buffer, pos);
+ return writeLineOpcode(opcode, buffer, pos);
}
private int writeSetBasicBlockOp(DebugContext context, byte[] buffer, int p) {
- byte opcode = DW_LNS_set_basic_block;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_set_basic_block;
int pos = p;
verboseLog(context, " [0x%08x] Set basic block", pos);
- return writeByte(opcode, buffer, pos);
+ return writeLineOpcode(opcode, buffer, pos);
}
private int writeConstAddPCOp(DebugContext context, byte[] buffer, int p) {
- byte opcode = DW_LNS_const_add_pc;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_const_add_pc;
int pos = p;
int advance = opcodeAddress((byte) 255);
debugAddress += advance;
verboseLog(context, " [0x%08x] Advance PC by constant %d to 0x%08x", pos, advance, debugAddress);
- return writeByte(opcode, buffer, pos);
+ return writeLineOpcode(opcode, buffer, pos);
}
private int writeFixedAdvancePCOp(DebugContext context, short arg, byte[] buffer, int p) {
- byte opcode = DW_LNS_fixed_advance_pc;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_fixed_advance_pc;
int pos = p;
debugAddress += arg;
verboseLog(context, " [0x%08x] Fixed advance Address by %d to 0x%08x", pos, arg, debugAddress);
- pos = writeByte(opcode, buffer, pos);
+ pos = writeLineOpcode(opcode, buffer, pos);
return writeShort(arg, buffer, pos);
}
private int writeEndSequenceOp(DebugContext context, byte[] buffer, int p) {
- byte opcode = DW_LNE_end_sequence;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNE_end_sequence;
int pos = p;
verboseLog(context, " [0x%08x] Extended opcode 1: End sequence", pos);
debugAddress = debugTextBase;
debugLine = 1;
debugCopyCount = 0;
- pos = writeByte(DW_LNS_extended_prefix, buffer, pos);
+ pos = writePrefixOpcode(buffer, pos);
/*
* Insert extended insn byte count as ULEB.
*/
pos = writeULEB(1, buffer, pos);
- return writeByte(opcode, buffer, pos);
+ return writeLineOpcode(opcode, buffer, pos);
}
private int writeSetAddressOp(DebugContext context, long arg, byte[] buffer, int p) {
- byte opcode = DW_LNE_set_address;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNE_set_address;
int pos = p;
debugAddress = debugTextBase + (int) arg;
verboseLog(context, " [0x%08x] Extended opcode 2: Set Address to 0x%08x", pos, debugAddress);
- pos = writeByte(DW_LNS_extended_prefix, buffer, pos);
+ pos = writePrefixOpcode(buffer, pos);
/*
* Insert extended insn byte count as ULEB.
*/
pos = writeULEB(9, buffer, pos);
- pos = writeByte(opcode, buffer, pos);
+ pos = writeLineOpcode(opcode, buffer, pos);
return writeRelocatableCodeOffset(arg, buffer, pos);
}
@SuppressWarnings("unused")
private int writeDefineFileOp(DebugContext context, String file, long uleb1, long uleb2, long uleb3, byte[] buffer, int p) {
- byte opcode = DW_LNE_define_file;
+ DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNE_define_file;
int pos = p;
/*
* Calculate bytes needed for opcode + args.
@@ -768,7 +694,7 @@ private int writeDefineFileOp(DebugContext context, String file, long uleb1, lon
insnBytes += writeULEB(uleb2, scratch, 0);
insnBytes += writeULEB(uleb3, scratch, 0);
verboseLog(context, " [0x%08x] Extended opcode 3: Define File %s idx %d ts1 %d ts2 %d", pos, file, uleb1, uleb2, uleb3);
- pos = writeByte(DW_LNS_extended_prefix, buffer, pos);
+ pos = writePrefixOpcode(buffer, pos);
/*
* Insert insn length as uleb.
*/
@@ -776,26 +702,34 @@ private int writeDefineFileOp(DebugContext context, String file, long uleb1, lon
/*
* Insert opcode and args.
*/
- pos = writeByte(opcode, buffer, pos);
+ pos = writeLineOpcode(opcode, buffer, pos);
pos = writeUTF8StringBytes(file, buffer, pos);
pos = writeULEB(uleb1, buffer, pos);
pos = writeULEB(uleb2, buffer, pos);
return writeULEB(uleb3, buffer, pos);
}
+ private int writePrefixOpcode(byte[] buffer, int p) {
+ return writeLineOpcode(DwarfLineOpcode.DW_LNS_extended_prefix, buffer, p);
+ }
+
+ private int writeLineOpcode(DwarfLineOpcode opcode, byte[] buffer, int p) {
+ return writeByte(opcode.value(), buffer, p);
+ }
+
private static int opcodeId(byte opcode) {
int iopcode = opcode & 0xff;
- return iopcode - DW_LN_OPCODE_BASE;
+ return iopcode - LN_OPCODE_BASE;
}
private static int opcodeAddress(byte opcode) {
int iopcode = opcode & 0xff;
- return (iopcode - DW_LN_OPCODE_BASE) / DW_LN_LINE_RANGE;
+ return (iopcode - LN_OPCODE_BASE) / LN_LINE_RANGE;
}
private static int opcodeLine(byte opcode) {
int iopcode = opcode & 0xff;
- return ((iopcode - DW_LN_OPCODE_BASE) % DW_LN_LINE_RANGE) + DW_LN_LINE_BASE;
+ return ((iopcode - LN_OPCODE_BASE) % LN_LINE_RANGE) + LN_LINE_BASE;
}
private int writeSpecialOpcode(DebugContext context, byte opcode, byte[] buffer, int p) {
@@ -810,21 +744,21 @@ private int writeSpecialOpcode(DebugContext context, byte opcode, byte[] buffer,
return writeByte(opcode, buffer, pos);
}
- private static final int MAX_ADDRESS_ONLY_DELTA = (0xff - DW_LN_OPCODE_BASE) / DW_LN_LINE_RANGE;
+ private static final int MAX_ADDRESS_ONLY_DELTA = (0xff - LN_OPCODE_BASE) / LN_LINE_RANGE;
private static final int MAX_ADDPC_DELTA = MAX_ADDRESS_ONLY_DELTA + (MAX_ADDRESS_ONLY_DELTA - 1);
private static byte isSpecialOpcode(long addressDelta, long lineDelta) {
if (addressDelta < 0) {
- return DW_LNS_undefined;
+ return LN_undefined;
}
- if (lineDelta >= DW_LN_LINE_BASE) {
- long offsetLineDelta = lineDelta - DW_LN_LINE_BASE;
- if (offsetLineDelta < DW_LN_LINE_RANGE) {
+ if (lineDelta >= LN_LINE_BASE) {
+ long offsetLineDelta = lineDelta - LN_LINE_BASE;
+ if (offsetLineDelta < LN_LINE_RANGE) {
/*
* The line delta can be encoded. Check if address is ok.
*/
if (addressDelta <= MAX_ADDRESS_ONLY_DELTA) {
- long opcode = DW_LN_OPCODE_BASE + (addressDelta * DW_LN_LINE_RANGE) + offsetLineDelta;
+ long opcode = LN_OPCODE_BASE + (addressDelta * LN_LINE_RANGE) + offsetLineDelta;
if (opcode <= 255) {
return (byte) opcode;
}
@@ -835,7 +769,7 @@ private static byte isSpecialOpcode(long addressDelta, long lineDelta) {
/*
* Answer no by returning an invalid opcode.
*/
- return DW_LNS_undefined;
+ return LN_undefined;
}
private static int isConstAddPC(long addressDelta) {
@@ -852,24 +786,4 @@ private static int isConstAddPC(long addressDelta) {
private static boolean isFixedAdvancePC(long addressDiff) {
return addressDiff >= 0 && addressDiff < 0xffff;
}
-
- /**
- * The debug_line section depends on debug_str section.
- */
- private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_STR_SECTION_NAME;
-
- @Override
- public String targetSectionName() {
- return TARGET_SECTION_NAME;
- }
-
- private final LayoutDecision.Kind[] targetSectionKinds = {
- LayoutDecision.Kind.CONTENT,
- LayoutDecision.Kind.SIZE,
- };
-
- @Override
- public LayoutDecision.Kind[] targetSectionKinds() {
- return targetSectionKinds;
- }
}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLocSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLocSectionImpl.java
index 10420c1d51be..2aad79b26251 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLocSectionImpl.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfLocSectionImpl.java
@@ -26,8 +26,6 @@
package com.oracle.objectfile.elf.dwarf;
-import static com.oracle.objectfile.elf.dwarf.DwarfDebugInfo.DW_OP_implicit_value;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -38,6 +36,8 @@
import com.oracle.objectfile.debugentry.ClassEntry;
import com.oracle.objectfile.debugentry.range.SubRange;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName;
import org.graalvm.compiler.debug.DebugContext;
import com.oracle.objectfile.BuildDependency;
@@ -72,16 +72,18 @@ public class DwarfLocSectionImpl extends DwarfSectionImpl {
*/
private int dwarfStackRegister;
+ private static final LayoutDecision.Kind[] targetLayoutKinds = {
+ LayoutDecision.Kind.CONTENT,
+ LayoutDecision.Kind.SIZE,
+ /* Add this so we can use the text section base address for debug. */
+ LayoutDecision.Kind.VADDR};
+
public DwarfLocSectionImpl(DwarfDebugInfo dwarfSections) {
- super(dwarfSections);
+ // debug_loc section depends on text section
+ super(dwarfSections, DwarfSectionName.DW_LOC_SECTION, DwarfSectionName.TEXT_SECTION, targetLayoutKinds);
initDwarfRegMap();
}
- @Override
- public String getSectionName() {
- return DwarfDebugInfo.DW_LOC_SECTION_NAME;
- }
-
@Override
public Set getDependencies(Map decisions) {
Set deps = super.getDependencies(decisions);
@@ -243,23 +245,23 @@ private int writeVarLocations(DebugContext context, DebugLocalInfo local, int ba
private int writeRegisterLocation(DebugContext context, int regIndex, byte[] buffer, int p) {
int targetIdx = mapToDwarfReg(regIndex);
+ assert targetIdx >= 0;
int pos = p;
- if (targetIdx < 32) {
+ if (targetIdx < 0x20) {
// can write using DW_OP_reg
short byteCount = 1;
- byte regOp = (byte) (DwarfDebugInfo.DW_OP_reg0 + targetIdx);
+ byte reg = (byte) targetIdx;
pos = writeShort(byteCount, buffer, pos);
- pos = writeByte(regOp, buffer, pos);
- verboseLog(context, " [0x%08x] REGOP count %d op 0x%x", pos, byteCount, regOp);
+ pos = writeExprOpcodeReg(reg, buffer, pos);
+ verboseLog(context, " [0x%08x] REGOP count %d op 0x%x", pos, byteCount, DwarfExpressionOpcode.DW_OP_reg0.value() + reg);
} else {
// have to write using DW_OP_regx + LEB operand
assert targetIdx < 128 : "unexpectedly high reg index!";
short byteCount = 2;
- byte regOp = DwarfDebugInfo.DW_OP_regx;
pos = writeShort(byteCount, buffer, pos);
- pos = writeByte(regOp, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_regx, buffer, pos);
pos = writeULEB(targetIdx, buffer, pos);
- verboseLog(context, " [0x%08x] REGOP count %d op 0x%x reg %d", pos, byteCount, regOp, targetIdx);
+ verboseLog(context, " [0x%08x] REGOP count %d op 0x%x reg %d", pos, byteCount, DwarfExpressionOpcode.DW_OP_regx.value(), targetIdx);
// target idx written as ULEB should fit in one byte
assert pos == p + 4 : "wrote the wrong number of bytes!";
}
@@ -269,32 +271,26 @@ private int writeRegisterLocation(DebugContext context, int regIndex, byte[] buf
private int writeStackLocation(DebugContext context, int offset, byte[] buffer, int p) {
int pos = p;
short byteCount = 0;
- int sp = getDwarfStackRegister();
- byte stackOp;
- if (sp < 32) {
- // fold the base reg index into the op
- stackOp = DwarfDebugInfo.DW_OP_breg0;
- stackOp += (byte) sp;
- } else {
- // pass base reg index as a ULEB operand
- stackOp = DwarfDebugInfo.DW_OP_bregx;
- }
+ byte sp = (byte) getDwarfStackRegister();
int patchPos = pos;
pos = writeShort(byteCount, buffer, pos);
int zeroPos = pos;
- pos = writeByte(stackOp, buffer, pos);
- if (stackOp == DwarfDebugInfo.DW_OP_bregx) {
- // need to pass base reg index as a ULEB operand
+ if (sp < 0x20) {
+ // fold the base reg index into the op
+ pos = writeExprOpcodeBReg(sp, buffer, pos);
+ } else {
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_bregx, buffer, pos);
+ // pass base reg index as a ULEB operand
pos = writeULEB(sp, buffer, pos);
}
pos = writeSLEB(offset, buffer, pos);
// now backpatch the byte count
byteCount = (byte) (pos - zeroPos);
writeShort(byteCount, buffer, patchPos);
- if (stackOp == DwarfDebugInfo.DW_OP_bregx) {
- verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x offset %d", pos, byteCount, stackOp, 0 - offset);
+ if (sp < 0x20) {
+ verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x offset %d", pos, byteCount, (DwarfExpressionOpcode.DW_OP_breg0.value() + sp), 0 - offset);
} else {
- verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x reg %d offset %d", pos, byteCount, stackOp, sp, 0 - offset);
+ verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x reg %d offset %d", pos, byteCount, DwarfExpressionOpcode.DW_OP_bregx.value(), sp, 0 - offset);
}
return pos;
}
@@ -302,13 +298,13 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer,
private int writePrimitiveConstantLocation(DebugContext context, JavaConstant constant, byte[] buffer, int p) {
assert constant instanceof PrimitiveConstant;
int pos = p;
- byte op = DW_OP_implicit_value;
+ DwarfExpressionOpcode op = DwarfExpressionOpcode.DW_OP_implicit_value;
JavaKind kind = constant.getJavaKind();
int dataByteCount = kind.getByteCount();
// total bytes is op + uleb + dataByteCount
int byteCount = 1 + 1 + dataByteCount;
pos = writeShort((short) byteCount, buffer, pos);
- pos = writeByte(op, buffer, pos);
+ pos = writeExprOpcode(op, buffer, pos);
pos = writeULEB(dataByteCount, buffer, pos);
if (dataByteCount == 1) {
if (kind == JavaKind.Boolean) {
@@ -332,12 +328,12 @@ private int writePrimitiveConstantLocation(DebugContext context, JavaConstant co
private int writeNullConstantLocation(DebugContext context, JavaConstant constant, byte[] buffer, int p) {
assert constant.isNull();
int pos = p;
- byte op = DW_OP_implicit_value;
+ DwarfExpressionOpcode op = DwarfExpressionOpcode.DW_OP_implicit_value;
int dataByteCount = 8;
// total bytes is op + uleb + dataByteCount
int byteCount = 1 + 1 + dataByteCount;
pos = writeShort((short) byteCount, buffer, pos);
- pos = writeByte(op, buffer, pos);
+ pos = writeExprOpcode(op, buffer, pos);
pos = writeULEB(dataByteCount, buffer, pos);
pos = writeAttrData8(0, buffer, pos);
verboseLog(context, " [0x%08x] CONSTANT (null) %s", pos, constant.toValueString());
@@ -416,28 +412,6 @@ public static List coalesce(DebugLocalInfo local, List= 0 && offset < 0x20;
+ value = (byte) (value + offset);
+ return writeByte(value, buffer, p);
+ }
+
+ protected int writeExprOpcodeReg(byte reg, byte[] buffer, int p) {
+ byte value = DwarfExpressionOpcode.DW_OP_reg0.value();
+ assert reg >= 0 && reg < 0x20;
+ value += reg;
+ return writeByte(value, buffer, p);
+ }
+
+ protected int writeExprOpcodeBReg(byte reg, byte[] buffer, int p) {
+ byte value = DwarfExpressionOpcode.DW_OP_breg0.value();
+ assert reg >= 0 && reg < 0x20;
+ value += reg;
+ return writeByte(value, buffer, p);
+ }
+
/*
* Common write methods that rely on called methods to handle a null buffer
*/
@@ -421,11 +480,12 @@ protected void patchLength(int lengthPos, byte[] buffer, int pos) {
writeInt(length, buffer, lengthPos);
}
- protected int writeAbbrevCode(long code, byte[] buffer, int pos) {
- return writeSLEB(code, buffer, pos);
+ protected int writeAbbrevCode(AbbrevCode code, byte[] buffer, int pos) {
+ return writeSLEB(code.ordinal(), buffer, pos);
}
- protected int writeTag(long code, byte[] buffer, int pos) {
+ protected int writeTag(DwarfTag dwarfTag, byte[] buffer, int pos) {
+ int code = dwarfTag.value();
if (code == 0) {
return writeByte((byte) 0, buffer, pos);
} else {
@@ -433,8 +493,12 @@ protected int writeTag(long code, byte[] buffer, int pos) {
}
}
- protected int writeFlag(byte flag, byte[] buffer, int pos) {
- return writeByte(flag, buffer, pos);
+ protected int writeDwarfVersion(DwarfVersion dwarfVersion, byte[] buffer, int pos) {
+ return writeShort(dwarfVersion.value(), buffer, pos);
+ }
+
+ protected int writeFlag(DwarfFlag flag, byte[] buffer, int pos) {
+ return writeByte(flag.value(), buffer, pos);
}
protected int writeAttrAddress(long address, byte[] buffer, int pos) {
@@ -459,19 +523,19 @@ protected int writeAttrData1(byte value, byte[] buffer, int pos) {
}
protected int writeInfoSectionOffset(int offset, byte[] buffer, int pos) {
- return writeDwarfSectionOffset(offset, buffer, DwarfDebugInfo.DW_INFO_SECTION_NAME, pos);
+ return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_INFO_SECTION, pos);
}
protected int writeLineSectionOffset(int offset, byte[] buffer, int pos) {
- return writeDwarfSectionOffset(offset, buffer, DwarfDebugInfo.DW_LINE_SECTION_NAME, pos);
+ return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_LINE_SECTION, pos);
}
protected int writeRangesSectionOffset(int offset, byte[] buffer, int pos) {
- return writeDwarfSectionOffset(offset, buffer, DwarfDebugInfo.DW_RANGES_SECTION_NAME, pos);
+ return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_RANGES_SECTION, pos);
}
protected int writeAbbrevSectionOffset(int offset, byte[] buffer, int pos) {
- return writeDwarfSectionOffset(offset, buffer, DwarfDebugInfo.DW_ABBREV_SECTION_NAME, pos);
+ return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_ABBREV_SECTION, pos);
}
protected int writeStrSectionOffset(String value, byte[] buffer, int p) {
@@ -481,18 +545,18 @@ protected int writeStrSectionOffset(String value, byte[] buffer, int p) {
}
private int writeStrSectionOffset(int offset, byte[] buffer, int pos) {
- return writeDwarfSectionOffset(offset, buffer, DwarfDebugInfo.DW_STR_SECTION_NAME, pos);
+ return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_STR_SECTION, pos);
}
protected int writeLocSectionOffset(int offset, byte[] buffer, int pos) {
- return writeDwarfSectionOffset(offset, buffer, DwarfDebugInfo.DW_LOC_SECTION_NAME, pos);
+ return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_LOC_SECTION, pos);
}
- protected int writeDwarfSectionOffset(int offset, byte[] buffer, String sectionName, int pos) {
+ protected int writeDwarfSectionOffset(int offset, byte[] buffer, DwarfSectionName referencedSectionName, int pos) {
// offsets to abbrev section DIEs need a relocation
// the linker uses this to update the offset when info sections are merged
if (buffer != null) {
- return putRelocatableDwarfSectionOffset(offset, buffer, sectionName, pos);
+ return putRelocatableDwarfSectionOffset(offset, buffer, referencedSectionName.value(), pos);
} else {
return pos + 4;
}
@@ -500,7 +564,7 @@ protected int writeDwarfSectionOffset(int offset, byte[] buffer, String sectionN
protected int writeAttrNull(byte[] buffer, int pos) {
// A null attribute is just a zero tag.
- return writeTag(0, buffer, pos);
+ return writeTag(DwarfTag.DW_TAG_null, buffer, pos);
}
/*
@@ -547,7 +611,7 @@ protected int writeHeapLocationLocList(long offset, byte[] buffer, int p) {
// write dummy length
pos = writeShort(len, buffer, pos);
pos = writeHeapLocation(offset, dwarfSections.useHeapBase(), buffer, pos);
- pos = writeByte(DW_OP_stack_value, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_stack_value, buffer, pos);
// backpatch length
len = (short) (pos - (lenPos + 2));
writeShort(len, buffer, lenPos);
@@ -571,17 +635,14 @@ protected int writeHeapLocation(long offset, boolean useHeapBase, byte[] buffer,
private int writeHeapLocationBaseRelative(long offset, byte[] buffer, int p) {
int pos = p;
/* Write a location rebasing the offset relative to the heapbase register. */
- byte regOp = (byte) (DwarfDebugInfo.DW_OP_breg0 + dwarfSections.getHeapbaseRegister());
- /* Write the size and expression into the output buffer. */
- pos = writeByte(regOp, buffer, pos);
+ pos = writeExprOpcodeBReg(dwarfSections.getHeapbaseRegister(), buffer, pos);
return writeSLEB(offset, buffer, pos);
}
private int writeHeapLocationRelocatable(long offset, byte[] buffer, int p) {
int pos = p;
/* Write a relocatable address relative to the heap section start. */
- byte regOp = DwarfDebugInfo.DW_OP_addr;
- pos = writeByte(regOp, buffer, pos);
+ pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_addr, buffer, pos);
return writeRelocatableHeapOffset(offset, buffer, pos);
}
@@ -605,28 +666,24 @@ protected static String formatValue(DebugLocalValueInfo value) {
*
* @return the name of the preceding section.
*/
- public abstract String targetSectionName();
-
- /**
- * Identify the layout properties of the target section which need to have been decided before
- * the contents of this section can be created.
- *
- * @return an array of the relevant decision kinds.
- */
- public abstract LayoutDecision.Kind[] targetSectionKinds();
+ public final String targetName() {
+ return targetSectionName.value();
+ }
/**
* Identify this debug section by name.
*
* @return the name of the debug section.
*/
- public abstract String getSectionName();
+ public final String getSectionName() {
+ return sectionName.value();
+ }
@Override
public int getOrDecideSize(Map alreadyDecided, int sizeHint) {
- if (targetSectionName().startsWith(".debug")) {
- ObjectFile.Element previousElement = this.getElement().getOwner().elementForName(targetSectionName());
+ if (targetName().startsWith(".debug")) {
+ ObjectFile.Element previousElement = this.getElement().getOwner().elementForName(targetName());
DwarfSectionImpl previousSection = (DwarfSectionImpl) previousElement.getImpl();
assert previousSection.contentByteArrayCreated();
}
@@ -652,13 +709,12 @@ public byte[] getOrDecideContent(Map alre
@Override
public Set getDependencies(Map decisions) {
Set deps = super.getDependencies(decisions);
- String targetName = targetSectionName();
+ String targetName = targetName();
ELFObjectFile.ELFSection targetSection = (ELFObjectFile.ELFSection) getElement().getOwner().elementForName(targetName);
LayoutDecision ourContent = decisions.get(getElement()).getDecision(LayoutDecision.Kind.CONTENT);
LayoutDecision ourSize = decisions.get(getElement()).getDecision(LayoutDecision.Kind.SIZE);
- LayoutDecision.Kind[] targetKinds = targetSectionKinds();
- for (LayoutDecision.Kind targetKind : targetKinds) {
+ for (LayoutDecision.Kind targetKind : targetSectionKinds) {
if (targetKind == LayoutDecision.Kind.SIZE) {
/* Make our size depend on the target size so we compute sizes in order. */
LayoutDecision targetDecision = decisions.get(targetSection).getDecision(targetKind);
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfStrSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfStrSectionImpl.java
index 7af9d23e4228..bec592b5a0e3 100644
--- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfStrSectionImpl.java
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfStrSectionImpl.java
@@ -26,8 +26,8 @@
package com.oracle.objectfile.elf.dwarf;
-import com.oracle.objectfile.LayoutDecision;
import com.oracle.objectfile.debugentry.StringEntry;
+import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName;
import org.graalvm.compiler.debug.DebugContext;
/**
@@ -35,12 +35,8 @@
*/
public class DwarfStrSectionImpl extends DwarfSectionImpl {
public DwarfStrSectionImpl(DwarfDebugInfo dwarfSections) {
- super(dwarfSections);
- }
-
- @Override
- public String getSectionName() {
- return DwarfDebugInfo.DW_STR_SECTION_NAME;
+ // debug_str section depends on info section
+ super(dwarfSections, DwarfSectionName.DW_STR_SECTION, DwarfSectionName.DW_INFO_SECTION);
}
@Override
@@ -80,24 +76,4 @@ public void writeContent(DebugContext context) {
}
assert pos == size;
}
-
- /**
- * The debug_str section depends on info section.
- */
- private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_INFO_SECTION_NAME;
-
- @Override
- public String targetSectionName() {
- return TARGET_SECTION_NAME;
- }
-
- private final LayoutDecision.Kind[] targetSectionKinds = {
- LayoutDecision.Kind.CONTENT,
- LayoutDecision.Kind.SIZE,
- };
-
- @Override
- public LayoutDecision.Kind[] targetSectionKinds() {
- return targetSectionKinds;
- }
}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAccess.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAccess.java
new file mode 100644
index 000000000000..4030e41e0d82
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAccess.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * DW_AT_Accessibility attribute values.
+ */
+public enum DwarfAccess {
+ DW_ACCESS_public((byte) 1),
+ DW_ACCESS_protected((byte) 2),
+ DW_ACCESS_private((byte) 3);
+
+ private final byte value;
+
+ DwarfAccess(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttribute.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttribute.java
new file mode 100644
index 000000000000..10c87e6b0715
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttribute.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * All the Dwarf attributes needed to populate DIEs generated by GraalVM.
+ */
+public enum DwarfAttribute {
+ DW_AT_null(0x0),
+ DW_AT_location(0x02),
+ DW_AT_name(0x3),
+ DW_AT_byte_size(0x0b),
+ DW_AT_bit_size(0x0d),
+ DW_AT_stmt_list(0x10),
+ DW_AT_low_pc(0x11),
+ DW_AT_hi_pc(0x12),
+ DW_AT_language(0x13),
+ DW_AT_comp_dir(0x1b),
+ DW_AT_containing_type(0x1d),
+ DW_AT_inline(0x20),
+ DW_AT_abstract_origin(0x31),
+ DW_AT_accessibility(0x32),
+ DW_AT_artificial(0x34),
+ DW_AT_count(0x37),
+ DW_AT_data_member_location(0x38),
+ @SuppressWarnings("unused")
+ DW_AT_decl_column(0x39),
+ DW_AT_decl_file(0x3a),
+ DW_AT_decl_line(0x3b),
+ DW_AT_declaration(0x3c),
+ DW_AT_encoding(0x3e),
+ DW_AT_external(0x3f),
+ @SuppressWarnings("unused")
+ DW_AT_return_addr(0x2a),
+ @SuppressWarnings("unused")
+ DW_AT_frame_base(0x40),
+ DW_AT_specification(0x47),
+ DW_AT_type(0x49),
+ DW_AT_data_location(0x50),
+ DW_AT_use_UTF8(0x53),
+ DW_AT_ranges(0x55),
+ DW_AT_call_file(0x58),
+ DW_AT_call_line(0x59),
+ DW_AT_object_pointer(0x64),
+ DW_AT_linkage_name(0x6e);
+
+ private final int value;
+
+ DwarfAttribute(int v) {
+ value = v;
+ }
+
+ public int value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfEncoding.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfEncoding.java
new file mode 100644
index 000000000000..c5cb704e0022
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfEncoding.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * DW_AT_encoding attribute values.
+ */
+public enum DwarfEncoding {
+ @SuppressWarnings("unused")
+ DW_ATE_address((byte) 0x1),
+ DW_ATE_boolean((byte) 0x2),
+ DW_ATE_float((byte) 0x4),
+ DW_ATE_signed((byte) 0x5),
+ DW_ATE_signed_char((byte) 0x6),
+ DW_ATE_unsigned((byte) 0x7),
+ @SuppressWarnings("unused")
+ DW_ATE_unsigned_char((byte) 0x8);
+
+ private final byte value;
+
+ DwarfEncoding(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcode.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcode.java
new file mode 100644
index 000000000000..c55014c908cb
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcode.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * Values used to build DWARF expressions and locations.
+ */
+public enum DwarfExpressionOpcode {
+ DW_OP_addr((byte) 0x03),
+ @SuppressWarnings("unused")
+ DW_OP_deref((byte) 0x06),
+ DW_OP_dup((byte) 0x12),
+ DW_OP_and((byte) 0x1a),
+ DW_OP_not((byte) 0x20),
+ DW_OP_plus((byte) 0x22),
+ DW_OP_shl((byte) 0x24),
+ DW_OP_shr((byte) 0x25),
+ DW_OP_bra((byte) 0x28),
+ DW_OP_eq((byte) 0x29),
+ DW_OP_lit0((byte) 0x30),
+ DW_OP_reg0((byte) 0x50),
+ DW_OP_breg0((byte) 0x70),
+ DW_OP_regx((byte) 0x90),
+ DW_OP_bregx((byte) 0x92),
+ DW_OP_push_object_address((byte) 0x97),
+ DW_OP_implicit_value((byte) 0x9e),
+ DW_OP_stack_value((byte) 0x9f);
+
+ private final byte value;
+
+ DwarfExpressionOpcode(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFlag.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFlag.java
new file mode 100644
index 000000000000..f83fe93b8bfd
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFlag.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * DW_FORM_flag only has two possible attribute values.
+ */
+public enum DwarfFlag {
+ @SuppressWarnings("unused")
+ DW_FLAG_false((byte) 0),
+ DW_FLAG_true((byte) 1);
+
+ private final byte value;
+
+ DwarfFlag(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForm.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForm.java
new file mode 100644
index 000000000000..0dc5b3aedad3
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForm.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * All the Dwarf attribute forms needed to type attribute values generated by GraalVM.
+ */
+public enum DwarfForm {
+ DW_FORM_null(0x0),
+ DW_FORM_addr(0x1),
+ DW_FORM_data2(0x05),
+ DW_FORM_data4(0x6),
+ @SuppressWarnings("unused")
+ DW_FORM_data8(0x7),
+ @SuppressWarnings("unused")
+ DW_FORM_string(0x8),
+ @SuppressWarnings("unused")
+ DW_FORM_block1(0x0a),
+ DW_FORM_ref_addr(0x10),
+ @SuppressWarnings("unused")
+ DW_FORM_ref1(0x11),
+ @SuppressWarnings("unused")
+ DW_FORM_ref2(0x12),
+ DW_FORM_ref4(0x13),
+ @SuppressWarnings("unused")
+ DW_FORM_ref8(0x14),
+ DW_FORM_sec_offset(0x17),
+ DW_FORM_data1(0x0b),
+ DW_FORM_flag(0xc),
+ DW_FORM_strp(0xe),
+ DW_FORM_expr_loc(0x18);
+
+ private final int value;
+
+ DwarfForm(int i) {
+ value = i;
+ }
+
+ public int value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValue.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValue.java
new file mode 100644
index 000000000000..77ba64cecf37
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValue.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * Constants that appear in CIE and FDE frame section entries.
+ */
+public enum DwarfFrameValue {
+ DW_CFA_CIE_version((byte) 1),
+ /* Values encoded in high 2 bits. */
+ DW_CFA_advance_loc((byte) 0x1),
+ DW_CFA_offset((byte) 0x2),
+ DW_CFA_restore((byte) 0x3),
+ /* Values encoded in low 6 bits. */
+ DW_CFA_nop((byte) 0x0),
+ @SuppressWarnings("unused")
+ DW_CFA_set_loc1((byte) 0x1),
+ DW_CFA_advance_loc1((byte) 0x2),
+ DW_CFA_advance_loc2((byte) 0x3),
+ DW_CFA_advance_loc4((byte) 0x4),
+ @SuppressWarnings("unused")
+ DW_CFA_offset_extended((byte) 0x5),
+ @SuppressWarnings("unused")
+ DW_CFA_restore_extended((byte) 0x6),
+ @SuppressWarnings("unused")
+ DW_CFA_undefined((byte) 0x7),
+ @SuppressWarnings("unused")
+ DW_CFA_same_value((byte) 0x8),
+ DW_CFA_register((byte) 0x9),
+ DW_CFA_def_cfa((byte) 0xc),
+ @SuppressWarnings("unused")
+ DW_CFA_def_cfa_register((byte) 0xd),
+ DW_CFA_def_cfa_offset((byte) 0xe);
+
+ private final byte value;
+
+ DwarfFrameValue(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfHasChildren.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfHasChildren.java
new file mode 100644
index 000000000000..d565d8080920
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfHasChildren.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/*
+ * Compile unit DIE header has_children attribute values.
+ */
+public enum DwarfHasChildren {
+ DW_CHILDREN_no((byte) 0),
+ DW_CHILDREN_yes((byte) 1);
+
+ private final byte value;
+
+ DwarfHasChildren(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfInline.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfInline.java
new file mode 100644
index 000000000000..91498c4a1ed0
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfInline.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/*
+ * Values for DW_AT_inline attribute.
+ */
+public enum DwarfInline {
+ @SuppressWarnings("unused")
+ DW_INL_not_inlined((byte) 0),
+ DW_INL_inlined((byte) 1),
+ @SuppressWarnings("unused")
+ DW_INL_declared_not_inlined((byte) 2),
+ @SuppressWarnings("unused")
+ DW_INL_declared_inlined((byte) 3);
+
+ private final byte value;
+
+ DwarfInline(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLanguage.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLanguage.java
new file mode 100644
index 000000000000..eb7ad06c1f22
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLanguage.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/*
+ * DW_AT_language attribute has a range of pre-defined values but we
+ * are only interested in Java.
+ */
+public enum DwarfLanguage {
+ DW_LANG_Java((byte) 0xb);
+
+ private final byte value;
+
+ DwarfLanguage(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcode.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcode.java
new file mode 100644
index 000000000000..2bb3269ee327
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcode.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * Standard line section opcodes defined by Dwarf 4.
+ */
+public enum DwarfLineOpcode {
+ /*
+ * 0 can be inserted as a prefix for extended opcodes.
+ */
+ DW_LNS_extended_prefix((byte) 0),
+ /*
+ * Append current state as matrix row 0 args.
+ */
+ DW_LNS_copy((byte) 1),
+ /*
+ * Increment address 1 uleb arg.
+ */
+ DW_LNS_advance_pc((byte) 2),
+ /*
+ * Increment line 1 sleb arg.
+ */
+ DW_LNS_advance_line((byte) 3),
+ /*
+ * Set file 1 uleb arg.
+ */
+ DW_LNS_set_file((byte) 4),
+ /*
+ * sSet column 1 uleb arg.
+ */
+ DW_LNS_set_column((byte) 5),
+ /*
+ * Flip is_stmt 0 args.
+ */
+ DW_LNS_negate_stmt((byte) 6),
+ /*
+ * Set end sequence and copy row 0 args.
+ */
+ DW_LNS_set_basic_block((byte) 7),
+ /*
+ * Increment address as per opcode 255 0 args.
+ */
+ DW_LNS_const_add_pc((byte) 8),
+ /*
+ * Increment address 1 ushort arg.
+ */
+ DW_LNS_fixed_advance_pc((byte) 9),
+ /*
+ * Increment address 1 ushort arg.
+ */
+ @SuppressWarnings("unused")
+ DW_LNS_set_prologue_end((byte) 10),
+ /*
+ * Increment address 1 ushort arg.
+ */
+ @SuppressWarnings("unused")
+ DW_LNS_set_epilogue_begin((byte) 11),
+ /*
+ * Extended line section opcodes defined by DWARF 2.
+ */
+ /*
+ * There is no extended opcode 0.
+ */
+ @SuppressWarnings("unused")
+ DW_LNE_undefined((byte) 0),
+ /*
+ * End sequence of addresses.
+ */
+ DW_LNE_end_sequence((byte) 1),
+ /*
+ * Set address as explicit long argument.
+ */
+ DW_LNE_set_address((byte) 2),
+ /*
+ * Set file as explicit string argument.
+ */
+ DW_LNE_define_file((byte) 3);
+
+ private final byte value;
+
+ DwarfLineOpcode(byte b) {
+ value = b;
+ }
+
+ public byte value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionName.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionName.java
new file mode 100644
index 000000000000..bb12f38edf89
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionName.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * Various ELF sections created by GraalVM including all debug info sections. The enum sequence
+ * starts with the text section (not defined in the DWARF spec and not created by debug info code).
+ */
+public enum DwarfSectionName {
+ TEXT_SECTION(".text"),
+ DW_STR_SECTION(".debug_str"),
+ DW_LINE_SECTION(".debug_line"),
+ DW_FRAME_SECTION(".debug_frame"),
+ DW_ABBREV_SECTION(".debug_abbrev"),
+ DW_INFO_SECTION(".debug_info"),
+ DW_LOC_SECTION(".debug_loc"),
+ DW_ARANGES_SECTION(".debug_aranges"),
+ DW_RANGES_SECTION(".debug_ranges");
+
+ private final String value;
+
+ DwarfSectionName(String s) {
+ value = s;
+ }
+
+ public String value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTag.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTag.java
new file mode 100644
index 000000000000..c15b59bd5938
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTag.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * All the Dwarf tags needed to type DIEs generated by GraalVM.
+ */
+public enum DwarfTag {
+ DW_TAG_null(0),
+ DW_TAG_array_type(0x01),
+ DW_TAG_class_type(0x02),
+ DW_TAG_formal_parameter(0x05),
+ DW_TAG_member(0x0d),
+ DW_TAG_pointer_type(0x0f),
+ DW_TAG_compile_unit(0x11),
+ DW_TAG_structure_type(0x13),
+ DW_TAG_typedef(0x16),
+ DW_TAG_union_type(0x17),
+ DW_TAG_inheritance(0x1c),
+ DW_TAG_subrange_type(0x21),
+ DW_TAG_base_type(0x24),
+ DW_TAG_constant(0x27),
+ DW_TAG_subprogram(0x2e),
+ DW_TAG_variable(0x34),
+ DW_TAG_namespace(0x39),
+ DW_TAG_unspecified_type(0x3b),
+ DW_TAG_inlined_subroutine(0x1d);
+
+ private final int value;
+
+ DwarfTag(int i) {
+ value = i;
+ }
+
+ public int value() {
+ return value;
+ }
+}
diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfVersion.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfVersion.java
new file mode 100644
index 000000000000..d646f501499c
--- /dev/null
+++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfVersion.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 2023, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.objectfile.elf.dwarf.constants;
+
+/**
+ * The DWARF version values used by GraalVM.
+ */
+public enum DwarfVersion {
+
+ /**
+ * Currently generated debug info relies on DWARF spec version 4. However, some sections may
+ * still need to be generated as version 2.
+ */
+ DW_VERSION_2((short) 2),
+ DW_VERSION_4((short) 4);
+
+ private final short value;
+
+ DwarfVersion(short s) {
+ value = s;
+ }
+
+ public short value() {
+ return value;
+ }
+
+}
diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/config/HybridLayoutSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/config/HybridLayoutSupport.java
index 7bd09002a6a6..b855e56bf34c 100644
--- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/config/HybridLayoutSupport.java
+++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/config/HybridLayoutSupport.java
@@ -87,7 +87,7 @@ protected HybridInfo inspectHybrid(HostedInstanceClass hybridClass, MetaAccessPr
arrayComponentType = foundArrayField.getType().getComponentType();
assert !arrayTypeIsSet || arrayComponentType.equals(metaAccess.lookupJavaType(annotation.componentType())) : //
- "@Hybrid.componentType must match the type of a @Hybrid.Array field when both are present";
+ "@Hybrid.componentType must match the type of a @Hybrid.Array field when both are present";
} else {
assert arrayTypeIsSet : "@Hybrid.componentType must be set when no @Hybrid.Array field is present (if present, ensure it is reachable)";
arrayComponentType = (HostedType) metaAccess.lookupJavaType(annotation.componentType());