author | herrick |
Tue, 09 Apr 2019 10:57:04 -0400 | |
branch | JDK-8200758-branch |
changeset 57314 | 23da9e6f446f |
parent 53379 | e47074d2d8cc |
child 58913 | e2dfab7beccb |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53379
e47074d2d8cc
8181313: SA: Remove libthread_db dependency on Linux
ysuenaga
parents:
51203
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
#ifndef _LIBPROC_H_ |
|
26 |
#define _LIBPROC_H_ |
|
27 |
||
13529
dc25e69fd16d
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
5547
diff
changeset
|
28 |
#include <jni.h> |
1 | 29 |
#include <unistd.h> |
30 |
#include <stdint.h> |
|
31 |
||
53379
e47074d2d8cc
8181313: SA: Remove libthread_db dependency on Linux
ysuenaga
parents:
51203
diff
changeset
|
32 |
#include <sys/procfs.h> |
25072 | 33 |
#include <sys/ptrace.h> |
1 | 34 |
|
35 |
||
35075
ca79cbf3f106
8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
asmundak
parents:
35073
diff
changeset
|
36 |
#if defined(sparc) || defined(sparcv9) || defined(ppc64) || defined(ppc64le) |
35073
3b3c2fb85d58
8144885: agent/src/os/linux/libproc.h needs to support Linux/SPARC builds
mikael
parents:
35049
diff
changeset
|
37 |
#include <asm/ptrace.h> |
1 | 38 |
#define user_regs_struct pt_regs |
39 |
#endif |
|
42664 | 40 |
#if defined(aarch64) || defined(arm64) |
31394 | 41 |
#include <asm/ptrace.h> |
29180 | 42 |
#define user_regs_struct user_pt_regs |
42664 | 43 |
#elif defined(arm) |
44 |
#include <asm/ptrace.h> |
|
45 |
#define user_regs_struct pt_regs |
|
29180 | 46 |
#endif |
1 | 47 |
|
48 |
// This C bool type must be int for compatibility with Linux calls and |
|
49 |
// it would be a mistake to equivalence it to C++ bool on many platforms |
|
50 |
||
51 |
typedef int bool; |
|
52 |
#define true 1 |
|
53 |
#define false 0 |
|
54 |
||
55 |
struct ps_prochandle; |
|
56 |
||
57 |
// attach to a process |
|
49440 | 58 |
JNIEXPORT struct ps_prochandle* JNICALL |
53379
e47074d2d8cc
8181313: SA: Remove libthread_db dependency on Linux
ysuenaga
parents:
51203
diff
changeset
|
59 |
Pgrab(pid_t pid, char* err_buf, size_t err_buf_len); |
1 | 60 |
|
61 |
// attach to a core dump |
|
49440 | 62 |
JNIEXPORT struct ps_prochandle* JNICALL |
63 |
Pgrab_core(const char* execfile, const char* corefile); |
|
1 | 64 |
|
65 |
// release a process or core |
|
49440 | 66 |
JNIEXPORT void JNICALL |
67 |
Prelease(struct ps_prochandle* ph); |
|
1 | 68 |
|
69 |
// functions not directly available in Solaris libproc |
|
70 |
||
71 |
// initialize libproc (call this only once per app) |
|
72 |
// pass true to make library verbose |
|
49440 | 73 |
JNIEXPORT bool JNICALL |
74 |
init_libproc(bool verbose); |
|
1 | 75 |
|
76 |
// get number of threads |
|
77 |
int get_num_threads(struct ps_prochandle* ph); |
|
78 |
||
79 |
// get lwp_id of n'th thread |
|
80 |
lwpid_t get_lwp_id(struct ps_prochandle* ph, int index); |
|
81 |
||
82 |
// get regs for a given lwp |
|
83 |
bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct user_regs_struct* regs); |
|
84 |
||
85 |
// get number of shared objects |
|
86 |
int get_num_libs(struct ps_prochandle* ph); |
|
87 |
||
88 |
// get name of n'th lib |
|
89 |
const char* get_lib_name(struct ps_prochandle* ph, int index); |
|
90 |
||
91 |
// get base of lib |
|
92 |
uintptr_t get_lib_base(struct ps_prochandle* ph, int index); |
|
93 |
||
94 |
// returns true if given library is found in lib list |
|
95 |
bool find_lib(struct ps_prochandle* ph, const char *lib_name); |
|
96 |
||
97 |
// symbol lookup |
|
98 |
uintptr_t lookup_symbol(struct ps_prochandle* ph, const char* object_name, |
|
99 |
const char* sym_name); |
|
100 |
||
101 |
// address->nearest symbol lookup. return NULL for no symbol |
|
102 |
const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* poffset); |
|
103 |
||
13529
dc25e69fd16d
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
5547
diff
changeset
|
104 |
struct ps_prochandle* get_proc_handle(JNIEnv* env, jobject this_obj); |
dc25e69fd16d
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
5547
diff
changeset
|
105 |
|
dc25e69fd16d
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
5547
diff
changeset
|
106 |
void throw_new_debugger_exception(JNIEnv* env, const char* errMsg); |
dc25e69fd16d
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
5547
diff
changeset
|
107 |
|
1 | 108 |
#endif //__LIBPROC_H_ |