annotate agent/src/os/bsd/libproc_impl.h @ 17716:cdb71841f4bc

6498581: ThreadInterruptTest3 produces wrong output on Windows Summary: There is race condition between os::interrupt and os::is_interrupted on Windows. In JVM_Sleep(Thread.sleep), check if thread gets interrupted, it may see interrupted but not really interrupted so cause spurious waking up (early return from sleep). Fix by checking if interrupt event really gets set thus prevent false return. For intrinsic of _isInterrupted, on Windows, go fastpath only on bit not set. Reviewed-by: acorn, kvn Contributed-by: david.holmes@oracle.com, yumin.qi@oracle.com
author minqi
date Wed, 26 Feb 2014 15:20:41 -0800
parents 39432a1cefdd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
1 /*
8058
2394a89e89f4 8008088: SA can hang the VM
rbackman
parents: 3960
diff changeset
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
4 *
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
7 * published by the Free Software Foundation.
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
8 *
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
13 * accompanied this code).
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
14 *
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
18 *
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
21 * questions.
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
22 *
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
23 */
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
24
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
25 #ifndef _LIBPROC_IMPL_H_
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
26 #define _LIBPROC_IMPL_H_
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
27
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
28 #include <unistd.h>
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
29 #include <limits.h>
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
30 #include "libproc.h"
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
31 #include "symtab.h"
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
32
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
33 #ifdef __APPLE__
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
34 #include <inttypes.h> // for PRIx64, 32, ...
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
35 #include <pthread.h>
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
36 #include <mach-o/loader.h>
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
37 #include <mach-o/nlist.h>
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
38 #include <mach-o/fat.h>
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
39
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
40 #ifndef register_t
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
41 #define register_t uint64_t
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
42 #endif
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
43
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
44 /*** registers copied from bsd/amd64 */
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
45 typedef struct reg {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
46 register_t r_r15;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
47 register_t r_r14;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
48 register_t r_r13;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
49 register_t r_r12;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
50 register_t r_r11;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
51 register_t r_r10;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
52 register_t r_r9;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
53 register_t r_r8;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
54 register_t r_rdi;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
55 register_t r_rsi;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
56 register_t r_rbp;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
57 register_t r_rbx;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
58 register_t r_rdx;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
59 register_t r_rcx;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
60 register_t r_rax;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
61 uint32_t r_trapno; // not used
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
62 uint16_t r_fs;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
63 uint16_t r_gs;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
64 uint32_t r_err; // not used
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
65 uint16_t r_es; // not used
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
66 uint16_t r_ds; // not used
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
67 register_t r_rip;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
68 register_t r_cs;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
69 register_t r_rflags;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
70 register_t r_rsp;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
71 register_t r_ss; // not used
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
72 } reg;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
73
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
74 // convenient defs
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
75 typedef struct mach_header_64 mach_header_64;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
76 typedef struct load_command load_command;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
77 typedef struct segment_command_64 segment_command_64;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
78 typedef struct thread_command thread_command;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
79 typedef struct dylib_command dylib_command;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
80 typedef struct symtab_command symtab_command;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
81 typedef struct nlist_64 nlist_64;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
82 #else
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
83 #include <thread_db.h>
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
84 #include "salibelf.h"
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
85 #endif // __APPLE__
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
86
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
87 // data structures in this file mimic those of Solaris 8.0 - libproc's Pcontrol.h
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
88
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
89 #define BUF_SIZE (PATH_MAX + NAME_MAX + 1)
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
90
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
91 // list of shared objects
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
92 typedef struct lib_info {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
93 char name[BUF_SIZE];
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
94 uintptr_t base;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
95 struct symtab* symtab;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
96 int fd; // file descriptor for lib
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
97 struct lib_info* next;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
98 } lib_info;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
99
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
100 // list of threads
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
101 typedef struct sa_thread_info {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
102 lwpid_t lwp_id; // same as pthread_t
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
103 pthread_t pthread_id; //
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
104 struct reg regs; // not for process, core uses for caching regset
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
105 struct sa_thread_info* next;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
106 } sa_thread_info;
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
107
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
108 // list of virtual memory maps
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
109 typedef struct map_info {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
110 int fd; // file descriptor
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
111 off_t offset; // file offset of this mapping
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
112 uintptr_t vaddr; // starting virtual address
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
113 size_t memsz; // size of the mapping
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
114 struct map_info* next;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
115 } map_info;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
116
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
117 // vtable for ps_prochandle
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
118 typedef struct ps_prochandle_ops {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
119 // "derived class" clean-up
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
120 void (*release)(struct ps_prochandle* ph);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
121 // read from debuggee
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
122 bool (*p_pread)(struct ps_prochandle *ph,
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
123 uintptr_t addr, char *buf, size_t size);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
124 // write into debuggee
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
125 bool (*p_pwrite)(struct ps_prochandle *ph,
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
126 uintptr_t addr, const char *buf , size_t size);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
127 // get integer regset of a thread
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
128 bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
129 // get info on thread
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
130 bool (*get_lwp_info)(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
131 } ps_prochandle_ops;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
132
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
133 // the ps_prochandle
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
134
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
135 struct core_data {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
136 int core_fd; // file descriptor of core file
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
137 int exec_fd; // file descriptor of exec file
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
138 int interp_fd; // file descriptor of interpreter (ld-elf.so.1)
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
139 // part of the class sharing workaround
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
140 int classes_jsa_fd; // file descriptor of class share archive
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
141 uintptr_t dynamic_addr; // address of dynamic section of a.out
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
142 uintptr_t ld_base_addr; // base address of ld.so
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
143 size_t num_maps; // number of maps.
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
144 map_info* maps; // maps in a linked list
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
145 // part of the class sharing workaround
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
146 map_info* class_share_maps;// class share maps in a linked list
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
147 map_info** map_array; // sorted (by vaddr) array of map_info pointers
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
148 char exec_path[4096]; // file name java
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
149 };
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
150
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
151 struct ps_prochandle {
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
152 ps_prochandle_ops* ops; // vtable ptr
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
153 pid_t pid;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
154 int num_libs;
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
155 lib_info* libs; // head of lib list
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
156 lib_info* lib_tail; // tail of lib list - to append at the end
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
157 int num_threads;
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
158 sa_thread_info* threads; // head of thread list
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
159 struct core_data* core; // data only used for core dumps, NULL for process
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
160 };
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
161
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
162 int pathmap_open(const char* name);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
163 void print_debug(const char* format,...);
8058
2394a89e89f4 8008088: SA can hang the VM
rbackman
parents: 3960
diff changeset
164 void print_error(const char* format,...);
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
165 bool is_debug();
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
166
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
167 typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
168
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
169 // reads thread info using libthread_db and calls above callback for each thread
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
170 bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
171
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
172 // adds a new shared object to lib list, returns NULL on failure
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
173 lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
174
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
175 // adds a new shared object to lib list, supply open lib file descriptor as well
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
176 lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
177 uintptr_t base);
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
178
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
179 sa_thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id);
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
180 // a test for ELF signature without using libelf
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
181
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
182 #ifdef __APPLE__
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
183 // a test for Mach-O signature
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
184 bool is_macho_file(int fd);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
185 // skip fat head to get image start offset of cpu_type_t
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
186 // return false if any error happens, else value in offset.
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
187 bool get_arch_off(int fd, cpu_type_t cputype, off_t *offset);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
188 #else
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
189 bool is_elf_file(int fd);
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
190 #endif // __APPLE__
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
191
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
192 lwpid_t get_lwp_id(struct ps_prochandle* ph, int index);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
193 bool set_lwp_id(struct ps_prochandle* ph, int index, lwpid_t lwpid);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
194 bool get_nth_lwp_regs(struct ps_prochandle* ph, int index, struct reg* regs);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
195
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
196 // ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
197 // of the load object object_name in the target process identified by ph.
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
198 // It returns the symbol's value as an address in the target process in
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
199 // *sym_addr.
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
200
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
201 ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
202 const char *sym_name, psaddr_t *sym_addr);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
203
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
204 // read "size" bytes info "buf" from address "addr"
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
205 ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t addr,
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
206 void *buf, size_t size);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
207
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
208 // write "size" bytes of data to debuggee at address "addr"
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
209 ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
210 const void *buf, size_t size);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
211
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
212 // fill in ptrace_lwpinfo for lid
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
213 ps_err_e ps_linfo(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
214
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
215 // needed for when libthread_db is compiled with TD_DEBUG defined
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
216 void ps_plog (const char *format, ...);
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
217
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
218 // untility, tells the position in file
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8058
diff changeset
219 off_t ltell(int fd);
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents:
diff changeset
220 #endif //_LIBPROC_IMPL_H_