From 78ac129deeccf89fa39c7d2839c6121b6fbb581e Mon Sep 17 00:00:00 2001 From: Andrew Dinn Date: Wed, 26 Jul 2023 10:38:12 +0100 Subject: [PATCH 1/7] Move all constants defined by the DWARF spec into an inheritable, reusable interface --- .../elf/dwarf/DwarfARangesSectionImpl.java | 18 +- .../elf/dwarf/DwarfAbbrevSectionImpl.java | 798 +++++++++--------- .../objectfile/elf/dwarf/DwarfConstants.java | 339 ++++++++ .../objectfile/elf/dwarf/DwarfDebugInfo.java | 292 ++----- .../elf/dwarf/DwarfFrameSectionImpl.java | 32 +- .../dwarf/DwarfFrameSectionImplAArch64.java | 22 +- .../dwarf/DwarfFrameSectionImplX86_64.java | 12 +- .../elf/dwarf/DwarfInfoSectionImpl.java | 198 ++--- .../elf/dwarf/DwarfLineSectionImpl.java | 116 +-- .../elf/dwarf/DwarfLocSectionImpl.java | 18 +- .../elf/dwarf/DwarfRangesSectionImpl.java | 4 +- .../elf/dwarf/DwarfSectionImpl.java | 22 +- .../elf/dwarf/DwarfStrSectionImpl.java | 4 +- 13 files changed, 970 insertions(+), 905 deletions(-) create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java 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..fda3e8b52645 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 @@ -42,8 +42,8 @@ */ 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); @@ -51,7 +51,7 @@ public DwarfARangesSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DwarfDebugInfo.DW_ARANGES_SECTION_NAME; + return DW_ARANGES_SECTION_NAME; } @Override @@ -104,9 +104,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 +161,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 = writeShort(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; @@ -189,7 +189,7 @@ int writeARange(DebugContext context, CompiledMethodEntry compiledMethod, byte[] /* * The debug_aranges section depends on debug_frame section. */ - private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_FRAME_SECTION_NAME; + private static final String TARGET_SECTION_NAME = DW_FRAME_SECTION_NAME; @Override public String targetSectionName() { 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..32310771023a 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 @@ -834,7 +834,7 @@ public DwarfAbbrevSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DwarfDebugInfo.DW_ABBREV_SECTION_NAME; + return DW_ABBREV_SECTION_NAME; } @Override @@ -938,114 +938,114 @@ private int writeAttrForm(long code, byte[] buffer, int 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, DwarfDebugInfo.ABBREV_CODE_builtin_unit, buffer, pos); + pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.ABBREV_CODE_class_unit1, buffer, pos); + pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.ABBREV_CODE_class_unit2, buffer, pos); return pos; } private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext context, int 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(DW_TAG_compile_unit, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_language, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_use_UTF8, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_comp_dir, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_class_unit2) { + pos = writeAttrType(DW_AT_ranges, buffer, pos); + pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_stmt_list, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_primitive_type, buffer, pos); + pos = writeTag(DW_TAG_base_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_bit_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_encoding, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_void_type, buffer, pos); + pos = writeTag(DW_TAG_unspecified_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_object_header, buffer, pos); + pos = writeTag(DW_TAG_structure_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_namespace, buffer, pos); + pos = writeTag(DW_TAG_namespace, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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, DwarfDebugInfo.ABBREV_CODE_class_layout1, buffer, pos); if (!dwarfSections.useHeapBase()) { - pos = writeClassLayoutAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_class_layout2, buffer, pos); + pos = writeClassLayoutAbbrev(context, DwarfDebugInfo.ABBREV_CODE_class_layout2, buffer, pos); } return pos; } @@ -1054,28 +1054,28 @@ private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont 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(DW_TAG_class_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(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 == DwarfDebugInfo.ABBREV_CODE_class_layout2) { + pos = writeAttrType(DW_AT_data_location, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1084,233 +1084,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(DwarfDebugInfo.ABBREV_CODE_class_pointer, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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, DwarfDebugInfo.ABBREV_CODE_method_declaration, buffer, pos); + pos = writeMethodDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_declaration_static, buffer, pos); return pos; } private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int 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(DW_TAG_subprogram, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_linkage_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_artificial, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(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_containing_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_declaration) { + pos = writeAttrType(DW_AT_object_pointer, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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, DwarfDebugInfo.ABBREV_CODE_field_declaration1, buffer, pos); /* An instance field with line and file. */ - pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_field_declaration2, buffer, pos); + pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_field_declaration2, buffer, pos); /* A static field no line and file. */ - pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_field_declaration3, buffer, pos); + pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_field_declaration3, buffer, pos); /* A static field with line and file. */ - pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.DW_ABBREV_CODE_field_declaration4, buffer, pos); + pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_field_declaration4, buffer, pos); return pos; } private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int 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(DW_TAG_member, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(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 == DwarfDebugInfo.ABBREV_CODE_field_declaration2 || abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration4) { + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(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(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration1 || abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration2) { /* 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(DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(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 == DwarfDebugInfo.ABBREV_CODE_field_declaration3 || abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration4) { + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_class_constant, buffer, pos); + pos = writeTag(DW_TAG_constant, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(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(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_location, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_array_layout, buffer, pos); + pos = writeTag(DW_TAG_class_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_array_pointer, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_interface_layout, buffer, pos); + pos = writeTag(DW_TAG_union_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_interface_pointer, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_interface_implementor, buffer, pos); + pos = writeTag(DW_TAG_member, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1318,21 +1318,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(DwarfDebugInfo.ABBREV_CODE_foreign_pointer, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1340,18 +1340,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(DwarfDebugInfo.ABBREV_CODE_foreign_typedef, buffer, pos); + pos = writeTag(DW_TAG_typedef, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1359,47 +1359,47 @@ 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(DwarfDebugInfo.ABBREV_CODE_foreign_struct, buffer, pos); + pos = writeTag(DW_TAG_structure_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_header_field, buffer, pos); + pos = writeTag(DW_TAG_member, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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, DwarfDebugInfo.ABBREV_CODE_array_data_type1, buffer, pos); + pos = writeArrayDataTypeAbbrev(context, DwarfDebugInfo.ABBREV_CODE_array_data_type2, buffer, pos); return pos; } @@ -1407,23 +1407,23 @@ private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext co 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(DW_TAG_array_type, buffer, pos); + boolean hasChildren = (abbrevCode == DwarfDebugInfo.ABBREV_CODE_array_data_type2); + pos = writeFlag((hasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no), buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_array_data_type2) { + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1431,96 +1431,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(DwarfDebugInfo.ABBREV_CODE_array_subrange, buffer, pos); + pos = writeTag(DW_TAG_subrange_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_count, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_method_location, buffer, pos); + pos = writeTag(DW_TAG_subprogram, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_hi_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_specification, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_abstract_inline_method, buffer, pos); + pos = writeTag(DW_TAG_subprogram, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_inline, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_specification, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_static_field_location, buffer, pos); + pos = writeTag(DW_TAG_variable, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_specification, buffer, pos); + pos = writeAttrForm(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(DW_AT_location, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_super_reference, buffer, pos); + pos = writeTag(DW_TAG_inheritance, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1535,21 +1535,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(DwarfDebugInfo.ABBREV_CODE_indirect_layout, buffer, pos); + pos = writeTag(DW_TAG_class_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DW_AT_data_location, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1558,176 +1558,176 @@ 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(DwarfDebugInfo.ABBREV_CODE_indirect_pointer, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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, DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration1, buffer, pos); + pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration2, buffer, pos); + pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration3, buffer, pos); return pos; } private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int 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(DW_TAG_formal_parameter, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration2) { /* 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(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(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(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration1) { /* 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(DW_AT_artificial, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); } - pos = writeAttrType(DwarfDebugInfo.DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DwarfDebugInfo.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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, DwarfDebugInfo.ABBREV_CODE_method_local_declaration1, buffer, pos); + pos = writeLocalDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_local_declaration2, buffer, pos); return pos; } private int writeLocalDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, int 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(DW_TAG_variable, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_local_declaration1) { /* 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(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(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(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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, DwarfDebugInfo.ABBREV_CODE_method_parameter_location1, buffer, pos); + pos = writeParameterLocationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_parameter_location2, 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, DwarfDebugInfo.ABBREV_CODE_method_local_location1, buffer, pos); + pos = writeLocalLocationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_local_location2, buffer, pos); return pos; } private int writeParameterLocationAbbrev(@SuppressWarnings("unused") DebugContext context, int 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(DW_TAG_formal_parameter, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_parameter_location2) { + pos = writeAttrType(DW_AT_location, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeLocalLocationAbbrev(@SuppressWarnings("unused") DebugContext context, int 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(DW_TAG_variable, buffer, pos); + pos = writeFlag(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_local_location2) { + pos = writeAttrType(DW_AT_location, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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(DwarfDebugInfo.ABBREV_CODE_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 ? DwarfDebugInfo.ABBREV_CODE_inlined_subroutine_with_children : DwarfDebugInfo.ABBREV_CODE_inlined_subroutine, buffer, pos); + pos = writeTag(DW_TAG_inlined_subroutine, buffer, pos); + pos = writeFlag(withChildren ? DW_CHILDREN_yes : DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeAttrType(DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_hi_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_call_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data4, buffer, pos); + pos = writeAttrType(DW_AT_call_line, buffer, pos); + pos = writeAttrForm(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(DW_AT_null, buffer, pos); + pos = writeAttrForm(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; + private static final String TARGET_SECTION_NAME = DW_RANGES_SECTION_NAME; @Override public String targetSectionName() { diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java new file mode 100644 index 000000000000..7a3283b099cf --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java @@ -0,0 +1,339 @@ +/* + * 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; + +/** + * An interface that provides definitions for a variety of constants defined + * by the DWARF standard, employing the same names and types. The primary + * reference for these constants is the DWARF Debugging Information Format + * Version 4 Specification published at dwarfstd.org.

+ * + * Note that this is not an exhaustive list of all DWARF constants. It merely + * includes constants that are needed by GraalVM. + */ +public interface DwarfConstants { + /* + * Names of the different ELF sections we create in reverse dependency order. The + * sequence starts with the name of the text section (not defined in the DWARF spec + * and not created by debug info code). + */ + String TEXT_SECTION_NAME = ".text"; + String DW_STR_SECTION_NAME = ".debug_str"; + String DW_LINE_SECTION_NAME = ".debug_line"; + String DW_FRAME_SECTION_NAME = ".debug_frame"; + String DW_ABBREV_SECTION_NAME = ".debug_abbrev"; + String DW_INFO_SECTION_NAME = ".debug_info"; + String DW_LOC_SECTION_NAME = ".debug_loc"; + String DW_ARANGES_SECTION_NAME = ".debug_aranges"; + String DW_RANGES_SECTION_NAME = ".debug_ranges"; + + /** + * Currently generated debug info relies on DWARF spec version 4. However, + * some sections may still need to be generated as version 2. + */ + short DW_VERSION_2 = 2; + short DW_VERSION_4 = 4; + + /* + * All the Dwarf tags needed to type DIEs generated by GraalVM. + */ + int DW_TAG_array_type = 0x01; + int DW_TAG_class_type = 0x02; + int DW_TAG_formal_parameter = 0x05; + int DW_TAG_member = 0x0d; + int DW_TAG_pointer_type = 0x0f; + int DW_TAG_compile_unit = 0x11; + int DW_TAG_structure_type = 0x13; + int DW_TAG_typedef = 0x16; + int DW_TAG_union_type = 0x17; + int DW_TAG_inheritance = 0x1c; + int DW_TAG_subrange_type = 0x21; + int DW_TAG_base_type = 0x24; + int DW_TAG_constant = 0x27; + int DW_TAG_subprogram = 0x2e; + int DW_TAG_variable = 0x34; + int DW_TAG_namespace = 0x39; + int DW_TAG_unspecified_type = 0x3b; + int DW_TAG_inlined_subroutine = 0x1d; + + /* + * All the Dwarf attributes needed to populate DIEs generated by GraalVM. + */ + int DW_AT_null = 0x0; + int DW_AT_location = 0x02; + int DW_AT_name = 0x3; + int DW_AT_byte_size = 0x0b; + int DW_AT_bit_size = 0x0d; + int DW_AT_stmt_list = 0x10; + int DW_AT_low_pc = 0x11; + int DW_AT_hi_pc = 0x12; + int DW_AT_language = 0x13; + int DW_AT_comp_dir = 0x1b; + int DW_AT_containing_type = 0x1d; + int DW_AT_inline = 0x20; + int DW_AT_abstract_origin = 0x31; + int DW_AT_accessibility = 0x32; + int DW_AT_artificial = 0x34; + int DW_AT_count = 0x37; + int DW_AT_data_member_location = 0x38; + @SuppressWarnings("unused") + int DW_AT_decl_column = 0x39; + int DW_AT_decl_file = 0x3a; + int DW_AT_decl_line = 0x3b; + int DW_AT_declaration = 0x3c; + int DW_AT_encoding = 0x3e; + int DW_AT_external = 0x3f; + @SuppressWarnings("unused") + int DW_AT_return_addr = 0x2a; + @SuppressWarnings("unused") + int DW_AT_frame_base = 0x40; + int DW_AT_specification = 0x47; + int DW_AT_type = 0x49; + int DW_AT_data_location = 0x50; + int DW_AT_use_UTF8 = 0x53; + int DW_AT_ranges = 0x55; + int DW_AT_call_file = 0x58; + int DW_AT_call_line = 0x59; + int DW_AT_object_pointer = 0x64; + int DW_AT_linkage_name = 0x6e; + + /* + * All the Dwarf attribute forms needed to type attribute values generated by GraalVM. + */ + int DW_FORM_null = 0x0; + int DW_FORM_addr = 0x1; + int DW_FORM_data2 = 0x05; + int DW_FORM_data4 = 0x6; + @SuppressWarnings("unused") + int DW_FORM_data8 = 0x7; + @SuppressWarnings("unused") + int DW_FORM_string = 0x8; + @SuppressWarnings("unused") + int DW_FORM_block1 = 0x0a; + int DW_FORM_ref_addr = 0x10; + @SuppressWarnings("unused") + int DW_FORM_ref1 = 0x11; + @SuppressWarnings("unused") + int DW_FORM_ref2 = 0x12; + @SuppressWarnings("unused") + int DW_FORM_ref4 = 0x13; + @SuppressWarnings("unused") + int DW_FORM_ref8 = 0x14; + int DW_FORM_sec_offset = 0x17; + int DW_FORM_data1 = 0x0b; + int DW_FORM_flag = 0xc; + int DW_FORM_strp = 0xe; + int DW_FORM_expr_loc = 0x18; + + /* + * The following constants correspond to pre-defined value ranges appropriate + * to a specific attribute or form. + */ + + /* + * Compile unit DIE header has_children attribute values. + */ + byte DW_CHILDREN_no = 0; + byte DW_CHILDREN_yes = 1; + + /* + * DW_FORM_flag haas two possible attribute values. + */ + @SuppressWarnings("unused") + byte DW_FLAG_false = 0; + byte DW_FLAG_true = 1; + + /* + * DW_AT_language attribute with form DATA1 has a range of pre-defined values. + */ + byte DW_LANG_Java = 0xb; + + /* + * Values for DW_AT_inline attribute with form DATA1. + */ + @SuppressWarnings("unused") + byte DW_INL_not_inlined = 0; + byte DW_INL_inlined = 1; + @SuppressWarnings("unused") + byte DW_INL_declared_not_inlined = 2; + @SuppressWarnings("unused") + byte DW_INL_declared_inlined = 3; + + /* + * DW_AT_Accessibility attribute values. + */ + @SuppressWarnings("unused") + byte DW_ACCESS_public = 1; + @SuppressWarnings("unused") + byte DW_ACCESS_protected = 2; + @SuppressWarnings("unused") + byte DW_ACCESS_private = 3; + + /* + * DW_AT_encoding attribute values + */ + @SuppressWarnings("unused") + byte DW_ATE_address = 0x1; + byte DW_ATE_boolean = 0x2; + byte DW_ATE_float = 0x4; + byte DW_ATE_signed = 0x5; + byte DW_ATE_signed_char = 0x6; + byte DW_ATE_unsigned = 0x7; + @SuppressWarnings("unused") + byte DW_ATE_unsigned_char = 0x8; + + /* + * Constants that appear in CIE and FDE frame section entries. + */ + byte DW_CFA_CIE_version = 1; + /* Values encoded in high 2 bits. */ + byte DW_CFA_advance_loc = 0x1; + byte DW_CFA_offset = 0x2; + byte DW_CFA_restore = 0x3; + /* Values encoded in low 6 bits. */ + byte DW_CFA_nop = 0x0; + @SuppressWarnings("unused") + byte DW_CFA_set_loc1 = 0x1; + byte DW_CFA_advance_loc1 = 0x2; + byte DW_CFA_advance_loc2 = 0x3; + byte DW_CFA_advance_loc4 = 0x4; + @SuppressWarnings("unused") + byte DW_CFA_offset_extended = 0x5; + @SuppressWarnings("unused") + byte DW_CFA_restore_extended = 0x6; + @SuppressWarnings("unused") + byte DW_CFA_undefined = 0x7; + @SuppressWarnings("unused") + byte DW_CFA_same_value = 0x8; + byte DW_CFA_register = 0x9; + byte DW_CFA_def_cfa = 0xc; + @SuppressWarnings("unused") + byte DW_CFA_def_cfa_register = 0xd; + byte DW_CFA_def_cfa_offset = 0xe; + + /* + * Values used to build DWARF expressions and locations + */ + byte DW_OP_addr = 0x03; + @SuppressWarnings("unused") + byte DW_OP_deref = 0x06; + byte DW_OP_dup = 0x12; + byte DW_OP_and = 0x1a; + byte DW_OP_not = 0x20; + byte DW_OP_plus = 0x22; + byte DW_OP_shl = 0x24; + byte DW_OP_shr = 0x25; + byte DW_OP_bra = 0x28; + byte DW_OP_eq = 0x29; + byte DW_OP_lit0 = 0x30; + byte DW_OP_reg0 = 0x50; + byte DW_OP_breg0 = 0x70; + byte DW_OP_regx = (byte) 0x90; + byte DW_OP_bregx = (byte) 0x92; + byte DW_OP_push_object_address = (byte) 0x97; + byte DW_OP_implicit_value = (byte) 0x9e; + byte DW_OP_stack_value = (byte) 0x9f; + + /* + * Standard line section opcodes defined by Dwarf 2 + */ + /* + * 0 can be returned to indicate an invalid opcode. + */ + byte DW_LNS_undefined = 0; + /* + * 0 can be inserted as a prefix for extended opcodes. + */ + byte DW_LNS_extended_prefix = 0; + /* + * Append current state as matrix row 0 args. + */ + byte DW_LNS_copy = 1; + /* + * Increment address 1 uleb arg. + */ + byte DW_LNS_advance_pc = 2; + /* + * Increment line 1 sleb arg. + */ + byte DW_LNS_advance_line = 3; + /* + * Set file 1 uleb arg. + */ + byte DW_LNS_set_file = 4; + /* + * sSet column 1 uleb arg. + */ + byte DW_LNS_set_column = 5; + /* + * Flip is_stmt 0 args. + */ + byte DW_LNS_negate_stmt = 6; + /* + * Set end sequence and copy row 0 args. + */ + byte DW_LNS_set_basic_block = 7; + /* + * Increment address as per opcode 255 0 args. + */ + byte DW_LNS_const_add_pc = 8; + /* + * Increment address 1 ushort arg. + */ + byte DW_LNS_fixed_advance_pc = 9; + + /* + * Increment address 1 ushort arg. + */ + @SuppressWarnings("unused") byte DW_LNS_set_prologue_end = 10; + + /* + * Increment address 1 ushort arg. + */ + @SuppressWarnings("unused") byte DW_LNS_set_epilogue_begin = 11; + + /* + * Extended line section opcodes defined by DWARF 2. + */ + /* + * There is no extended opcode 0. + */ + @SuppressWarnings("unused") byte DW_LNE_undefined = 0; + /* + * End sequence of addresses. + */ + byte DW_LNE_end_sequence = 1; + /* + * Set address as explicit long argument. + */ + byte DW_LNE_set_address = 2; + /* + * Set file as explicit string argument. + */ + byte DW_LNE_define_file = 3; + +} 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..4c1d98d11677 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 @@ -44,267 +44,72 @@ * DWARF sections. It groups common data and behaviours for use by the various subclasses of class * DwarfSectionImpl that take responsibility for generating content for a specific section type. */ -public class DwarfDebugInfo extends DebugInfoBase { +public class DwarfDebugInfo extends DebugInfoBase implements DwarfConstants { - /* - * 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; + public static final int 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; + public static final int ABBREV_CODE_builtin_unit = 1; + public static final int ABBREV_CODE_class_unit1 = 2; + public static final int 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; + public static final int ABBREV_CODE_primitive_type = 4; + public static final int ABBREV_CODE_void_type = 5; + public static final int ABBREV_CODE_object_header = 6; + public static final int ABBREV_CODE_namespace = 7; + public static final int ABBREV_CODE_class_layout1 = 8; + public static final int ABBREV_CODE_class_layout2 = 9; + public static final int ABBREV_CODE_class_pointer = 10; + public static final int ABBREV_CODE_foreign_pointer = 11; + public static final int ABBREV_CODE_foreign_typedef = 12; + public static final int ABBREV_CODE_foreign_struct = 13; + public static final int ABBREV_CODE_method_location = 14; + public static final int ABBREV_CODE_static_field_location = 15; + public static final int ABBREV_CODE_array_layout = 16; + public static final int ABBREV_CODE_array_pointer = 17; + public static final int ABBREV_CODE_interface_layout = 18; + public static final int ABBREV_CODE_interface_pointer = 19; + public static final int ABBREV_CODE_indirect_layout = 20; + public static final int 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; + public static final int ABBREV_CODE_method_declaration = 22; + public static final int ABBREV_CODE_method_declaration_static = 23; + public static final int ABBREV_CODE_field_declaration1 = 24; + public static final int ABBREV_CODE_field_declaration2 = 25; + public static final int ABBREV_CODE_field_declaration3 = 26; + public static final int ABBREV_CODE_field_declaration4 = 27; + public static final int ABBREV_CODE_class_constant = 28; + public static final int ABBREV_CODE_header_field = 29; + public static final int ABBREV_CODE_array_data_type1 = 30; + public static final int ABBREV_CODE_array_data_type2 = 31; + public static final int ABBREV_CODE_array_subrange = 32; + public static final int ABBREV_CODE_super_reference = 33; + public static final int 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; + public static final int ABBREV_CODE_inlined_subroutine = 35; + public static final int ABBREV_CODE_inlined_subroutine_with_children = 36; + public static final int 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; + public static final int ABBREV_CODE_method_parameter_declaration1 = 38; + public static final int ABBREV_CODE_method_parameter_declaration2 = 39; + public static final int ABBREV_CODE_method_parameter_declaration3 = 40; + public static final int ABBREV_CODE_method_local_declaration1 = 41; + public static final int 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; + public static final int ABBREV_CODE_method_parameter_location1 = 43; + public static final int ABBREV_CODE_method_parameter_location2 = 44; + public static final int ABBREV_CODE_method_local_location1 = 45; + public static final int ABBREV_CODE_method_local_location2 = 46; - /* - * 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; - - /* - * 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; /* Register constants for AArch64. */ public static final byte rheapbase_aarch64 = (byte) 27; @@ -323,6 +128,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..3a9d680bd2a6 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 @@ -41,13 +41,15 @@ public abstract class DwarfFrameSectionImpl extends DwarfSectionImpl { private static final int PADDING_NOPS_ALIGNMENT = 8; + private static final int CFA_CIE_id_default = -1; + public DwarfFrameSectionImpl(DwarfDebugInfo dwarfSections) { super(dwarfSections); } @Override public String getSectionName() { - return DwarfDebugInfo.DW_FRAME_SECTION_NAME; + return DW_FRAME_SECTION_NAME; } @Override @@ -100,7 +102,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 +121,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 = writeByte(DW_CFA_CIE_version, buffer, pos); pos = writeByte((byte) 0, buffer, pos); pos = writeULEB(1, buffer, pos); pos = writeSLEB(-8, buffer, pos); @@ -194,21 +196,21 @@ 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(DW_CFA_nop, 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(DW_CFA_def_cfa, 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); + pos = writeByte(DW_CFA_def_cfa_offset, buffer, pos); return writeULEB(offset, buffer, pos); } @@ -231,20 +233,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 = DW_CFA_advance_loc1; 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 = DW_CFA_advance_loc2; 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 = DW_CFA_advance_loc4; int pos = p; pos = writeByte(op, buffer, pos); return writeInt(offset, buffer, pos); @@ -266,7 +268,7 @@ 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); + pos = writeByte(DW_CFA_register, buffer, pos); pos = writeULEB(savedReg, buffer, pos); return writeULEB(savedToReg, buffer, pos); } @@ -281,7 +283,7 @@ protected int writeRegister(int savedReg, int savedToReg, byte[] buffer, int p) /** * The debug_frame section depends on debug_line section. */ - private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_LINE_SECTION_NAME; + private static final String TARGET_SECTION_NAME = DW_LINE_SECTION_NAME; @Override public String targetSectionName() { @@ -300,16 +302,16 @@ public LayoutDecision.Kind[] targetSectionKinds() { private static byte offsetOp(int register) { assert (register >> 6) == 0; - return (byte) ((DwarfDebugInfo.DW_CFA_offset << 6) | register); + return (byte) ((DW_CFA_offset << 6) | register); } private static byte restoreOp(int register) { assert (register >> 6) == 0; - return (byte) ((DwarfDebugInfo.DW_CFA_restore << 6) | register); + return (byte) ((DW_CFA_restore << 6) | register); } private static byte advanceLoc0Op(int offset) { assert (offset >= 0 && offset <= 0x3f); - return (byte) ((DwarfDebugInfo.DW_CFA_advance_loc << 6) | offset); + return (byte) ((DW_CFA_advance_loc << 6) | offset); } } 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..854449e43968 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 @@ -71,7 +71,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 @@ -92,7 +92,7 @@ public DwarfInfoSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DwarfDebugInfo.DW_INFO_SECTION_NAME; + return DW_INFO_SECTION_NAME; } @Override @@ -129,22 +129,22 @@ byte computeEncoding(int flags, int bitCount) { if ((flags & DebugPrimitiveTypeInfo.FLAG_SIGNED) != 0) { switch (bitCount) { case 8: - return DwarfDebugInfo.DW_ATE_signed_char; + return DW_ATE_signed_char; default: assert bitCount == 16 || bitCount == 32 || bitCount == 64; - return DwarfDebugInfo.DW_ATE_signed; + return DW_ATE_signed; } } else { assert bitCount == 16; - return DwarfDebugInfo.DW_ATE_unsigned; + return DW_ATE_unsigned; } } else { assert bitCount == 32 || bitCount == 64; - return DwarfDebugInfo.DW_ATE_float; + return DW_ATE_float; } } else { assert bitCount == 1; - return DwarfDebugInfo.DW_ATE_boolean; + return DW_ATE_boolean; } } @@ -175,8 +175,8 @@ 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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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"); @@ -233,7 +233,7 @@ public int writePrimitiveType(DebugContext context, PrimitiveTypeEntry primitive * might want an indirect type */ setIndirectTypeIndex(primitiveTypeEntry, pos); - int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_primitive_type; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_primitive_type; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); byte byteSize = (byte) primitiveTypeEntry.getSize(); @@ -265,7 +265,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_void_type; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String name = primitiveTypeEntry.getTypeName(); @@ -285,7 +285,7 @@ public int writeHeaderType(DebugContext context, HeaderTypeEntry headerTypeEntry * want an indirect type. */ setIndirectTypeIndex(headerTypeEntry, pos); - int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_object_header; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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 +349,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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,8 +383,8 @@ 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; + int abbrevCode = (classEntry.hasCompiledEntries() ? DwarfDebugInfo.ABBREV_CODE_class_unit2 : DwarfDebugInfo.ABBREV_CODE_class_unit1); 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"); @@ -400,7 +400,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 == DwarfDebugInfo.ABBREV_CODE_class_unit2) { int codeRangesIndex = getCodeRangesIndex(classEntry); log(context, " [0x%08x] ranges 0x%x", pos, codeRangesIndex); pos = writeRangesSectionOffset(codeRangesIndex, buffer, pos); @@ -470,7 +470,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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 +487,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_class_constant; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); @@ -522,13 +522,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_class_layout1; /* * 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 = DwarfDebugInfo.ABBREV_CODE_class_layout2; } log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); @@ -541,7 +541,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 == DwarfDebugInfo.ABBREV_CODE_class_layout2) { /* 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 +575,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 = DwarfDebugInfo.ABBREV_CODE_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 +604,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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); @@ -637,15 +637,15 @@ private int writeField(DebugContext context, StructureTypeEntry entry, FieldEntr boolean isStatic = Modifier.isStatic(modifiers); if (!isStatic) { if (!hasFile) { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration1; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_field_declaration1; } else { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration2; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_field_declaration2; } } else { if (!hasFile) { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration3; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_field_declaration3; } else { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_field_declaration4; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_field_declaration4; } /* Record the position of the declaration to use when we write the definition. */ setFieldDeclarationIndex(entry, fieldEntry.fieldName(), pos); @@ -709,7 +709,7 @@ 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); + int abbrevCode = (isStatic ? DwarfDebugInfo.ABBREV_CODE_method_declaration_static : DwarfDebugInfo.ABBREV_CODE_method_declaration); log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); log(context, " [0x%08x] external true", pos); @@ -743,7 +743,7 @@ private int writeMethodDeclaration(DebugContext context, ClassEntry classEntry, 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 == DwarfDebugInfo.ABBREV_CODE_method_declaration) { /* Record the current position so we can back patch the object pointer. */ int objectPointerIndex = pos; /* @@ -793,17 +793,17 @@ private int writeMethodParameterDeclaration(DebugContext context, DebugLocalInfo TypeEntry paramType = lookupType(paramInfo.valueType()); int line = paramInfo.line(); if (artificial) { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration1; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration1; } else if (line >= 0) { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration2; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration2; } else { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_declaration3; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration3; } 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 == DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration2) { 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,7 +812,7 @@ 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 == DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration1) { log(context, " [0x%08x] artificial true", pos); pos = writeFlag((byte) 1, buffer, pos); } @@ -842,15 +842,15 @@ private int writeMethodLocalDeclaration(DebugContext context, DebugLocalInfo par TypeEntry paramType = lookupType(paramInfo.valueType()); int line = paramInfo.line(); if (line >= 0) { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration1; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_method_local_declaration1; } else { - abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_method_local_declaration2; + abbrevCode = DwarfDebugInfo.ABBREV_CODE_method_local_declaration2; } 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 == DwarfDebugInfo.ABBREV_CODE_method_local_declaration1) { log(context, " [0x%08x] file 0x%x", pos, fileIdx); pos = writeAttrData2((short) fileIdx, buffer, pos); log(context, " [0x%08x] line 0x%x", pos, line); @@ -869,7 +869,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_interface_layout; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String name = interfaceClassEntry.getTypeName(); @@ -893,7 +893,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 = DwarfDebugInfo.ABBREV_CODE_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 +927,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_interface_implementor; log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String name = uniqueDebugString("_" + classEntry.getTypeName()); @@ -993,7 +993,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_foreign_struct; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String typedefName = foreignTypeEntry.getTypedefName(); @@ -1028,7 +1028,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_primitive_type; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); assert size >= 0; @@ -1039,7 +1039,7 @@ 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); + byte encoding = (isSigned ? DW_ATE_signed : DW_ATE_unsigned); log(context, " [0x%08x] encoding 0x%x", pos, encoding); pos = writeAttrData1(encoding, buffer, pos); String name = uniqueDebugString(integralTypeName(byteSize, isSigned)); @@ -1051,7 +1051,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_primitive_type; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); assert size > 0; @@ -1062,7 +1062,7 @@ 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); + byte encoding = (isSigned ? DW_ATE_signed : DW_ATE_unsigned); log(context, " [0x%08x] encoding 0x%x", pos, encoding); pos = writeAttrData1(encoding, buffer, pos); String name = uniqueDebugString(integralTypeName(byteSize, isSigned)); @@ -1074,7 +1074,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_primitive_type; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); assert size > 0; @@ -1085,7 +1085,7 @@ 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; + byte encoding = DW_ATE_float; log(context, " [0x%08x] encoding 0x%x", pos, encoding); pos = writeAttrData1(encoding, buffer, pos); String name = uniqueDebugString(size == 4 ? "float" : (size == 8 ? "double" : "long double")); @@ -1112,7 +1112,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_class_pointer; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); int pointerSize = dwarfSections.pointerSize(); @@ -1126,7 +1126,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 = DwarfDebugInfo.ABBREV_CODE_indirect_pointer; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); int oopReferenceSize = dwarfSections.oopReferenceSize(); @@ -1149,7 +1149,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_interface_pointer; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); int pointerSize = dwarfSections.pointerSize(); @@ -1163,7 +1163,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 = DwarfDebugInfo.ABBREV_CODE_indirect_pointer; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); int byteSize = dwarfSections.oopReferenceSize(); @@ -1190,7 +1190,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_foreign_pointer; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); int pointerSize = dwarfSections.pointerSize(); @@ -1204,7 +1204,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 = DwarfDebugInfo.ABBREV_CODE_foreign_typedef; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String name = uniqueDebugString(foreignTypeEntry.getTypeName()); @@ -1242,7 +1242,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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,8 +1271,8 @@ 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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_class_unit1; 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"); @@ -1325,7 +1325,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_array_layout; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String name = arrayTypeEntry.getTypeName(); @@ -1366,7 +1366,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_indirect_layout; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String name = arrayTypeEntry.getTypeName(); @@ -1389,7 +1389,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_array_data_type1; 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 +1404,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_array_data_type2; log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); // Foreign arrays have a fixed byte_size @@ -1434,7 +1434,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 = DwarfDebugInfo.ABBREV_CODE_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 +1448,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_header_field; log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); String fieldName = uniqueDebugString("data"); @@ -1484,7 +1484,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_array_pointer; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); int pointerSize = dwarfSections.pointerSize(); @@ -1497,7 +1497,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 = DwarfDebugInfo.ABBREV_CODE_indirect_pointer; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); int byteSize = dwarfSections.oopReferenceSize(); @@ -1524,7 +1524,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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 +1535,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(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); @@ -1627,16 +1627,16 @@ private int writeMethodLocalLocation(DebugContext context, Range range, DebugLoc } int abbrevCode; if (localValues.isEmpty()) { - abbrevCode = (isParam ? DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location1 : DwarfDebugInfo.DW_ABBREV_CODE_method_local_location1); + abbrevCode = (isParam ? DwarfDebugInfo.ABBREV_CODE_method_parameter_location1 : DwarfDebugInfo.ABBREV_CODE_method_local_location1); } else { - abbrevCode = (isParam ? DwarfDebugInfo.DW_ABBREV_CODE_method_parameter_location2 : DwarfDebugInfo.DW_ABBREV_CODE_method_local_location2); + abbrevCode = (isParam ? DwarfDebugInfo.ABBREV_CODE_method_parameter_location2 : DwarfDebugInfo.ABBREV_CODE_method_local_location2); } 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 == DwarfDebugInfo.ABBREV_CODE_method_local_location2 || + abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_parameter_location2) { int locRefAddr = getRangeLocalIndex(range, localInfo); log(context, " [0x%08x] loc list 0x%x", pos, locRefAddr); pos = writeLocSectionOffset(locRefAddr, buffer, pos); @@ -1716,7 +1716,7 @@ private int writeInlineSubroutine(DebugContext context, ClassEntry classEntry, S } } final int code; - code = DwarfDebugInfo.DW_ABBREV_CODE_inlined_subroutine_with_children; + code = DwarfDebugInfo.ABBREV_CODE_inlined_subroutine_with_children; log(context, " [0x%08x] <%d> Abbrev Number %d", pos, depth, code); pos = writeAbbrevCode(code, buffer, pos); log(context, " [0x%08x] abstract_origin 0x%x", pos, abstractOriginIndex); @@ -1778,16 +1778,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; + int abbrevCode = DwarfDebugInfo.ABBREV_CODE_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, DW_INL_inlined); + pos = writeAttrData1(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(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 +1826,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 = writeShort(DW_VERSION_4, buffer, pos); /* Abbrev offset. */ pos = writeAbbrevSectionOffset(0, buffer, pos); /* Address size. */ @@ -1842,14 +1842,14 @@ public int writeAttrString(String value, byte[] buffer, int p) { public int writeAttrAccessibility(int modifiers, byte[] buffer, int p) { byte access; if (Modifier.isPublic(modifiers)) { - access = DwarfDebugInfo.DW_ACCESS_public; + access = DW_ACCESS_public; } else if (Modifier.isProtected(modifiers)) { - access = DwarfDebugInfo.DW_ACCESS_protected; + access = DW_ACCESS_protected; } else if (Modifier.isPrivate(modifiers)) { - access = DwarfDebugInfo.DW_ACCESS_private; + access = DW_ACCESS_private; } else { /* Actually package private -- make it public for now. */ - access = DwarfDebugInfo.DW_ACCESS_public; + access = DW_ACCESS_public; } return writeAttrData1(access, buffer, p); } @@ -1954,40 +1954,40 @@ 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 = writeByte(DW_OP_push_object_address, buffer, pos); + pos = writeByte((byte) (DW_OP_lit0 + mask), buffer, pos); + pos = writeByte(DW_OP_not, buffer, pos); + pos = writeByte(DW_OP_and, buffer, pos); } else { - pos = writeByte(DwarfDebugInfo.DW_OP_push_object_address, buffer, pos); + pos = writeByte(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 = writeByte(DW_OP_dup, buffer, pos); + pos = writeByte(DW_OP_lit0, buffer, pos); + pos = writeByte(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 = writeByte(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 = writeByte((byte) (DW_OP_lit0 + mask), buffer, pos); + pos = writeByte(DW_OP_not, buffer, pos); + pos = writeByte(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 = writeByte((byte) (DW_OP_lit0 + rightShift), buffer, pos); + pos = writeByte(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 = writeByte((byte) (DW_OP_lit0 + leftShift), buffer, pos); + pos = writeByte(DW_OP_shl, buffer, pos); } } /* add the resulting offset to the heapbase register */ - byte regOp = (byte) (DwarfDebugInfo.DW_OP_breg0 + dwarfSections.getHeapbaseRegister()); + byte regOp = (byte) (DW_OP_breg0 + dwarfSections.getHeapbaseRegister()); pos = writeByte(regOp, buffer, pos); pos = writeSLEB(0, buffer, pos); /* 1 byte. */ - pos = writeByte(DwarfDebugInfo.DW_OP_plus, buffer, pos); + pos = writeByte(DW_OP_plus, buffer, pos); assert pos == skipStart + offsetToEnd; /* make sure we added up correctly */ @@ -1999,7 +1999,7 @@ public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, in /** * The debug_info section depends on loc section. */ - protected static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_LOC_SECTION_NAME; + protected static final String TARGET_SECTION_NAME = DW_LOC_SECTION_NAME; @Override public String targetSectionName() { 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..70999f2dedaf 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 @@ -47,97 +47,19 @@ public class DwarfLineSectionImpl extends DwarfSectionImpl { /** * 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); @@ -145,7 +67,7 @@ public class DwarfLineSectionImpl extends DwarfSectionImpl { @Override public String getSectionName() { - return DwarfDebugInfo.DW_LINE_SECTION_NAME; + return DW_LINE_SECTION_NAME; } @Override @@ -203,7 +125,7 @@ private static int headerSize() { * */ - return DW_LN_HEADER_SIZE; + return LN_HEADER_SIZE; } private int computeDirTableSize(ClassEntry classEntry) { @@ -318,7 +240,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 = writeShort(DW_VERSION_4, buffer, pos); /* * 4 ubyte prologue length includes rest of header and dir + file table section. */ @@ -339,15 +261,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. */ @@ -785,17 +707,17 @@ private int writeDefineFileOp(DebugContext context, String file, long uleb1, lon 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 +732,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; } - 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; } @@ -856,7 +778,7 @@ private static boolean isFixedAdvancePC(long addressDiff) { /** * The debug_line section depends on debug_str section. */ - private static final String TARGET_SECTION_NAME = DwarfDebugInfo.DW_STR_SECTION_NAME; + private static final String TARGET_SECTION_NAME = DW_STR_SECTION_NAME; @Override public String targetSectionName() { 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..07ae54086a2d 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; @@ -79,7 +77,7 @@ public DwarfLocSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DwarfDebugInfo.DW_LOC_SECTION_NAME; + return DW_LOC_SECTION_NAME; } @Override @@ -247,7 +245,7 @@ private int writeRegisterLocation(DebugContext context, int regIndex, byte[] buf if (targetIdx < 32) { // can write using DW_OP_reg short byteCount = 1; - byte regOp = (byte) (DwarfDebugInfo.DW_OP_reg0 + targetIdx); + byte regOp = (byte) (DW_OP_reg0 + targetIdx); pos = writeShort(byteCount, buffer, pos); pos = writeByte(regOp, buffer, pos); verboseLog(context, " [0x%08x] REGOP count %d op 0x%x", pos, byteCount, regOp); @@ -255,7 +253,7 @@ private int writeRegisterLocation(DebugContext context, int regIndex, byte[] buf // 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; + byte regOp = DW_OP_regx; pos = writeShort(byteCount, buffer, pos); pos = writeByte(regOp, buffer, pos); pos = writeULEB(targetIdx, buffer, pos); @@ -273,17 +271,17 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer, byte stackOp; if (sp < 32) { // fold the base reg index into the op - stackOp = DwarfDebugInfo.DW_OP_breg0; + stackOp = DW_OP_breg0; stackOp += (byte) sp; } else { // pass base reg index as a ULEB operand - stackOp = DwarfDebugInfo.DW_OP_bregx; + stackOp = DW_OP_bregx; } int patchPos = pos; pos = writeShort(byteCount, buffer, pos); int zeroPos = pos; pos = writeByte(stackOp, buffer, pos); - if (stackOp == DwarfDebugInfo.DW_OP_bregx) { + if (stackOp == DW_OP_bregx) { // need to pass base reg index as a ULEB operand pos = writeULEB(sp, buffer, pos); } @@ -291,7 +289,7 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer, // now backpatch the byte count byteCount = (byte) (pos - zeroPos); writeShort(byteCount, buffer, patchPos); - if (stackOp == DwarfDebugInfo.DW_OP_bregx) { + if (stackOp == DW_OP_bregx) { verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x offset %d", pos, byteCount, stackOp, 0 - offset); } else { verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x reg %d offset %d", pos, byteCount, stackOp, sp, 0 - offset); @@ -419,7 +417,7 @@ public static List coalesce(DebugLocalInfo local, List Date: Sun, 30 Jul 2023 10:53:52 +0100 Subject: [PATCH 2/7] Use an enum for DIE abbrev codes --- .../elf/dwarf/DwarfAbbrevSectionImpl.java | 462 +++++++++--------- .../objectfile/elf/dwarf/DwarfConstants.java | 105 ++-- .../objectfile/elf/dwarf/DwarfDebugInfo.java | 108 ++-- .../elf/dwarf/DwarfInfoSectionImpl.java | 130 ++--- .../elf/dwarf/DwarfSectionImpl.java | 5 +- 5 files changed, 393 insertions(+), 417 deletions(-) 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 32310771023a..d670b535372f 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 @@ -28,6 +28,7 @@ import com.oracle.objectfile.LayoutDecision; 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 +78,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 +96,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. * *
    * @@ -109,56 +110,56 @@ * *
      * - *
    • 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. * *
    * @@ -166,30 +167,31 @@ * *
      * - *
    • 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 * *
    * @@ -197,20 +199,20 @@ * *
      * - *
    • 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 * *
    * * Detailed layouts of the DIEs listed above are as follows: *

    * - * 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 +223,12 @@ * *
    * - * Instances of the level 0 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 +237,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 +256,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 +268,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 +280,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 +294,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 +315,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 +337,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 +348,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 +390,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 +401,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 +440,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 +480,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 +503,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 +527,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 +535,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 +562,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 +576,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 +605,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 +625,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 +664,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 +679,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 +697,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 +705,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 +730,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 +761,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 +777,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 +803,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 * @@ -938,13 +938,13 @@ private int writeAttrForm(long code, byte[] buffer, int pos) { private int writeCompileUnitAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.ABBREV_CODE_builtin_unit, buffer, pos); - pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.ABBREV_CODE_class_unit1, buffer, pos); - pos = writeCompileUnitAbbrev(context, DwarfDebugInfo.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(DW_TAG_compile_unit, buffer, pos); @@ -957,7 +957,7 @@ private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext cont pos = writeAttrForm(DW_FORM_strp, buffer, pos); pos = writeAttrType(DW_AT_comp_dir, buffer, pos); pos = writeAttrForm(DW_FORM_strp, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_class_unit2) { + if (abbrevCode == AbbrevCode.CLASS_UNIT_2) { pos = writeAttrType(DW_AT_ranges, buffer, pos); pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); pos = writeAttrType(DW_AT_low_pc, buffer, pos); @@ -975,7 +975,7 @@ private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext cont private int writePrimitiveTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_primitive_type, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.PRIMITIVE_TYPE, buffer, pos); pos = writeTag(DW_TAG_base_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_byte_size, buffer, pos); @@ -996,7 +996,7 @@ private int writePrimitiveTypeAbbrev(@SuppressWarnings("unused") DebugContext co private int writeVoidTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_void_type, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.VOID_TYPE, buffer, pos); pos = writeTag(DW_TAG_unspecified_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1011,7 +1011,7 @@ private int writeVoidTypeAbbrev(@SuppressWarnings("unused") DebugContext context private int writeObjectHeaderAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_object_header, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.OBJECT_HEADER, buffer, pos); pos = writeTag(DW_TAG_structure_type, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1028,7 +1028,7 @@ private int writeObjectHeaderAbbrev(@SuppressWarnings("unused") DebugContext con private int writeNamespaceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_namespace, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.NAMESPACE, buffer, pos); pos = writeTag(DW_TAG_namespace, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1043,14 +1043,14 @@ private int writeNamespaceAbbrev(@SuppressWarnings("unused") DebugContext contex private int writeClassLayoutAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeClassLayoutAbbrev(context, DwarfDebugInfo.ABBREV_CODE_class_layout1, buffer, pos); + pos = writeClassLayoutAbbrev(context, AbbrevCode.CLASS_LAYOUT_1, buffer, pos); if (!dwarfSections.useHeapBase()) { - pos = writeClassLayoutAbbrev(context, DwarfDebugInfo.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); @@ -1067,7 +1067,7 @@ private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos); pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos); */ - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_class_layout2) { + if (abbrevCode == AbbrevCode.CLASS_LAYOUT_2) { pos = writeAttrType(DW_AT_data_location, buffer, pos); pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); } @@ -1084,7 +1084,7 @@ private int writeClassReferenceAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; /* A pointer to the class struct type. */ - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_class_pointer, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.CLASS_POINTER, buffer, pos); pos = writeTag(DW_TAG_pointer_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_byte_size, buffer, pos); @@ -1101,12 +1101,12 @@ private int writeClassReferenceAbbrev(@SuppressWarnings("unused") DebugContext c private int writeMethodDeclarationAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeMethodDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_declaration, buffer, pos); - pos = writeMethodDeclarationAbbrev(context, DwarfDebugInfo.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(DW_TAG_subprogram, buffer, pos); @@ -1134,7 +1134,7 @@ private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContex // pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos); pos = writeAttrType(DW_AT_containing_type, buffer, pos); pos = writeAttrForm(DW_FORM_ref4, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_declaration) { + if (abbrevCode == AbbrevCode.METHOD_DECLARATION) { pos = writeAttrType(DW_AT_object_pointer, buffer, pos); pos = writeAttrForm(DW_FORM_ref4, buffer, pos); } @@ -1149,17 +1149,17 @@ private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContex private int writeFieldDeclarationAbbrevs(DebugContext context, byte[] buffer, int p) { int pos = p; /* An instance field no line and file. */ - pos = writeFieldDeclarationAbbrev(context, DwarfDebugInfo.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.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.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.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(DW_TAG_member, buffer, pos); @@ -1167,7 +1167,7 @@ private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext pos = writeAttrType(DW_AT_name, buffer, pos); pos = writeAttrForm(DW_FORM_strp, buffer, pos); /* We may not have a file and line for a field. */ - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration2 || abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration4) { + if (abbrevCode == AbbrevCode.FIELD_DECLARATION_2 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { pos = writeAttrType(DW_AT_decl_file, buffer, pos); pos = writeAttrForm(DW_FORM_data2, buffer, pos); /* At present we definitely don't have line numbers. */ @@ -1176,7 +1176,7 @@ private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext } pos = writeAttrType(DW_AT_type, buffer, pos); pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration1 || abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration2) { + 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(DW_AT_data_member_location, buffer, pos); pos = writeAttrForm(DW_FORM_data2, buffer, pos); @@ -1184,7 +1184,7 @@ private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext pos = writeAttrType(DW_AT_accessibility, buffer, pos); pos = writeAttrForm(DW_FORM_data1, buffer, pos); /* Static fields are only declared here and are external. */ - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration3 || abbrevCode == DwarfDebugInfo.ABBREV_CODE_field_declaration4) { + if (abbrevCode == AbbrevCode.FIELD_DECLARATION_3 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { pos = writeAttrType(DW_AT_external, buffer, pos); pos = writeAttrForm(DW_FORM_flag, buffer, pos); pos = writeAttrType(DW_AT_declaration, buffer, pos); @@ -1200,7 +1200,7 @@ private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext private int writeClassConstantAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_class_constant, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.CLASS_CONSTANT, buffer, pos); pos = writeTag(DW_TAG_constant, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1227,7 +1227,7 @@ private int writeClassConstantAbbrev(@SuppressWarnings("unused") DebugContext co private int writeArrayLayoutAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_array_layout, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.ARRAY_LAYOUT, buffer, pos); pos = writeTag(DW_TAG_class_type, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1245,7 +1245,7 @@ private int writeArrayLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont private int writeArrayReferenceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_array_pointer, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.ARRAY_POINTER, buffer, pos); pos = writeTag(DW_TAG_pointer_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_byte_size, buffer, pos); @@ -1263,7 +1263,7 @@ private int writeArrayReferenceAbbrev(@SuppressWarnings("unused") DebugContext c private int writeInterfaceLayoutAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_interface_layout, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.INTERFACE_LAYOUT, buffer, pos); pos = writeTag(DW_TAG_union_type, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1279,7 +1279,7 @@ private int writeInterfaceLayoutAbbrev(@SuppressWarnings("unused") DebugContext private int writeInterfaceReferenceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_interface_pointer, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.INTERFACE_POINTER, buffer, pos); pos = writeTag(DW_TAG_pointer_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_byte_size, buffer, pos); @@ -1297,7 +1297,7 @@ private int writeInterfaceReferenceAbbrev(@SuppressWarnings("unused") DebugConte private int writeInterfaceImplementorAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_interface_implementor, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.INTERFACE_IMPLEMENTOR, buffer, pos); pos = writeTag(DW_TAG_member, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1318,7 +1318,7 @@ private int writeForeignReferenceAbbrev(@SuppressWarnings("unused") DebugContext int pos = p; /* A pointer to the class struct type. */ - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_foreign_pointer, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.FOREIGN_POINTER, buffer, pos); pos = writeTag(DW_TAG_pointer_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_byte_size, buffer, pos); @@ -1340,7 +1340,7 @@ private int writeForeignTypedefAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; /* A pointer to the class struct type. */ - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_foreign_typedef, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.FOREIGN_TYPEDEF, buffer, pos); pos = writeTag(DW_TAG_typedef, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1359,7 +1359,7 @@ private int writeForeignStructAbbrev(@SuppressWarnings("unused") DebugContext co int pos = p; /* A pointer to the class struct type. */ - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_foreign_struct, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.FOREIGN_STRUCT, buffer, pos); pos = writeTag(DW_TAG_structure_type, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1377,7 +1377,7 @@ private int writeForeignStructAbbrev(@SuppressWarnings("unused") DebugContext co private int writeHeaderFieldAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_header_field, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.HEADER_FIELD, buffer, pos); pos = writeTag(DW_TAG_member, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1398,19 +1398,19 @@ private int writeHeaderFieldAbbrev(@SuppressWarnings("unused") DebugContext cont private int writeArrayDataTypeAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeArrayDataTypeAbbrev(context, DwarfDebugInfo.ABBREV_CODE_array_data_type1, buffer, pos); - pos = writeArrayDataTypeAbbrev(context, DwarfDebugInfo.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(DW_TAG_array_type, buffer, pos); - boolean hasChildren = (abbrevCode == DwarfDebugInfo.ABBREV_CODE_array_data_type2); + boolean hasChildren = (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2); pos = writeFlag((hasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no), buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_array_data_type2) { + if (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2) { pos = writeAttrType(DW_AT_byte_size, buffer, pos); pos = writeAttrForm(DW_FORM_data4, buffer, pos); } @@ -1431,7 +1431,7 @@ private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext co private int writeArraySubrangeTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_array_subrange, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.ARRAY_SUBRANGE, buffer, pos); pos = writeTag(DW_TAG_subrange_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_count, buffer, pos); @@ -1446,7 +1446,7 @@ private int writeArraySubrangeTypeAbbrev(@SuppressWarnings("unused") DebugContex private int writeMethodLocationAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_method_location, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.METHOD_LOCATION, buffer, pos); pos = writeTag(DW_TAG_subprogram, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_low_pc, buffer, pos); @@ -1467,7 +1467,7 @@ private int writeMethodLocationAbbrev(@SuppressWarnings("unused") DebugContext c private int writeAbstractInlineMethodAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_abstract_inline_method, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.ABSTRACT_INLINE_METHOD, buffer, pos); pos = writeTag(DW_TAG_subprogram, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_inline, buffer, pos); @@ -1487,7 +1487,7 @@ private int writeAbstractInlineMethodAbbrev(@SuppressWarnings("unused") DebugCon private int writeStaticFieldLocationAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_static_field_location, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.STATIC_FIELD_LOCATION, buffer, pos); pos = writeTag(DW_TAG_variable, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_specification, buffer, pos); @@ -1507,7 +1507,7 @@ private int writeStaticFieldLocationAbbrev(@SuppressWarnings("unused") DebugCont private int writeSuperReferenceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_super_reference, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.SUPER_REFERENCE, buffer, pos); pos = writeTag(DW_TAG_inheritance, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_type, buffer, pos); @@ -1535,7 +1535,7 @@ 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.ABBREV_CODE_indirect_layout, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.INDIRECT_LAYOUT, buffer, pos); pos = writeTag(DW_TAG_class_type, buffer, pos); pos = writeFlag(DW_CHILDREN_yes, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); @@ -1558,7 +1558,7 @@ private int writeIndirectReferenceAbbrev(@SuppressWarnings("unused") DebugContex int pos = p; /* The type for a pointer to the indirect layout type. */ - pos = writeAbbrevCode(DwarfDebugInfo.ABBREV_CODE_indirect_pointer, buffer, pos); + pos = writeAbbrevCode(AbbrevCode.INDIRECT_POINTER, buffer, pos); pos = writeTag(DW_TAG_pointer_type, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_byte_size, buffer, pos); @@ -1575,20 +1575,20 @@ private int writeIndirectReferenceAbbrev(@SuppressWarnings("unused") DebugContex private int writeParameterDeclarationAbbrevs(DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration1, buffer, pos); - pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration2, buffer, pos); - pos = writeParameterDeclarationAbbrev(context, DwarfDebugInfo.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(DW_TAG_formal_parameter, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); pos = writeAttrForm(DW_FORM_strp, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration2) { + if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_2) { /* Line numbers for parameter declarations are not (yet?) available. */ pos = writeAttrType(DW_AT_decl_file, buffer, pos); pos = writeAttrForm(DW_FORM_data2, buffer, pos); @@ -1597,7 +1597,7 @@ private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugCon } pos = writeAttrType(DW_AT_type, buffer, pos); pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration1) { + if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_1) { /* Only this parameter is artificial and it has no line. */ pos = writeAttrType(DW_AT_artificial, buffer, pos); pos = writeAttrForm(DW_FORM_flag, buffer, pos); @@ -1614,19 +1614,19 @@ private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugCon private int writeLocalDeclarationAbbrevs(DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeLocalDeclarationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_local_declaration1, buffer, pos); - pos = writeLocalDeclarationAbbrev(context, DwarfDebugInfo.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(DW_TAG_variable, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_name, buffer, pos); pos = writeAttrForm(DW_FORM_strp, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_local_declaration1) { + if (abbrevCode == AbbrevCode.METHOD_LOCAL_DECLARATION_1) { /* Line numbers for parameter declarations are not (yet?) available. */ pos = writeAttrType(DW_AT_decl_file, buffer, pos); pos = writeAttrForm(DW_FORM_data2, buffer, pos); @@ -1647,26 +1647,26 @@ private int writeLocalDeclarationAbbrev(@SuppressWarnings("unused") DebugContext private int writeParameterLocationAbbrevs(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeParameterLocationAbbrev(context, DwarfDebugInfo.ABBREV_CODE_method_parameter_location1, buffer, pos); - pos = writeParameterLocationAbbrev(context, DwarfDebugInfo.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.ABBREV_CODE_method_local_location1, buffer, pos); - pos = writeLocalLocationAbbrev(context, DwarfDebugInfo.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(DW_TAG_formal_parameter, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); pos = writeAttrForm(DW_FORM_ref4, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_parameter_location2) { + if (abbrevCode == AbbrevCode.METHOD_PARAMETER_LOCATION_2) { pos = writeAttrType(DW_AT_location, buffer, pos); pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); } @@ -1678,14 +1678,14 @@ private int writeParameterLocationAbbrev(@SuppressWarnings("unused") DebugContex 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(DW_TAG_variable, buffer, pos); pos = writeFlag(DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); pos = writeAttrForm(DW_FORM_ref4, buffer, pos); - if (abbrevCode == DwarfDebugInfo.ABBREV_CODE_method_local_location2) { + if (abbrevCode == AbbrevCode.METHOD_LOCAL_LOCATION_2) { pos = writeAttrType(DW_AT_location, buffer, pos); pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); } @@ -1699,13 +1699,13 @@ private int writeLocalLocationAbbrev(@SuppressWarnings("unused") DebugContext co private int writeNullAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; - pos = writeAbbrevCode(DwarfDebugInfo.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.ABBREV_CODE_inlined_subroutine_with_children : DwarfDebugInfo.ABBREV_CODE_inlined_subroutine, buffer, pos); + pos = writeAbbrevCode(withChildren ? AbbrevCode.INLINED_SUBROUTINE_WITH_CHILDREN : AbbrevCode.INLINED_SUBROUTINE, buffer, pos); pos = writeTag(DW_TAG_inlined_subroutine, buffer, pos); pos = writeFlag(withChildren ? DW_CHILDREN_yes : DW_CHILDREN_no, buffer, pos); pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java index 7a3283b099cf..e7985a20a6fe 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java @@ -27,19 +27,19 @@ package com.oracle.objectfile.elf.dwarf; /** - * An interface that provides definitions for a variety of constants defined - * by the DWARF standard, employing the same names and types. The primary - * reference for these constants is the DWARF Debugging Information Format - * Version 4 Specification published at dwarfstd.org.

                      + * An interface that provides definitions for a variety of constants defined by the DWARF standard, + * employing the same names and types. The primary reference for these constants is the DWARF + * Debugging Information Format Version 4 Specification published at dwarfstd.org. + *

                      * - * Note that this is not an exhaustive list of all DWARF constants. It merely - * includes constants that are needed by GraalVM. + * Note that this is not an exhaustive list of all DWARF constants. It merely includes constants + * that are needed by GraalVM. */ public interface DwarfConstants { /* - * Names of the different ELF sections we create in reverse dependency order. The - * sequence starts with the name of the text section (not defined in the DWARF spec - * and not created by debug info code). + * Names of the different ELF sections we create in reverse dependency order. The sequence + * starts with the name of the text section (not defined in the DWARF spec and not created by + * debug info code). */ String TEXT_SECTION_NAME = ".text"; String DW_STR_SECTION_NAME = ".debug_str"; @@ -52,8 +52,8 @@ public interface DwarfConstants { String DW_RANGES_SECTION_NAME = ".debug_ranges"; /** - * Currently generated debug info relies on DWARF spec version 4. However, - * some sections may still need to be generated as version 2. + * Currently generated debug info relies on DWARF spec version 4. However, some sections may + * still need to be generated as version 2. */ short DW_VERSION_2 = 2; short DW_VERSION_4 = 4; @@ -100,17 +100,14 @@ public interface DwarfConstants { int DW_AT_artificial = 0x34; int DW_AT_count = 0x37; int DW_AT_data_member_location = 0x38; - @SuppressWarnings("unused") - int DW_AT_decl_column = 0x39; + @SuppressWarnings("unused") int DW_AT_decl_column = 0x39; int DW_AT_decl_file = 0x3a; int DW_AT_decl_line = 0x3b; int DW_AT_declaration = 0x3c; int DW_AT_encoding = 0x3e; int DW_AT_external = 0x3f; - @SuppressWarnings("unused") - int DW_AT_return_addr = 0x2a; - @SuppressWarnings("unused") - int DW_AT_frame_base = 0x40; + @SuppressWarnings("unused") int DW_AT_return_addr = 0x2a; + @SuppressWarnings("unused") int DW_AT_frame_base = 0x40; int DW_AT_specification = 0x47; int DW_AT_type = 0x49; int DW_AT_data_location = 0x50; @@ -128,21 +125,14 @@ public interface DwarfConstants { int DW_FORM_addr = 0x1; int DW_FORM_data2 = 0x05; int DW_FORM_data4 = 0x6; - @SuppressWarnings("unused") - int DW_FORM_data8 = 0x7; - @SuppressWarnings("unused") - int DW_FORM_string = 0x8; - @SuppressWarnings("unused") - int DW_FORM_block1 = 0x0a; + @SuppressWarnings("unused") int DW_FORM_data8 = 0x7; + @SuppressWarnings("unused") int DW_FORM_string = 0x8; + @SuppressWarnings("unused") int DW_FORM_block1 = 0x0a; int DW_FORM_ref_addr = 0x10; - @SuppressWarnings("unused") - int DW_FORM_ref1 = 0x11; - @SuppressWarnings("unused") - int DW_FORM_ref2 = 0x12; - @SuppressWarnings("unused") - int DW_FORM_ref4 = 0x13; - @SuppressWarnings("unused") - int DW_FORM_ref8 = 0x14; + @SuppressWarnings("unused") int DW_FORM_ref1 = 0x11; + @SuppressWarnings("unused") int DW_FORM_ref2 = 0x12; + @SuppressWarnings("unused") int DW_FORM_ref4 = 0x13; + @SuppressWarnings("unused") int DW_FORM_ref8 = 0x14; int DW_FORM_sec_offset = 0x17; int DW_FORM_data1 = 0x0b; int DW_FORM_flag = 0xc; @@ -150,8 +140,8 @@ public interface DwarfConstants { int DW_FORM_expr_loc = 0x18; /* - * The following constants correspond to pre-defined value ranges appropriate - * to a specific attribute or form. + * The following constants correspond to pre-defined value ranges appropriate to a specific + * attribute or form. */ /* @@ -163,8 +153,7 @@ public interface DwarfConstants { /* * DW_FORM_flag haas two possible attribute values. */ - @SuppressWarnings("unused") - byte DW_FLAG_false = 0; + @SuppressWarnings("unused") byte DW_FLAG_false = 0; byte DW_FLAG_true = 1; /* @@ -175,36 +164,28 @@ public interface DwarfConstants { /* * Values for DW_AT_inline attribute with form DATA1. */ - @SuppressWarnings("unused") - byte DW_INL_not_inlined = 0; + @SuppressWarnings("unused") byte DW_INL_not_inlined = 0; byte DW_INL_inlined = 1; - @SuppressWarnings("unused") - byte DW_INL_declared_not_inlined = 2; - @SuppressWarnings("unused") - byte DW_INL_declared_inlined = 3; + @SuppressWarnings("unused") byte DW_INL_declared_not_inlined = 2; + @SuppressWarnings("unused") byte DW_INL_declared_inlined = 3; /* * DW_AT_Accessibility attribute values. */ - @SuppressWarnings("unused") - byte DW_ACCESS_public = 1; - @SuppressWarnings("unused") - byte DW_ACCESS_protected = 2; - @SuppressWarnings("unused") - byte DW_ACCESS_private = 3; + @SuppressWarnings("unused") byte DW_ACCESS_public = 1; + @SuppressWarnings("unused") byte DW_ACCESS_protected = 2; + @SuppressWarnings("unused") byte DW_ACCESS_private = 3; /* * DW_AT_encoding attribute values */ - @SuppressWarnings("unused") - byte DW_ATE_address = 0x1; + @SuppressWarnings("unused") byte DW_ATE_address = 0x1; byte DW_ATE_boolean = 0x2; byte DW_ATE_float = 0x4; byte DW_ATE_signed = 0x5; byte DW_ATE_signed_char = 0x6; byte DW_ATE_unsigned = 0x7; - @SuppressWarnings("unused") - byte DW_ATE_unsigned_char = 0x8; + @SuppressWarnings("unused") byte DW_ATE_unsigned_char = 0x8; /* * Constants that appear in CIE and FDE frame section entries. @@ -216,31 +197,24 @@ public interface DwarfConstants { byte DW_CFA_restore = 0x3; /* Values encoded in low 6 bits. */ byte DW_CFA_nop = 0x0; - @SuppressWarnings("unused") - byte DW_CFA_set_loc1 = 0x1; + @SuppressWarnings("unused") byte DW_CFA_set_loc1 = 0x1; byte DW_CFA_advance_loc1 = 0x2; byte DW_CFA_advance_loc2 = 0x3; byte DW_CFA_advance_loc4 = 0x4; - @SuppressWarnings("unused") - byte DW_CFA_offset_extended = 0x5; - @SuppressWarnings("unused") - byte DW_CFA_restore_extended = 0x6; - @SuppressWarnings("unused") - byte DW_CFA_undefined = 0x7; - @SuppressWarnings("unused") - byte DW_CFA_same_value = 0x8; + @SuppressWarnings("unused") byte DW_CFA_offset_extended = 0x5; + @SuppressWarnings("unused") byte DW_CFA_restore_extended = 0x6; + @SuppressWarnings("unused") byte DW_CFA_undefined = 0x7; + @SuppressWarnings("unused") byte DW_CFA_same_value = 0x8; byte DW_CFA_register = 0x9; byte DW_CFA_def_cfa = 0xc; - @SuppressWarnings("unused") - byte DW_CFA_def_cfa_register = 0xd; + @SuppressWarnings("unused") byte DW_CFA_def_cfa_register = 0xd; byte DW_CFA_def_cfa_offset = 0xe; /* * Values used to build DWARF expressions and locations */ byte DW_OP_addr = 0x03; - @SuppressWarnings("unused") - byte DW_OP_deref = 0x06; + @SuppressWarnings("unused") byte DW_OP_deref = 0x06; byte DW_OP_dup = 0x12; byte DW_OP_and = 0x1a; byte DW_OP_not = 0x20; @@ -335,5 +309,4 @@ public interface DwarfConstants { * Set file as explicit string argument. */ byte DW_LNE_define_file = 3; - } 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 4c1d98d11677..0805e4cc3bbb 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 @@ -51,59 +51,61 @@ public class DwarfDebugInfo extends DebugInfoBase implements DwarfConstants { /* * Define all the abbrev section codes we need for our DIEs. */ - public static final int ABBREV_CODE_null = 0; - /* Level 0 DIEs. */ - public static final int ABBREV_CODE_builtin_unit = 1; - public static final int ABBREV_CODE_class_unit1 = 2; - public static final int ABBREV_CODE_class_unit2 = 3; - /* Level 1 DIEs. */ - public static final int ABBREV_CODE_primitive_type = 4; - public static final int ABBREV_CODE_void_type = 5; - public static final int ABBREV_CODE_object_header = 6; - public static final int ABBREV_CODE_namespace = 7; - public static final int ABBREV_CODE_class_layout1 = 8; - public static final int ABBREV_CODE_class_layout2 = 9; - public static final int ABBREV_CODE_class_pointer = 10; - public static final int ABBREV_CODE_foreign_pointer = 11; - public static final int ABBREV_CODE_foreign_typedef = 12; - public static final int ABBREV_CODE_foreign_struct = 13; - public static final int ABBREV_CODE_method_location = 14; - public static final int ABBREV_CODE_static_field_location = 15; - public static final int ABBREV_CODE_array_layout = 16; - public static final int ABBREV_CODE_array_pointer = 17; - public static final int ABBREV_CODE_interface_layout = 18; - public static final int ABBREV_CODE_interface_pointer = 19; - public static final int ABBREV_CODE_indirect_layout = 20; - public static final int ABBREV_CODE_indirect_pointer = 21; - /* Level 2 DIEs. */ - public static final int ABBREV_CODE_method_declaration = 22; - public static final int ABBREV_CODE_method_declaration_static = 23; - public static final int ABBREV_CODE_field_declaration1 = 24; - public static final int ABBREV_CODE_field_declaration2 = 25; - public static final int ABBREV_CODE_field_declaration3 = 26; - public static final int ABBREV_CODE_field_declaration4 = 27; - public static final int ABBREV_CODE_class_constant = 28; - public static final int ABBREV_CODE_header_field = 29; - public static final int ABBREV_CODE_array_data_type1 = 30; - public static final int ABBREV_CODE_array_data_type2 = 31; - public static final int ABBREV_CODE_array_subrange = 32; - public static final int ABBREV_CODE_super_reference = 33; - public static final int ABBREV_CODE_interface_implementor = 34; - /* Level 2+K DIEs (where inline depth K >= 0) */ - public static final int ABBREV_CODE_inlined_subroutine = 35; - public static final int ABBREV_CODE_inlined_subroutine_with_children = 36; - public static final int ABBREV_CODE_abstract_inline_method = 37; - /* Level 2 DIEs. */ - public static final int ABBREV_CODE_method_parameter_declaration1 = 38; - public static final int ABBREV_CODE_method_parameter_declaration2 = 39; - public static final int ABBREV_CODE_method_parameter_declaration3 = 40; - public static final int ABBREV_CODE_method_local_declaration1 = 41; - public static final int ABBREV_CODE_method_local_declaration2 = 42; - /* Level 3 DIEs. */ - public static final int ABBREV_CODE_method_parameter_location1 = 43; - public static final int ABBREV_CODE_method_parameter_location2 = 44; - public static final int ABBREV_CODE_method_local_location1 = 45; - public static final int ABBREV_CODE_method_local_location2 = 46; + 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, + } /** * This field defines the value used for the DW_AT_language attribute of compile units. 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 854449e43968..8dfc3f074c7f 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 @@ -54,6 +54,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; @@ -176,7 +177,7 @@ private int writeBuiltInTypes(DebugContext context, byte[] buffer, int p) { cuStart = p; pos = writeCUHeader(buffer, pos); assert pos == lengthPos + DIE_HEADER_SIZE; - int abbrevCode = DwarfDebugInfo.ABBREV_CODE_builtin_unit; + 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"); @@ -233,7 +234,7 @@ public int writePrimitiveType(DebugContext context, PrimitiveTypeEntry primitive * might want an indirect type */ setIndirectTypeIndex(primitiveTypeEntry, pos); - int abbrevCode = DwarfDebugInfo.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(); @@ -265,7 +266,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.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 +286,7 @@ public int writeHeaderType(DebugContext context, HeaderTypeEntry headerTypeEntry * want an indirect type. */ setIndirectTypeIndex(headerTypeEntry, pos); - int abbrevCode = DwarfDebugInfo.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 +350,7 @@ private int writeStructField(DebugContext context, FieldEntry fieldEntry, byte[] valueTypeIdx = getIndirectTypeIndex(valueType); } log(context, " [0x%08x] struct field", pos); - int abbrevCode = DwarfDebugInfo.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); @@ -384,7 +385,7 @@ private int writeInstanceClassInfo(DebugContext context, ClassEntry classEntry, log(context, " [0x%08x] Instance class unit", pos); pos = writeCUHeader(buffer, pos); assert pos == lengthPos + DIE_HEADER_SIZE; - int abbrevCode = (classEntry.hasCompiledEntries() ? DwarfDebugInfo.ABBREV_CODE_class_unit2 : DwarfDebugInfo.ABBREV_CODE_class_unit1); + 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"); @@ -400,7 +401,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.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 +471,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.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 +488,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.ABBREV_CODE_class_constant; + AbbrevCode abbrevCode = AbbrevCode.CLASS_CONSTANT; log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); @@ -522,13 +523,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.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.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 +542,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.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 +576,7 @@ private int writeClassLayout(DebugContext context, ClassEntry classEntry, byte[] */ setIndirectLayoutIndex(classEntry, pos); log(context, " [0x%08x] indirect class layout", pos); - abbrevCode = DwarfDebugInfo.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 +605,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.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 +634,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.ABBREV_CODE_field_declaration1; + abbrevCode = AbbrevCode.FIELD_DECLARATION_1; } else { - abbrevCode = DwarfDebugInfo.ABBREV_CODE_field_declaration2; + abbrevCode = AbbrevCode.FIELD_DECLARATION_2; } } else { if (!hasFile) { - abbrevCode = DwarfDebugInfo.ABBREV_CODE_field_declaration3; + abbrevCode = AbbrevCode.FIELD_DECLARATION_3; } else { - abbrevCode = DwarfDebugInfo.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); @@ -709,7 +710,7 @@ 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.ABBREV_CODE_method_declaration_static : DwarfDebugInfo.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); @@ -743,7 +744,7 @@ private int writeMethodDeclaration(DebugContext context, ClassEntry classEntry, 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.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 +789,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.ABBREV_CODE_method_parameter_declaration1; + abbrevCode = AbbrevCode.METHOD_PARAMETER_DECLARATION_1; } else if (line >= 0) { - abbrevCode = DwarfDebugInfo.ABBREV_CODE_method_parameter_declaration2; + abbrevCode = AbbrevCode.METHOD_PARAMETER_DECLARATION_2; } else { - abbrevCode = DwarfDebugInfo.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.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,7 +813,7 @@ 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.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); } @@ -837,20 +838,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.ABBREV_CODE_method_local_declaration1; + abbrevCode = AbbrevCode.METHOD_LOCAL_DECLARATION_1; } else { - abbrevCode = DwarfDebugInfo.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.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); @@ -869,7 +870,7 @@ private int writeInterfaceLayout(DebugContext context, InterfaceClassEntry inter int layoutOffset = pos; setLayoutIndex(interfaceClassEntry, layoutOffset); log(context, " [0x%08x] interface layout", pos); - int abbrevCode = DwarfDebugInfo.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 +894,7 @@ private int writeInterfaceLayout(DebugContext context, InterfaceClassEntry inter */ setIndirectLayoutIndex(interfaceClassEntry, pos); log(context, " [0x%08x] indirect class layout", pos); - abbrevCode = DwarfDebugInfo.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 +928,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.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 +994,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.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 +1029,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.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; @@ -1051,7 +1052,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.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; @@ -1074,7 +1075,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.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; @@ -1112,7 +1113,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.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 +1127,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.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 +1150,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.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 +1164,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.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 +1191,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.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 +1205,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.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 +1243,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.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 @@ -1272,7 +1273,7 @@ private int writeArray(DebugContext context, ArrayTypeEntry arrayTypeEntry, byte log(context, " [0x%08x] Array class unit", pos); pos = writeCUHeader(buffer, pos); assert pos == lengthPos + DIE_HEADER_SIZE; - int abbrevCode = DwarfDebugInfo.ABBREV_CODE_class_unit1; + 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"); @@ -1325,7 +1326,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.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 +1367,7 @@ private int writeIndirectArrayLayout(DebugContext context, ArrayTypeEntry arrayT * indirect pointer */ log(context, " [0x%08x] indirect class layout", pos); - int abbrevCode = DwarfDebugInfo.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 +1390,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.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 +1405,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.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 +1435,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.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 +1449,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.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 +1485,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.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 +1498,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.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 +1525,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.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()); @@ -1625,18 +1626,18 @@ private int writeMethodLocalLocation(DebugContext context, Range range, DebugLoc } } } - int abbrevCode; + AbbrevCode abbrevCode; if (localValues.isEmpty()) { - abbrevCode = (isParam ? DwarfDebugInfo.ABBREV_CODE_method_parameter_location1 : DwarfDebugInfo.ABBREV_CODE_method_local_location1); + abbrevCode = (isParam ? AbbrevCode.METHOD_PARAMETER_LOCATION_1 : AbbrevCode.METHOD_LOCAL_LOCATION_1); } else { - abbrevCode = (isParam ? DwarfDebugInfo.ABBREV_CODE_method_parameter_location2 : DwarfDebugInfo.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.ABBREV_CODE_method_local_location2 || - abbrevCode == DwarfDebugInfo.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 +1716,9 @@ private int writeInlineSubroutine(DebugContext context, ClassEntry classEntry, S fileIndex = classEntry.getFileIdx(); } } - final int code; - code = DwarfDebugInfo.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,7 +1778,7 @@ 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.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, DW_INL_inlined); diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java index 656bc4dd7514..d71f2791c760 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java @@ -44,6 +44,7 @@ import com.oracle.objectfile.debugentry.TypeEntry; import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalInfo; import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo; +import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo.AbbrevCode; import com.oracle.objectfile.elf.ELFMachine; import com.oracle.objectfile.elf.ELFObjectFile; import jdk.vm.ci.meta.ResolvedJavaType; @@ -419,8 +420,8 @@ 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) { From 7266269852e38e2adfabd3e0ac3a83e06c1c94f5 Mon Sep 17 00:00:00 2001 From: Andrew Dinn Date: Mon, 31 Jul 2023 10:08:36 +0100 Subject: [PATCH 3/7] Distinguish different DWARF constants and move to a dedicated package --- .../elf/dwarf/DwarfARangesSectionImpl.java | 5 +- .../elf/dwarf/DwarfAbbrevSectionImpl.java | 685 +++++++++--------- .../objectfile/elf/dwarf/DwarfConstants.java | 312 -------- .../objectfile/elf/dwarf/DwarfDebugInfo.java | 4 +- .../elf/dwarf/DwarfFrameSectionImpl.java | 28 +- .../elf/dwarf/DwarfInfoSectionImpl.java | 75 +- .../elf/dwarf/DwarfLineSectionImpl.java | 46 +- .../elf/dwarf/DwarfLocSectionImpl.java | 22 +- .../elf/dwarf/DwarfRangesSectionImpl.java | 5 +- .../elf/dwarf/DwarfSectionImpl.java | 23 +- .../elf/dwarf/DwarfStrSectionImpl.java | 5 +- .../dwarf/constants/DwarfAttributeValues.java | 70 ++ .../elf/dwarf/constants/DwarfAttributes.java | 67 ++ .../elf/dwarf/constants/DwarfConstants.java | 47 ++ .../constants/DwarfExpressionOpcodes.java | 51 ++ .../elf/dwarf/constants/DwarfForms.java | 50 ++ .../elf/dwarf/constants/DwarfFrameValues.java | 52 ++ .../elf/dwarf/constants/DwarfLineOpcodes.java | 104 +++ .../dwarf/constants/DwarfSectionNames.java | 44 ++ .../elf/dwarf/constants/DwarfTags.java | 51 ++ 20 files changed, 996 insertions(+), 750 deletions(-) delete mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributes.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfConstants.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcodes.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValues.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcodes.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionNames.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTags.java 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 fda3e8b52645..8d963a2a48dc 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,7 @@ import java.util.Map; import com.oracle.objectfile.debugentry.ClassEntry; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; import org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.LayoutDecision; @@ -51,7 +52,7 @@ public DwarfARangesSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DW_ARANGES_SECTION_NAME; + return DwarfSectionNames.DW_ARANGES_SECTION_NAME; } @Override @@ -189,7 +190,7 @@ int writeARange(DebugContext context, CompiledMethodEntry compiledMethod, byte[] /* * The debug_aranges section depends on debug_frame section. */ - private static final String TARGET_SECTION_NAME = DW_FRAME_SECTION_NAME; + private static final String TARGET_SECTION_NAME = DwarfSectionNames.DW_FRAME_SECTION_NAME; @Override public String targetSectionName() { 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 d670b535372f..7f290ea6677d 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 @@ -27,6 +27,11 @@ package com.oracle.objectfile.elf.dwarf; import com.oracle.objectfile.LayoutDecision; +import com.oracle.objectfile.elf.dwarf.constants.DwarfAttributeValues; +import com.oracle.objectfile.elf.dwarf.constants.DwarfAttributes; +import com.oracle.objectfile.elf.dwarf.constants.DwarfForms; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; +import com.oracle.objectfile.elf.dwarf.constants.DwarfTags; import org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo.AbbrevCode; @@ -834,7 +839,7 @@ public DwarfAbbrevSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DW_ABBREV_SECTION_NAME; + return DwarfSectionNames.DW_ABBREV_SECTION_NAME; } @Override @@ -947,97 +952,97 @@ private int writeCompileUnitAbbrevs(@SuppressWarnings("unused") DebugContext con private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_compile_unit, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_language, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_use_UTF8, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_comp_dir, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_compile_unit, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_language, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_use_UTF8, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_comp_dir, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); if (abbrevCode == AbbrevCode.CLASS_UNIT_2) { - pos = writeAttrType(DW_AT_ranges, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); - pos = writeAttrType(DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_stmt_list, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_ranges, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_stmt_list, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writePrimitiveTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.PRIMITIVE_TYPE, buffer, pos); - pos = writeTag(DW_TAG_base_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_bit_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_encoding, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_base_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_bit_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_encoding, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writeVoidTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.VOID_TYPE, buffer, pos); - pos = writeTag(DW_TAG_unspecified_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_unspecified_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writeObjectHeaderAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.OBJECT_HEADER, buffer, pos); - pos = writeTag(DW_TAG_structure_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_structure_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writeNamespaceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.NAMESPACE, buffer, pos); - pos = writeTag(DW_TAG_namespace, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_namespace, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1054,28 +1059,28 @@ private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_class_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_class_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DwarfForms.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 == AbbrevCode.CLASS_LAYOUT_2) { - pos = writeAttrType(DW_AT_data_location, buffer, pos); - pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_data_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1085,17 +1090,17 @@ private int writeClassReferenceAbbrev(@SuppressWarnings("unused") DebugContext c /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.CLASS_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1109,40 +1114,40 @@ private int writeMethodDeclarationAbbrevs(@SuppressWarnings("unused") DebugConte private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_subprogram, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_linkage_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_artificial, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_subprogram, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_linkage_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_artificial, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DwarfForms.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(DW_AT_containing_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_containing_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_DECLARATION) { - pos = writeAttrType(DW_AT_object_pointer, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_object_pointer, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1162,65 +1167,65 @@ private int writeFieldDeclarationAbbrevs(DebugContext context, byte[] buffer, in private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_member, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_member, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); /* We may not have a file and line for a field. */ if (abbrevCode == AbbrevCode.FIELD_DECLARATION_2 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DwarfForms.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(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.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(DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); /* Static fields are only declared here and are external. */ if (abbrevCode == AbbrevCode.FIELD_DECLARATION_3 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writeClassConstantAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.CLASS_CONSTANT, buffer, pos); - pos = writeTag(DW_TAG_constant, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_constant, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); /* We may not have a file and line for a field. */ - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_location, buffer, pos); - pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1228,17 +1233,17 @@ private int writeArrayLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_LAYOUT, buffer, pos); - pos = writeTag(DW_TAG_class_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_class_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1246,17 +1251,17 @@ private int writeArrayReferenceAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1264,15 +1269,15 @@ private int writeInterfaceLayoutAbbrev(@SuppressWarnings("unused") DebugContext int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_LAYOUT, buffer, pos); - pos = writeTag(DW_TAG_union_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_union_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1280,17 +1285,17 @@ private int writeInterfaceReferenceAbbrev(@SuppressWarnings("unused") DebugConte int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1298,19 +1303,19 @@ private int writeInterfaceImplementorAbbrev(@SuppressWarnings("unused") DebugCon int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_IMPLEMENTOR, buffer, pos); - pos = writeTag(DW_TAG_member, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_member, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1319,20 +1324,20 @@ private int writeForeignReferenceAbbrev(@SuppressWarnings("unused") DebugContext /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.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(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1341,17 +1346,17 @@ private int writeForeignTypedefAbbrev(@SuppressWarnings("unused") DebugContext c /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_TYPEDEF, buffer, pos); - pos = writeTag(DW_TAG_typedef, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_typedef, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1360,17 +1365,17 @@ private int writeForeignStructAbbrev(@SuppressWarnings("unused") DebugContext co /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_STRUCT, buffer, pos); - pos = writeTag(DW_TAG_structure_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_structure_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1378,21 +1383,21 @@ private int writeHeaderFieldAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(AbbrevCode.HEADER_FIELD, buffer, pos); - pos = writeTag(DW_TAG_member, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_member, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1407,23 +1412,23 @@ private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext co int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_array_type, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_array_type, buffer, pos); boolean hasChildren = (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2); - pos = writeFlag((hasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no), buffer, pos); + pos = writeFlag((hasChildren ? DwarfAttributeValues.DW_CHILDREN_yes : DwarfAttributeValues.DW_CHILDREN_no), buffer, pos); if (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2) { - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.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(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1432,55 +1437,55 @@ private int writeArraySubrangeTypeAbbrev(@SuppressWarnings("unused") DebugContex int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_SUBRANGE, buffer, pos); - pos = writeTag(DW_TAG_subrange_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_count, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_subrange_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_count, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writeMethodLocationAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.METHOD_LOCATION, buffer, pos); - pos = writeTag(DW_TAG_subprogram, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_hi_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_specification, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_subprogram, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_hi_pc, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_specification, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writeAbstractInlineMethodAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.ABSTRACT_INLINE_METHOD, buffer, pos); - pos = writeTag(DW_TAG_subprogram, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_inline, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_specification, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_subprogram, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_inline, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_specification, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1488,19 +1493,19 @@ private int writeStaticFieldLocationAbbrev(@SuppressWarnings("unused") DebugCont int pos = p; pos = writeAbbrevCode(AbbrevCode.STATIC_FIELD_LOCATION, buffer, pos); - pos = writeTag(DW_TAG_variable, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_specification, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_variable, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_specification, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); // pos = writeAttrType(DwarfDebugInfo.DW_AT_linkage_name, buffer, pos); // pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_location, buffer, pos); - pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1508,19 +1513,19 @@ private int writeSuperReferenceAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; pos = writeAbbrevCode(AbbrevCode.SUPER_REFERENCE, buffer, pos); - pos = writeTag(DW_TAG_inheritance, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_inheritance, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1536,20 +1541,20 @@ private int writeIndirectLayoutAbbrev(@SuppressWarnings("unused") DebugContext c */ /* the type for an indirect layout that includes address translation info */ pos = writeAbbrevCode(AbbrevCode.INDIRECT_LAYOUT, buffer, pos); - pos = writeTag(DW_TAG_class_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_class_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); /* Add a data location expression to rebase oop pointers stored as offsets. */ - pos = writeAttrType(DW_AT_data_location, buffer, pos); - pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_data_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1559,17 +1564,17 @@ private int writeIndirectReferenceAbbrev(@SuppressWarnings("unused") DebugContex /* The type for a pointer to the indirect layout type. */ pos = writeAbbrevCode(AbbrevCode.INDIRECT_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1584,31 +1589,31 @@ private int writeParameterDeclarationAbbrevs(DebugContext context, byte[] buffer private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_formal_parameter, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_formal_parameter, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_2) { /* Line numbers for parameter declarations are not (yet?) available. */ - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.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(DW_AT_artificial, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_artificial, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); } - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1622,26 +1627,26 @@ private int writeLocalDeclarationAbbrevs(DebugContext context, byte[] buffer, in private int writeLocalDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_variable, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_variable, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_LOCAL_DECLARATION_1) { /* Line numbers for parameter declarations are not (yet?) available. */ - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1662,38 +1667,38 @@ private int writeLocalLocationAbbrevs(@SuppressWarnings("unused") DebugContext c private int writeParameterLocationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_formal_parameter, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_formal_parameter, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_PARAMETER_LOCATION_2) { - pos = writeAttrType(DW_AT_location, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } private int writeLocalLocationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_variable, buffer, pos); - pos = writeFlag(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_variable, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_LOCAL_LOCATION_2) { - pos = writeAttrType(DW_AT_location, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } @@ -1706,28 +1711,28 @@ private int writeNullAbbrev(@SuppressWarnings("unused") DebugContext context, by private int writeInlinedSubroutineAbbrev(byte[] buffer, int p, boolean withChildren) { int pos = p; pos = writeAbbrevCode(withChildren ? AbbrevCode.INLINED_SUBROUTINE_WITH_CHILDREN : AbbrevCode.INLINED_SUBROUTINE, buffer, pos); - pos = writeTag(DW_TAG_inlined_subroutine, buffer, pos); - pos = writeFlag(withChildren ? DW_CHILDREN_yes : DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); - pos = writeAttrType(DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_hi_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_call_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, buffer, pos); - pos = writeAttrType(DW_AT_call_line, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, buffer, pos); + pos = writeTag(DwarfTags.DW_TAG_inlined_subroutine, buffer, pos); + pos = writeFlag(withChildren ? DwarfAttributeValues.DW_CHILDREN_yes : DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_hi_pc, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_call_file, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data4, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_call_line, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_data4, buffer, pos); /* Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); return pos; } /** * The debug_abbrev section depends on debug_ranges section. */ - private static final String TARGET_SECTION_NAME = DW_RANGES_SECTION_NAME; + private static final String TARGET_SECTION_NAME = DwarfSectionNames.DW_RANGES_SECTION_NAME; @Override public String targetSectionName() { diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java deleted file mode 100644 index e7985a20a6fe..000000000000 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfConstants.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * 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; - -/** - * An interface that provides definitions for a variety of constants defined by the DWARF standard, - * employing the same names and types. The primary reference for these constants is the DWARF - * Debugging Information Format Version 4 Specification published at dwarfstd.org. - *

                      - * - * Note that this is not an exhaustive list of all DWARF constants. It merely includes constants - * that are needed by GraalVM. - */ -public interface DwarfConstants { - /* - * Names of the different ELF sections we create in reverse dependency order. The sequence - * starts with the name of the text section (not defined in the DWARF spec and not created by - * debug info code). - */ - String TEXT_SECTION_NAME = ".text"; - String DW_STR_SECTION_NAME = ".debug_str"; - String DW_LINE_SECTION_NAME = ".debug_line"; - String DW_FRAME_SECTION_NAME = ".debug_frame"; - String DW_ABBREV_SECTION_NAME = ".debug_abbrev"; - String DW_INFO_SECTION_NAME = ".debug_info"; - String DW_LOC_SECTION_NAME = ".debug_loc"; - String DW_ARANGES_SECTION_NAME = ".debug_aranges"; - String DW_RANGES_SECTION_NAME = ".debug_ranges"; - - /** - * Currently generated debug info relies on DWARF spec version 4. However, some sections may - * still need to be generated as version 2. - */ - short DW_VERSION_2 = 2; - short DW_VERSION_4 = 4; - - /* - * All the Dwarf tags needed to type DIEs generated by GraalVM. - */ - int DW_TAG_array_type = 0x01; - int DW_TAG_class_type = 0x02; - int DW_TAG_formal_parameter = 0x05; - int DW_TAG_member = 0x0d; - int DW_TAG_pointer_type = 0x0f; - int DW_TAG_compile_unit = 0x11; - int DW_TAG_structure_type = 0x13; - int DW_TAG_typedef = 0x16; - int DW_TAG_union_type = 0x17; - int DW_TAG_inheritance = 0x1c; - int DW_TAG_subrange_type = 0x21; - int DW_TAG_base_type = 0x24; - int DW_TAG_constant = 0x27; - int DW_TAG_subprogram = 0x2e; - int DW_TAG_variable = 0x34; - int DW_TAG_namespace = 0x39; - int DW_TAG_unspecified_type = 0x3b; - int DW_TAG_inlined_subroutine = 0x1d; - - /* - * All the Dwarf attributes needed to populate DIEs generated by GraalVM. - */ - int DW_AT_null = 0x0; - int DW_AT_location = 0x02; - int DW_AT_name = 0x3; - int DW_AT_byte_size = 0x0b; - int DW_AT_bit_size = 0x0d; - int DW_AT_stmt_list = 0x10; - int DW_AT_low_pc = 0x11; - int DW_AT_hi_pc = 0x12; - int DW_AT_language = 0x13; - int DW_AT_comp_dir = 0x1b; - int DW_AT_containing_type = 0x1d; - int DW_AT_inline = 0x20; - int DW_AT_abstract_origin = 0x31; - int DW_AT_accessibility = 0x32; - int DW_AT_artificial = 0x34; - int DW_AT_count = 0x37; - int DW_AT_data_member_location = 0x38; - @SuppressWarnings("unused") int DW_AT_decl_column = 0x39; - int DW_AT_decl_file = 0x3a; - int DW_AT_decl_line = 0x3b; - int DW_AT_declaration = 0x3c; - int DW_AT_encoding = 0x3e; - int DW_AT_external = 0x3f; - @SuppressWarnings("unused") int DW_AT_return_addr = 0x2a; - @SuppressWarnings("unused") int DW_AT_frame_base = 0x40; - int DW_AT_specification = 0x47; - int DW_AT_type = 0x49; - int DW_AT_data_location = 0x50; - int DW_AT_use_UTF8 = 0x53; - int DW_AT_ranges = 0x55; - int DW_AT_call_file = 0x58; - int DW_AT_call_line = 0x59; - int DW_AT_object_pointer = 0x64; - int DW_AT_linkage_name = 0x6e; - - /* - * All the Dwarf attribute forms needed to type attribute values generated by GraalVM. - */ - int DW_FORM_null = 0x0; - int DW_FORM_addr = 0x1; - int DW_FORM_data2 = 0x05; - int DW_FORM_data4 = 0x6; - @SuppressWarnings("unused") int DW_FORM_data8 = 0x7; - @SuppressWarnings("unused") int DW_FORM_string = 0x8; - @SuppressWarnings("unused") int DW_FORM_block1 = 0x0a; - int DW_FORM_ref_addr = 0x10; - @SuppressWarnings("unused") int DW_FORM_ref1 = 0x11; - @SuppressWarnings("unused") int DW_FORM_ref2 = 0x12; - @SuppressWarnings("unused") int DW_FORM_ref4 = 0x13; - @SuppressWarnings("unused") int DW_FORM_ref8 = 0x14; - int DW_FORM_sec_offset = 0x17; - int DW_FORM_data1 = 0x0b; - int DW_FORM_flag = 0xc; - int DW_FORM_strp = 0xe; - int DW_FORM_expr_loc = 0x18; - - /* - * The following constants correspond to pre-defined value ranges appropriate to a specific - * attribute or form. - */ - - /* - * Compile unit DIE header has_children attribute values. - */ - byte DW_CHILDREN_no = 0; - byte DW_CHILDREN_yes = 1; - - /* - * DW_FORM_flag haas two possible attribute values. - */ - @SuppressWarnings("unused") byte DW_FLAG_false = 0; - byte DW_FLAG_true = 1; - - /* - * DW_AT_language attribute with form DATA1 has a range of pre-defined values. - */ - byte DW_LANG_Java = 0xb; - - /* - * Values for DW_AT_inline attribute with form DATA1. - */ - @SuppressWarnings("unused") byte DW_INL_not_inlined = 0; - byte DW_INL_inlined = 1; - @SuppressWarnings("unused") byte DW_INL_declared_not_inlined = 2; - @SuppressWarnings("unused") byte DW_INL_declared_inlined = 3; - - /* - * DW_AT_Accessibility attribute values. - */ - @SuppressWarnings("unused") byte DW_ACCESS_public = 1; - @SuppressWarnings("unused") byte DW_ACCESS_protected = 2; - @SuppressWarnings("unused") byte DW_ACCESS_private = 3; - - /* - * DW_AT_encoding attribute values - */ - @SuppressWarnings("unused") byte DW_ATE_address = 0x1; - byte DW_ATE_boolean = 0x2; - byte DW_ATE_float = 0x4; - byte DW_ATE_signed = 0x5; - byte DW_ATE_signed_char = 0x6; - byte DW_ATE_unsigned = 0x7; - @SuppressWarnings("unused") byte DW_ATE_unsigned_char = 0x8; - - /* - * Constants that appear in CIE and FDE frame section entries. - */ - byte DW_CFA_CIE_version = 1; - /* Values encoded in high 2 bits. */ - byte DW_CFA_advance_loc = 0x1; - byte DW_CFA_offset = 0x2; - byte DW_CFA_restore = 0x3; - /* Values encoded in low 6 bits. */ - byte DW_CFA_nop = 0x0; - @SuppressWarnings("unused") byte DW_CFA_set_loc1 = 0x1; - byte DW_CFA_advance_loc1 = 0x2; - byte DW_CFA_advance_loc2 = 0x3; - byte DW_CFA_advance_loc4 = 0x4; - @SuppressWarnings("unused") byte DW_CFA_offset_extended = 0x5; - @SuppressWarnings("unused") byte DW_CFA_restore_extended = 0x6; - @SuppressWarnings("unused") byte DW_CFA_undefined = 0x7; - @SuppressWarnings("unused") byte DW_CFA_same_value = 0x8; - byte DW_CFA_register = 0x9; - byte DW_CFA_def_cfa = 0xc; - @SuppressWarnings("unused") byte DW_CFA_def_cfa_register = 0xd; - byte DW_CFA_def_cfa_offset = 0xe; - - /* - * Values used to build DWARF expressions and locations - */ - byte DW_OP_addr = 0x03; - @SuppressWarnings("unused") byte DW_OP_deref = 0x06; - byte DW_OP_dup = 0x12; - byte DW_OP_and = 0x1a; - byte DW_OP_not = 0x20; - byte DW_OP_plus = 0x22; - byte DW_OP_shl = 0x24; - byte DW_OP_shr = 0x25; - byte DW_OP_bra = 0x28; - byte DW_OP_eq = 0x29; - byte DW_OP_lit0 = 0x30; - byte DW_OP_reg0 = 0x50; - byte DW_OP_breg0 = 0x70; - byte DW_OP_regx = (byte) 0x90; - byte DW_OP_bregx = (byte) 0x92; - byte DW_OP_push_object_address = (byte) 0x97; - byte DW_OP_implicit_value = (byte) 0x9e; - byte DW_OP_stack_value = (byte) 0x9f; - - /* - * Standard line section opcodes defined by Dwarf 2 - */ - /* - * 0 can be returned to indicate an invalid opcode. - */ - byte DW_LNS_undefined = 0; - /* - * 0 can be inserted as a prefix for extended opcodes. - */ - byte DW_LNS_extended_prefix = 0; - /* - * Append current state as matrix row 0 args. - */ - byte DW_LNS_copy = 1; - /* - * Increment address 1 uleb arg. - */ - byte DW_LNS_advance_pc = 2; - /* - * Increment line 1 sleb arg. - */ - byte DW_LNS_advance_line = 3; - /* - * Set file 1 uleb arg. - */ - byte DW_LNS_set_file = 4; - /* - * sSet column 1 uleb arg. - */ - byte DW_LNS_set_column = 5; - /* - * Flip is_stmt 0 args. - */ - byte DW_LNS_negate_stmt = 6; - /* - * Set end sequence and copy row 0 args. - */ - byte DW_LNS_set_basic_block = 7; - /* - * Increment address as per opcode 255 0 args. - */ - byte DW_LNS_const_add_pc = 8; - /* - * Increment address 1 ushort arg. - */ - byte DW_LNS_fixed_advance_pc = 9; - - /* - * Increment address 1 ushort arg. - */ - @SuppressWarnings("unused") byte DW_LNS_set_prologue_end = 10; - - /* - * Increment address 1 ushort arg. - */ - @SuppressWarnings("unused") byte DW_LNS_set_epilogue_begin = 11; - - /* - * Extended line section opcodes defined by DWARF 2. - */ - /* - * There is no extended opcode 0. - */ - @SuppressWarnings("unused") byte DW_LNE_undefined = 0; - /* - * End sequence of addresses. - */ - byte DW_LNE_end_sequence = 1; - /* - * Set address as explicit long argument. - */ - byte DW_LNE_set_address = 2; - /* - * Set file as explicit string argument. - */ - byte DW_LNE_define_file = 3; -} 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 0805e4cc3bbb..d4d6c99f4577 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,8 @@ 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.DwarfAttributeValues; +import com.oracle.objectfile.elf.dwarf.constants.DwarfConstants; import org.graalvm.collections.EconomicMap; /** @@ -111,7 +113,7 @@ enum AbbrevCode { * This field defines the value used for the DW_AT_language attribute of compile units. * */ - public static final byte LANG_ENCODING = DW_LANG_Java; + public static final byte LANG_ENCODING = DwarfAttributeValues.DW_LANG_Java; /* Register constants for AArch64. */ public static final byte rheapbase_aarch64 = (byte) 27; 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 3a9d680bd2a6..33a79a4d2885 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 @@ -30,6 +30,8 @@ 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.DwarfFrameValues; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; import org.graalvm.compiler.debug.DebugContext; import java.util.List; @@ -49,7 +51,7 @@ public DwarfFrameSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DW_FRAME_SECTION_NAME; + return DwarfSectionNames.DW_FRAME_SECTION_NAME; } @Override @@ -122,7 +124,7 @@ private int writeCIE(byte[] buffer, int p) { int lengthPos = pos; pos = writeInt(0, buffer, pos); pos = writeInt(CFA_CIE_id_default, buffer, pos); - pos = writeByte(DW_CFA_CIE_version, buffer, pos); + pos = writeByte(DwarfFrameValues.DW_CFA_CIE_version, buffer, pos); pos = writeByte((byte) 0, buffer, pos); pos = writeULEB(1, buffer, pos); pos = writeSLEB(-8, buffer, pos); @@ -196,21 +198,21 @@ 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(DW_CFA_nop, buffer, pos); + pos = writeByte(DwarfFrameValues.DW_CFA_nop, buffer, pos); } return pos; } protected int writeDefCFA(int register, int offset, byte[] buffer, int p) { int pos = p; - pos = writeByte(DW_CFA_def_cfa, buffer, pos); + pos = writeByte(DwarfFrameValues.DW_CFA_def_cfa, 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(DW_CFA_def_cfa_offset, buffer, pos); + pos = writeByte(DwarfFrameValues.DW_CFA_def_cfa_offset, buffer, pos); return writeULEB(offset, buffer, pos); } @@ -233,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 = DW_CFA_advance_loc1; + byte op = DwarfFrameValues.DW_CFA_advance_loc1; pos = writeByte(op, buffer, pos); return writeByte(offset, buffer, pos); } protected int writeAdvanceLoc2(short offset, byte[] buffer, int p) { - byte op = DW_CFA_advance_loc2; + byte op = DwarfFrameValues.DW_CFA_advance_loc2; int pos = p; pos = writeByte(op, buffer, pos); return writeShort(offset, buffer, pos); } protected int writeAdvanceLoc4(int offset, byte[] buffer, int p) { - byte op = DW_CFA_advance_loc4; + byte op = DwarfFrameValues.DW_CFA_advance_loc4; int pos = p; pos = writeByte(op, buffer, pos); return writeInt(offset, buffer, pos); @@ -268,7 +270,7 @@ 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(DW_CFA_register, buffer, pos); + pos = writeByte(DwarfFrameValues.DW_CFA_register, buffer, pos); pos = writeULEB(savedReg, buffer, pos); return writeULEB(savedToReg, buffer, pos); } @@ -283,7 +285,7 @@ protected int writeRegister(int savedReg, int savedToReg, byte[] buffer, int p) /** * The debug_frame section depends on debug_line section. */ - private static final String TARGET_SECTION_NAME = DW_LINE_SECTION_NAME; + private static final String TARGET_SECTION_NAME = DwarfSectionNames.DW_LINE_SECTION_NAME; @Override public String targetSectionName() { @@ -302,16 +304,16 @@ public LayoutDecision.Kind[] targetSectionKinds() { private static byte offsetOp(int register) { assert (register >> 6) == 0; - return (byte) ((DW_CFA_offset << 6) | register); + return (byte) ((DwarfFrameValues.DW_CFA_offset << 6) | register); } private static byte restoreOp(int register) { assert (register >> 6) == 0; - return (byte) ((DW_CFA_restore << 6) | register); + return (byte) ((DwarfFrameValues.DW_CFA_restore << 6) | register); } private static byte advanceLoc0Op(int offset) { assert (offset >= 0 && offset <= 0x3f); - return (byte) ((DW_CFA_advance_loc << 6) | offset); + return (byte) ((DwarfFrameValues.DW_CFA_advance_loc << 6) | offset); } } 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 8dfc3f074c7f..93e985997ab7 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,6 +33,9 @@ import java.util.List; import java.util.stream.Stream; +import com.oracle.objectfile.elf.dwarf.constants.DwarfAttributeValues; +import com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcodes; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; import org.graalvm.collections.EconomicSet; import org.graalvm.compiler.debug.DebugContext; @@ -93,7 +96,7 @@ public DwarfInfoSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DW_INFO_SECTION_NAME; + return DwarfSectionNames.DW_INFO_SECTION_NAME; } @Override @@ -130,22 +133,22 @@ byte computeEncoding(int flags, int bitCount) { if ((flags & DebugPrimitiveTypeInfo.FLAG_SIGNED) != 0) { switch (bitCount) { case 8: - return DW_ATE_signed_char; + return DwarfAttributeValues.DW_ATE_signed_char; default: assert bitCount == 16 || bitCount == 32 || bitCount == 64; - return DW_ATE_signed; + return DwarfAttributeValues.DW_ATE_signed; } } else { assert bitCount == 16; - return DW_ATE_unsigned; + return DwarfAttributeValues.DW_ATE_unsigned; } } else { assert bitCount == 32 || bitCount == 64; - return DW_ATE_float; + return DwarfAttributeValues.DW_ATE_float; } } else { assert bitCount == 1; - return DW_ATE_boolean; + return DwarfAttributeValues.DW_ATE_boolean; } } @@ -1040,7 +1043,7 @@ 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 ? DW_ATE_signed : DW_ATE_unsigned); + byte encoding = (isSigned ? DwarfAttributeValues.DW_ATE_signed : DwarfAttributeValues.DW_ATE_unsigned); log(context, " [0x%08x] encoding 0x%x", pos, encoding); pos = writeAttrData1(encoding, buffer, pos); String name = uniqueDebugString(integralTypeName(byteSize, isSigned)); @@ -1063,7 +1066,7 @@ 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 ? DW_ATE_signed : DW_ATE_unsigned); + byte encoding = (isSigned ? DwarfAttributeValues.DW_ATE_signed : DwarfAttributeValues.DW_ATE_unsigned); log(context, " [0x%08x] encoding 0x%x", pos, encoding); pos = writeAttrData1(encoding, buffer, pos); String name = uniqueDebugString(integralTypeName(byteSize, isSigned)); @@ -1086,7 +1089,7 @@ 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 = DW_ATE_float; + byte encoding = DwarfAttributeValues.DW_ATE_float; log(context, " [0x%08x] encoding 0x%x", pos, encoding); pos = writeAttrData1(encoding, buffer, pos); String name = uniqueDebugString(size == 4 ? "float" : (size == 8 ? "double" : "long double")); @@ -1536,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(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfAttributeValues.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); @@ -1781,13 +1784,13 @@ private int writeAbstractInlineMethod(DebugContext context, ClassEntry classEntr 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, DW_INL_inlined); - pos = writeAttrData1(DW_INL_inlined, buffer, pos); + log(context, " [0x%08x] inline 0x%x", pos, DwarfAttributeValues.DW_INL_inlined); + pos = writeAttrData1(DwarfAttributeValues.DW_INL_inlined, buffer, pos); /* * Should pass true only if method is non-private. */ log(context, " [0x%08x] external true", pos); - pos = writeFlag(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfAttributeValues.DW_FLAG_true, buffer, pos); int methodSpecOffset = getMethodDeclarationIndex(method); log(context, " [0x%08x] specification 0x%x", pos, methodSpecOffset); pos = writeInfoSectionOffset(methodSpecOffset, buffer, pos); @@ -1842,14 +1845,14 @@ public int writeAttrString(String value, byte[] buffer, int p) { public int writeAttrAccessibility(int modifiers, byte[] buffer, int p) { byte access; if (Modifier.isPublic(modifiers)) { - access = DW_ACCESS_public; + access = DwarfAttributeValues.DW_ACCESS_public; } else if (Modifier.isProtected(modifiers)) { - access = DW_ACCESS_protected; + access = DwarfAttributeValues.DW_ACCESS_protected; } else if (Modifier.isPrivate(modifiers)) { - access = DW_ACCESS_private; + access = DwarfAttributeValues.DW_ACCESS_private; } else { /* Actually package private -- make it public for now. */ - access = DW_ACCESS_public; + access = DwarfAttributeValues.DW_ACCESS_public; } return writeAttrData1(access, buffer, p); } @@ -1954,40 +1957,40 @@ public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, in pos = writeULEB(exprSize, buffer, pos); int exprStart = pos; if (!useHeapBase) { - pos = writeByte(DW_OP_push_object_address, buffer, pos); - pos = writeByte((byte) (DW_OP_lit0 + mask), buffer, pos); - pos = writeByte(DW_OP_not, buffer, pos); - pos = writeByte(DW_OP_and, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_push_object_address, buffer, pos); + pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + mask), buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_not, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_and, buffer, pos); } else { - pos = writeByte(DW_OP_push_object_address, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_push_object_address, buffer, pos); /* skip to end if oop is null */ - pos = writeByte(DW_OP_dup, buffer, pos); - pos = writeByte(DW_OP_lit0, buffer, pos); - pos = writeByte(DW_OP_eq, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_dup, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_lit0, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_eq, buffer, pos); int skipStart = pos + 3; /* offset excludes BR op + 2 operand bytes */ short offsetToEnd = (short) (exprSize - (skipStart - exprStart)); - pos = writeByte(DW_OP_bra, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_bra, buffer, pos); pos = writeShort(offsetToEnd, buffer, pos); /* insert mask or shifts as necessary */ if (mask != 0) { - pos = writeByte((byte) (DW_OP_lit0 + mask), buffer, pos); - pos = writeByte(DW_OP_not, buffer, pos); - pos = writeByte(DW_OP_and, buffer, pos); + pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + mask), buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_not, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_and, buffer, pos); } else { if (rightShift != 0) { - pos = writeByte((byte) (DW_OP_lit0 + rightShift), buffer, pos); - pos = writeByte(DW_OP_shr, buffer, pos); + pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + rightShift), buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_shr, buffer, pos); } if (leftShift != 0) { - pos = writeByte((byte) (DW_OP_lit0 + leftShift), buffer, pos); - pos = writeByte(DW_OP_shl, buffer, pos); + pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + leftShift), buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_shl, buffer, pos); } } /* add the resulting offset to the heapbase register */ - byte regOp = (byte) (DW_OP_breg0 + dwarfSections.getHeapbaseRegister()); + byte regOp = (byte) (DwarfExpressionOpcodes.DW_OP_breg0 + dwarfSections.getHeapbaseRegister()); pos = writeByte(regOp, buffer, pos); pos = writeSLEB(0, buffer, pos); /* 1 byte. */ - pos = writeByte(DW_OP_plus, buffer, pos); + pos = writeByte(DwarfExpressionOpcodes.DW_OP_plus, buffer, pos); assert pos == skipStart + offsetToEnd; /* make sure we added up correctly */ @@ -1999,7 +2002,7 @@ public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, in /** * The debug_info section depends on loc section. */ - protected static final String TARGET_SECTION_NAME = DW_LOC_SECTION_NAME; + protected static final String TARGET_SECTION_NAME = DwarfSectionNames.DW_LOC_SECTION_NAME; @Override public String targetSectionName() { 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 70999f2dedaf..d55dd9b1049d 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,8 @@ import java.util.Map; import com.oracle.objectfile.debugentry.ClassEntry; +import com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcodes; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; import org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.LayoutDecision; @@ -67,7 +69,7 @@ public class DwarfLineSectionImpl extends DwarfSectionImpl { @Override public String getSectionName() { - return DW_LINE_SECTION_NAME; + return DwarfSectionNames.DW_LINE_SECTION_NAME; } @Override @@ -470,7 +472,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 != DwarfLineOpcodes.DW_LNS_undefined) { /* * Ignore pointless write when addressDelta == lineDelta == 0. */ @@ -489,7 +491,7 @@ private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEn * line delta. */ opcode = isSpecialOpcode(remainder, lineDelta); - if (opcode != DW_LNS_undefined) { + if (opcode != DwarfLineOpcodes.DW_LNS_undefined) { /* * Address remainder and line now fit. */ @@ -500,7 +502,7 @@ private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEn * remainder. */ opcode = isSpecialOpcode(remainder, 0); - assert opcode != DW_LNS_undefined; + assert opcode != DwarfLineOpcodes.DW_LNS_undefined; pos = writeAdvanceLineOp(context, lineDelta, buffer, pos); pos = writeSpecialOpcode(context, opcode, buffer, pos); } @@ -574,7 +576,7 @@ private static SubRange prologueLeafRange(CompiledMethodEntry compiledEntry) { } private int writeCopyOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DW_LNS_copy; + byte opcode = DwarfLineOpcodes.DW_LNS_copy; int pos = p; debugCopyCount++; verboseLog(context, " [0x%08x] Copy %d", pos, debugCopyCount); @@ -582,7 +584,7 @@ private int writeCopyOp(DebugContext context, byte[] buffer, int p) { } private int writeAdvancePCOp(DebugContext context, long uleb, byte[] buffer, int p) { - byte opcode = DW_LNS_advance_pc; + byte opcode = DwarfLineOpcodes.DW_LNS_advance_pc; int pos = p; debugAddress += uleb; verboseLog(context, " [0x%08x] Advance PC by %d to 0x%08x", pos, uleb, debugAddress); @@ -591,7 +593,7 @@ private int writeAdvancePCOp(DebugContext context, long uleb, byte[] buffer, int } private int writeAdvanceLineOp(DebugContext context, long sleb, byte[] buffer, int p) { - byte opcode = DW_LNS_advance_line; + byte opcode = DwarfLineOpcodes.DW_LNS_advance_line; int pos = p; debugLine += sleb; verboseLog(context, " [0x%08x] Advance Line by %d to %d", pos, sleb, debugLine); @@ -600,7 +602,7 @@ private int writeAdvanceLineOp(DebugContext context, long sleb, byte[] buffer, i } private int writeSetFileOp(DebugContext context, String file, long uleb, byte[] buffer, int p) { - byte opcode = DW_LNS_set_file; + byte opcode = DwarfLineOpcodes.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); @@ -609,7 +611,7 @@ private int writeSetFileOp(DebugContext context, String file, long uleb, byte[] @SuppressWarnings("unused") private int writeSetColumnOp(DebugContext context, long uleb, byte[] buffer, int p) { - byte opcode = DW_LNS_set_column; + byte opcode = DwarfLineOpcodes.DW_LNS_set_column; int pos = p; pos = writeByte(opcode, buffer, pos); return writeULEB(uleb, buffer, pos); @@ -617,20 +619,20 @@ private int writeSetColumnOp(DebugContext context, long uleb, byte[] buffer, int @SuppressWarnings("unused") private int writeNegateStmtOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DW_LNS_negate_stmt; + byte opcode = DwarfLineOpcodes.DW_LNS_negate_stmt; int pos = p; return writeByte(opcode, buffer, pos); } private int writeSetBasicBlockOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DW_LNS_set_basic_block; + byte opcode = DwarfLineOpcodes.DW_LNS_set_basic_block; int pos = p; verboseLog(context, " [0x%08x] Set basic block", pos); return writeByte(opcode, buffer, pos); } private int writeConstAddPCOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DW_LNS_const_add_pc; + byte opcode = DwarfLineOpcodes.DW_LNS_const_add_pc; int pos = p; int advance = opcodeAddress((byte) 255); debugAddress += advance; @@ -639,7 +641,7 @@ private int writeConstAddPCOp(DebugContext context, byte[] buffer, int p) { } private int writeFixedAdvancePCOp(DebugContext context, short arg, byte[] buffer, int p) { - byte opcode = DW_LNS_fixed_advance_pc; + byte opcode = DwarfLineOpcodes.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); @@ -648,13 +650,13 @@ private int writeFixedAdvancePCOp(DebugContext context, short arg, byte[] buffer } private int writeEndSequenceOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DW_LNE_end_sequence; + byte opcode = DwarfLineOpcodes.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 = writeByte(DwarfLineOpcodes.DW_LNS_extended_prefix, buffer, pos); /* * Insert extended insn byte count as ULEB. */ @@ -663,11 +665,11 @@ private int writeEndSequenceOp(DebugContext context, byte[] buffer, int p) { } private int writeSetAddressOp(DebugContext context, long arg, byte[] buffer, int p) { - byte opcode = DW_LNE_set_address; + byte opcode = DwarfLineOpcodes.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 = writeByte(DwarfLineOpcodes.DW_LNS_extended_prefix, buffer, pos); /* * Insert extended insn byte count as ULEB. */ @@ -678,7 +680,7 @@ private int writeSetAddressOp(DebugContext context, long arg, byte[] buffer, int @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; + byte opcode = DwarfLineOpcodes.DW_LNE_define_file; int pos = p; /* * Calculate bytes needed for opcode + args. @@ -690,7 +692,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 = writeByte(DwarfLineOpcodes.DW_LNS_extended_prefix, buffer, pos); /* * Insert insn length as uleb. */ @@ -737,7 +739,7 @@ private int writeSpecialOpcode(DebugContext context, byte opcode, byte[] buffer, private static byte isSpecialOpcode(long addressDelta, long lineDelta) { if (addressDelta < 0) { - return DW_LNS_undefined; + return DwarfLineOpcodes.DW_LNS_undefined; } if (lineDelta >= LN_LINE_BASE) { long offsetLineDelta = lineDelta - LN_LINE_BASE; @@ -757,7 +759,7 @@ private static byte isSpecialOpcode(long addressDelta, long lineDelta) { /* * Answer no by returning an invalid opcode. */ - return DW_LNS_undefined; + return DwarfLineOpcodes.DW_LNS_undefined; } private static int isConstAddPC(long addressDelta) { @@ -778,7 +780,7 @@ private static boolean isFixedAdvancePC(long addressDiff) { /** * The debug_line section depends on debug_str section. */ - private static final String TARGET_SECTION_NAME = DW_STR_SECTION_NAME; + private static final String TARGET_SECTION_NAME = DwarfSectionNames.DW_STR_SECTION_NAME; @Override public String targetSectionName() { 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 07ae54086a2d..2ae3f57299c1 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 @@ -36,6 +36,8 @@ import com.oracle.objectfile.debugentry.ClassEntry; import com.oracle.objectfile.debugentry.range.SubRange; +import com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcodes; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; import org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.BuildDependency; @@ -77,7 +79,7 @@ public DwarfLocSectionImpl(DwarfDebugInfo dwarfSections) { @Override public String getSectionName() { - return DW_LOC_SECTION_NAME; + return DwarfSectionNames.DW_LOC_SECTION_NAME; } @Override @@ -245,7 +247,7 @@ private int writeRegisterLocation(DebugContext context, int regIndex, byte[] buf if (targetIdx < 32) { // can write using DW_OP_reg short byteCount = 1; - byte regOp = (byte) (DW_OP_reg0 + targetIdx); + byte regOp = (byte) (DwarfExpressionOpcodes.DW_OP_reg0 + targetIdx); pos = writeShort(byteCount, buffer, pos); pos = writeByte(regOp, buffer, pos); verboseLog(context, " [0x%08x] REGOP count %d op 0x%x", pos, byteCount, regOp); @@ -253,7 +255,7 @@ private int writeRegisterLocation(DebugContext context, int regIndex, byte[] buf // have to write using DW_OP_regx + LEB operand assert targetIdx < 128 : "unexpectedly high reg index!"; short byteCount = 2; - byte regOp = DW_OP_regx; + byte regOp = DwarfExpressionOpcodes.DW_OP_regx; pos = writeShort(byteCount, buffer, pos); pos = writeByte(regOp, buffer, pos); pos = writeULEB(targetIdx, buffer, pos); @@ -271,17 +273,17 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer, byte stackOp; if (sp < 32) { // fold the base reg index into the op - stackOp = DW_OP_breg0; + stackOp = DwarfExpressionOpcodes.DW_OP_breg0; stackOp += (byte) sp; } else { // pass base reg index as a ULEB operand - stackOp = DW_OP_bregx; + stackOp = DwarfExpressionOpcodes.DW_OP_bregx; } int patchPos = pos; pos = writeShort(byteCount, buffer, pos); int zeroPos = pos; pos = writeByte(stackOp, buffer, pos); - if (stackOp == DW_OP_bregx) { + if (stackOp == DwarfExpressionOpcodes.DW_OP_bregx) { // need to pass base reg index as a ULEB operand pos = writeULEB(sp, buffer, pos); } @@ -289,7 +291,7 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer, // now backpatch the byte count byteCount = (byte) (pos - zeroPos); writeShort(byteCount, buffer, patchPos); - if (stackOp == DW_OP_bregx) { + if (stackOp == DwarfExpressionOpcodes.DW_OP_bregx) { verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x offset %d", pos, byteCount, stackOp, 0 - offset); } else { verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x reg %d offset %d", pos, byteCount, stackOp, sp, 0 - offset); @@ -300,7 +302,7 @@ 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; + byte op = DwarfExpressionOpcodes.DW_OP_implicit_value; JavaKind kind = constant.getJavaKind(); int dataByteCount = kind.getByteCount(); // total bytes is op + uleb + dataByteCount @@ -330,7 +332,7 @@ 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; + byte op = DwarfExpressionOpcodes.DW_OP_implicit_value; int dataByteCount = 8; // total bytes is op + uleb + dataByteCount int byteCount = 1 + 1 + dataByteCount; @@ -417,7 +419,7 @@ public static List coalesce(DebugLocalInfo local, List + * + * Note that this is not an exhaustive list of all DWARF constants. It merely includes constants + * that are needed by GraalVM. + */ +public interface DwarfConstants extends DwarfAttributes, DwarfAttributeValues, DwarfExpressionOpcodes, DwarfForms, DwarfFrameValues, DwarfLineOpcodes, DwarfSectionNames, DwarfTags { + + /** + * Currently generated debug info relies on DWARF spec version 4. However, some sections may + * still need to be generated as version 2. + */ + short DW_VERSION_2 = 2; + short DW_VERSION_4 = 4; + +} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcodes.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcodes.java new file mode 100644 index 000000000000..03a0b91680af --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcodes.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; + +/** + * Values used to build DWARF expressions and locations. + */ +public interface DwarfExpressionOpcodes { + byte DW_OP_addr = 0x03; + @SuppressWarnings("unused") byte DW_OP_deref = 0x06; + byte DW_OP_dup = 0x12; + byte DW_OP_and = 0x1a; + byte DW_OP_not = 0x20; + byte DW_OP_plus = 0x22; + byte DW_OP_shl = 0x24; + byte DW_OP_shr = 0x25; + byte DW_OP_bra = 0x28; + byte DW_OP_eq = 0x29; + byte DW_OP_lit0 = 0x30; + byte DW_OP_reg0 = 0x50; + byte DW_OP_breg0 = 0x70; + byte DW_OP_regx = (byte) 0x90; + byte DW_OP_bregx = (byte) 0x92; + byte DW_OP_push_object_address = (byte) 0x97; + byte DW_OP_implicit_value = (byte) 0x9e; + byte DW_OP_stack_value = (byte) 0x9f; +} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java new file mode 100644 index 000000000000..645ff816f487 --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.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; + +/** + * All the Dwarf attribute forms needed to type attribute values generated by GraalVM. + */ +public interface DwarfForms { + int DW_FORM_null = 0x0; + int DW_FORM_addr = 0x1; + int DW_FORM_data2 = 0x05; + int DW_FORM_data4 = 0x6; + @SuppressWarnings("unused") int DW_FORM_data8 = 0x7; + @SuppressWarnings("unused") int DW_FORM_string = 0x8; + @SuppressWarnings("unused") int DW_FORM_block1 = 0x0a; + int DW_FORM_ref_addr = 0x10; + @SuppressWarnings("unused") int DW_FORM_ref1 = 0x11; + @SuppressWarnings("unused") int DW_FORM_ref2 = 0x12; + @SuppressWarnings("unused") int DW_FORM_ref4 = 0x13; + @SuppressWarnings("unused") int DW_FORM_ref8 = 0x14; + int DW_FORM_sec_offset = 0x17; + int DW_FORM_data1 = 0x0b; + int DW_FORM_flag = 0xc; + int DW_FORM_strp = 0xe; + int DW_FORM_expr_loc = 0x18; +} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValues.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValues.java new file mode 100644 index 000000000000..6daa70566d03 --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValues.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; + +/** + * Constants that appear in CIE and FDE frame section entries. + */ +public interface DwarfFrameValues { + byte DW_CFA_CIE_version = 1; + /* Values encoded in high 2 bits. */ + byte DW_CFA_advance_loc = 0x1; + byte DW_CFA_offset = 0x2; + byte DW_CFA_restore = 0x3; + /* Values encoded in low 6 bits. */ + byte DW_CFA_nop = 0x0; + @SuppressWarnings("unused") byte DW_CFA_set_loc1 = 0x1; + byte DW_CFA_advance_loc1 = 0x2; + byte DW_CFA_advance_loc2 = 0x3; + byte DW_CFA_advance_loc4 = 0x4; + @SuppressWarnings("unused") byte DW_CFA_offset_extended = 0x5; + @SuppressWarnings("unused") byte DW_CFA_restore_extended = 0x6; + @SuppressWarnings("unused") byte DW_CFA_undefined = 0x7; + @SuppressWarnings("unused") byte DW_CFA_same_value = 0x8; + byte DW_CFA_register = 0x9; + byte DW_CFA_def_cfa = 0xc; + @SuppressWarnings("unused") byte DW_CFA_def_cfa_register = 0xd; + byte DW_CFA_def_cfa_offset = 0xe; +} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcodes.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcodes.java new file mode 100644 index 000000000000..8026b5dabe40 --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcodes.java @@ -0,0 +1,104 @@ +/* + * 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 interface DwarfLineOpcodes { + /* + * 0 can be returned to indicate an invalid opcode. + */ + byte DW_LNS_undefined = 0; + /* + * 0 can be inserted as a prefix for extended opcodes. + */ + byte DW_LNS_extended_prefix = 0; + /* + * Append current state as matrix row 0 args. + */ + byte DW_LNS_copy = 1; + /* + * Increment address 1 uleb arg. + */ + byte DW_LNS_advance_pc = 2; + /* + * Increment line 1 sleb arg. + */ + byte DW_LNS_advance_line = 3; + /* + * Set file 1 uleb arg. + */ + byte DW_LNS_set_file = 4; + /* + * sSet column 1 uleb arg. + */ + byte DW_LNS_set_column = 5; + /* + * Flip is_stmt 0 args. + */ + byte DW_LNS_negate_stmt = 6; + /* + * Set end sequence and copy row 0 args. + */ + byte DW_LNS_set_basic_block = 7; + /* + * Increment address as per opcode 255 0 args. + */ + byte DW_LNS_const_add_pc = 8; + /* + * Increment address 1 ushort arg. + */ + byte DW_LNS_fixed_advance_pc = 9; + /* + * Increment address 1 ushort arg. + */ + @SuppressWarnings("unused") byte DW_LNS_set_prologue_end = 10; + /* + * Increment address 1 ushort arg. + */ + @SuppressWarnings("unused") byte DW_LNS_set_epilogue_begin = 11; + /* + * Extended line section opcodes defined by DWARF 2. + */ + /* + * There is no extended opcode 0. + */ + @SuppressWarnings("unused") byte DW_LNE_undefined = 0; + /* + * End sequence of addresses. + */ + byte DW_LNE_end_sequence = 1; + /* + * Set address as explicit long argument. + */ + byte DW_LNE_set_address = 2; + /* + * Set file as explicit string argument. + */ + byte DW_LNE_define_file = 3; +} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionNames.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionNames.java new file mode 100644 index 000000000000..ca592506277e --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionNames.java @@ -0,0 +1,44 @@ +/* + * 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; + +/** + * Names of the different ELF sections created by GraalVM in reverse dependency order. The sequence + * starts with the name of the text section (not defined in the DWARF spec and not created by debug + * info code). + */ +public interface DwarfSectionNames { + String TEXT_SECTION_NAME = ".text"; + String DW_STR_SECTION_NAME = ".debug_str"; + String DW_LINE_SECTION_NAME = ".debug_line"; + String DW_FRAME_SECTION_NAME = ".debug_frame"; + String DW_ABBREV_SECTION_NAME = ".debug_abbrev"; + String DW_INFO_SECTION_NAME = ".debug_info"; + String DW_LOC_SECTION_NAME = ".debug_loc"; + String DW_ARANGES_SECTION_NAME = ".debug_aranges"; + String DW_RANGES_SECTION_NAME = ".debug_ranges"; +} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTags.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTags.java new file mode 100644 index 000000000000..cb6232f93b3b --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTags.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; + +/** + * All the Dwarf tags needed to type DIEs generated by GraalVM. + */ +public interface DwarfTags { + int DW_TAG_array_type = 0x01; + int DW_TAG_class_type = 0x02; + int DW_TAG_formal_parameter = 0x05; + int DW_TAG_member = 0x0d; + int DW_TAG_pointer_type = 0x0f; + int DW_TAG_compile_unit = 0x11; + int DW_TAG_structure_type = 0x13; + int DW_TAG_typedef = 0x16; + int DW_TAG_union_type = 0x17; + int DW_TAG_inheritance = 0x1c; + int DW_TAG_subrange_type = 0x21; + int DW_TAG_base_type = 0x24; + int DW_TAG_constant = 0x27; + int DW_TAG_subprogram = 0x2e; + int DW_TAG_variable = 0x34; + int DW_TAG_namespace = 0x39; + int DW_TAG_unspecified_type = 0x3b; + int DW_TAG_inlined_subroutine = 0x1d; +} From ed5568471eff01f211c2f801e1c21543a0e8bfa2 Mon Sep 17 00:00:00 2001 From: Andrew Dinn Date: Mon, 31 Jul 2023 10:13:19 +0100 Subject: [PATCH 4/7] Remove invalid suppress unused annotations. --- .../elf/dwarf/constants/DwarfAttributeValues.java | 6 +++--- .../oracle/objectfile/elf/dwarf/constants/DwarfForms.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java index 0a1b33fbb0af..c2742d7426e9 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java @@ -54,9 +54,9 @@ public interface DwarfAttributeValues { /* * DW_AT_Accessibility attribute values. */ - @SuppressWarnings("unused") byte DW_ACCESS_public = 1; - @SuppressWarnings("unused") byte DW_ACCESS_protected = 2; - @SuppressWarnings("unused") byte DW_ACCESS_private = 3; + byte DW_ACCESS_public = 1; + byte DW_ACCESS_protected = 2; + byte DW_ACCESS_private = 3; /* * DW_AT_encoding attribute values */ diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java index 645ff816f487..bf2f2c52546d 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java @@ -40,7 +40,7 @@ public interface DwarfForms { int DW_FORM_ref_addr = 0x10; @SuppressWarnings("unused") int DW_FORM_ref1 = 0x11; @SuppressWarnings("unused") int DW_FORM_ref2 = 0x12; - @SuppressWarnings("unused") int DW_FORM_ref4 = 0x13; + int DW_FORM_ref4 = 0x13; @SuppressWarnings("unused") int DW_FORM_ref8 = 0x14; int DW_FORM_sec_offset = 0x17; int DW_FORM_data1 = 0x0b; From e88caee1637ae87a4bc15226033e5369b0914bb6 Mon Sep 17 00:00:00 2001 From: Andrew Dinn Date: Wed, 2 Aug 2023 12:06:06 +0100 Subject: [PATCH 5/7] Use enums for DWARF constants instead of interfaces --- .../elf/dwarf/DwarfARangesSectionImpl.java | 35 +- .../elf/dwarf/DwarfAbbrevSectionImpl.java | 798 +++++++++--------- .../objectfile/elf/dwarf/DwarfDebugInfo.java | 7 +- .../elf/dwarf/DwarfFrameSectionImpl.java | 74 +- .../elf/dwarf/DwarfInfoSectionImpl.java | 194 ++--- .../elf/dwarf/DwarfLineSectionImpl.java | 95 +-- .../elf/dwarf/DwarfLocSectionImpl.java | 94 +-- .../elf/dwarf/DwarfRangesSectionImpl.java | 32 +- .../elf/dwarf/DwarfSectionImpl.java | 146 +++- .../elf/dwarf/DwarfStrSectionImpl.java | 33 +- ...xpressionOpcodes.java => DwarfAccess.java} | 35 +- ...arfAttributes.java => DwarfAttribute.java} | 83 +- .../dwarf/constants/DwarfAttributeValues.java | 70 -- ...rfSectionNames.java => DwarfEncoding.java} | 34 +- .../constants/DwarfExpressionOpcode.java | 62 ++ .../elf/dwarf/constants/DwarfFlag.java | 46 + .../{DwarfForms.java => DwarfForm.java} | 52 +- ...fFrameValues.java => DwarfFrameValue.java} | 52 +- .../elf/dwarf/constants/DwarfHasChildren.java | 45 + .../elf/dwarf/constants/DwarfInline.java | 50 ++ .../elf/dwarf/constants/DwarfLanguage.java | 45 + ...fLineOpcodes.java => DwarfLineOpcode.java} | 51 +- .../elf/dwarf/constants/DwarfSectionName.java | 53 ++ .../{DwarfTags.java => DwarfTag.java} | 49 +- ...{DwarfConstants.java => DwarfVersion.java} | 24 +- 25 files changed, 1287 insertions(+), 972 deletions(-) rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfExpressionOpcodes.java => DwarfAccess.java} (65%) rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfAttributes.java => DwarfAttribute.java} (53%) delete mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfSectionNames.java => DwarfEncoding.java} (65%) create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcode.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFlag.java rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfForms.java => DwarfForm.java} (65%) rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfFrameValues.java => DwarfFrameValue.java} (60%) create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfHasChildren.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfInline.java create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLanguage.java rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfLineOpcodes.java => DwarfLineOpcode.java} (74%) create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionName.java rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfTags.java => DwarfTag.java} (66%) rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/{DwarfConstants.java => DwarfVersion.java} (69%) 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 8d963a2a48dc..59506700867f 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,7 +29,6 @@ import java.util.Map; import com.oracle.objectfile.debugentry.ClassEntry; -import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; import org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.LayoutDecision; @@ -38,6 +37,11 @@ import com.oracle.objectfile.debugentry.CompiledMethodEntry; import com.oracle.objectfile.debugentry.range.Range; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_ARANGES_SECTION; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_FRAME_SECTION; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfVersion.DW_VERSION_2; + /** * Section generator for debug_aranges section. */ @@ -47,12 +51,7 @@ public class DwarfARangesSectionImpl extends DwarfSectionImpl { private static final int AR_HEADER_PAD_SIZE = 4; public DwarfARangesSectionImpl(DwarfDebugInfo dwarfSections) { - super(dwarfSections); - } - - @Override - public String getSectionName() { - return DwarfSectionNames.DW_ARANGES_SECTION_NAME; + super(dwarfSections, DW_ARANGES_SECTION, DW_FRAME_SECTION); } @Override @@ -162,7 +161,7 @@ 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(DW_VERSION_2, buffer, pos); + pos = writeDwarfVersion(DW_VERSION_2, buffer, pos); pos = writeInfoSectionOffset(cuIndex, buffer, pos); /* Address size is always 8. */ pos = writeByte((byte) 8, buffer, pos); @@ -186,24 +185,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 = DwarfSectionNames.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 7f290ea6677d..4de1ea05464c 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,15 +26,81 @@ package com.oracle.objectfile.elf.dwarf; -import com.oracle.objectfile.LayoutDecision; -import com.oracle.objectfile.elf.dwarf.constants.DwarfAttributeValues; -import com.oracle.objectfile.elf.dwarf.constants.DwarfAttributes; -import com.oracle.objectfile.elf.dwarf.constants.DwarfForms; -import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; -import com.oracle.objectfile.elf.dwarf.constants.DwarfTags; +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 org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.elf.dwarf.DwarfDebugInfo.AbbrevCode; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_abstract_origin; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_accessibility; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_artificial; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_bit_size; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_byte_size; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_call_file; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_call_line; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_comp_dir; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_containing_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_count; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_data_location; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_data_member_location; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_decl_file; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_decl_line; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_declaration; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_encoding; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_external; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_hi_pc; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_inline; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_language; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_linkage_name; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_location; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_low_pc; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_name; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_null; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_object_pointer; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_ranges; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_specification; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_stmt_list; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_use_UTF8; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_addr; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_data1; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_data2; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_data4; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_expr_loc; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_flag; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_null; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_ref4; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_ref_addr; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_sec_offset; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_strp; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfHasChildren.DW_CHILDREN_no; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfHasChildren.DW_CHILDREN_yes; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_ABBREV_SECTION; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_RANGES_SECTION; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_array_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_base_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_class_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_compile_unit; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_constant; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_formal_parameter; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_inheritance; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_inlined_subroutine; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_member; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_namespace; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_pointer_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_structure_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_subprogram; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_subrange_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_typedef; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_union_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_unspecified_type; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_variable; + /** * Section generator for debug_abbrev section. That section defines the layout of the * DWARF Information Entries (DIEs) used to model Java debug info. Top level DIEs define Java @@ -834,12 +900,8 @@ public class DwarfAbbrevSectionImpl extends DwarfSectionImpl { public DwarfAbbrevSectionImpl(DwarfDebugInfo dwarfSections) { - super(dwarfSections); - } - - @Override - public String getSectionName() { - return DwarfSectionNames.DW_ABBREV_SECTION_NAME; + // abbrev section depends on ranges section + super(dwarfSections, DW_ABBREV_SECTION, DW_RANGES_SECTION); } @Override @@ -933,12 +995,16 @@ 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(long code, byte[] buffer, int pos) { - return writeSLEB(code, buffer, pos); + private int writeAttrForm(DwarfForm dwarfForm, byte[] buffer, int pos) { + return writeULEB(dwarfForm.value(), 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) { @@ -952,97 +1018,97 @@ private int writeCompileUnitAbbrevs(@SuppressWarnings("unused") DebugContext con private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_compile_unit, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_language, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_use_UTF8, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_comp_dir, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_compile_unit, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_language, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_use_UTF8, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_comp_dir, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); if (abbrevCode == AbbrevCode.CLASS_UNIT_2) { - pos = writeAttrType(DwarfAttributes.DW_AT_ranges, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_stmt_list, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DW_AT_ranges, buffer, pos); + pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_stmt_list, buffer, pos); + pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writePrimitiveTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.PRIMITIVE_TYPE, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_base_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_bit_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_encoding, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_base_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_bit_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_encoding, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeVoidTypeAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.VOID_TYPE, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_unspecified_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_unspecified_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeObjectHeaderAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.OBJECT_HEADER, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_structure_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeTag(DW_TAG_structure_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeNamespaceAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.NAMESPACE, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_namespace, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_namespace, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1059,28 +1125,28 @@ private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_class_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeTag(DW_TAG_class_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(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 == AbbrevCode.CLASS_LAYOUT_2) { - pos = writeAttrType(DwarfAttributes.DW_AT_data_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DW_AT_data_location, buffer, pos); + pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1090,17 +1156,17 @@ private int writeClassReferenceAbbrev(@SuppressWarnings("unused") DebugContext c /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.CLASS_POINTER, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1114,40 +1180,40 @@ private int writeMethodDeclarationAbbrevs(@SuppressWarnings("unused") DebugConte private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_subprogram, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_linkage_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_artificial, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeTag(DW_TAG_subprogram, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_linkage_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_artificial, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(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(DwarfAttributes.DW_AT_containing_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + // pos = writeAttrType(DW_AT_virtuality, buffer, pos); + // pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_containing_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_DECLARATION) { - pos = writeAttrType(DwarfAttributes.DW_AT_object_pointer, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeAttrType(DW_AT_object_pointer, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1167,65 +1233,65 @@ private int writeFieldDeclarationAbbrevs(DebugContext context, byte[] buffer, in private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_member, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_member, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); /* We may not have a file and line for a field. */ if (abbrevCode == AbbrevCode.FIELD_DECLARATION_2 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { - pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(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(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DwarfAttributes.DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); /* Static fields are only declared here and are external. */ if (abbrevCode == AbbrevCode.FIELD_DECLARATION_3 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { - pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeClassConstantAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.CLASS_CONSTANT, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_constant, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_constant, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); /* We may not have a file and line for a field. */ - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_location, buffer, pos); + pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1233,17 +1299,17 @@ private int writeArrayLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_LAYOUT, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_class_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeTag(DW_TAG_class_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1251,17 +1317,17 @@ private int writeArrayReferenceAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_POINTER, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1269,15 +1335,15 @@ private int writeInterfaceLayoutAbbrev(@SuppressWarnings("unused") DebugContext int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_LAYOUT, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_union_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_union_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1285,17 +1351,17 @@ private int writeInterfaceReferenceAbbrev(@SuppressWarnings("unused") DebugConte int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_POINTER, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1303,19 +1369,19 @@ private int writeInterfaceImplementorAbbrev(@SuppressWarnings("unused") DebugCon int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_IMPLEMENTOR, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_member, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeTag(DW_TAG_member, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1324,20 +1390,20 @@ private int writeForeignReferenceAbbrev(@SuppressWarnings("unused") DebugContext /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_POINTER, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1346,17 +1412,17 @@ private int writeForeignTypedefAbbrev(@SuppressWarnings("unused") DebugContext c /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_TYPEDEF, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_typedef, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_typedef, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1365,17 +1431,17 @@ private int writeForeignStructAbbrev(@SuppressWarnings("unused") DebugContext co /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_STRUCT, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_structure_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeTag(DW_TAG_structure_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1383,21 +1449,21 @@ private int writeHeaderFieldAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(AbbrevCode.HEADER_FIELD, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_member, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeTag(DW_TAG_member, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1412,23 +1478,23 @@ private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext co int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_array_type, buffer, pos); + pos = writeTag(DW_TAG_array_type, buffer, pos); boolean hasChildren = (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2); - pos = writeFlag((hasChildren ? DwarfAttributeValues.DW_CHILDREN_yes : DwarfAttributeValues.DW_CHILDREN_no), buffer, pos); + pos = writeHasChildren((hasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no), buffer, pos); if (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2) { - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data4, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(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(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1437,55 +1503,55 @@ private int writeArraySubrangeTypeAbbrev(@SuppressWarnings("unused") DebugContex int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_SUBRANGE, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_subrange_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_count, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data4, buffer, pos); + pos = writeTag(DW_TAG_subrange_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_count, buffer, pos); + pos = writeAttrForm(DW_FORM_data4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeMethodLocationAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.METHOD_LOCATION, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_subprogram, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_hi_pc, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_specification, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_subprogram, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_hi_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_specification, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeAbstractInlineMethodAbbrev(@SuppressWarnings("unused") DebugContext context, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(AbbrevCode.ABSTRACT_INLINE_METHOD, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_subprogram, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_inline, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_external, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_specification, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeTag(DW_TAG_subprogram, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_inline, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_external, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_specification, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1493,19 +1559,19 @@ private int writeStaticFieldLocationAbbrev(@SuppressWarnings("unused") DebugCont int pos = p; pos = writeAbbrevCode(AbbrevCode.STATIC_FIELD_LOCATION, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_variable, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_specification, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_variable, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_specification, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); // pos = writeAttrType(DwarfDebugInfo.DW_AT_linkage_name, buffer, pos); // pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DW_AT_location, buffer, pos); + pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1513,19 +1579,19 @@ private int writeSuperReferenceAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; pos = writeAbbrevCode(AbbrevCode.SUPER_REFERENCE, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_inheritance, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); + pos = writeTag(DW_TAG_inheritance, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_data_member_location, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_accessibility, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1541,20 +1607,20 @@ private int writeIndirectLayoutAbbrev(@SuppressWarnings("unused") DebugContext c */ /* the type for an indirect layout that includes address translation info */ pos = writeAbbrevCode(AbbrevCode.INDIRECT_LAYOUT, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_class_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeTag(DW_TAG_class_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); /* Add a data location expression to rebase oop pointers stored as offsets. */ - pos = writeAttrType(DwarfAttributes.DW_AT_data_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_expr_loc, buffer, pos); + pos = writeAttrType(DW_AT_data_location, buffer, pos); + pos = writeAttrForm(DW_FORM_expr_loc, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1564,17 +1630,17 @@ private int writeIndirectReferenceAbbrev(@SuppressWarnings("unused") DebugContex /* The type for a pointer to the indirect layout type. */ pos = writeAbbrevCode(AbbrevCode.INDIRECT_POINTER, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_pointer_type, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data1, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_pointer_type, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_byte_size, buffer, pos); + pos = writeAttrForm(DW_FORM_data1, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1589,31 +1655,31 @@ private int writeParameterDeclarationAbbrevs(DebugContext context, byte[] buffer private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_formal_parameter, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_formal_parameter, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_2) { /* Line numbers for parameter declarations are not (yet?) available. */ - pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(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(DwarfAttributes.DW_AT_artificial, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_artificial, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); } - pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1627,26 +1693,26 @@ private int writeLocalDeclarationAbbrevs(DebugContext context, byte[] buffer, in private int writeLocalDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_variable, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_name, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_strp, buffer, pos); + pos = writeTag(DW_TAG_variable, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_name, buffer, pos); + pos = writeAttrForm(DW_FORM_strp, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_LOCAL_DECLARATION_1) { /* Line numbers for parameter declarations are not (yet?) available. */ - pos = writeAttrType(DwarfAttributes.DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); + pos = writeAttrType(DW_AT_decl_line, buffer, pos); + pos = writeAttrForm(DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DwarfAttributes.DW_AT_type, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_flag, buffer, pos); + pos = writeAttrType(DW_AT_type, buffer, pos); + pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + pos = writeAttrType(DW_AT_declaration, buffer, pos); + pos = writeAttrForm(DW_FORM_flag, buffer, pos); /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1667,38 +1733,38 @@ private int writeLocalLocationAbbrevs(@SuppressWarnings("unused") DebugContext c private int writeParameterLocationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_formal_parameter, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_formal_parameter, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_PARAMETER_LOCATION_2) { - pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DW_AT_location, buffer, pos); + pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } private int writeLocalLocationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_variable, buffer, pos); - pos = writeFlag(DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); + pos = writeTag(DW_TAG_variable, buffer, pos); + pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_LOCAL_LOCATION_2) { - pos = writeAttrType(DwarfAttributes.DW_AT_location, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DW_AT_location, buffer, pos); + pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } @@ -1711,41 +1777,21 @@ private int writeNullAbbrev(@SuppressWarnings("unused") DebugContext context, by private int writeInlinedSubroutineAbbrev(byte[] buffer, int p, boolean withChildren) { int pos = p; pos = writeAbbrevCode(withChildren ? AbbrevCode.INLINED_SUBROUTINE_WITH_CHILDREN : AbbrevCode.INLINED_SUBROUTINE, buffer, pos); - pos = writeTag(DwarfTags.DW_TAG_inlined_subroutine, buffer, pos); - pos = writeFlag(withChildren ? DwarfAttributeValues.DW_CHILDREN_yes : DwarfAttributeValues.DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_ref4, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_hi_pc, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_addr, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_call_file, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data4, buffer, pos); - pos = writeAttrType(DwarfAttributes.DW_AT_call_line, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_data4, buffer, pos); + pos = writeTag(DW_TAG_inlined_subroutine, buffer, pos); + pos = writeHasChildren(withChildren ? DW_CHILDREN_yes : DW_CHILDREN_no, buffer, pos); + pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); + pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeAttrType(DW_AT_low_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_hi_pc, buffer, pos); + pos = writeAttrForm(DW_FORM_addr, buffer, pos); + pos = writeAttrType(DW_AT_call_file, buffer, pos); + pos = writeAttrForm(DW_FORM_data4, buffer, pos); + pos = writeAttrType(DW_AT_call_line, buffer, pos); + pos = writeAttrForm(DW_FORM_data4, buffer, pos); /* Now terminate. */ - pos = writeAttrType(DwarfAttributes.DW_AT_null, buffer, pos); - pos = writeAttrForm(DwarfForms.DW_FORM_null, buffer, pos); + pos = writeAttrType(DW_AT_null, buffer, pos); + pos = writeAttrForm(DW_FORM_null, buffer, pos); return pos; } - - /** - * The debug_abbrev section depends on debug_ranges section. - */ - private static final String TARGET_SECTION_NAME = DwarfSectionNames.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 d4d6c99f4577..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,8 +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.DwarfAttributeValues; -import com.oracle.objectfile.elf.dwarf.constants.DwarfConstants; +import com.oracle.objectfile.elf.dwarf.constants.DwarfLanguage; import org.graalvm.collections.EconomicMap; /** @@ -46,7 +45,7 @@ * DWARF sections. It groups common data and behaviours for use by the various subclasses of class * DwarfSectionImpl that take responsibility for generating content for a specific section type. */ -public class DwarfDebugInfo extends DebugInfoBase implements DwarfConstants { +public class DwarfDebugInfo extends DebugInfoBase { public static final String HEAP_BEGIN_NAME = "__svm_heap_begin"; @@ -113,7 +112,7 @@ enum AbbrevCode { * This field defines the value used for the DW_AT_language attribute of compile units. * */ - public static final byte LANG_ENCODING = DwarfAttributeValues.DW_LANG_Java; + public static final DwarfLanguage LANG_ENCODING = DwarfLanguage.DW_LANG_Java; /* Register constants for AArch64. */ public static final byte rheapbase_aarch64 = (byte) 27; 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 33a79a4d2885..b8b95eee02e8 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,16 +26,17 @@ 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.DwarfFrameValues; -import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; +import com.oracle.objectfile.elf.dwarf.constants.DwarfFrameValue; import org.graalvm.compiler.debug.DebugContext; import java.util.List; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_FRAME_SECTION; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LINE_SECTION; + /** * Section generic generator for debug_frame section. */ @@ -46,12 +47,8 @@ public abstract class DwarfFrameSectionImpl extends DwarfSectionImpl { private static final int CFA_CIE_id_default = -1; public DwarfFrameSectionImpl(DwarfDebugInfo dwarfSections) { - super(dwarfSections); - } - - @Override - public String getSectionName() { - return DwarfSectionNames.DW_FRAME_SECTION_NAME; + // debug_frame section depends on debug_line section + super(dwarfSections, DW_FRAME_SECTION, DW_LINE_SECTION); } @Override @@ -124,7 +121,7 @@ private int writeCIE(byte[] buffer, int p) { int lengthPos = pos; pos = writeInt(0, buffer, pos); pos = writeInt(CFA_CIE_id_default, buffer, pos); - pos = writeByte(DwarfFrameValues.DW_CFA_CIE_version, buffer, pos); + pos = writeCIEVersion(buffer, pos); pos = writeByte((byte) 0, buffer, pos); pos = writeULEB(1, buffer, pos); pos = writeSLEB(-8, buffer, pos); @@ -141,6 +138,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; @@ -198,21 +199,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(DwarfFrameValues.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(DwarfFrameValues.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(DwarfFrameValues.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); } @@ -235,20 +237,20 @@ protected int writeAdvanceLoc0(byte offset, byte[] buffer, int pos) { protected int writeAdvanceLoc1(byte offset, byte[] buffer, int p) { int pos = p; - byte op = DwarfFrameValues.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 = DwarfFrameValues.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 = DwarfFrameValues.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); @@ -270,7 +272,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(DwarfFrameValues.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); } @@ -282,38 +285,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 = DwarfSectionNames.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) ((DwarfFrameValues.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) ((DwarfFrameValues.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) ((DwarfFrameValues.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/DwarfInfoSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfInfoSectionImpl.java index 93e985997ab7..d4a10b327dcb 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,13 +33,14 @@ import java.util.List; import java.util.stream.Stream; -import com.oracle.objectfile.elf.dwarf.constants.DwarfAttributeValues; -import com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcodes; -import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; +import com.oracle.objectfile.elf.dwarf.constants.DwarfAccess; +import com.oracle.objectfile.elf.dwarf.constants.DwarfEncoding; +import com.oracle.objectfile.elf.dwarf.constants.DwarfInline; +import com.oracle.objectfile.elf.dwarf.constants.DwarfLanguage; +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; @@ -63,6 +64,23 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.PrimitiveConstant; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_and; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_bra; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_dup; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_eq; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_lit0; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_not; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_plus; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_push_object_address; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_shl; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_shr; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfFlag.DW_FLAG_false; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfFlag.DW_FLAG_true; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_INFO_SECTION; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LOC_SECTION; + /** * Section generator for debug_info section. */ @@ -87,18 +105,14 @@ public class DwarfInfoSectionImpl extends DwarfSectionImpl { private int cuStart; public DwarfInfoSectionImpl(DwarfDebugInfo dwarfSections) { - super(dwarfSections); + // debug_info section depends on loc section + super(dwarfSections, DW_INFO_SECTION, DW_LOC_SECTION); // initialize to an invalid value voidOffset = -1; // initialize CU start to an invalid value cuStart = -1; } - @Override - public String getSectionName() { - return DwarfSectionNames.DW_INFO_SECTION_NAME; - } - @Override public void createContent() { assert !contentByteArrayCreated(); @@ -126,29 +140,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 DwarfAttributeValues.DW_ATE_signed_char; + return DwarfEncoding.DW_ATE_signed_char; default: assert bitCount == 16 || bitCount == 32 || bitCount == 64; - return DwarfAttributeValues.DW_ATE_signed; + return DwarfEncoding.DW_ATE_signed; } } else { assert bitCount == 16; - return DwarfAttributeValues.DW_ATE_unsigned; + return DwarfEncoding.DW_ATE_unsigned; } } else { assert bitCount == 32 || bitCount == 64; - return DwarfAttributeValues.DW_ATE_float; + return DwarfEncoding.DW_ATE_float; } } else { assert bitCount == 1; - return DwarfAttributeValues.DW_ATE_boolean; + return DwarfEncoding.DW_ATE_boolean; } } @@ -184,9 +198,9 @@ private int writeBuiltInTypes(DebugContext context, byte[] buffer, int p) { 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(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); @@ -246,9 +260,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); @@ -392,9 +406,9 @@ private int writeInstanceClassInfo(DebugContext context, ClassEntry classEntry, 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(DW_FLAG_true, buffer, pos); String name = classEntry.getFullFileName(); if (name == null) { name = classEntry.getTypeName().replace('.', '/') + ".java"; @@ -509,9 +523,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(DW_FLAG_true, buffer, pos); log(context, " [0x%08x] definition(true)", pos); - pos = writeFlag((byte) 1, buffer, pos); + pos = writeFlag(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. @@ -684,9 +698,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(DW_FLAG_true, buffer, pos); log(context, " [0x%08x] definition(true)", pos); - pos = writeFlag((byte) 1, buffer, pos); + pos = writeFlag(DW_FLAG_true, buffer, pos); } return pos; } @@ -717,7 +731,7 @@ private int writeMethodDeclaration(DebugContext context, ClassEntry classEntry, 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(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); @@ -739,11 +753,11 @@ 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() ? DW_FLAG_true : 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(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); @@ -818,10 +832,10 @@ private int writeMethodParameterDeclaration(DebugContext context, DebugLocalInfo pos = writeInfoSectionOffset(typeIdx, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_1) { log(context, " [0x%08x] artificial true", pos); - pos = writeFlag((byte) 1, buffer, pos); + pos = writeFlag(DW_FLAG_true, buffer, pos); } log(context, " [0x%08x] declaration true", pos); - pos = writeFlag((byte) 1, buffer, pos); + pos = writeFlag(DW_FLAG_true, buffer, pos); return pos; } @@ -864,7 +878,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(DW_FLAG_true, buffer, pos); return pos; } @@ -1043,9 +1057,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 ? DwarfAttributeValues.DW_ATE_signed : DwarfAttributeValues.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); @@ -1066,9 +1080,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 ? DwarfAttributeValues.DW_ATE_signed : DwarfAttributeValues.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); @@ -1089,9 +1103,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 = DwarfAttributeValues.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); @@ -1280,9 +1294,9 @@ private int writeArray(DebugContext context, ArrayTypeEntry arrayTypeEntry, byte 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(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); @@ -1539,7 +1553,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(DwarfAttributeValues.DW_FLAG_true, buffer, pos); + pos = writeFlag(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); @@ -1784,13 +1798,13 @@ private int writeAbstractInlineMethod(DebugContext context, ClassEntry classEntr 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, DwarfAttributeValues.DW_INL_inlined); - pos = writeAttrData1(DwarfAttributeValues.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(DwarfAttributeValues.DW_FLAG_true, buffer, pos); + pos = writeFlag(DW_FLAG_true, buffer, pos); int methodSpecOffset = getMethodDeclarationIndex(method); log(context, " [0x%08x] specification 0x%x", pos, methodSpecOffset); pos = writeInfoSectionOffset(methodSpecOffset, buffer, pos); @@ -1829,7 +1843,7 @@ private int writeCUHeader(byte[] buffer, int p) { /* CU length. */ pos = writeInt(0, buffer, pos); /* DWARF version. */ - pos = writeShort(DW_VERSION_4, buffer, pos); + pos = writeDwarfVersion(DwarfVersion.DW_VERSION_4, buffer, pos); /* Abbrev offset. */ pos = writeAbbrevSectionOffset(0, buffer, pos); /* Address size. */ @@ -1842,19 +1856,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 = DwarfAttributeValues.DW_ACCESS_public; + access = DwarfAccess.DW_ACCESS_public; } else if (Modifier.isProtected(modifiers)) { - access = DwarfAttributeValues.DW_ACCESS_protected; + access = DwarfAccess.DW_ACCESS_protected; } else if (Modifier.isPrivate(modifiers)) { - access = DwarfAttributeValues.DW_ACCESS_private; + access = DwarfAccess.DW_ACCESS_private; } else { /* Actually package private -- make it public for now. */ - access = DwarfAttributeValues.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) { @@ -1957,40 +1984,39 @@ public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, in pos = writeULEB(exprSize, buffer, pos); int exprStart = pos; if (!useHeapBase) { - pos = writeByte(DwarfExpressionOpcodes.DW_OP_push_object_address, buffer, pos); - pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + mask), buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_not, buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_and, buffer, pos); + pos = writeExprOpcode(DW_OP_push_object_address, buffer, pos); + pos = writeExprOpcodeLiteral(mask, buffer, pos); + pos = writeExprOpcode(DW_OP_not, buffer, pos); + pos = writeExprOpcode(DW_OP_and, buffer, pos); } else { - pos = writeByte(DwarfExpressionOpcodes.DW_OP_push_object_address, buffer, pos); + pos = writeExprOpcode(DW_OP_push_object_address, buffer, pos); /* skip to end if oop is null */ - pos = writeByte(DwarfExpressionOpcodes.DW_OP_dup, buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_lit0, buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_eq, buffer, pos); + pos = writeExprOpcode(DW_OP_dup, buffer, pos); + pos = writeExprOpcode(DW_OP_lit0, buffer, pos); + pos = writeExprOpcode(DW_OP_eq, buffer, pos); int skipStart = pos + 3; /* offset excludes BR op + 2 operand bytes */ short offsetToEnd = (short) (exprSize - (skipStart - exprStart)); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_bra, buffer, pos); + pos = writeExprOpcode(DW_OP_bra, buffer, pos); pos = writeShort(offsetToEnd, buffer, pos); /* insert mask or shifts as necessary */ if (mask != 0) { - pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + mask), buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_not, buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_and, buffer, pos); + pos = writeExprOpcodeLiteral(mask, buffer, pos); + pos = writeExprOpcode(DW_OP_not, buffer, pos); + pos = writeExprOpcode(DW_OP_and, buffer, pos); } else { if (rightShift != 0) { - pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + rightShift), buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_shr, buffer, pos); + pos = writeExprOpcodeLiteral(rightShift, buffer, pos); + pos = writeExprOpcode(DW_OP_shr, buffer, pos); } if (leftShift != 0) { - pos = writeByte((byte) (DwarfExpressionOpcodes.DW_OP_lit0 + leftShift), buffer, pos); - pos = writeByte(DwarfExpressionOpcodes.DW_OP_shl, buffer, pos); + pos = writeExprOpcodeLiteral(leftShift, buffer, pos); + pos = writeExprOpcode(DW_OP_shl, buffer, pos); } } /* add the resulting offset to the heapbase register */ - byte regOp = (byte) (DwarfExpressionOpcodes.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(DwarfExpressionOpcodes.DW_OP_plus, buffer, pos); + pos = writeExprOpcode(DW_OP_plus, buffer, pos); assert pos == skipStart + offsetToEnd; /* make sure we added up correctly */ @@ -1998,24 +2024,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 = DwarfSectionNames.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 d55dd9b1049d..6f5334716bc1 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,8 +30,7 @@ import java.util.Map; import com.oracle.objectfile.debugentry.ClassEntry; -import com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcodes; -import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; +import com.oracle.objectfile.elf.dwarf.constants.DwarfVersion; import org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.LayoutDecision; @@ -42,10 +41,32 @@ import com.oracle.objectfile.debugentry.range.Range; import com.oracle.objectfile.debugentry.range.SubRange; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNE_define_file; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNE_end_sequence; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNE_set_address; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_advance_line; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_advance_pc; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_const_add_pc; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_copy; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_extended_prefix; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_fixed_advance_pc; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_negate_stmt; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_set_basic_block; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_set_column; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_set_file; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LINE_SECTION; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_STR_SECTION; + /** * 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. */ @@ -64,12 +85,8 @@ public class DwarfLineSectionImpl extends DwarfSectionImpl { private static final int LN_OPCODE_BASE = 13; DwarfLineSectionImpl(DwarfDebugInfo dwarfSections) { - super(dwarfSections); - } - - @Override - public String getSectionName() { - return DwarfSectionNames.DW_LINE_SECTION_NAME; + // line section depends on string section + super(dwarfSections, DW_LINE_SECTION, DW_STR_SECTION); } @Override @@ -242,7 +259,7 @@ private int writeHeader(ClassEntry classEntry, byte[] buffer, int p) { /* * 2 ubyte version is always 2. */ - pos = writeShort(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. */ @@ -472,7 +489,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 != DwarfLineOpcodes.DW_LNS_undefined) { + if (opcode != LN_undefined) { /* * Ignore pointless write when addressDelta == lineDelta == 0. */ @@ -491,7 +508,7 @@ private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEn * line delta. */ opcode = isSpecialOpcode(remainder, lineDelta); - if (opcode != DwarfLineOpcodes.DW_LNS_undefined) { + if (opcode != LN_undefined) { /* * Address remainder and line now fit. */ @@ -502,7 +519,7 @@ private int writeCompiledMethodLineInfo(DebugContext context, ClassEntry classEn * remainder. */ opcode = isSpecialOpcode(remainder, 0); - assert opcode != DwarfLineOpcodes.DW_LNS_undefined; + assert opcode != LN_undefined; pos = writeAdvanceLineOp(context, lineDelta, buffer, pos); pos = writeSpecialOpcode(context, opcode, buffer, pos); } @@ -576,7 +593,7 @@ private static SubRange prologueLeafRange(CompiledMethodEntry compiledEntry) { } private int writeCopyOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_copy; + byte opcode = DW_LNS_copy.value(); int pos = p; debugCopyCount++; verboseLog(context, " [0x%08x] Copy %d", pos, debugCopyCount); @@ -584,7 +601,7 @@ private int writeCopyOp(DebugContext context, byte[] buffer, int p) { } private int writeAdvancePCOp(DebugContext context, long uleb, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_advance_pc; + byte opcode = DW_LNS_advance_pc.value(); int pos = p; debugAddress += uleb; verboseLog(context, " [0x%08x] Advance PC by %d to 0x%08x", pos, uleb, debugAddress); @@ -593,7 +610,7 @@ private int writeAdvancePCOp(DebugContext context, long uleb, byte[] buffer, int } private int writeAdvanceLineOp(DebugContext context, long sleb, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_advance_line; + byte opcode = DW_LNS_advance_line.value(); int pos = p; debugLine += sleb; verboseLog(context, " [0x%08x] Advance Line by %d to %d", pos, sleb, debugLine); @@ -602,7 +619,7 @@ private int writeAdvanceLineOp(DebugContext context, long sleb, byte[] buffer, i } private int writeSetFileOp(DebugContext context, String file, long uleb, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_set_file; + byte opcode = DW_LNS_set_file.value(); 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); @@ -611,7 +628,7 @@ private int writeSetFileOp(DebugContext context, String file, long uleb, byte[] @SuppressWarnings("unused") private int writeSetColumnOp(DebugContext context, long uleb, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_set_column; + byte opcode = DW_LNS_set_column.value(); int pos = p; pos = writeByte(opcode, buffer, pos); return writeULEB(uleb, buffer, pos); @@ -619,20 +636,20 @@ private int writeSetColumnOp(DebugContext context, long uleb, byte[] buffer, int @SuppressWarnings("unused") private int writeNegateStmtOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_negate_stmt; + byte opcode = DW_LNS_negate_stmt.value(); int pos = p; return writeByte(opcode, buffer, pos); } private int writeSetBasicBlockOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_set_basic_block; + byte opcode = DW_LNS_set_basic_block.value(); int pos = p; verboseLog(context, " [0x%08x] Set basic block", pos); return writeByte(opcode, buffer, pos); } private int writeConstAddPCOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_const_add_pc; + byte opcode = DW_LNS_const_add_pc.value(); int pos = p; int advance = opcodeAddress((byte) 255); debugAddress += advance; @@ -641,7 +658,7 @@ private int writeConstAddPCOp(DebugContext context, byte[] buffer, int p) { } private int writeFixedAdvancePCOp(DebugContext context, short arg, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNS_fixed_advance_pc; + byte opcode = DW_LNS_fixed_advance_pc.value(); int pos = p; debugAddress += arg; verboseLog(context, " [0x%08x] Fixed advance Address by %d to 0x%08x", pos, arg, debugAddress); @@ -650,13 +667,13 @@ private int writeFixedAdvancePCOp(DebugContext context, short arg, byte[] buffer } private int writeEndSequenceOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNE_end_sequence; + byte opcode = DW_LNE_end_sequence.value(); int pos = p; verboseLog(context, " [0x%08x] Extended opcode 1: End sequence", pos); debugAddress = debugTextBase; debugLine = 1; debugCopyCount = 0; - pos = writeByte(DwarfLineOpcodes.DW_LNS_extended_prefix, buffer, pos); + pos = writeByte(DW_LNS_extended_prefix.value(), buffer, pos); /* * Insert extended insn byte count as ULEB. */ @@ -665,11 +682,11 @@ private int writeEndSequenceOp(DebugContext context, byte[] buffer, int p) { } private int writeSetAddressOp(DebugContext context, long arg, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNE_set_address; + byte opcode = DW_LNE_set_address.value(); int pos = p; debugAddress = debugTextBase + (int) arg; verboseLog(context, " [0x%08x] Extended opcode 2: Set Address to 0x%08x", pos, debugAddress); - pos = writeByte(DwarfLineOpcodes.DW_LNS_extended_prefix, buffer, pos); + pos = writeByte(DW_LNS_extended_prefix.value(), buffer, pos); /* * Insert extended insn byte count as ULEB. */ @@ -680,7 +697,7 @@ private int writeSetAddressOp(DebugContext context, long arg, byte[] buffer, int @SuppressWarnings("unused") private int writeDefineFileOp(DebugContext context, String file, long uleb1, long uleb2, long uleb3, byte[] buffer, int p) { - byte opcode = DwarfLineOpcodes.DW_LNE_define_file; + byte opcode = DW_LNE_define_file.value(); int pos = p; /* * Calculate bytes needed for opcode + args. @@ -692,7 +709,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(DwarfLineOpcodes.DW_LNS_extended_prefix, buffer, pos); + pos = writeByte(DW_LNS_extended_prefix.value(), buffer, pos); /* * Insert insn length as uleb. */ @@ -739,7 +756,7 @@ private int writeSpecialOpcode(DebugContext context, byte opcode, byte[] buffer, private static byte isSpecialOpcode(long addressDelta, long lineDelta) { if (addressDelta < 0) { - return DwarfLineOpcodes.DW_LNS_undefined; + return LN_undefined; } if (lineDelta >= LN_LINE_BASE) { long offsetLineDelta = lineDelta - LN_LINE_BASE; @@ -759,7 +776,7 @@ private static byte isSpecialOpcode(long addressDelta, long lineDelta) { /* * Answer no by returning an invalid opcode. */ - return DwarfLineOpcodes.DW_LNS_undefined; + return LN_undefined; } private static int isConstAddPC(long addressDelta) { @@ -776,24 +793,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 = DwarfSectionNames.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 2ae3f57299c1..01e957ba91db 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 @@ -36,8 +36,7 @@ import com.oracle.objectfile.debugentry.ClassEntry; import com.oracle.objectfile.debugentry.range.SubRange; -import com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcodes; -import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; +import com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode; import org.graalvm.compiler.debug.DebugContext; import com.oracle.objectfile.BuildDependency; @@ -57,6 +56,13 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.PrimitiveConstant; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_breg0; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_bregx; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_implicit_value; + +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LOC_SECTION; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.TEXT_SECTION; + /** * Section generator for debug_loc section. */ @@ -72,16 +78,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, DW_LOC_SECTION, TEXT_SECTION, targetLayoutKinds); initDwarfRegMap(); } - @Override - public String getSectionName() { - return DwarfSectionNames.DW_LOC_SECTION_NAME; - } - @Override public Set getDependencies(Map decisions) { Set deps = super.getDependencies(decisions); @@ -243,23 +251,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) (DwarfExpressionOpcodes.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 = DwarfExpressionOpcodes.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 +277,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 = DwarfExpressionOpcodes.DW_OP_breg0; - stackOp += (byte) sp; - } else { - // pass base reg index as a ULEB operand - stackOp = DwarfExpressionOpcodes.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 == DwarfExpressionOpcodes.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(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 == DwarfExpressionOpcodes.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, (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, DW_OP_bregx.value(), sp, 0 - offset); } return pos; } @@ -302,13 +304,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 = DwarfExpressionOpcodes.DW_OP_implicit_value; + DwarfExpressionOpcode op = 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 +334,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 = DwarfExpressionOpcodes.DW_OP_implicit_value; + DwarfExpressionOpcode op = 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 +418,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 */ @@ -427,7 +492,8 @@ 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 { @@ -435,8 +501,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) { @@ -461,19 +531,19 @@ protected int writeAttrData1(byte value, byte[] buffer, int pos) { } protected int writeInfoSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DwarfSectionNames.DW_INFO_SECTION_NAME, pos); + return writeDwarfSectionOffset(offset, buffer, DW_INFO_SECTION, pos); } protected int writeLineSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DwarfSectionNames.DW_LINE_SECTION_NAME, pos); + return writeDwarfSectionOffset(offset, buffer, DW_LINE_SECTION, pos); } protected int writeRangesSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DwarfSectionNames.DW_RANGES_SECTION_NAME, pos); + return writeDwarfSectionOffset(offset, buffer, DW_RANGES_SECTION, pos); } protected int writeAbbrevSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DwarfSectionNames.DW_ABBREV_SECTION_NAME, pos); + return writeDwarfSectionOffset(offset, buffer, DW_ABBREV_SECTION, pos); } protected int writeStrSectionOffset(String value, byte[] buffer, int p) { @@ -483,18 +553,18 @@ protected int writeStrSectionOffset(String value, byte[] buffer, int p) { } private int writeStrSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DwarfSectionNames.DW_STR_SECTION_NAME, pos); + return writeDwarfSectionOffset(offset, buffer, DW_STR_SECTION, pos); } protected int writeLocSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DwarfSectionNames.DW_LOC_SECTION_NAME, pos); + return writeDwarfSectionOffset(offset, buffer, 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; } @@ -502,7 +572,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); } /* @@ -549,7 +619,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(DwarfExpressionOpcodes.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); @@ -573,17 +643,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) (DwarfExpressionOpcodes.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 = DwarfExpressionOpcodes.DW_OP_addr; - pos = writeByte(regOp, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_addr, buffer, pos); return writeRelocatableHeapOffset(offset, buffer, pos); } @@ -607,28 +674,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(); } @@ -654,13 +717,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 a99a5254800d..79d276b22486 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,22 +26,19 @@ package com.oracle.objectfile.elf.dwarf; -import com.oracle.objectfile.LayoutDecision; import com.oracle.objectfile.debugentry.StringEntry; -import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionNames; import org.graalvm.compiler.debug.DebugContext; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_INFO_SECTION; +import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_STR_SECTION; + /** * Generator for debug_str section. */ public class DwarfStrSectionImpl extends DwarfSectionImpl { public DwarfStrSectionImpl(DwarfDebugInfo dwarfSections) { - super(dwarfSections); - } - - @Override - public String getSectionName() { - return DwarfSectionNames.DW_STR_SECTION_NAME; + // debug_str section depends on info section + super(dwarfSections, DW_STR_SECTION, DW_INFO_SECTION); } @Override @@ -81,24 +78,4 @@ public void writeContent(DebugContext context) { } assert pos == size; } - - /** - * The debug_str section depends on info section. - */ - private static final String TARGET_SECTION_NAME = DwarfSectionNames.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/DwarfExpressionOpcodes.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAccess.java similarity index 65% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcodes.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAccess.java index 03a0b91680af..be2485c773b8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfExpressionOpcodes.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAccess.java @@ -27,25 +27,20 @@ package com.oracle.objectfile.elf.dwarf.constants; /** - * Values used to build DWARF expressions and locations. + * DW_AT_Accessibility attribute values. */ -public interface DwarfExpressionOpcodes { - byte DW_OP_addr = 0x03; - @SuppressWarnings("unused") byte DW_OP_deref = 0x06; - byte DW_OP_dup = 0x12; - byte DW_OP_and = 0x1a; - byte DW_OP_not = 0x20; - byte DW_OP_plus = 0x22; - byte DW_OP_shl = 0x24; - byte DW_OP_shr = 0x25; - byte DW_OP_bra = 0x28; - byte DW_OP_eq = 0x29; - byte DW_OP_lit0 = 0x30; - byte DW_OP_reg0 = 0x50; - byte DW_OP_breg0 = 0x70; - byte DW_OP_regx = (byte) 0x90; - byte DW_OP_bregx = (byte) 0x92; - byte DW_OP_push_object_address = (byte) 0x97; - byte DW_OP_implicit_value = (byte) 0x9e; - byte DW_OP_stack_value = (byte) 0x9f; +public enum DwarfAccess { + DW_ACCESS_public((byte) 1), + DW_ACCESS_protected((byte) 2), + DW_ACCESS_private((byte) 3); + + 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/DwarfAttributes.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttribute.java similarity index 53% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributes.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttribute.java index 0b9a2b050360..10c87e6b0715 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributes.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttribute.java @@ -29,39 +29,52 @@ /** * All the Dwarf attributes needed to populate DIEs generated by GraalVM. */ -public interface DwarfAttributes { - int DW_AT_null = 0x0; - int DW_AT_location = 0x02; - int DW_AT_name = 0x3; - int DW_AT_byte_size = 0x0b; - int DW_AT_bit_size = 0x0d; - int DW_AT_stmt_list = 0x10; - int DW_AT_low_pc = 0x11; - int DW_AT_hi_pc = 0x12; - int DW_AT_language = 0x13; - int DW_AT_comp_dir = 0x1b; - int DW_AT_containing_type = 0x1d; - int DW_AT_inline = 0x20; - int DW_AT_abstract_origin = 0x31; - int DW_AT_accessibility = 0x32; - int DW_AT_artificial = 0x34; - int DW_AT_count = 0x37; - int DW_AT_data_member_location = 0x38; - @SuppressWarnings("unused") int DW_AT_decl_column = 0x39; - int DW_AT_decl_file = 0x3a; - int DW_AT_decl_line = 0x3b; - int DW_AT_declaration = 0x3c; - int DW_AT_encoding = 0x3e; - int DW_AT_external = 0x3f; - @SuppressWarnings("unused") int DW_AT_return_addr = 0x2a; - @SuppressWarnings("unused") int DW_AT_frame_base = 0x40; - int DW_AT_specification = 0x47; - int DW_AT_type = 0x49; - int DW_AT_data_location = 0x50; - int DW_AT_use_UTF8 = 0x53; - int DW_AT_ranges = 0x55; - int DW_AT_call_file = 0x58; - int DW_AT_call_line = 0x59; - int DW_AT_object_pointer = 0x64; - int DW_AT_linkage_name = 0x6e; +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/DwarfAttributeValues.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java deleted file mode 100644 index c2742d7426e9..000000000000 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfAttributeValues.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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; - -/** - * Pre-defined value ranges appropriate to a specific attribute or form. - */ -public interface DwarfAttributeValues { - /* - * Compile unit DIE header has_children attribute values. - */ - byte DW_CHILDREN_no = 0; - byte DW_CHILDREN_yes = 1; - /* - * DW_FORM_flag haas two possible attribute values. - */ - @SuppressWarnings("unused") byte DW_FLAG_false = 0; - byte DW_FLAG_true = 1; - /* - * DW_AT_language attribute with form DATA1 has a range of pre-defined values. - */ - byte DW_LANG_Java = 0xb; - /* - * Values for DW_AT_inline attribute with form DATA1. - */ - @SuppressWarnings("unused") byte DW_INL_not_inlined = 0; - byte DW_INL_inlined = 1; - @SuppressWarnings("unused") byte DW_INL_declared_not_inlined = 2; - @SuppressWarnings("unused") byte DW_INL_declared_inlined = 3; - /* - * DW_AT_Accessibility attribute values. - */ - byte DW_ACCESS_public = 1; - byte DW_ACCESS_protected = 2; - byte DW_ACCESS_private = 3; - /* - * DW_AT_encoding attribute values - */ - @SuppressWarnings("unused") byte DW_ATE_address = 0x1; - byte DW_ATE_boolean = 0x2; - byte DW_ATE_float = 0x4; - byte DW_ATE_signed = 0x5; - byte DW_ATE_signed_char = 0x6; - byte DW_ATE_unsigned = 0x7; - @SuppressWarnings("unused") byte DW_ATE_unsigned_char = 0x8; -} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionNames.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfEncoding.java similarity index 65% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionNames.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfEncoding.java index ca592506277e..746e7d7f656e 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfSectionNames.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfEncoding.java @@ -27,18 +27,26 @@ package com.oracle.objectfile.elf.dwarf.constants; /** - * Names of the different ELF sections created by GraalVM in reverse dependency order. The sequence - * starts with the name of the text section (not defined in the DWARF spec and not created by debug - * info code). + * DW_AT_encoding attribute values. */ -public interface DwarfSectionNames { - String TEXT_SECTION_NAME = ".text"; - String DW_STR_SECTION_NAME = ".debug_str"; - String DW_LINE_SECTION_NAME = ".debug_line"; - String DW_FRAME_SECTION_NAME = ".debug_frame"; - String DW_ABBREV_SECTION_NAME = ".debug_abbrev"; - String DW_INFO_SECTION_NAME = ".debug_info"; - String DW_LOC_SECTION_NAME = ".debug_loc"; - String DW_ARANGES_SECTION_NAME = ".debug_aranges"; - String DW_RANGES_SECTION_NAME = ".debug_ranges"; +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); + + 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..4f30dc434951 --- /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); + + 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..171f01bb98a2 --- /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); + + 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/DwarfForms.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForm.java similarity index 65% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForm.java index bf2f2c52546d..907c3508989b 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForms.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfForm.java @@ -29,22 +29,38 @@ /** * All the Dwarf attribute forms needed to type attribute values generated by GraalVM. */ -public interface DwarfForms { - int DW_FORM_null = 0x0; - int DW_FORM_addr = 0x1; - int DW_FORM_data2 = 0x05; - int DW_FORM_data4 = 0x6; - @SuppressWarnings("unused") int DW_FORM_data8 = 0x7; - @SuppressWarnings("unused") int DW_FORM_string = 0x8; - @SuppressWarnings("unused") int DW_FORM_block1 = 0x0a; - int DW_FORM_ref_addr = 0x10; - @SuppressWarnings("unused") int DW_FORM_ref1 = 0x11; - @SuppressWarnings("unused") int DW_FORM_ref2 = 0x12; - int DW_FORM_ref4 = 0x13; - @SuppressWarnings("unused") int DW_FORM_ref8 = 0x14; - int DW_FORM_sec_offset = 0x17; - int DW_FORM_data1 = 0x0b; - int DW_FORM_flag = 0xc; - int DW_FORM_strp = 0xe; - int DW_FORM_expr_loc = 0x18; +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); + + 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/DwarfFrameValues.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValue.java similarity index 60% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValues.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValue.java index 6daa70566d03..fe797960b95a 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValues.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfFrameValue.java @@ -29,24 +29,40 @@ /** * Constants that appear in CIE and FDE frame section entries. */ -public interface DwarfFrameValues { - byte DW_CFA_CIE_version = 1; +public enum DwarfFrameValue { + DW_CFA_CIE_version((byte) 1), /* Values encoded in high 2 bits. */ - byte DW_CFA_advance_loc = 0x1; - byte DW_CFA_offset = 0x2; - byte DW_CFA_restore = 0x3; + DW_CFA_advance_loc((byte) 0x1), + DW_CFA_offset((byte) 0x2), + DW_CFA_restore((byte) 0x3), /* Values encoded in low 6 bits. */ - byte DW_CFA_nop = 0x0; - @SuppressWarnings("unused") byte DW_CFA_set_loc1 = 0x1; - byte DW_CFA_advance_loc1 = 0x2; - byte DW_CFA_advance_loc2 = 0x3; - byte DW_CFA_advance_loc4 = 0x4; - @SuppressWarnings("unused") byte DW_CFA_offset_extended = 0x5; - @SuppressWarnings("unused") byte DW_CFA_restore_extended = 0x6; - @SuppressWarnings("unused") byte DW_CFA_undefined = 0x7; - @SuppressWarnings("unused") byte DW_CFA_same_value = 0x8; - byte DW_CFA_register = 0x9; - byte DW_CFA_def_cfa = 0xc; - @SuppressWarnings("unused") byte DW_CFA_def_cfa_register = 0xd; - byte DW_CFA_def_cfa_offset = 0xe; + 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); + + 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..727f6d170453 --- /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); + + 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..210656de739e --- /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); + + 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..1ef4e33d81e1 --- /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); + + 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/DwarfLineOpcodes.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcode.java similarity index 74% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcodes.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcode.java index 8026b5dabe40..3e9a5e00cb23 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcodes.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfLineOpcode.java @@ -29,76 +29,85 @@ /** * Standard line section opcodes defined by Dwarf 4. */ -public interface DwarfLineOpcodes { - /* - * 0 can be returned to indicate an invalid opcode. - */ - byte DW_LNS_undefined = 0; +public enum DwarfLineOpcode { /* * 0 can be inserted as a prefix for extended opcodes. */ - byte DW_LNS_extended_prefix = 0; + DW_LNS_extended_prefix((byte) 0), /* * Append current state as matrix row 0 args. */ - byte DW_LNS_copy = 1; + DW_LNS_copy((byte) 1), /* * Increment address 1 uleb arg. */ - byte DW_LNS_advance_pc = 2; + DW_LNS_advance_pc((byte) 2), /* * Increment line 1 sleb arg. */ - byte DW_LNS_advance_line = 3; + DW_LNS_advance_line((byte) 3), /* * Set file 1 uleb arg. */ - byte DW_LNS_set_file = 4; + DW_LNS_set_file((byte) 4), /* * sSet column 1 uleb arg. */ - byte DW_LNS_set_column = 5; + DW_LNS_set_column((byte) 5), /* * Flip is_stmt 0 args. */ - byte DW_LNS_negate_stmt = 6; + DW_LNS_negate_stmt((byte) 6), /* * Set end sequence and copy row 0 args. */ - byte DW_LNS_set_basic_block = 7; + DW_LNS_set_basic_block((byte) 7), /* * Increment address as per opcode 255 0 args. */ - byte DW_LNS_const_add_pc = 8; + DW_LNS_const_add_pc((byte) 8), /* * Increment address 1 ushort arg. */ - byte DW_LNS_fixed_advance_pc = 9; + DW_LNS_fixed_advance_pc((byte) 9), /* * Increment address 1 ushort arg. */ - @SuppressWarnings("unused") byte DW_LNS_set_prologue_end = 10; + @SuppressWarnings("unused") + DW_LNS_set_prologue_end((byte) 10), /* * Increment address 1 ushort arg. */ - @SuppressWarnings("unused") byte DW_LNS_set_epilogue_begin = 11; + @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") byte DW_LNE_undefined = 0; + @SuppressWarnings("unused") + DW_LNE_undefined((byte) 0), /* * End sequence of addresses. */ - byte DW_LNE_end_sequence = 1; + DW_LNE_end_sequence((byte) 1), /* * Set address as explicit long argument. */ - byte DW_LNE_set_address = 2; + DW_LNE_set_address((byte) 2), /* * Set file as explicit string argument. */ - byte DW_LNE_define_file = 3; + DW_LNE_define_file((byte) 3); + + 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..23d0b4d113e2 --- /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"); + + 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/DwarfTags.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTag.java similarity index 66% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTags.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTag.java index cb6232f93b3b..77d032819818 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTags.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfTag.java @@ -29,23 +29,34 @@ /** * All the Dwarf tags needed to type DIEs generated by GraalVM. */ -public interface DwarfTags { - int DW_TAG_array_type = 0x01; - int DW_TAG_class_type = 0x02; - int DW_TAG_formal_parameter = 0x05; - int DW_TAG_member = 0x0d; - int DW_TAG_pointer_type = 0x0f; - int DW_TAG_compile_unit = 0x11; - int DW_TAG_structure_type = 0x13; - int DW_TAG_typedef = 0x16; - int DW_TAG_union_type = 0x17; - int DW_TAG_inheritance = 0x1c; - int DW_TAG_subrange_type = 0x21; - int DW_TAG_base_type = 0x24; - int DW_TAG_constant = 0x27; - int DW_TAG_subprogram = 0x2e; - int DW_TAG_variable = 0x34; - int DW_TAG_namespace = 0x39; - int DW_TAG_unspecified_type = 0x3b; - int DW_TAG_inlined_subroutine = 0x1d; +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); + + 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/DwarfConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfVersion.java similarity index 69% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfConstants.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfVersion.java index 07af3042a36b..f1643e645fdc 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/constants/DwarfVersion.java @@ -27,21 +27,25 @@ package com.oracle.objectfile.elf.dwarf.constants; /** - * An interface that provides definitions for a variety of constants defined by the DWARF standard, - * employing the same names and types. The primary reference for these constants is the DWARF - * Debugging Information Format Version 4 Specification published at dwarfstd.org. - *

                      - * - * Note that this is not an exhaustive list of all DWARF constants. It merely includes constants - * that are needed by GraalVM. + * The DWARF version values used by GraalVM. */ -public interface DwarfConstants extends DwarfAttributes, DwarfAttributeValues, DwarfExpressionOpcodes, DwarfForms, DwarfFrameValues, DwarfLineOpcodes, DwarfSectionNames, DwarfTags { +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. */ - short DW_VERSION_2 = 2; - short DW_VERSION_4 = 4; + DW_VERSION_2((short) 2), + DW_VERSION_4((short) 4); + + short value; + + DwarfVersion(short s) { + value = s; + } + + public short value() { + return value; + } } From 377d7afd2a788a340a7f8364bf1038b4fffe3750 Mon Sep 17 00:00:00 2001 From: Andrew Dinn Date: Thu, 3 Aug 2023 11:23:25 +0100 Subject: [PATCH 6/7] Respond to review feedback --- .../elf/dwarf/DwarfLineSectionImpl.java | 63 +++++++++++-------- 1 file changed, 36 insertions(+), 27 deletions(-) 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 6f5334716bc1..34d3e3c8a600 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,7 @@ 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.DwarfVersion; import org.graalvm.compiler.debug.DebugContext; @@ -593,111 +594,111 @@ private static SubRange prologueLeafRange(CompiledMethodEntry compiledEntry) { } private int writeCopyOp(DebugContext context, byte[] buffer, int p) { - byte opcode = DW_LNS_copy.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(); + DwarfLineOpcode opcode = 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.value(), 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.value(); + DwarfLineOpcode opcode = 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.value(), 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.value(); + DwarfLineOpcode opcode = DW_LNE_define_file; int pos = p; /* * Calculate bytes needed for opcode + args. @@ -709,7 +710,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.value(), buffer, pos); + pos = writePrefixOpcode(buffer, pos); /* * Insert insn length as uleb. */ @@ -717,13 +718,21 @@ 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(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 - LN_OPCODE_BASE; From bc435f5d095c54b19b0fad0d9724464e148792c4 Mon Sep 17 00:00:00 2001 From: Andrew Dinn Date: Mon, 7 Aug 2023 19:04:50 +0100 Subject: [PATCH 7/7] respond to second review --- .../elf/dwarf/DwarfARangesSectionImpl.java | 11 +- .../elf/dwarf/DwarfAbbrevSectionImpl.java | 749 ++++++++---------- .../elf/dwarf/DwarfFrameSectionImpl.java | 6 +- .../elf/dwarf/DwarfInfoSectionImpl.java | 78 +- .../elf/dwarf/DwarfLineSectionImpl.java | 46 +- .../elf/dwarf/DwarfLocSectionImpl.java | 20 +- .../elf/dwarf/DwarfRangesSectionImpl.java | 6 +- .../elf/dwarf/DwarfSectionImpl.java | 22 +- .../elf/dwarf/DwarfStrSectionImpl.java | 6 +- .../elf/dwarf/constants/DwarfAccess.java | 2 +- .../elf/dwarf/constants/DwarfEncoding.java | 2 +- .../constants/DwarfExpressionOpcode.java | 2 +- .../elf/dwarf/constants/DwarfFlag.java | 2 +- .../elf/dwarf/constants/DwarfForm.java | 2 +- .../elf/dwarf/constants/DwarfFrameValue.java | 2 +- .../elf/dwarf/constants/DwarfHasChildren.java | 2 +- .../elf/dwarf/constants/DwarfInline.java | 2 +- .../elf/dwarf/constants/DwarfLanguage.java | 2 +- .../elf/dwarf/constants/DwarfLineOpcode.java | 2 +- .../elf/dwarf/constants/DwarfSectionName.java | 2 +- .../elf/dwarf/constants/DwarfTag.java | 2 +- .../elf/dwarf/constants/DwarfVersion.java | 2 +- 22 files changed, 425 insertions(+), 545 deletions(-) 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 59506700867f..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; @@ -37,11 +39,6 @@ import com.oracle.objectfile.debugentry.CompiledMethodEntry; import com.oracle.objectfile.debugentry.range.Range; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_ARANGES_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_FRAME_SECTION; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfVersion.DW_VERSION_2; - /** * Section generator for debug_aranges section. */ @@ -51,7 +48,7 @@ public class DwarfARangesSectionImpl extends DwarfSectionImpl { private static final int AR_HEADER_PAD_SIZE = 4; public DwarfARangesSectionImpl(DwarfDebugInfo dwarfSections) { - super(dwarfSections, DW_ARANGES_SECTION, DW_FRAME_SECTION); + super(dwarfSections, DwarfSectionName.DW_ARANGES_SECTION, DwarfSectionName.DW_FRAME_SECTION); } @Override @@ -161,7 +158,7 @@ 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 = writeDwarfVersion(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); 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 4de1ea05464c..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 @@ -29,78 +29,11 @@ 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; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_abstract_origin; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_accessibility; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_artificial; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_bit_size; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_byte_size; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_call_file; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_call_line; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_comp_dir; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_containing_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_count; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_data_location; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_data_member_location; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_decl_file; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_decl_line; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_declaration; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_encoding; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_external; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_hi_pc; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_inline; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_language; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_linkage_name; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_location; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_low_pc; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_name; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_null; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_object_pointer; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_ranges; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_specification; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_stmt_list; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfAttribute.DW_AT_use_UTF8; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_addr; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_data1; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_data2; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_data4; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_expr_loc; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_flag; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_null; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_ref4; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_ref_addr; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_sec_offset; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfForm.DW_FORM_strp; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfHasChildren.DW_CHILDREN_no; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfHasChildren.DW_CHILDREN_yes; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_ABBREV_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_RANGES_SECTION; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_array_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_base_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_class_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_compile_unit; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_constant; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_formal_parameter; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_inheritance; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_inlined_subroutine; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_member; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_namespace; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_pointer_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_structure_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_subprogram; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_subrange_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_typedef; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_union_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_unspecified_type; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfTag.DW_TAG_variable; - /** * Section generator for debug_abbrev section. That section defines the layout of the * DWARF Information Entries (DIEs) used to model Java debug info. Top level DIEs define Java @@ -901,7 +834,7 @@ public class DwarfAbbrevSectionImpl extends DwarfSectionImpl { public DwarfAbbrevSectionImpl(DwarfDebugInfo dwarfSections) { // abbrev section depends on ranges section - super(dwarfSections, DW_ABBREV_SECTION, DW_RANGES_SECTION); + super(dwarfSections, DwarfSectionName.DW_ABBREV_SECTION, DwarfSectionName.DW_RANGES_SECTION); } @Override @@ -1018,97 +951,97 @@ private int writeCompileUnitAbbrevs(@SuppressWarnings("unused") DebugContext con private int writeCompileUnitAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_compile_unit, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_language, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_use_UTF8, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_comp_dir, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, 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(DW_AT_ranges, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); - pos = writeAttrType(DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_stmt_list, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(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(AbbrevCode.PRIMITIVE_TYPE, buffer, pos); - pos = writeTag(DW_TAG_base_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_bit_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_encoding, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(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(AbbrevCode.VOID_TYPE, buffer, pos); - pos = writeTag(DW_TAG_unspecified_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(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(AbbrevCode.OBJECT_HEADER, buffer, pos); - pos = writeTag(DW_TAG_structure_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(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(AbbrevCode.NAMESPACE, buffer, pos); - pos = writeTag(DW_TAG_namespace, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1125,28 +1058,28 @@ private int writeClassLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_class_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(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 == AbbrevCode.CLASS_LAYOUT_2) { - pos = writeAttrType(DW_AT_data_location, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1156,17 +1089,17 @@ private int writeClassReferenceAbbrev(@SuppressWarnings("unused") DebugContext c /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.CLASS_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1180,40 +1113,40 @@ private int writeMethodDeclarationAbbrevs(@SuppressWarnings("unused") DebugConte private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_subprogram, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_linkage_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_artificial, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(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(DW_AT_virtuality, buffer, pos); // pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_containing_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_object_pointer, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_object_pointer, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_ref4, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1233,65 +1166,65 @@ private int writeFieldDeclarationAbbrevs(DebugContext context, byte[] buffer, in private int writeFieldDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_member, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(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 == AbbrevCode.FIELD_DECLARATION_2 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { - pos = writeAttrType(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(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 line numbers. */ // pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos); // pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos); } - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + 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(DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(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(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(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 == AbbrevCode.FIELD_DECLARATION_3 || abbrevCode == AbbrevCode.FIELD_DECLARATION_4) { - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, 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); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(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(AbbrevCode.CLASS_CONSTANT, buffer, pos); - pos = writeTag(DW_TAG_constant, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, 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(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_location, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1299,17 +1232,17 @@ private int writeArrayLayoutAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_LAYOUT, buffer, pos); - pos = writeTag(DW_TAG_class_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(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); /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1317,17 +1250,17 @@ private int writeArrayReferenceAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1335,15 +1268,15 @@ private int writeInterfaceLayoutAbbrev(@SuppressWarnings("unused") DebugContext int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_LAYOUT, buffer, pos); - pos = writeTag(DW_TAG_union_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1351,17 +1284,17 @@ private int writeInterfaceReferenceAbbrev(@SuppressWarnings("unused") DebugConte int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1369,19 +1302,19 @@ private int writeInterfaceImplementorAbbrev(@SuppressWarnings("unused") DebugCon int pos = p; pos = writeAbbrevCode(AbbrevCode.INTERFACE_IMPLEMENTOR, buffer, pos); - pos = writeTag(DW_TAG_member, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1390,20 +1323,20 @@ private int writeForeignReferenceAbbrev(@SuppressWarnings("unused") DebugContext /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, 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(DW_AT_type, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1412,17 +1345,17 @@ private int writeForeignTypedefAbbrev(@SuppressWarnings("unused") DebugContext c /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_TYPEDEF, buffer, pos); - pos = writeTag(DW_TAG_typedef, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1431,17 +1364,17 @@ private int writeForeignStructAbbrev(@SuppressWarnings("unused") DebugContext co /* A pointer to the class struct type. */ pos = writeAbbrevCode(AbbrevCode.FOREIGN_STRUCT, buffer, pos); - pos = writeTag(DW_TAG_structure_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1449,21 +1382,21 @@ private int writeHeaderFieldAbbrev(@SuppressWarnings("unused") DebugContext cont int pos = p; pos = writeAbbrevCode(AbbrevCode.HEADER_FIELD, buffer, pos); - pos = writeTag(DW_TAG_member, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1478,23 +1411,23 @@ private int writeArrayDataTypeAbbrev(@SuppressWarnings("unused") DebugContext co int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_array_type, buffer, pos); + pos = writeTag(DwarfTag.DW_TAG_array_type, buffer, pos); boolean hasChildren = (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2); - pos = writeHasChildren((hasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no), buffer, pos); + pos = writeHasChildren((hasChildren ? DwarfHasChildren.DW_CHILDREN_yes : DwarfHasChildren.DW_CHILDREN_no), buffer, pos); if (abbrevCode == AbbrevCode.ARRAY_DATA_TYPE_2) { - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, buffer, pos); + 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(DW_AT_type, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1503,55 +1436,55 @@ private int writeArraySubrangeTypeAbbrev(@SuppressWarnings("unused") DebugContex int pos = p; pos = writeAbbrevCode(AbbrevCode.ARRAY_SUBRANGE, buffer, pos); - pos = writeTag(DW_TAG_subrange_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_count, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(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(AbbrevCode.METHOD_LOCATION, buffer, pos); - pos = writeTag(DW_TAG_subprogram, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_hi_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_specification, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(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(AbbrevCode.ABSTRACT_INLINE_METHOD, buffer, pos); - pos = writeTag(DW_TAG_subprogram, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_inline, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_external, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); - pos = writeAttrType(DW_AT_specification, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1559,19 +1492,19 @@ private int writeStaticFieldLocationAbbrev(@SuppressWarnings("unused") DebugCont int pos = p; pos = writeAbbrevCode(AbbrevCode.STATIC_FIELD_LOCATION, buffer, pos); - pos = writeTag(DW_TAG_variable, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_specification, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_location, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1579,19 +1512,19 @@ private int writeSuperReferenceAbbrev(@SuppressWarnings("unused") DebugContext c int pos = p; pos = writeAbbrevCode(AbbrevCode.SUPER_REFERENCE, buffer, pos); - pos = writeTag(DW_TAG_inheritance, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_data_member_location, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_accessibility, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1607,20 +1540,20 @@ private int writeIndirectLayoutAbbrev(@SuppressWarnings("unused") DebugContext c */ /* the type for an indirect layout that includes address translation info */ pos = writeAbbrevCode(AbbrevCode.INDIRECT_LAYOUT, buffer, pos); - pos = writeTag(DW_TAG_class_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_yes, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(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); /* Add a data location expression to rebase oop pointers stored as offsets. */ - pos = writeAttrType(DW_AT_data_location, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1630,17 +1563,17 @@ private int writeIndirectReferenceAbbrev(@SuppressWarnings("unused") DebugContex /* The type for a pointer to the indirect layout type. */ pos = writeAbbrevCode(AbbrevCode.INDIRECT_POINTER, buffer, pos); - pos = writeTag(DW_TAG_pointer_type, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_byte_size, buffer, pos); - pos = writeAttrForm(DW_FORM_data1, buffer, pos); - pos = writeAttrType(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1655,31 +1588,31 @@ private int writeParameterDeclarationAbbrevs(DebugContext context, byte[] buffer private int writeParameterDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_formal_parameter, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + 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(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(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(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); + 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(DW_AT_artificial, buffer, pos); - pos = writeAttrForm(DW_FORM_flag, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_artificial, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_flag, buffer, pos); } - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1693,26 +1626,26 @@ private int writeLocalDeclarationAbbrevs(DebugContext context, byte[] buffer, in private int writeLocalDeclarationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_variable, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_name, buffer, pos); - pos = writeAttrForm(DW_FORM_strp, buffer, pos); + 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(DW_AT_decl_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data2, buffer, pos); - pos = writeAttrType(DW_AT_decl_line, buffer, pos); - pos = writeAttrForm(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(DW_AT_type, buffer, pos); - pos = writeAttrForm(DW_FORM_ref_addr, buffer, pos); - pos = writeAttrType(DW_AT_declaration, buffer, pos); - pos = writeAttrForm(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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1733,38 +1666,38 @@ private int writeLocalLocationAbbrevs(@SuppressWarnings("unused") DebugContext c private int writeParameterLocationAbbrev(@SuppressWarnings("unused") DebugContext context, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_formal_parameter, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_location, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_location, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(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, AbbrevCode abbrevCode, byte[] buffer, int p) { int pos = p; pos = writeAbbrevCode(abbrevCode, buffer, pos); - pos = writeTag(DW_TAG_variable, buffer, pos); - pos = writeHasChildren(DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, 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(DW_AT_location, buffer, pos); - pos = writeAttrForm(DW_FORM_sec_offset, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_location, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_sec_offset, buffer, pos); } /* * Now terminate. */ - pos = writeAttrType(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } @@ -1777,21 +1710,21 @@ private int writeNullAbbrev(@SuppressWarnings("unused") DebugContext context, by private int writeInlinedSubroutineAbbrev(byte[] buffer, int p, boolean withChildren) { int pos = p; pos = writeAbbrevCode(withChildren ? AbbrevCode.INLINED_SUBROUTINE_WITH_CHILDREN : AbbrevCode.INLINED_SUBROUTINE, buffer, pos); - pos = writeTag(DW_TAG_inlined_subroutine, buffer, pos); - pos = writeHasChildren(withChildren ? DW_CHILDREN_yes : DW_CHILDREN_no, buffer, pos); - pos = writeAttrType(DW_AT_abstract_origin, buffer, pos); - pos = writeAttrForm(DW_FORM_ref4, buffer, pos); - pos = writeAttrType(DW_AT_low_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_hi_pc, buffer, pos); - pos = writeAttrForm(DW_FORM_addr, buffer, pos); - pos = writeAttrType(DW_AT_call_file, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, buffer, pos); - pos = writeAttrType(DW_AT_call_line, buffer, pos); - pos = writeAttrForm(DW_FORM_data4, 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(DW_AT_null, buffer, pos); - pos = writeAttrForm(DW_FORM_null, buffer, pos); + pos = writeAttrType(DwarfAttribute.DW_AT_null, buffer, pos); + pos = writeAttrForm(DwarfForm.DW_FORM_null, buffer, pos); return pos; } } 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 b8b95eee02e8..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 @@ -30,13 +30,11 @@ 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; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_FRAME_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LINE_SECTION; - /** * Section generic generator for debug_frame section. */ @@ -48,7 +46,7 @@ public abstract class DwarfFrameSectionImpl extends DwarfSectionImpl { public DwarfFrameSectionImpl(DwarfDebugInfo dwarfSections) { // debug_frame section depends on debug_line section - super(dwarfSections, DW_FRAME_SECTION, DW_LINE_SECTION); + super(dwarfSections, DwarfSectionName.DW_FRAME_SECTION, DwarfSectionName.DW_LINE_SECTION); } @Override 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 d4a10b327dcb..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 @@ -35,8 +35,11 @@ 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; @@ -64,23 +67,6 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.PrimitiveConstant; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_and; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_bra; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_dup; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_eq; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_lit0; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_not; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_plus; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_push_object_address; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_shl; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_shr; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfFlag.DW_FLAG_false; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfFlag.DW_FLAG_true; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_INFO_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LOC_SECTION; - /** * Section generator for debug_info section. */ @@ -106,7 +92,7 @@ public class DwarfInfoSectionImpl extends DwarfSectionImpl { public DwarfInfoSectionImpl(DwarfDebugInfo dwarfSections) { // debug_info section depends on loc section - super(dwarfSections, DW_INFO_SECTION, DW_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 @@ -200,7 +186,7 @@ private int writeBuiltInTypes(DebugContext context, byte[] buffer, int p) { log(context, " [0x%08x] language %s", pos, "DW_LANG_Java"); pos = writeAttrLanguage(DwarfDebugInfo.LANG_ENCODING, buffer, pos); log(context, " [0x%08x] use_UTF8", pos); - pos = writeFlag(DW_FLAG_true, 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); @@ -408,7 +394,7 @@ private int writeInstanceClassInfo(DebugContext context, ClassEntry classEntry, log(context, " [0x%08x] language %s", pos, "DW_LANG_Java"); pos = writeAttrLanguage(DwarfDebugInfo.LANG_ENCODING, buffer, pos); log(context, " [0x%08x] use_UTF8", pos); - pos = writeFlag(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos); String name = classEntry.getFullFileName(); if (name == null) { name = classEntry.getTypeName().replace('.', '/') + ".java"; @@ -523,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(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos); log(context, " [0x%08x] definition(true)", pos); - pos = writeFlag(DW_FLAG_true, 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. @@ -698,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(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos); log(context, " [0x%08x] definition(true)", pos); - pos = writeFlag(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos); } return pos; } @@ -731,7 +717,7 @@ private int writeMethodDeclaration(DebugContext context, ClassEntry classEntry, log(context, " [0x%08x] <2> Abbrev Number %d", pos, abbrevCode); pos = writeAbbrevCode(abbrevCode, buffer, pos); log(context, " [0x%08x] external true", pos); - pos = writeFlag(DW_FLAG_true, 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); @@ -753,11 +739,11 @@ 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() ? DW_FLAG_true : DW_FLAG_false), 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(DW_FLAG_true, 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); @@ -832,10 +818,10 @@ private int writeMethodParameterDeclaration(DebugContext context, DebugLocalInfo pos = writeInfoSectionOffset(typeIdx, buffer, pos); if (abbrevCode == AbbrevCode.METHOD_PARAMETER_DECLARATION_1) { log(context, " [0x%08x] artificial true", pos); - pos = writeFlag(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos); } log(context, " [0x%08x] declaration true", pos); - pos = writeFlag(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos); return pos; } @@ -878,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(DW_FLAG_true, buffer, pos); + pos = writeFlag(DwarfFlag.DW_FLAG_true, buffer, pos); return pos; } @@ -1296,7 +1282,7 @@ private int writeArray(DebugContext context, ArrayTypeEntry arrayTypeEntry, byte log(context, " [0x%08x] language %s", pos, "DW_LANG_Java"); pos = writeAttrLanguage(DwarfDebugInfo.LANG_ENCODING, buffer, pos); log(context, " [0x%08x] use_UTF8", pos); - pos = writeFlag(DW_FLAG_true, 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); @@ -1553,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(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); @@ -1804,7 +1790,7 @@ private int writeAbstractInlineMethod(DebugContext context, ClassEntry classEntr * Should pass true only if method is non-private. */ log(context, " [0x%08x] external true", pos); - pos = writeFlag(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); @@ -1984,39 +1970,39 @@ public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, in pos = writeULEB(exprSize, buffer, pos); int exprStart = pos; if (!useHeapBase) { - pos = writeExprOpcode(DW_OP_push_object_address, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_push_object_address, buffer, pos); pos = writeExprOpcodeLiteral(mask, buffer, pos); - pos = writeExprOpcode(DW_OP_not, buffer, pos); - pos = writeExprOpcode(DW_OP_and, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_not, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_and, buffer, pos); } else { - pos = writeExprOpcode(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 = writeExprOpcode(DW_OP_dup, buffer, pos); - pos = writeExprOpcode(DW_OP_lit0, buffer, pos); - pos = writeExprOpcode(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 = writeExprOpcode(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 = writeExprOpcodeLiteral(mask, buffer, pos); - pos = writeExprOpcode(DW_OP_not, buffer, pos); - pos = writeExprOpcode(DW_OP_and, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_not, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_and, buffer, pos); } else { if (rightShift != 0) { pos = writeExprOpcodeLiteral(rightShift, buffer, pos); - pos = writeExprOpcode(DW_OP_shr, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_shr, buffer, pos); } if (leftShift != 0) { pos = writeExprOpcodeLiteral(leftShift, buffer, pos); - pos = writeExprOpcode(DW_OP_shl, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_shl, buffer, pos); } } /* add the resulting offset to the heapbase register */ pos = writeExprOpcodeBReg(dwarfSections.getHeapbaseRegister(), buffer, pos); pos = writeSLEB(0, buffer, pos); /* 1 byte. */ - pos = writeExprOpcode(DW_OP_plus, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_plus, buffer, pos); assert pos == skipStart + offsetToEnd; /* make sure we added up correctly */ 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 34d3e3c8a600..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 @@ -31,6 +31,7 @@ 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; @@ -42,23 +43,6 @@ import com.oracle.objectfile.debugentry.range.Range; import com.oracle.objectfile.debugentry.range.SubRange; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNE_define_file; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNE_end_sequence; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNE_set_address; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_advance_line; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_advance_pc; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_const_add_pc; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_copy; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_extended_prefix; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_fixed_advance_pc; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_negate_stmt; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_set_basic_block; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_set_column; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfLineOpcode.DW_LNS_set_file; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LINE_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_STR_SECTION; - /** * Section generator for debug_line section. */ @@ -87,7 +71,7 @@ public class DwarfLineSectionImpl extends DwarfSectionImpl { DwarfLineSectionImpl(DwarfDebugInfo dwarfSections) { // line section depends on string section - super(dwarfSections, DW_LINE_SECTION, DW_STR_SECTION); + super(dwarfSections, DwarfSectionName.DW_LINE_SECTION, DwarfSectionName.DW_STR_SECTION); } @Override @@ -594,7 +578,7 @@ private static SubRange prologueLeafRange(CompiledMethodEntry compiledEntry) { } private int writeCopyOp(DebugContext context, byte[] buffer, int p) { - DwarfLineOpcode opcode = DW_LNS_copy; + DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_copy; int pos = p; debugCopyCount++; verboseLog(context, " [0x%08x] Copy %d", pos, debugCopyCount); @@ -602,7 +586,7 @@ private int writeCopyOp(DebugContext context, byte[] buffer, int p) { } private int writeAdvancePCOp(DebugContext context, long uleb, byte[] buffer, int p) { - DwarfLineOpcode 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); @@ -611,7 +595,7 @@ private int writeAdvancePCOp(DebugContext context, long uleb, byte[] buffer, int } private int writeAdvanceLineOp(DebugContext context, long sleb, byte[] buffer, int p) { - DwarfLineOpcode 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); @@ -620,7 +604,7 @@ private int writeAdvanceLineOp(DebugContext context, long sleb, byte[] buffer, i } private int writeSetFileOp(DebugContext context, String file, long uleb, byte[] buffer, int p) { - DwarfLineOpcode 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 = writeLineOpcode(opcode, buffer, pos); @@ -629,7 +613,7 @@ private int writeSetFileOp(DebugContext context, String file, long uleb, byte[] @SuppressWarnings("unused") private int writeSetColumnOp(DebugContext context, long uleb, byte[] buffer, int p) { - DwarfLineOpcode opcode = DW_LNS_set_column; + DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_set_column; int pos = p; pos = writeLineOpcode(opcode, buffer, pos); return writeULEB(uleb, buffer, pos); @@ -637,20 +621,20 @@ private int writeSetColumnOp(DebugContext context, long uleb, byte[] buffer, int @SuppressWarnings("unused") private int writeNegateStmtOp(DebugContext context, byte[] buffer, int p) { - DwarfLineOpcode opcode = DW_LNS_negate_stmt; + DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_negate_stmt; int pos = p; return writeLineOpcode(opcode, buffer, pos); } private int writeSetBasicBlockOp(DebugContext context, byte[] buffer, int p) { - DwarfLineOpcode 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 writeLineOpcode(opcode, buffer, pos); } private int writeConstAddPCOp(DebugContext context, byte[] buffer, int p) { - DwarfLineOpcode opcode = DW_LNS_const_add_pc; + DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNS_const_add_pc; int pos = p; int advance = opcodeAddress((byte) 255); debugAddress += advance; @@ -659,7 +643,7 @@ private int writeConstAddPCOp(DebugContext context, byte[] buffer, int p) { } private int writeFixedAdvancePCOp(DebugContext context, short arg, byte[] buffer, int p) { - DwarfLineOpcode 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); @@ -668,7 +652,7 @@ private int writeFixedAdvancePCOp(DebugContext context, short arg, byte[] buffer } private int writeEndSequenceOp(DebugContext context, byte[] buffer, int p) { - DwarfLineOpcode 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; @@ -683,7 +667,7 @@ private int writeEndSequenceOp(DebugContext context, byte[] buffer, int p) { } private int writeSetAddressOp(DebugContext context, long arg, byte[] buffer, int p) { - DwarfLineOpcode 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); @@ -698,7 +682,7 @@ private int writeSetAddressOp(DebugContext context, long arg, byte[] buffer, int @SuppressWarnings("unused") private int writeDefineFileOp(DebugContext context, String file, long uleb1, long uleb2, long uleb3, byte[] buffer, int p) { - DwarfLineOpcode opcode = DW_LNE_define_file; + DwarfLineOpcode opcode = DwarfLineOpcode.DW_LNE_define_file; int pos = p; /* * Calculate bytes needed for opcode + args. @@ -726,7 +710,7 @@ private int writeDefineFileOp(DebugContext context, String file, long uleb1, lon } private int writePrefixOpcode(byte[] buffer, int p) { - return writeLineOpcode(DW_LNS_extended_prefix, buffer, p); + return writeLineOpcode(DwarfLineOpcode.DW_LNS_extended_prefix, buffer, p); } private int writeLineOpcode(DwarfLineOpcode opcode, byte[] buffer, int p) { 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 01e957ba91db..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 @@ -37,6 +37,7 @@ 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; @@ -56,13 +57,6 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.PrimitiveConstant; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_breg0; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_bregx; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfExpressionOpcode.DW_OP_implicit_value; - -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LOC_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.TEXT_SECTION; - /** * Section generator for debug_loc section. */ @@ -86,7 +80,7 @@ public class DwarfLocSectionImpl extends DwarfSectionImpl { public DwarfLocSectionImpl(DwarfDebugInfo dwarfSections) { // debug_loc section depends on text section - super(dwarfSections, DW_LOC_SECTION, TEXT_SECTION, targetLayoutKinds); + super(dwarfSections, DwarfSectionName.DW_LOC_SECTION, DwarfSectionName.TEXT_SECTION, targetLayoutKinds); initDwarfRegMap(); } @@ -285,7 +279,7 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer, // fold the base reg index into the op pos = writeExprOpcodeBReg(sp, buffer, pos); } else { - pos = writeExprOpcode(DW_OP_bregx, buffer, pos); + pos = writeExprOpcode(DwarfExpressionOpcode.DW_OP_bregx, buffer, pos); // pass base reg index as a ULEB operand pos = writeULEB(sp, buffer, pos); } @@ -294,9 +288,9 @@ private int writeStackLocation(DebugContext context, int offset, byte[] buffer, byteCount = (byte) (pos - zeroPos); writeShort(byteCount, buffer, patchPos); if (sp < 0x20) { - verboseLog(context, " [0x%08x] STACKOP count %d op 0x%x offset %d", pos, byteCount, (DW_OP_breg0.value() + sp), 0 - offset); + 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, DW_OP_bregx.value(), 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; } @@ -304,7 +298,7 @@ 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; - DwarfExpressionOpcode 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 @@ -334,7 +328,7 @@ private int writePrimitiveConstantLocation(DebugContext context, JavaConstant co private int writeNullConstantLocation(DebugContext context, JavaConstant constant, byte[] buffer, int p) { assert constant.isNull(); int pos = p; - DwarfExpressionOpcode 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; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfRangesSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfRangesSectionImpl.java index f2aaf5e79c6a..f649d24fc474 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfRangesSectionImpl.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfRangesSectionImpl.java @@ -30,17 +30,15 @@ import com.oracle.objectfile.LayoutDecisionMap; import com.oracle.objectfile.ObjectFile; import com.oracle.objectfile.debugentry.ClassEntry; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName; import org.graalvm.compiler.debug.DebugContext; import java.util.Map; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_ARANGES_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_RANGES_SECTION; - public class DwarfRangesSectionImpl extends DwarfSectionImpl { public DwarfRangesSectionImpl(DwarfDebugInfo dwarfSections) { // debug_ranges section depends on debug_aranges section - super(dwarfSections, DW_RANGES_SECTION, DW_ARANGES_SECTION); + super(dwarfSections, DwarfSectionName.DW_RANGES_SECTION, DwarfSectionName.DW_ARANGES_SECTION); } @Override diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java index efc481bac00a..7d0715f411c8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfSectionImpl.java @@ -61,14 +61,6 @@ import java.util.Set; import java.util.stream.Stream; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_ABBREV_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_INFO_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LINE_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_LOC_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_RANGES_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_STR_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.TEXT_SECTION; - /** * A class from which all DWARF debug sections inherit providing common behaviours. */ @@ -290,7 +282,7 @@ protected int putRelocatableCodeOffset(long l, byte[] buffer, int p) { /* * Mark address so it is relocated relative to the start of the text segment. */ - markRelocationSite(pos, ObjectFile.RelocationKind.DIRECT_8, TEXT_SECTION.value(), l); + markRelocationSite(pos, ObjectFile.RelocationKind.DIRECT_8, DwarfSectionName.TEXT_SECTION.value(), l); pos = writeLong(0, buffer, pos); return pos; } @@ -531,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, DW_INFO_SECTION, pos); + return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_INFO_SECTION, pos); } protected int writeLineSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DW_LINE_SECTION, pos); + return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_LINE_SECTION, pos); } protected int writeRangesSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DW_RANGES_SECTION, pos); + return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_RANGES_SECTION, pos); } protected int writeAbbrevSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DW_ABBREV_SECTION, pos); + return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_ABBREV_SECTION, pos); } protected int writeStrSectionOffset(String value, byte[] buffer, int p) { @@ -553,11 +545,11 @@ protected int writeStrSectionOffset(String value, byte[] buffer, int p) { } private int writeStrSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DW_STR_SECTION, pos); + return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_STR_SECTION, pos); } protected int writeLocSectionOffset(int offset, byte[] buffer, int pos) { - return writeDwarfSectionOffset(offset, buffer, DW_LOC_SECTION, pos); + return writeDwarfSectionOffset(offset, buffer, DwarfSectionName.DW_LOC_SECTION, pos); } protected int writeDwarfSectionOffset(int offset, byte[] buffer, DwarfSectionName referencedSectionName, int pos) { 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 79d276b22486..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 @@ -27,18 +27,16 @@ package com.oracle.objectfile.elf.dwarf; import com.oracle.objectfile.debugentry.StringEntry; +import com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName; import org.graalvm.compiler.debug.DebugContext; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_INFO_SECTION; -import static com.oracle.objectfile.elf.dwarf.constants.DwarfSectionName.DW_STR_SECTION; - /** * Generator for debug_str section. */ public class DwarfStrSectionImpl extends DwarfSectionImpl { public DwarfStrSectionImpl(DwarfDebugInfo dwarfSections) { // debug_str section depends on info section - super(dwarfSections, DW_STR_SECTION, DW_INFO_SECTION); + super(dwarfSections, DwarfSectionName.DW_STR_SECTION, DwarfSectionName.DW_INFO_SECTION); } @Override 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 index be2485c773b8..4030e41e0d82 100644 --- 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 @@ -34,7 +34,7 @@ public enum DwarfAccess { DW_ACCESS_protected((byte) 2), DW_ACCESS_private((byte) 3); - byte value; + private final byte value; DwarfAccess(byte b) { value = b; 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 index 746e7d7f656e..c5cb704e0022 100644 --- 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 @@ -40,7 +40,7 @@ public enum DwarfEncoding { @SuppressWarnings("unused") DW_ATE_unsigned_char((byte) 0x8); - byte value; + private final byte value; DwarfEncoding(byte b) { value = b; 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 index 4f30dc434951..c55014c908cb 100644 --- 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 @@ -50,7 +50,7 @@ public enum DwarfExpressionOpcode { DW_OP_implicit_value((byte) 0x9e), DW_OP_stack_value((byte) 0x9f); - byte value; + private final byte value; DwarfExpressionOpcode(byte b) { value = b; 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 index 171f01bb98a2..f83fe93b8bfd 100644 --- 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 @@ -34,7 +34,7 @@ public enum DwarfFlag { DW_FLAG_false((byte) 0), DW_FLAG_true((byte) 1); - byte value; + private final byte value; DwarfFlag(byte b) { value = b; 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 index 907c3508989b..0dc5b3aedad3 100644 --- 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 @@ -54,7 +54,7 @@ public enum DwarfForm { DW_FORM_strp(0xe), DW_FORM_expr_loc(0x18); - int value; + private final int value; DwarfForm(int i) { value = i; 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 index fe797960b95a..77ba64cecf37 100644 --- 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 @@ -56,7 +56,7 @@ public enum DwarfFrameValue { DW_CFA_def_cfa_register((byte) 0xd), DW_CFA_def_cfa_offset((byte) 0xe); - byte value; + private final byte value; DwarfFrameValue(byte b) { value = b; 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 index 727f6d170453..d565d8080920 100644 --- 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 @@ -33,7 +33,7 @@ public enum DwarfHasChildren { DW_CHILDREN_no((byte) 0), DW_CHILDREN_yes((byte) 1); - byte value; + private final byte value; DwarfHasChildren(byte b) { value = b; 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 index 210656de739e..91498c4a1ed0 100644 --- 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 @@ -38,7 +38,7 @@ public enum DwarfInline { @SuppressWarnings("unused") DW_INL_declared_inlined((byte) 3); - byte value; + private final byte value; DwarfInline(byte b) { value = b; 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 index 1ef4e33d81e1..eb7ad06c1f22 100644 --- 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 @@ -33,7 +33,7 @@ public enum DwarfLanguage { DW_LANG_Java((byte) 0xb); - byte value; + private final byte value; DwarfLanguage(byte b) { value = b; 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 index 3e9a5e00cb23..2bb3269ee327 100644 --- 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 @@ -101,7 +101,7 @@ public enum DwarfLineOpcode { */ DW_LNE_define_file((byte) 3); - byte value; + private final byte value; DwarfLineOpcode(byte b) { value = b; 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 index 23d0b4d113e2..bb12f38edf89 100644 --- 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 @@ -41,7 +41,7 @@ public enum DwarfSectionName { DW_ARANGES_SECTION(".debug_aranges"), DW_RANGES_SECTION(".debug_ranges"); - String value; + private final String value; DwarfSectionName(String s) { value = s; 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 index 77d032819818..c15b59bd5938 100644 --- 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 @@ -50,7 +50,7 @@ public enum DwarfTag { DW_TAG_unspecified_type(0x3b), DW_TAG_inlined_subroutine(0x1d); - int value; + private final int value; DwarfTag(int i) { value = i; 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 index f1643e645fdc..d646f501499c 100644 --- 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 @@ -38,7 +38,7 @@ public enum DwarfVersion { DW_VERSION_2((short) 2), DW_VERSION_4((short) 4); - short value; + private final short value; DwarfVersion(short s) { value = s;