Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java
41161 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324package sun.jvm.hotspot.tools;2526import java.io.*;27import java.util.*;28import sun.jvm.hotspot.*;29import sun.jvm.hotspot.debugger.*;30import sun.jvm.hotspot.debugger.cdbg.*;31import sun.jvm.hotspot.debugger.remote.*;32import sun.jvm.hotspot.utilities.PlatformInfo;3334public class PMap extends Tool {3536public PMap() {37super();38}3940public PMap(JVMDebugger d) {41super(d);42}4344public PMap(HotSpotAgent agent) {45super(agent);46}4748@Override49public String getName() {50return "pmap";51}5253public void run() {54run(System.out);55}5657public void run(PrintStream out) {58run(out, getAgent().getDebugger());59}6061public void run(PrintStream out, Debugger dbg) {62CDebugger cdbg = dbg.getCDebugger();63if (cdbg != null) {64List<LoadObject> l = cdbg.getLoadObjectList();65Iterator<LoadObject> itr = l.iterator();66if (!itr.hasNext() && PlatformInfo.getOS().equals("darwin")) {67// If the list is empty, we assume we attached to a process, and on OSX we can only68// get LoadObjects for a core file.69out.println("Not available for Mac OS X processes");70return;71}72while (itr.hasNext()) {73LoadObject lo = itr.next();74out.print(lo.getBase() + "\t");75out.print(lo.getSize()/1024 + "K\t");76out.println(lo.getName());77}78} else {79if (getDebugeeType() == DEBUGEE_REMOTE) {80out.print(((RemoteDebuggerClient)dbg).execCommandOnServer("pmap", null));81} else {82out.println("not yet implemented (debugger does not support CDebugger)!");83}84}85}8687public static void main(String[] args) throws Exception {88PMap t = new PMap();89t.execute(args);90}91}929394