comparison src/share/vm/utilities/elfFile.hpp @ 4970:33df1aeaebbf

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 27 Feb 2012 13:10:13 +0100
parents d7e3846464d0
children d2a62e0f25eb
comparison
equal deleted inserted replaced
4703:2cfb7fb2dce7 4970:33df1aeaebbf
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 #ifndef __ELF_FILE_HPP 25 #ifndef SHARE_VM_UTILITIES_ELF_FILE_HPP
26 #define __ELF_FILE_HPP 26 #define SHARE_VM_UTILITIES_ELF_FILE_HPP
27 27
28 #if !defined(_WINDOWS) && !defined(__APPLE__) 28 #if !defined(_WINDOWS) && !defined(__APPLE__)
29 29
30 #if defined(__OpenBSD__) 30 #if defined(__OpenBSD__)
31 #include <sys/exec_elf.h> 31 #include <sys/exec_elf.h>
81 // Beware, this code is called from vm error reporting code, when vm is already 81 // Beware, this code is called from vm error reporting code, when vm is already
82 // in "error" state, so there are scenarios, lookup will fail. We want this 82 // in "error" state, so there are scenarios, lookup will fail. We want this
83 // part of code to be very defensive, and bait out if anything went wrong. 83 // part of code to be very defensive, and bait out if anything went wrong.
84 84
85 class ElfFile: public CHeapObj { 85 class ElfFile: public CHeapObj {
86 friend class Decoder; 86 friend class ElfDecoder;
87 public: 87 public:
88 ElfFile(const char* filepath); 88 ElfFile(const char* filepath);
89 ~ElfFile(); 89 ~ElfFile();
90 90
91 const char* decode(address addr, int* offset); 91 bool decode(address addr, char* buf, int buflen, int* offset);
92 const char* filepath() { 92 const char* filepath() {
93 return m_filepath; 93 return m_filepath;
94 } 94 }
95 95
96 bool same_elf_file(const char* filepath) { 96 bool same_elf_file(const char* filepath) {
97 assert(filepath, "null file path"); 97 assert(filepath, "null file path");
98 assert(m_filepath, "already out of memory"); 98 assert(m_filepath, "already out of memory");
99 return (m_filepath && !strcmp(filepath, m_filepath)); 99 return (m_filepath && !strcmp(filepath, m_filepath));
100 } 100 }
101 101
102 Decoder::decoder_status get_status() { 102 NullDecoder::decoder_status get_status() {
103 return m_status; 103 return m_status;
104 } 104 }
105 105
106 private: 106 private:
107 // sanity check, if the file is a real elf file 107 // sanity check, if the file is a real elf file
117 void add_symbol_table(ElfSymbolTable* table); 117 void add_symbol_table(ElfSymbolTable* table);
118 118
119 // return a string table at specified section index 119 // return a string table at specified section index
120 ElfStringTable* get_string_table(int index); 120 ElfStringTable* get_string_table(int index);
121 121
122 // look up an address and return the nearest symbol 122 protected:
123 const char* look_up(Elf_Shdr shdr, address addr, int* offset); 123 ElfFile* next() const { return m_next; }
124 void set_next(ElfFile* file) { m_next = file; }
124 125
125 protected: 126 protected:
126 ElfFile* m_next; 127 ElfFile* m_next;
127 128
128 private: 129 private:
129 // file 130 // file
130 const char* m_filepath; 131 const char* m_filepath;
131 FILE* m_file; 132 FILE* m_file;
132 133
133 // Elf header 134 // Elf header
134 Elf_Ehdr m_elfHdr; 135 Elf_Ehdr m_elfHdr;
135 136
136 // symbol tables 137 // symbol tables
137 ElfSymbolTable* m_symbol_tables; 138 ElfSymbolTable* m_symbol_tables;
138 139
139 // string tables 140 // string tables
140 ElfStringTable* m_string_tables; 141 ElfStringTable* m_string_tables;
141 142
142 Decoder::decoder_status m_status; 143 NullDecoder::decoder_status m_status;
143 }; 144 };
144 145
145 #endif // _WINDOWS 146 #endif // _WINDOWS
146 147
147 #endif // __ELF_FILE_HPP 148 #endif // SHARE_VM_UTILITIES_ELF_FILE_HPP