--- old/src/hotspot/share/utilities/elfFile.hpp 2018-02-15 12:29:54.163952684 -0500 +++ new/src/hotspot/share/utilities/elfFile.hpp 2018-02-15 12:29:53.974953080 -0500 @@ -45,6 +45,7 @@ typedef Elf64_Shdr Elf_Shdr; typedef Elf64_Phdr Elf_Phdr; typedef Elf64_Sym Elf_Sym; +typedef Elf64_Nhdr Elf_Nhdr; #if !defined(_ALLBSD_SOURCE) || defined(__APPLE__) #define ELF_ST_TYPE ELF64_ST_TYPE @@ -61,6 +62,7 @@ typedef Elf32_Shdr Elf_Shdr; typedef Elf32_Phdr Elf_Phdr; typedef Elf32_Sym Elf_Sym; +typedef Elf32_Nhdr Elf_Nhdr; #if !defined(_ALLBSD_SOURCE) || defined(__APPLE__) #define ELF_ST_TYPE ELF32_ST_TYPE @@ -117,6 +119,13 @@ bool has_mark() const { return _marked_pos >= 0; } }; +// Interface to external debug info file +class ElfDebugInfo : public CHeapObj { +public: + virtual bool decode(address addr, char* const buf, size_t buflen, int* offset) = 0; + virtual bool has_error() const = 0; +}; + // ElfFile is basically an elf file parser, which can lookup the symbol // that is the nearest to the given address. // Beware, this code is called from vm error reporting code, when vm is already @@ -148,10 +157,13 @@ // function descriptors table ElfFuncDescTable* _funcDesc_table; + // external debug info + ElfDebugInfo* _debuginfo; + NullDecoder::decoder_status _status; public: - ElfFile(const char* filepath); + ElfFile(const char* filepath, bool load_debug_info = true); ~ElfFile(); bool decode(address addr, char* buf, int buflen, int* offset); @@ -182,6 +194,12 @@ // parse this elf file NullDecoder::decoder_status parse_elf(const char* filename); + // load external debuginfo file for this file. + ElfDebugInfo* load_debuginfo() NOT_LINUX({ return NULL; }); + + // internal implementation + bool decode_impl(address addr, char* buf, int buflen, int* offset); + // load string, symbol and function descriptor tables from the elf file NullDecoder::decoder_status load_tables();