< prev index next >

src/hotspot/share/prims/jvmtiEnvThreadState.hpp

Print this page

 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 #ifndef SHARE_PRIMS_JVMTIENVTHREADSTATE_HPP
 26 #define SHARE_PRIMS_JVMTIENVTHREADSTATE_HPP
 27 
 28 #include "jvmtifiles/jvmti.h"
 29 #include "memory/allocation.hpp"
 30 #include "oops/instanceKlass.hpp"

 31 #include "prims/jvmtiEventController.hpp"
 32 #include "utilities/globalDefinitions.hpp"
 33 #include "utilities/growableArray.hpp"
 34 
 35 class JvmtiEnv;
 36 
 37 ///////////////////////////////////////////////////////////////
 38 //
 39 // class JvmtiFramePop
 40 // Used by              : JvmtiFramePops
 41 // Used by JVMTI methods: none directly.
 42 //
 43 // Wrapper class for FramePop, used in the JvmtiFramePops class.
 44 //
 45 // Two problems: 1) this isn't being used as a value class, in
 46 // several places there are constructors for it. 2) It seems like
 47 // overkill as a means to get an assert and name the greater than
 48 // operator.  I'm trying to to rewrite everything.
 49 
 50 class JvmtiFramePop {

 92   ~JvmtiFramePops();
 93 
 94   bool contains(JvmtiFramePop& fp) { return _pops->contains(fp.frame_number()); }
 95   int length() { return _pops->length(); }
 96   void print() PRODUCT_RETURN;
 97 };
 98 
 99 
100 ///////////////////////////////////////////////////////////////
101 //
102 // class JvmtiEnvThreadState
103 //
104 // 2. Cache of pending frame_pop_events, created by NotifyFramePop
105 //    and lazily initialized.
106 // 3: Location of last executed instruction, used to filter out duplicate
107 //    events due to instruction rewriting.
108 
109 class JvmtiEnvThreadState : public CHeapObj<mtInternal> {
110 private:
111   friend class JvmtiEnv;
112   JavaThread        *_thread;
113   JvmtiEnv          *_env;
114   JvmtiEnvThreadState *_next;
115   jmethodID         _current_method_id;
116   int               _current_bci;
117   bool              _breakpoint_posted;
118   bool              _single_stepping_posted;
119   JvmtiEnvThreadEventEnable _event_enable;
120   void              *_agent_thread_local_storage_data; // per env and per thread agent allocated data.
121 
122   // Class used to store pending framepops.
123   // lazily initialized by get_frame_pops();
124   JvmtiFramePops *_frame_pops;
125 
126   inline void set_current_location(jmethodID method_id, int bci) {
127     _current_method_id = method_id;
128     _current_bci  = bci;
129   }
130 
131   friend class JvmtiEnvThreadStateIterator;
132   JvmtiEnvThreadState* next() { return _next; }
133 
134   friend class JvmtiThreadState;
135   void set_next(JvmtiEnvThreadState* link) { _next = link; }
136 
137 public:
138   JvmtiEnvThreadState(JavaThread *thread, JvmtiEnvBase *env);
139   ~JvmtiEnvThreadState();
140 
141   bool is_enabled(jvmtiEvent event_type) { return _event_enable.is_enabled(event_type); }
142 
143   JvmtiEnvThreadEventEnable *event_enable() { return &_event_enable; }
144   void *get_agent_thread_local_storage_data() { return _agent_thread_local_storage_data; }
145   void set_agent_thread_local_storage_data (void *data) { _agent_thread_local_storage_data = data; }
146 


147 
148   // If the thread is in the given method at the given
149   // location just return.  Otherwise, reset the current location
150   // and reset _breakpoint_posted and _single_stepping_posted.
151   // _breakpoint_posted and _single_stepping_posted are only cleared
152   // here.
153   void compare_and_set_current_location(Method* method, address location, jvmtiEvent event);
154 
155   void clear_current_location() { set_current_location((jmethodID)NULL, 0); }
156 
157   void reset_current_location(jvmtiEvent event, bool enabled);
158 
159   inline void set_breakpoint_posted()  { _breakpoint_posted = true; }
160   inline void set_single_stepping_posted() {
161     _single_stepping_posted = true;
162   }
163   inline bool breakpoint_posted() { return _breakpoint_posted; }
164   inline bool single_stepping_posted() {
165     return _single_stepping_posted;
166   }

167 
168   inline JavaThread *get_thread() { return _thread; }




169   inline JvmtiEnv *get_env() { return _env; }
170 
171   // lazily initialize _frame_pops
172   JvmtiFramePops* get_frame_pops();
173 
174   bool has_frame_pops();
175 
176   // quickly test whether we should deliver a frame pop event on return from sp
177   bool is_frame_pop(int cur_stack_depth);
178 
179   void set_frame_pop(int frame_number);
180   void clear_frame_pop(int frame_number);
181 
182 };
183 
184 #endif // SHARE_PRIMS_JVMTIENVTHREADSTATE_HPP

 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 #ifndef SHARE_PRIMS_JVMTIENVTHREADSTATE_HPP
 26 #define SHARE_PRIMS_JVMTIENVTHREADSTATE_HPP
 27 
 28 #include "jvmtifiles/jvmti.h"
 29 #include "memory/allocation.hpp"
 30 #include "oops/instanceKlass.hpp"
 31 #include "prims/jvmtiThreadState.hpp"
 32 #include "prims/jvmtiEventController.hpp"
 33 #include "utilities/globalDefinitions.hpp"
 34 #include "utilities/growableArray.hpp"
 35 
 36 class JvmtiEnv;
 37 
 38 ///////////////////////////////////////////////////////////////
 39 //
 40 // class JvmtiFramePop
 41 // Used by              : JvmtiFramePops
 42 // Used by JVMTI methods: none directly.
 43 //
 44 // Wrapper class for FramePop, used in the JvmtiFramePops class.
 45 //
 46 // Two problems: 1) this isn't being used as a value class, in
 47 // several places there are constructors for it. 2) It seems like
 48 // overkill as a means to get an assert and name the greater than
 49 // operator.  I'm trying to to rewrite everything.
 50 
 51 class JvmtiFramePop {

 93   ~JvmtiFramePops();
 94 
 95   bool contains(JvmtiFramePop& fp) { return _pops->contains(fp.frame_number()); }
 96   int length() { return _pops->length(); }
 97   void print() PRODUCT_RETURN;
 98 };
 99 
100 
101 ///////////////////////////////////////////////////////////////
102 //
103 // class JvmtiEnvThreadState
104 //
105 // 2. Cache of pending frame_pop_events, created by NotifyFramePop
106 //    and lazily initialized.
107 // 3: Location of last executed instruction, used to filter out duplicate
108 //    events due to instruction rewriting.
109 
110 class JvmtiEnvThreadState : public CHeapObj<mtInternal> {
111 private:
112   friend class JvmtiEnv;
113   JvmtiThreadState  *_state;
114   JvmtiEnv          *_env;
115   JvmtiEnvThreadState *_next;
116   jmethodID         _current_method_id;
117   int               _current_bci;
118   bool              _breakpoint_posted;
119   bool              _single_stepping_posted;
120   JvmtiEnvThreadEventEnable _event_enable;
121   void              *_agent_thread_local_storage_data; // per env and per thread agent allocated data.
122 
123   // Class used to store pending framepops.
124   // lazily initialized by get_frame_pops();
125   JvmtiFramePops *_frame_pops;
126 
127   inline void set_current_location(jmethodID method_id, int bci) {
128     _current_method_id = method_id;
129     _current_bci  = bci;
130   }
131 
132   friend class JvmtiEnvThreadStateIterator;
133   JvmtiEnvThreadState* next() { return _next; }
134 
135   friend class JvmtiThreadState;
136   void set_next(JvmtiEnvThreadState* link) { _next = link; }
137 
138 public:
139   JvmtiEnvThreadState(JvmtiThreadState* state, JvmtiEnvBase *env);
140   ~JvmtiEnvThreadState();
141 
142   bool is_enabled(jvmtiEvent event_type) { return _event_enable.is_enabled(event_type); }
143 
144   JvmtiEnvThreadEventEnable *event_enable() { return &_event_enable; }


145 
146   void *get_agent_thread_local_storage_data(); 
147   void set_agent_thread_local_storage_data (void *data);
148 
149   // If the thread is in the given method at the given
150   // location just return.  Otherwise, reset the current location
151   // and reset _breakpoint_posted and _single_stepping_posted.
152   // _breakpoint_posted and _single_stepping_posted are only cleared
153   // here.
154   void compare_and_set_current_location(Method* method, address location, jvmtiEvent event);
155 
156   void clear_current_location() { set_current_location((jmethodID)NULL, 0); }
157 
158   void reset_current_location(jvmtiEvent event, bool enabled);
159 
160   inline void set_breakpoint_posted()  { _breakpoint_posted = true; }
161   inline void set_single_stepping_posted() {
162     _single_stepping_posted = true;
163   }
164   inline bool breakpoint_posted() { return _breakpoint_posted; }
165   inline bool single_stepping_posted() {
166     return _single_stepping_posted;
167   }
168   bool is_virtual(); 
169 
170   inline JvmtiThreadState* jvmti_thread_state() { return _state; }
171 
172   // use _thread_saved if cthread is detached from JavaThread
173   JavaThread *get_thread_or_saved();
174   JavaThread *get_thread();
175   inline JvmtiEnv *get_env() { return _env; }
176 
177   // lazily initialize _frame_pops
178   JvmtiFramePops* get_frame_pops();
179 
180   bool has_frame_pops();
181 
182   // quickly test whether we should deliver a frame pop event on return from sp
183   bool is_frame_pop(int cur_stack_depth);
184 
185   void set_frame_pop(int frame_number);
186   void clear_frame_pop(int frame_number);
187 
188 };
189 
190 #endif // SHARE_PRIMS_JVMTIENVTHREADSTATE_HPP
< prev index next >