Mercurial > hg > truffle
annotate src/share/vm/utilities/decoder.hpp @ 14694:58cf34613a72
8036976: PPC64: implement the template interpreter
Reviewed-by: kvn, coleenp
Contributed-by: axel.siebenborn@sap.com, martin.doerr@sap.com
author | goetz |
---|---|
date | Mon, 10 Mar 2014 12:58:02 +0100 |
parents | de6a9e811145 |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12199
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2022
2d4762ec74af
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. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
4 * |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
8 * |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
13 * accompanied this code). |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
14 * |
2d4762ec74af
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 |
2d4762ec74af
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, |
2d4762ec74af
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. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
18 * |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
21 * questions. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
22 * |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
23 */ |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
24 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
25 |
4803 | 26 #ifndef SHARE_VM_UTILITIES_DECODER_HPP |
27 #define SHARE_VM_UTILITIES_DECODER_HPP | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
28 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
29 #include "memory/allocation.hpp" |
4803 | 30 #include "runtime/mutex.hpp" |
12199
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
31 #include "runtime/mutexLocker.hpp" |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
32 |
6197 | 33 class AbstractDecoder : public CHeapObj<mtInternal> { |
4803 | 34 public: |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
35 // status code for decoding native C frame |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
36 enum decoder_status { |
4803 | 37 not_available = -10, // real decoder is not available |
38 no_error = 0, // successfully decoded frames | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
39 out_of_memory, // out of memory |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
40 file_invalid, // invalid elf file |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
41 file_not_found, // could not found symbol file (on windows), such as jvm.pdb or jvm.map |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
42 helper_not_found, // could not load dbghelp.dll (Windows only) |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
43 helper_func_error, // decoding functions not found (Windows only) |
4803 | 44 helper_init_error // SymInitialize failed (Windows only) |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
45 }; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
46 |
4917 | 47 // decode an pc address to corresponding function name and an offset from the beginning of |
48 // the function | |
49 virtual bool decode(address pc, char* buf, int buflen, int* offset, | |
50 const char* modulepath = NULL) = 0; | |
6258 | 51 virtual bool decode(address pc, char* buf, int buflen, int* offset, const void* base) = 0; |
52 | |
4917 | 53 // demangle a C++ symbol |
54 virtual bool demangle(const char* symbol, char* buf, int buflen) = 0; | |
55 // if the decoder can decode symbols in vm | |
56 virtual bool can_decode_C_frame_in_vm() const = 0; | |
57 | |
58 virtual decoder_status status() const { | |
59 return _decoder_status; | |
60 } | |
61 | |
62 virtual bool has_error() const { | |
63 return is_error(_decoder_status); | |
64 } | |
65 | |
66 static bool is_error(decoder_status status) { | |
67 return (status > 0); | |
68 } | |
69 | |
70 protected: | |
71 decoder_status _decoder_status; | |
72 }; | |
73 | |
74 // Do nothing decoder | |
75 class NullDecoder : public AbstractDecoder { | |
76 public: | |
4803 | 77 NullDecoder() { |
78 _decoder_status = not_available; | |
79 } | |
80 | |
81 ~NullDecoder() {}; | |
82 | |
83 virtual bool decode(address pc, char* buf, int buflen, int* offset, | |
84 const char* modulepath = NULL) { | |
85 return false; | |
86 } | |
87 | |
6258 | 88 virtual bool decode(address pc, char* buf, int buflen, int* offset, const void* base) { |
89 return false; | |
90 } | |
91 | |
4803 | 92 virtual bool demangle(const char* symbol, char* buf, int buflen) { |
93 return false; | |
94 } | |
95 | |
96 virtual bool can_decode_C_frame_in_vm() const { | |
97 return false; | |
98 } | |
99 }; | |
100 | |
101 | |
4917 | 102 class Decoder : AllStatic { |
4803 | 103 public: |
104 static bool decode(address pc, char* buf, int buflen, int* offset, const char* modulepath = NULL); | |
6258 | 105 static bool decode(address pc, char* buf, int buflen, int* offset, const void* base); |
4803 | 106 static bool demangle(const char* symbol, char* buf, int buflen); |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
107 static bool can_decode_C_frame_in_vm(); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
108 |
4917 | 109 // shutdown shared instance |
4803 | 110 static void shutdown(); |
111 protected: | |
4917 | 112 // shared decoder instance, _shared_instance_lock is needed |
113 static AbstractDecoder* get_shared_instance(); | |
114 // a private instance for error handler. Error handler can be | |
115 // triggered almost everywhere, including signal handler, where | |
116 // no lock can be taken. So the shared decoder can not be used | |
117 // in this scenario. | |
118 static AbstractDecoder* get_error_handler_instance(); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
119 |
4917 | 120 static AbstractDecoder* create_decoder(); |
4803 | 121 private: |
4917 | 122 static AbstractDecoder* _shared_decoder; |
123 static AbstractDecoder* _error_handler_decoder; | |
124 static NullDecoder _do_nothing_decoder; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
125 |
4803 | 126 protected: |
4917 | 127 static Mutex* _shared_decoder_lock; |
12199
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
128 static Mutex* shared_decoder_lock(); |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
129 |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
130 friend class DecoderLocker; |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
131 }; |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
132 |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
133 class DecoderLocker : public MutexLockerEx { |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
134 AbstractDecoder* _decoder; |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
135 inline bool is_first_error_thread(); |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
136 public: |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
137 DecoderLocker(); |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
138 AbstractDecoder* decoder() { |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
139 return _decoder; |
38f750491293
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
6258
diff
changeset
|
140 } |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
141 }; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
142 |
4803 | 143 #endif // SHARE_VM_UTILITIES_DECODER_HPP |