src/share/vm/prims/jvmtiEnvThreadState.hpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Initial load

duke@435 1 /*
duke@435 2 * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24 #ifndef _JAVA_JVMTIENVTHREADSTATE_H_
duke@435 25 #define _JAVA_JVMTIENVTHREADSTATE_H_
duke@435 26
duke@435 27 ///////////////////////////////////////////////////////////////
duke@435 28 //
duke@435 29 // class JvmtiFramePop
duke@435 30 // Used by : JvmtiFramePops
duke@435 31 // Used by JVMTI methods: none directly.
duke@435 32 //
duke@435 33 // Wrapper class for FramePop, used in the JvmtiFramePops class.
duke@435 34 //
duke@435 35 // Two problems: 1) this isn't being used as a ValueObj class, in
duke@435 36 // several places there are constructors for it. 2) It seems like
duke@435 37 // overkill as a means to get an assert and name the geater than
duke@435 38 // operator. I'm trying to to rewrite everything.
duke@435 39
duke@435 40 class JvmtiFramePop VALUE_OBJ_CLASS_SPEC {
duke@435 41 private:
duke@435 42 // Frame number counting from BOTTOM (oldest) frame;
duke@435 43 // bottom frame == #0
duke@435 44 int _frame_number;
duke@435 45 public:
duke@435 46 JvmtiFramePop() {}
duke@435 47 JvmtiFramePop(int frame_number) {
duke@435 48 assert(frame_number >= 0, "invalid frame number");
duke@435 49 _frame_number = frame_number;
duke@435 50 }
duke@435 51
duke@435 52 int frame_number() { return _frame_number; }
duke@435 53 int above_on_stack(JvmtiFramePop& other) { return _frame_number > other._frame_number; }
duke@435 54 void print() PRODUCT_RETURN;
duke@435 55 };
duke@435 56
duke@435 57
duke@435 58 ///////////////////////////////////////////////////////////////
duke@435 59 //
duke@435 60 // class JvmtiFramePops
duke@435 61 // Used by : JvmtiThreadState
duke@435 62 // Used by JVMTI methods: none directly.
duke@435 63 //
duke@435 64 // A collection of JvmtiFramePop.
duke@435 65 // It records what frames on a threads stack should post frame_pop events when they're exited.
duke@435 66 //
duke@435 67
duke@435 68 class JvmtiFramePops : public CHeapObj {
duke@435 69 private:
duke@435 70 GrowableArray<int>* _pops;
duke@435 71
duke@435 72 // should only be used by JvmtiEventControllerPrivate
duke@435 73 // to insure they only occur at safepoints.
duke@435 74 // Todo: add checks for safepoint
duke@435 75 friend class JvmtiEventControllerPrivate;
duke@435 76 void set(JvmtiFramePop& fp);
duke@435 77 void clear(JvmtiFramePop& fp);
duke@435 78 int clear_to(JvmtiFramePop& fp);
duke@435 79
duke@435 80 public:
duke@435 81 JvmtiFramePops();
duke@435 82 ~JvmtiFramePops();
duke@435 83
duke@435 84 bool contains(JvmtiFramePop& fp) { return _pops->contains(fp.frame_number()); }
duke@435 85 int length() { return _pops->length(); }
duke@435 86 void print() PRODUCT_RETURN;
duke@435 87 };
duke@435 88
duke@435 89
duke@435 90 ///////////////////////////////////////////////////////////////
duke@435 91 //
duke@435 92 // class JvmtiEnvThreadState
duke@435 93 //
duke@435 94 // 2. Cache of pending frame_pop_events, created by NotifyFramePop
duke@435 95 // and lazily initialized.
duke@435 96 // 3: Location of last executed instruction, used to filter out duplicate
duke@435 97 // events due to instruction rewriting.
duke@435 98
duke@435 99 class JvmtiEnvThreadState : public CHeapObj {
duke@435 100 private:
duke@435 101 friend class JvmtiEnv;
duke@435 102 JavaThread *_thread;
duke@435 103 JvmtiEnv *_env;
duke@435 104 JvmtiEnvThreadState *_next;
duke@435 105 jmethodID _current_method_id;
duke@435 106 int _current_bci;
duke@435 107 bool _breakpoint_posted;
duke@435 108 bool _single_stepping_posted;
duke@435 109 JvmtiEnvThreadEventEnable _event_enable;
duke@435 110 void *_agent_thread_local_storage_data; // per env and per thread agent allocated data.
duke@435 111
duke@435 112 // Class used to store pending framepops.
duke@435 113 // lazily initialized by get_frame_pops();
duke@435 114 JvmtiFramePops *_frame_pops;
duke@435 115
duke@435 116 inline void set_current_location(jmethodID method_id, int bci) {
duke@435 117 _current_method_id = method_id;
duke@435 118 _current_bci = bci;
duke@435 119 }
duke@435 120
duke@435 121 friend class JvmtiEnvThreadStateIterator;
duke@435 122 JvmtiEnvThreadState* next() { return _next; }
duke@435 123
duke@435 124 friend class JvmtiThreadState;
duke@435 125 void set_next(JvmtiEnvThreadState* link) { _next = link; }
duke@435 126
duke@435 127 public:
duke@435 128 JvmtiEnvThreadState(JavaThread *thread, JvmtiEnvBase *env);
duke@435 129 ~JvmtiEnvThreadState();
duke@435 130
duke@435 131 bool is_enabled(jvmtiEvent event_type) { return _event_enable.is_enabled(event_type); }
duke@435 132
duke@435 133 JvmtiEnvThreadEventEnable *event_enable() { return &_event_enable; }
duke@435 134 void *get_agent_thread_local_storage_data() { return _agent_thread_local_storage_data; }
duke@435 135 void set_agent_thread_local_storage_data (void *data) { _agent_thread_local_storage_data = data; }
duke@435 136
duke@435 137
duke@435 138 // If the thread is in the given method at the given
duke@435 139 // location just return. Otherwise, reset the current location
duke@435 140 // and reset _breakpoint_posted and _single_stepping_posted.
duke@435 141 // _breakpoint_posted and _single_stepping_posted are only cleared
duke@435 142 // here.
duke@435 143 void compare_and_set_current_location(methodOop method, address location, jvmtiEvent event);
duke@435 144
duke@435 145 void clear_current_location() { set_current_location((jmethodID)NULL, 0); }
duke@435 146
duke@435 147 void reset_current_location(jvmtiEvent event, bool enabled);
duke@435 148
duke@435 149 inline void set_breakpoint_posted() { _breakpoint_posted = true; }
duke@435 150 inline void set_single_stepping_posted() {
duke@435 151 _single_stepping_posted = true;
duke@435 152 }
duke@435 153 inline bool breakpoint_posted() { return _breakpoint_posted; }
duke@435 154 inline bool single_stepping_posted() {
duke@435 155 return _single_stepping_posted;
duke@435 156 }
duke@435 157
duke@435 158 inline JavaThread *get_thread() { return _thread; }
duke@435 159 inline JvmtiEnv *get_env() { return _env; }
duke@435 160
duke@435 161 // lazily initialize _frame_pops
duke@435 162 JvmtiFramePops* get_frame_pops();
duke@435 163
duke@435 164 bool has_frame_pops();
duke@435 165
duke@435 166 // quickly test whether we should deliver a frame pop event on return from sp
duke@435 167 bool is_frame_pop(int cur_stack_depth);
duke@435 168
duke@435 169 void set_frame_pop(int frame_number);
duke@435 170 void clear_frame_pop(int frame_number);
duke@435 171 void clear_to_frame_pop(int frame_number);
duke@435 172
duke@435 173 };
duke@435 174
duke@435 175 #endif /* _JAVA_JVMTIENVTHREADSTATE_H_ */

mercurial