Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThread.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 | 758935f7c23f |
children |
rev | line source |
---|---|
3960 | 1 /* |
8750 | 2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. |
3960 | 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.debugger.bsd; | |
26 | |
27 import sun.jvm.hotspot.debugger.*; | |
28 | |
29 class BsdThread implements ThreadProxy { | |
30 private BsdDebugger debugger; | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
31 private int thread_id; |
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
32 private long unique_thread_id; |
3960 | 33 |
34 /** The address argument must be the address of the _thread_id in the | |
35 OSThread. It's value is result ::gettid() call. */ | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
36 BsdThread(BsdDebugger debugger, Address threadIdAddr, Address uniqueThreadIdAddr) { |
3960 | 37 this.debugger = debugger; |
38 // FIXME: size of data fetched here should be configurable. | |
39 // However, making it so would produce a dependency on the "types" | |
40 // package from the debugger package, which is not desired. | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
41 this.thread_id = (int) threadIdAddr.getCIntegerAt(0, 4, true); |
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
42 this.unique_thread_id = uniqueThreadIdAddr.getCIntegerAt(0, 8, true); |
3960 | 43 } |
44 | |
45 BsdThread(BsdDebugger debugger, long id) { | |
46 this.debugger = debugger; | |
8750 | 47 // use unique_thread_id to identify thread |
48 this.unique_thread_id = id; | |
3960 | 49 } |
50 | |
51 public boolean equals(Object obj) { | |
52 if ((obj == null) || !(obj instanceof BsdThread)) { | |
53 return false; | |
54 } | |
55 | |
8750 | 56 return (((BsdThread) obj).unique_thread_id == unique_thread_id); |
3960 | 57 } |
58 | |
59 public int hashCode() { | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
60 return thread_id; |
3960 | 61 } |
62 | |
63 public String toString() { | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
64 return Integer.toString(thread_id); |
3960 | 65 } |
66 | |
67 public ThreadContext getContext() throws IllegalThreadStateException { | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
68 long[] data = debugger.getThreadIntegerRegisterSet(unique_thread_id); |
3960 | 69 ThreadContext context = BsdThreadContextFactory.createThreadContext(debugger); |
70 for (int i = 0; i < data.length; i++) { | |
71 context.setRegister(i, data[i]); | |
72 } | |
73 return context; | |
74 } | |
75 | |
76 public boolean canSetContext() throws DebuggerException { | |
77 return false; | |
78 } | |
79 | |
80 public void setContext(ThreadContext context) | |
81 throws IllegalThreadStateException, DebuggerException { | |
82 throw new DebuggerException("Unimplemented"); | |
83 } | |
8750 | 84 |
85 /** this is not interface function, used in core file to get unique thread id on Macosx*/ | |
86 public long getUniqueThreadId() { | |
87 return unique_thread_id; | |
88 } | |
3960 | 89 } |