Mercurial > hg > truffle
annotate agent/src/os/linux/libproc.h @ 7610:ed6154d7d259
8005590: java_lang_Class injected field resolved_constructor appears unused
Reviewed-by: coleenp, dholmes
author | stefank |
---|---|
date | Tue, 15 Jan 2013 13:32:13 +0100 |
parents | a9fed06c01d2 |
children | 9fae07c31641 |
rev | line source |
---|---|
0 | 1 /* |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 #ifndef _LIBPROC_H_ | |
26 #define _LIBPROC_H_ | |
27 | |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
28 #include <jni.h> |
0 | 29 #include <unistd.h> |
30 #include <stdint.h> | |
31 #include "proc_service.h" | |
32 | |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
33 #if defined(arm) || defined(ppc) |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
34 #include "libproc_md.h" |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
35 #endif |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
36 |
0 | 37 #if defined(sparc) || defined(sparcv9) |
38 /* | |
39 If _LP64 is defined ptrace.h should be taken from /usr/include/asm-sparc64 | |
40 otherwise it should be from /usr/include/asm-sparc | |
41 These two files define pt_regs structure differently | |
42 */ | |
43 #ifdef _LP64 | |
44 #include "asm-sparc64/ptrace.h" | |
45 #else | |
46 #include "asm-sparc/ptrace.h" | |
47 #endif | |
48 | |
49 #endif //sparc or sparcv9 | |
50 | |
51 /************************************************************************************ | |
52 | |
53 0. This is very minimal subset of Solaris libproc just enough for current application. | |
54 Please note that the bulk of the functionality is from proc_service interface. This | |
55 adds Pgrab__ and some missing stuff. We hide the difference b/w live process and core | |
56 file by this interface. | |
57 | |
58 1. pthread_id unique in both NPTL & LinuxThreads. We store this in | |
59 OSThread::_pthread_id in JVM code. | |
60 | |
61 2. All threads see the same pid when they call getpid() under NPTL. | |
62 Threads receive different pid under LinuxThreads. We used to save the result of | |
63 ::getpid() call in OSThread::_thread_id. This way uniqueness of OSThread::_thread_id | |
64 was lost under NPTL. Now, we store the result of ::gettid() call in | |
65 OSThread::_thread_id. Because gettid returns actual pid of thread (lwp id), this is | |
66 unique again. We therefore use OSThread::_thread_id as unique identifier. | |
67 | |
68 3. There is a unique LWP id under both thread libraries. libthread_db maps pthread_id | |
69 to its underlying lwp_id under both the thread libraries. thread_info.lwp_id stores | |
70 lwp_id of the thread. The lwp id is nothing but the actual pid of clone'd processes. But | |
71 unfortunately libthread_db does not work very well for core dumps. So, we get pthread_id | |
72 only for processes. For core dumps, we don't use libthread_db at all (like gdb). | |
73 | |
74 4. ptrace operates on this LWP id under both the thread libraries. When we say 'pid' for | |
75 ptrace call, we refer to lwp_id of the thread. | |
76 | |
77 5. for core file, we parse ELF files and read data from them. For processes we use | |
78 combination of ptrace and /proc calls. | |
79 | |
80 *************************************************************************************/ | |
81 | |
82 #ifdef ia64 | |
83 struct user_regs_struct { | |
84 /* copied from user.h which doesn't define this in a struct */ | |
85 | |
86 #define IA64_REG_COUNT (EF_SIZE/8+32) /* integer and fp regs */ | |
87 unsigned long regs[IA64_REG_COUNT]; /* integer and fp regs */ | |
88 }; | |
89 #endif | |
90 | |
91 #if defined(sparc) || defined(sparcv9) | |
92 #define user_regs_struct pt_regs | |
93 #endif | |
94 | |
95 // This C bool type must be int for compatibility with Linux calls and | |
96 // it would be a mistake to equivalence it to C++ bool on many platforms | |
97 | |
98 typedef int bool; | |
99 #define true 1 | |
100 #define false 0 | |
101 | |
102 struct ps_prochandle; | |
103 | |
104 // attach to a process | |
105 struct ps_prochandle* Pgrab(pid_t pid); | |
106 | |
107 // attach to a core dump | |
108 struct ps_prochandle* Pgrab_core(const char* execfile, const char* corefile); | |
109 | |
110 // release a process or core | |
111 void Prelease(struct ps_prochandle* ph); | |
112 | |
113 // functions not directly available in Solaris libproc | |
114 | |
115 // initialize libproc (call this only once per app) | |
116 // pass true to make library verbose | |
117 bool init_libproc(bool verbose); | |
118 | |
119 // get number of threads | |
120 int get_num_threads(struct ps_prochandle* ph); | |
121 | |
122 // get lwp_id of n'th thread | |
123 lwpid_t get_lwp_id(struct ps_prochandle* ph, int index); | |
124 | |
125 // get regs for a given lwp | |
126 bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct user_regs_struct* regs); | |
127 | |
128 // get number of shared objects | |
129 int get_num_libs(struct ps_prochandle* ph); | |
130 | |
131 // get name of n'th lib | |
132 const char* get_lib_name(struct ps_prochandle* ph, int index); | |
133 | |
134 // get base of lib | |
135 uintptr_t get_lib_base(struct ps_prochandle* ph, int index); | |
136 | |
137 // returns true if given library is found in lib list | |
138 bool find_lib(struct ps_prochandle* ph, const char *lib_name); | |
139 | |
140 // symbol lookup | |
141 uintptr_t lookup_symbol(struct ps_prochandle* ph, const char* object_name, | |
142 const char* sym_name); | |
143 | |
144 // address->nearest symbol lookup. return NULL for no symbol | |
145 const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* poffset); | |
146 | |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
147 struct ps_prochandle* get_proc_handle(JNIEnv* env, jobject this_obj); |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
148 |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
149 void throw_new_debugger_exception(JNIEnv* env, const char* errMsg); |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
150 |
0 | 151 #endif //__LIBPROC_H_ |