author | mr |
Tue, 29 Oct 2019 13:52:04 -0700 | |
changeset 58850 | f4290bf1cc21 |
parent 51334 | cc2c79d22508 |
permissions | -rw-r--r-- |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
1 |
/* |
48975 | 2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
4 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
8 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
13 |
* accompanied this code). |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
14 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
18 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
21 |
* questions. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
22 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
23 |
*/ |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
24 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
26 |
|
10565 | 27 |
#if !defined(_WINDOWS) && !defined(__APPLE__) |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
28 |
|
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
29 |
#include "jvm.h" |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
30 |
#include "memory/allocation.inline.hpp" |
9403
6f3c6231c20a
7036747: 7017009 reappeared, problem with ElfStringTable
zgu
parents:
7447
diff
changeset
|
31 |
#include "runtime/os.hpp" |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
32 |
#include "utilities/elfStringTable.hpp" |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
33 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
34 |
// We will try to load whole string table into memory if we can. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
35 |
// Otherwise, fallback to more expensive file operation. |
48975 | 36 |
ElfStringTable::ElfStringTable(FILE* const file, Elf_Shdr& shdr, int index) : |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
48975
diff
changeset
|
37 |
_next(NULL), _index(index), _section(file, shdr), _fd(file) { |
48975 | 38 |
_status = _section.status(); |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
39 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
40 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
41 |
ElfStringTable::~ElfStringTable() { |
48975 | 42 |
if (_next != NULL) { |
43 |
delete _next; |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
44 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
45 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
46 |
|
48975 | 47 |
bool ElfStringTable::string_at(size_t pos, char* buf, int buflen) { |
48 |
if (NullDecoder::is_error(get_status())) { |
|
49 |
return false; |
|
50 |
} |
|
51 |
||
52 |
assert(buflen > 0, "no buffer"); |
|
53 |
if (pos >= _section.section_header()->sh_size) { |
|
11483 | 54 |
return false; |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
55 |
} |
48975 | 56 |
|
57 |
const char* data = (const char*)_section.section_data(); |
|
58 |
if (data != NULL) { |
|
59 |
jio_snprintf(buf, buflen, "%s", data + pos); |
|
11483 | 60 |
return true; |
48975 | 61 |
} else { // no cache data, read from file instead |
62 |
const Elf_Shdr* const shdr = _section.section_header(); |
|
63 |
MarkedFileReader mfd(_fd); |
|
64 |
if (mfd.has_mark() && |
|
65 |
mfd.set_position(shdr->sh_offset + pos) && |
|
66 |
mfd.read((void*)buf, size_t(buflen))) { |
|
67 |
buf[buflen - 1] = '\0'; |
|
68 |
return true; |
|
69 |
} else { |
|
70 |
// put it in error state to avoid retry |
|
71 |
_status = NullDecoder::file_invalid; |
|
11483 | 72 |
return false; |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
73 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
74 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
75 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
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__ |