author | stefank |
Tue, 05 Apr 2016 10:35:39 +0200 | |
changeset 37254 | 8631304f255c |
parent 31352 | a6ab7217b5cc |
permissions | -rw-r--r-- |
11483 | 1 |
/* |
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
22857
diff
changeset
|
2 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
11483 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
||
27 |
#if !defined(_WINDOWS) && !defined(__APPLE__) |
|
28 |
#include "decoder_elf.hpp" |
|
29 |
||
30 |
ElfDecoder::~ElfDecoder() { |
|
31 |
if (_opened_elf_files != NULL) { |
|
32 |
delete _opened_elf_files; |
|
33 |
_opened_elf_files = NULL; |
|
34 |
} |
|
35 |
} |
|
36 |
||
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
22857
diff
changeset
|
37 |
bool ElfDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* filepath, bool demangle_name) { |
11483 | 38 |
assert(filepath, "null file path"); |
39 |
assert(buf != NULL && buflen > 0, "Invalid buffer"); |
|
40 |
if (has_error()) return false; |
|
41 |
ElfFile* file = get_elf_file(filepath); |
|
42 |
if (file == NULL) { |
|
43 |
return false; |
|
44 |
} |
|
45 |
||
46 |
if (!file->decode(addr, buf, buflen, offset)) { |
|
47 |
return false; |
|
48 |
} |
|
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
22857
diff
changeset
|
49 |
if (demangle_name && (buf[0] != '\0')) { |
11483 | 50 |
demangle(buf, buf, buflen); |
51 |
} |
|
52 |
return true; |
|
53 |
} |
|
54 |
||
55 |
ElfFile* ElfDecoder::get_elf_file(const char* filepath) { |
|
56 |
ElfFile* file; |
|
57 |
||
58 |
file = _opened_elf_files; |
|
59 |
while (file != NULL) { |
|
60 |
if (file->same_elf_file(filepath)) { |
|
61 |
return file; |
|
62 |
} |
|
63 |
file = file->next(); |
|
64 |
} |
|
65 |
||
66 |
file = new (std::nothrow)ElfFile(filepath); |
|
67 |
if (file != NULL) { |
|
68 |
if (_opened_elf_files != NULL) { |
|
69 |
file->set_next(_opened_elf_files); |
|
70 |
} |
|
71 |
_opened_elf_files = file; |
|
72 |
} |
|
73 |
||
74 |
return file; |
|
75 |
} |
|
22857
2167396cfc83
8019929: PPC64 (part 107): Extend ELF-decoder to support PPC64 function descriptor tables
simonis
parents:
13963
diff
changeset
|
76 |
#endif // !_WINDOWS && !__APPLE__ |