8262504: Some CLHSDB command cannot know they run on remote debugger

Reviewed-by: cjplummer, sspitsyn
This commit is contained in:
Yasumasa Suenaga 2021-03-16 05:46:23 +00:00
parent d896246a11
commit e03a59489c
5 changed files with 43 additions and 12 deletions

View File

@ -1136,7 +1136,7 @@ public class CommandProcessor {
},
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 class CommandProcessor {
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());
}
},

View File

@ -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 class HotSpotAgent {
// Accessors (once the system is set up)
//
public synchronized Debugger getDebugger() {
public synchronized JVMDebugger getDebugger() {
return debugger;
}
@ -647,4 +647,8 @@ public class HotSpotAgent {
throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
}
}
public int getStartupMode() {
return startupMode;
}
}

View File

@ -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 @@ package sun.jvm.hotspot.tools;
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 class PMap extends Tool {
super(d);
}
public PMap(HotSpotAgent agent) {
super(agent);
}
@Override
public String getName() {
return "pmap";

View File

@ -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 @@ package sun.jvm.hotspot.tools;
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 @@ import sun.jvm.hotspot.utilities.PlatformInfo;
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) {

View File

@ -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 abstract class Tool implements Runnable {
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();
}