Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java
41161 views
1
/*
2
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
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.tools;
26
27
import java.io.*;
28
import java.util.*;
29
import sun.jvm.hotspot.*;
30
import sun.jvm.hotspot.debugger.*;
31
import sun.jvm.hotspot.debugger.cdbg.*;
32
import sun.jvm.hotspot.debugger.remote.*;
33
import sun.jvm.hotspot.utilities.PlatformInfo;
34
35
public class PMap extends Tool {
36
37
public PMap() {
38
super();
39
}
40
41
public PMap(JVMDebugger d) {
42
super(d);
43
}
44
45
public PMap(HotSpotAgent agent) {
46
super(agent);
47
}
48
49
@Override
50
public String getName() {
51
return "pmap";
52
}
53
54
public void run() {
55
run(System.out);
56
}
57
58
public void run(PrintStream out) {
59
run(out, getAgent().getDebugger());
60
}
61
62
public void run(PrintStream out, Debugger dbg) {
63
CDebugger cdbg = dbg.getCDebugger();
64
if (cdbg != null) {
65
List<LoadObject> l = cdbg.getLoadObjectList();
66
Iterator<LoadObject> itr = l.iterator();
67
if (!itr.hasNext() && PlatformInfo.getOS().equals("darwin")) {
68
// If the list is empty, we assume we attached to a process, and on OSX we can only
69
// get LoadObjects for a core file.
70
out.println("Not available for Mac OS X processes");
71
return;
72
}
73
while (itr.hasNext()) {
74
LoadObject lo = itr.next();
75
out.print(lo.getBase() + "\t");
76
out.print(lo.getSize()/1024 + "K\t");
77
out.println(lo.getName());
78
}
79
} else {
80
if (getDebugeeType() == DEBUGEE_REMOTE) {
81
out.print(((RemoteDebuggerClient)dbg).execCommandOnServer("pmap", null));
82
} else {
83
out.println("not yet implemented (debugger does not support CDebugger)!");
84
}
85
}
86
}
87
88
public static void main(String[] args) throws Exception {
89
PMap t = new PMap();
90
t.execute(args);
91
}
92
}
93
94