001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.cldchi.tools.memoryprofiler.data;
028:
029: import java.net.*;
030: import java.io.*;
031: import java.util.*;
032: import com.sun.cldchi.tools.memoryprofiler.jdwp.VMConnection;
033:
034: /**
035: * The <code>MPDataProvider</code> declares interface which provides data for
036: * data-displaying GUI tool.
037: * For work it requires some implementation of <code>VMConnection</code>.
038: * The implementation of this interface is provided by <code>MPDataProviderFactory</code>.
039: *
040: * To work with this interface you should firstly obtain its realization from <code>MPDataProviderFactory</code>,
041: * passing it an instance of <code>VMConnection</code>.
042: * After this you should connect to a KDP
043: * running on hostName:port by calling <code>connect(String hostName, int port)</code>
044: * To control VM execution use <code>pauseVM()</code> and <code>resumeVM()</code> funtions. *
045: * All other functions provide processed information.
046: *
047: * @see com.sun.cldchi.tools.memoryprofiler.data.MPDataProviderFactory
048: * @see com.sun.cldchi.tools.memoryprofiler.jdwp.VMConnection
049: *
050: */
051: public interface MPDataProvider {
052:
053: //internal VM object types
054: public static final int JAVA_OBJECT = 0;
055: public static final int STATICS_OBJECT = 1;
056: public static final int STACK_OBJECT = 2;
057: public static final int VM_OBJECT = 3;
058:
059: /**
060: * Connects to the KDP running on hostName:port using <code>VMConnection</code>, which should
061: * be set before by <code>setConnector(VMConnection connector)</code> call.
062: *
063: * It will throw <code>java.net.ConnectException</code> unless connection is successful.
064: *
065: * @param hostName - name of host where KDP runs
066: * @param port - number of port where KDP listens
067: *
068: * @see #closeConnections()
069: */
070: public void connect(String hostName, int port)
071: throws java.net.ConnectException, SocketException;
072:
073: /**
074: * Disconnects from the KDP. Does nothing if not connected.
075: */
076: public void closeConnections();
077:
078: /**
079: * Returns list of all classes in systems. All objects in array are <code>JavaClass</code>
080: * The provider must be connected to a KDP, see interface description.
081: * The function will throw <code>SocketException</code> unless communication with VM is successful
082: *
083: * @return array of <code>JavaClass</code>
084: *
085: * @see #connect(String hostName, int port)
086: */
087: public JavaClass[] getClassList() throws SocketException;
088:
089: /**
090: * Pauses the VM execution.
091: * The provider must be connected to a kdp, see interface description.
092: * The function will throw <code>SocketException</code> unless communication with VM is successful
093: *
094: * @see #connect(String hostName, int port)
095: */
096: public void pauseVM() throws SocketException;
097:
098: /**
099: * Resumes the VM execution.
100: * The provider must be connected to a KDP, see interface description.
101: * The function will throw <code>SocketException</code> unless communication with VM is successful
102: *
103: * @see #connect(String hostName, int port)
104: */
105: public void resumeVM() throws SocketException;
106:
107: /**
108: * Returns value of _heap_start global varaible, which is address where VM heap starts.
109: * The provider must be connected to a KDP, see interface description.
110: * The function will throw <code>SocketException</code> unless communication with VM is successful
111: *
112: * @return value of _heap_start global varaible
113: *
114: * @see #connect(String hostName, int port)
115: */
116: public int get_heap_start();
117:
118: /**
119: * Returns value of _heap_top global varaible, which is address where VM heap ends.
120: * The provider must be connected to a KDP, see interface description.
121: * The function will throw <code>SocketException</code> unless communication with VM is successful
122: *
123: * @return value of _heap_top global varaible
124: *
125: * @see #connect(String hostName, int port)
126: */
127: public int get_heap_top();
128:
129: /**
130: * Returns value of _old_generation_end global varaible,
131: * which is address where old generation of heap objects ends.
132: * The provider must be connected to a KDP, see interface description.
133: * The function will throw <code>SocketException</code> unless communication with VM is successful
134: *
135: * @return value of _old_generation_end global varaible
136: *
137: * @see #connect(String hostName, int port)
138: */
139: public int get_old_gen_end();
140:
141: /**
142: * Returns value of _old_generation_end global varaible,
143: * which is address where old generation of heap objects ends.
144: * The provider must be connected to a KDP, see interface description.
145: * The function will throw <code>SocketException</code> unless communication with VM is successful
146: *
147: * @return value of _old_generation_end global varaible
148: *
149: * @see #connect(String hostName, int port)
150: */
151: public int get_allocation_top();
152:
153: /**
154: * Returns all objects with given extended class id.
155: * The provider must be connected to a KDP, see interface description.
156: * The function will throw <code>SocketException</code> unless communication with VM is successful
157: *
158: * @param jc - class which objects you want to find.
159: *
160: * @return all objects with given extended class id.
161: *
162: * @see #connect(String hostName, int port)
163: */
164: public JavaObject[] getObjectsOfClass(JavaClass jc);
165:
166: /**
167: * Returns all objects.
168: * The provider must be connected to a KDP, see interface description.
169: * The function will throw <code>SocketException</code> unless communication with VM is successful
170: *
171: * @return all objects. Iterator returns instances of <code>JavaObject</code>
172: *
173: * @see #connect(String hostName, int port)
174: */
175: public Iterator getObjects();
176:
177: /**
178: * Returns name of the type of the object.
179: * The provider must be connected to a KDP, see interface description.
180: * The function will throw <code>SocketException</code> unless communication with VM is successful
181: *
182: * @param obj
183: *
184: * @return name of the type of the object.
185: *
186: * @see #connect(String hostName, int port)
187: */
188: public String getObjectTypeName(JavaObject obj);
189:
190: /**
191: * Returns array of linked JavaObjects, where first one is a root object and last one is the parameter.
192: * The provider must be connected to a KDP, see interface description.
193: * The function will throw <code>SocketException</code> unless communication with VM is successful
194: *
195: * @param obj
196: *
197: * @return array of linked JavaObjects, where first one is a root object and last one is the parameter.
198: *
199: * @see #connect(String hostName, int port)
200: */
201: public JavaObject[] pathFromTheRoot(JavaObject obj);
202:
203: /**
204: * Returns array JavaObjects, sorted by address from given memory block.
205: * The provider must be connected to a KDP, see interface description.
206: * The function will throw <code>SocketException</code> unless communication with VM is successful
207: *
208: * @param start - start address of the zone in heap
209: * @param end - end address of the zone in heap
210: *
211: * @return array JavaObjects, sorted by address from given memory block.
212: *
213: * @see #connect(String hostName, int port)
214: */
215: public JavaObject[] getObjectsFromTheAddresses(int start, int end);
216:
217: /**
218: * Returns statistics of memory usage for each class in the VM.
219: * There is separate <code>ClassStatistics</code> object int the returned array for each class.
220: * The provider must be connected to a KDP, see interface description.
221: * The function will throw <code>SocketException</code> unless communication with VM is successful
222: *
223: * @return array of <code>ClassStatistics</code>.
224: *
225: * @see #connect(String hostName, int port)
226: */
227: public ClassStatistics[] calculateStatistics();
228:
229: /**
230: * Returns stacktrace of an address on java stack
231: * The provider must be connected to a KDP, see interface description.
232: * The function will throw <code>SocketException</code> unless communication with VM is successful
233: *
234: * @param stackObject - JavaObject of stack type
235: * @param ptrAddress - address of the pointer on stack
236: *
237: * @return String.
238: *
239: * @see #connect(String hostName, int port)
240: */
241: public String getStackTrace(JavaObject stackObject, int ptrAddress)
242: throws SocketException;;
243:
244: }
|