Skip to content
Permalink
Browse files
8262504: Some CLHSDB command cannot know they run on remote debugger
Reviewed-by: cjplummer, sspitsyn
  • Loading branch information
YaSuenag committed Mar 16, 2021
1 parent d896246 commit e03a59489c2db3c7d442a14c49da7b82db88f92b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
@@ -1136,7 +1136,7 @@ public void doit(Tokens t) {
},
new Command("pmap", "pmap", false) {
public void doit(Tokens t) {
PMap pmap = new PMap();
PMap pmap = new PMap(debugger.getAgent());
pmap.run(out, debugger.getAgent().getDebugger());
}
},
@@ -1146,7 +1146,7 @@ public void doit(Tokens t) {
if (t.countTokens() > 0 && t.nextToken().equals("-v")) {
verbose = true;
}
PStack pstack = new PStack(verbose, true);
PStack pstack = new PStack(verbose, true, debugger.getAgent());
pstack.run(out, debugger.getAgent().getDebugger());
}
},
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -72,9 +72,9 @@ public class HotSpotAgent {
// - Starting debug server for core file

// These are options for the "client" side of things
private static final int PROCESS_MODE = 0;
private static final int CORE_FILE_MODE = 1;
private static final int REMOTE_MODE = 2;
public static final int PROCESS_MODE = 0;
public static final int CORE_FILE_MODE = 1;
public static final int REMOTE_MODE = 2;
private int startupMode;

// This indicates whether we are really starting a server or not
@@ -115,7 +115,7 @@ public void run() {
// Accessors (once the system is set up)
//

public synchronized Debugger getDebugger() {
public synchronized JVMDebugger getDebugger() {
return debugger;
}

@@ -647,4 +647,8 @@ private void attachDebugger() {
throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
}
}

public int getStartupMode() {
return startupMode;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@

import java.io.*;
import java.util.*;
import sun.jvm.hotspot.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.utilities.PlatformInfo;
@@ -40,6 +41,10 @@ public PMap(JVMDebugger d) {
super(d);
}

public PMap(HotSpotAgent agent) {
super(agent);
}

@Override
public String getName() {
return "pmap";
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@

import java.io.*;
import java.util.*;
import sun.jvm.hotspot.*;
import sun.jvm.hotspot.code.*;
import sun.jvm.hotspot.interpreter.*;
import sun.jvm.hotspot.debugger.*;
@@ -36,13 +37,18 @@

public class PStack extends Tool {
// in non-verbose mode, Method*s are not printed in java frames
public PStack(boolean v, boolean concurrentLocks) {
public PStack(boolean v, boolean concurrentLocks, HotSpotAgent agent) {
super(agent);
this.verbose = v;
this.concurrentLocks = concurrentLocks;
}

public PStack(boolean v, boolean concurrentLocks) {
this(v, concurrentLocks, null);
}

public PStack() {
this(true, true);
this(true, true, null);
}

public PStack(JVMDebugger d) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,22 @@ public Tool(JVMDebugger d) {
jvmDebugger = d;
}

public Tool(HotSpotAgent agent) {
this.agent = agent;
if (agent == null) {
jvmDebugger = null;
debugeeType = -1;
} else {
jvmDebugger = agent.getDebugger();
debugeeType = switch (agent.getStartupMode()) {
case HotSpotAgent.PROCESS_MODE -> DEBUGEE_PID;
case HotSpotAgent.CORE_FILE_MODE -> DEBUGEE_CORE;
case HotSpotAgent.REMOTE_MODE -> DEBUGEE_REMOTE;
default -> throw new IllegalStateException("Invalid attach mode");
};
}
}

public String getName() {
return getClass().getName();
}

0 comments on commit e03a594

Please sign in to comment.