7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 package sun.jvm.hotspot.debugger;
26
27 /** <P> DebuggerBase is a recommended base class for debugger
28 implementations. It can use a PageCache to cache data from the
29 target process. Note that this class would not be suitable if the
30 system were used to reflect upon itself; it would never be safe to
31 store the value in an OopHandle in anything but an OopHandle.
32 However, it provides a fair amount of code sharing to the current
33 dbx and win32 implementations. </P>
34
35 <P> NOTE that much of the code sharing is achieved by having this
36 class implement many of the methods in the Win32Debugger and
37 DbxDebugger interfaces. </P> */
38
39 public abstract class DebuggerBase implements Debugger {
40
41 // May be set lazily, but must be set before calling any of the read
42 // routines below
43 protected MachineDescription machDesc;
44 protected DebuggerUtilities utils;
45 // Java primitive type sizes, set during bootstrapping. Do not call
46 // any of the Java read routines until these are set up.
377 }
378 }
379
380 protected long readAddressValue(long address)
381 throws UnmappedAddressException, UnalignedAddressException {
382 return readCInteger(address, machDesc.getAddressSize(), true);
383 }
384
385 protected long readCompOopAddressValue(long address)
386 throws UnmappedAddressException, UnalignedAddressException {
387 long value = readCInteger(address, getHeapOopSize(), true);
388 if (value != 0) {
389 // See oop.inline.hpp decode_heap_oop
390 value = (long)(narrowOopBase + (long)(value << narrowOopShift));
391 }
392 return value;
393 }
394
395 protected long readCompKlassAddressValue(long address)
396 throws UnmappedAddressException, UnalignedAddressException {
397 long value = readCInteger(address, getKlassPtrSize(), true);
398 if (value != 0) {
399 value = (long)(narrowKlassBase + (long)(value << narrowKlassShift));
400 }
401 return value;
402 }
403
404 /** Can be called by subclasses but can not be overridden */
405 protected final void checkConfigured() {
406 if (machDesc == null) {
407 throw new RuntimeException("MachineDescription must have been set by this point");
408 }
409 if (utils == null) {
410 throw new RuntimeException("DebuggerUtilities must have been set by this point");
411 }
412 }
413
414 /** Can be called by subclasses but can not be overridden */
415 protected final void checkJavaConfigured() {
416 checkConfigured();
417
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 package sun.jvm.hotspot.debugger;
26
27 import sun.jvm.hotspot.oops.Mark;
28 import sun.jvm.hotspot.runtime.VM;
29
30 /** <P> DebuggerBase is a recommended base class for debugger
31 implementations. It can use a PageCache to cache data from the
32 target process. Note that this class would not be suitable if the
33 system were used to reflect upon itself; it would never be safe to
34 store the value in an OopHandle in anything but an OopHandle.
35 However, it provides a fair amount of code sharing to the current
36 dbx and win32 implementations. </P>
37
38 <P> NOTE that much of the code sharing is achieved by having this
39 class implement many of the methods in the Win32Debugger and
40 DbxDebugger interfaces. </P> */
41
42 public abstract class DebuggerBase implements Debugger {
43
44 // May be set lazily, but must be set before calling any of the read
45 // routines below
46 protected MachineDescription machDesc;
47 protected DebuggerUtilities utils;
48 // Java primitive type sizes, set during bootstrapping. Do not call
49 // any of the Java read routines until these are set up.
380 }
381 }
382
383 protected long readAddressValue(long address)
384 throws UnmappedAddressException, UnalignedAddressException {
385 return readCInteger(address, machDesc.getAddressSize(), true);
386 }
387
388 protected long readCompOopAddressValue(long address)
389 throws UnmappedAddressException, UnalignedAddressException {
390 long value = readCInteger(address, getHeapOopSize(), true);
391 if (value != 0) {
392 // See oop.inline.hpp decode_heap_oop
393 value = (long)(narrowOopBase + (long)(value << narrowOopShift));
394 }
395 return value;
396 }
397
398 protected long readCompKlassAddressValue(long address)
399 throws UnmappedAddressException, UnalignedAddressException {
400 long value;
401 if (VM.getVM().isCompactObjectHeadersEnabled()) {
402 // With compact headers, the compressed Klass* is currently read from the mark
403 // word. We need to load the whole mark, and shift the upper parts.
404 value = readCInteger(address, machDesc.getAddressSize(), true);
405 value = value >>> Mark.getKlassShift();
406 } else {
407 value = readCInteger(address, getKlassPtrSize(), true);
408 }
409 if (value != 0) {
410 value = (long)(narrowKlassBase + (long)(value << narrowKlassShift));
411 }
412 return value;
413 }
414
415 /** Can be called by subclasses but can not be overridden */
416 protected final void checkConfigured() {
417 if (machDesc == null) {
418 throw new RuntimeException("MachineDescription must have been set by this point");
419 }
420 if (utils == null) {
421 throw new RuntimeException("DebuggerUtilities must have been set by this point");
422 }
423 }
424
425 /** Can be called by subclasses but can not be overridden */
426 protected final void checkJavaConfigured() {
427 checkConfigured();
428
|