author | mr |
Tue, 29 Oct 2019 13:52:04 -0700 | |
changeset 58850 | f4290bf1cc21 |
parent 48157 | 7c4d43c26352 |
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" |
|
48157 | 29 |
#include "memory/allocation.inline.hpp" |
11483 | 30 |
|
31 |
ElfDecoder::~ElfDecoder() { |
|
32 |
if (_opened_elf_files != NULL) { |
|
33 |
delete _opened_elf_files; |
|
34 |
_opened_elf_files = NULL; |
|
35 |
} |
|
36 |
} |
|
37 |
||
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
22857
diff
changeset
|
38 |
bool ElfDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* filepath, bool demangle_name) { |
11483 | 39 |
assert(filepath, "null file path"); |
40 |
assert(buf != NULL && buflen > 0, "Invalid buffer"); |
|
41 |
if (has_error()) return false; |
|
42 |
ElfFile* file = get_elf_file(filepath); |
|
43 |
if (file == NULL) { |
|
44 |
return false; |
|
45 |
} |
|
46 |
||
47 |
if (!file->decode(addr, buf, buflen, offset)) { |
|
48 |
return false; |
|
49 |
} |
|
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
22857
diff
changeset
|
50 |
if (demangle_name && (buf[0] != '\0')) { |
11483 | 51 |
demangle(buf, buf, buflen); |
52 |
} |
|
53 |
return true; |
|
54 |
} |
|
55 |
||
56 |
ElfFile* ElfDecoder::get_elf_file(const char* filepath) { |
|
57 |
ElfFile* file; |
|
58 |
||
59 |
file = _opened_elf_files; |
|
60 |
while (file != NULL) { |
|
61 |
if (file->same_elf_file(filepath)) { |
|
62 |
return file; |
|
63 |
} |
|
64 |
file = file->next(); |
|
65 |
} |
|
66 |
||
67 |
file = new (std::nothrow)ElfFile(filepath); |
|
68 |
if (file != NULL) { |
|
69 |
if (_opened_elf_files != NULL) { |
|
70 |
file->set_next(_opened_elf_files); |
|
71 |
} |
|
72 |
_opened_elf_files = file; |
|
73 |
} |
|
74 |
||
75 |
return file; |
|
76 |
} |
|
22857
2167396cfc83
8019929: PPC64 (part 107): Extend ELF-decoder to support PPC64 function descriptor tables
simonis
parents:
13963
diff
changeset
|
77 |
#endif // !_WINDOWS && !__APPLE__ |