diff agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java @ 8750:39432a1cefdd

8003348: SA can not read core file on OS Summary: Macosx uses Mach-O file format for binary files, not ELF format. Currently SA works on core files on other platforms, t his change enables SA work on core file generated on Darwin. Reviewed-by: sla, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Thu, 14 Mar 2013 00:33:08 -0700
parents 5a98bf7d847b
children
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Wed Mar 13 17:34:29 2013 -0400
+++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Thu Mar 14 00:33:08 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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
@@ -42,6 +42,7 @@
 public class Threads {
     private static JavaThreadFactory threadFactory;
     private static AddressField      threadListField;
+    private static CIntegerField     numOfThreadsField;
     private static VirtualConstructor virtualConstructor;
     private static JavaThreadPDAccess access;
 
@@ -57,6 +58,7 @@
         Type type = db.lookupType("Threads");
 
         threadListField = type.getAddressField("_thread_list");
+        numOfThreadsField = type.getCIntegerField("_number_of_threads");
 
         // Instantiate appropriate platform-specific JavaThreadFactory
         String os  = VM.getVM().getOS();
@@ -102,6 +104,10 @@
             } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
                 access = new BsdAMD64JavaThreadPDAccess();
             }
+        } else if (os.equals("darwin")) {
+            if (cpu.equals("amd64") || cpu.equals("x86_64")) {
+                access = new BsdAMD64JavaThreadPDAccess();
+            }
         }
 
         if (access == null) {
@@ -144,6 +150,10 @@
         return createJavaThreadWrapper(threadAddr);
     }
 
+    public int getNumberOfThreads() {
+        return (int) numOfThreadsField.getValue();
+    }
+
     /** Routine for instantiating appropriately-typed wrapper for a
       JavaThread. Currently needs to be public for OopUtilities to
       access it. */