aboutsummaryrefslogtreecommitdiffstats
path: root/exec
diff options
context:
space:
mode:
authorPo Lu2023-05-03 16:00:13 +0800
committerPo Lu2023-05-03 16:00:13 +0800
commit7b3c774bcee29fa0a13f38a60ddebc6fbdbedd0e (patch)
tree2a541d968f9e3d0c90997621dc41f580d4e5f9e1 /exec
parent35eae084bcd2ece057e2e5fa89a11281c40e51f7 (diff)
downloademacs-7b3c774bcee29fa0a13f38a60ddebc6fbdbedd0e.tar.gz
emacs-7b3c774bcee29fa0a13f38a60ddebc6fbdbedd0e.zip
Update Android port
* exec/config.h.in: Autoheader. * exec/configure.ac: Use system extensions. (HAVE_PROCESS_VM): Define if process_vm_readv and process_vm_writev are available. * exec/trace.c (read_memory, user_copy): Implement in terms of process_vm if possible.
Diffstat (limited to 'exec')
-rw-r--r--exec/config.h.in106
-rw-r--r--exec/configure.ac13
-rw-r--r--exec/trace.c44
3 files changed, 161 insertions, 2 deletions
diff --git a/exec/config.h.in b/exec/config.h.in
index c360e54a4ba..6301275fd8a 100644
--- a/exec/config.h.in
+++ b/exec/config.h.in
@@ -52,6 +52,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
52/* Define to 1 if you have the <inttypes.h> header file. */ 52/* Define to 1 if you have the <inttypes.h> header file. */
53#undef HAVE_INTTYPES_H 53#undef HAVE_INTTYPES_H
54 54
55/* Define to 1 if you have the <minix/config.h> header file. */
56#undef HAVE_MINIX_CONFIG_H
57
58/* Define to 1 if process_vm_readv is available. */
59#undef HAVE_PROCESS_VM
60
55/* Define to 1 if stdbool.h conforms to C99. */ 61/* Define to 1 if stdbool.h conforms to C99. */
56#undef HAVE_STDBOOL_H 62#undef HAVE_STDBOOL_H
57 63
@@ -85,12 +91,18 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
85/* Define to 1 if you have the <sys/types.h> header file. */ 91/* Define to 1 if you have the <sys/types.h> header file. */
86#undef HAVE_SYS_TYPES_H 92#undef HAVE_SYS_TYPES_H
87 93
94/* Define to 1 if you have the <sys/uio.h> header file. */
95#undef HAVE_SYS_UIO_H
96
88/* Define to 1 if the system has the type `uintptr_t'. */ 97/* Define to 1 if the system has the type `uintptr_t'. */
89#undef HAVE_UINTPTR_T 98#undef HAVE_UINTPTR_T
90 99
91/* Define to 1 if you have the <unistd.h> header file. */ 100/* Define to 1 if you have the <unistd.h> header file. */
92#undef HAVE_UNISTD_H 101#undef HAVE_UNISTD_H
93 102
103/* Define to 1 if you have the <wchar.h> header file. */
104#undef HAVE_WCHAR_H
105
94/* Define to 1 if the system has the type `_Bool'. */ 106/* Define to 1 if the system has the type `_Bool'. */
95#undef HAVE__BOOL 107#undef HAVE__BOOL
96 108
@@ -168,6 +180,94 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
168/* Define to word type used by tracees. */ 180/* Define to word type used by tracees. */
169#undef USER_WORD 181#undef USER_WORD
170 182
183/* Enable extensions on AIX 3, Interix. */
184#ifndef _ALL_SOURCE
185# undef _ALL_SOURCE
186#endif
187/* Enable general extensions on macOS. */
188#ifndef _DARWIN_C_SOURCE
189# undef _DARWIN_C_SOURCE
190#endif
191/* Enable general extensions on Solaris. */
192#ifndef __EXTENSIONS__
193# undef __EXTENSIONS__
194#endif
195/* Enable GNU extensions on systems that have them. */
196#ifndef _GNU_SOURCE
197# undef _GNU_SOURCE
198#endif
199/* Enable X/Open compliant socket functions that do not require linking
200 with -lxnet on HP-UX 11.11. */
201#ifndef _HPUX_ALT_XOPEN_SOCKET_API
202# undef _HPUX_ALT_XOPEN_SOCKET_API
203#endif
204/* Identify the host operating system as Minix.
205 This macro does not affect the system headers' behavior.
206 A future release of Autoconf may stop defining this macro. */
207#ifndef _MINIX
208# undef _MINIX
209#endif
210/* Enable general extensions on NetBSD.
211 Enable NetBSD compatibility extensions on Minix. */
212#ifndef _NETBSD_SOURCE
213# undef _NETBSD_SOURCE
214#endif
215/* Enable OpenBSD compatibility extensions on NetBSD.
216 Oddly enough, this does nothing on OpenBSD. */
217#ifndef _OPENBSD_SOURCE
218# undef _OPENBSD_SOURCE
219#endif
220/* Define to 1 if needed for POSIX-compatible behavior. */
221#ifndef _POSIX_SOURCE
222# undef _POSIX_SOURCE
223#endif
224/* Define to 2 if needed for POSIX-compatible behavior. */
225#ifndef _POSIX_1_SOURCE
226# undef _POSIX_1_SOURCE
227#endif
228/* Enable POSIX-compatible threading on Solaris. */
229#ifndef _POSIX_PTHREAD_SEMANTICS
230# undef _POSIX_PTHREAD_SEMANTICS
231#endif
232/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
233#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
234# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
235#endif
236/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
237#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
238# undef __STDC_WANT_IEC_60559_BFP_EXT__
239#endif
240/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
241#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
242# undef __STDC_WANT_IEC_60559_DFP_EXT__
243#endif
244/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
245#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
246# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
247#endif
248/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
249#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
250# undef __STDC_WANT_IEC_60559_TYPES_EXT__
251#endif
252/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
253#ifndef __STDC_WANT_LIB_EXT2__
254# undef __STDC_WANT_LIB_EXT2__
255#endif
256/* Enable extensions specified by ISO/IEC 24747:2009. */
257#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
258# undef __STDC_WANT_MATH_SPEC_FUNCS__
259#endif
260/* Enable extensions on HP NonStop. */
261#ifndef _TANDEM_SOURCE
262# undef _TANDEM_SOURCE
263#endif
264/* Enable X/Open extensions. Define to 500 only if necessary
265 to make mbstate_t available. */
266#ifndef _XOPEN_SOURCE
267# undef _XOPEN_SOURCE
268#endif
269
270
171/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most 271/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
172 significant byte first (like Motorola and SPARC, unlike Intel). */ 272 significant byte first (like Motorola and SPARC, unlike Intel). */
173#if defined AC_APPLE_UNIVERSAL_BUILD 273#if defined AC_APPLE_UNIVERSAL_BUILD
@@ -198,6 +298,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
198/* Define as a signed integer type capable of holding a process identifier. */ 298/* Define as a signed integer type capable of holding a process identifier. */
199#undef pid_t 299#undef pid_t
200 300
301/* Define to `unsigned int' if <sys/types.h> does not define. */
302#undef size_t
303
304/* Define to `int' if <sys/types.h> does not define. */
305#undef ssize_t
306
201/* Define to the type of an unsigned integer type of width exactly 16 bits if 307/* Define to the type of an unsigned integer type of width exactly 16 bits if
202 such a type exists and the standard includes do not define it. */ 308 such a type exists and the standard includes do not define it. */
203#undef uint16_t 309#undef uint16_t
diff --git a/exec/configure.ac b/exec/configure.ac
index b948e184896..efefc6c7dbc 100644
--- a/exec/configure.ac
+++ b/exec/configure.ac
@@ -47,6 +47,7 @@ AC_ARG_WITH([reentrancy],
47 [Generate library which can be used within a signal handler.])], 47 [Generate library which can be used within a signal handler.])],
48 [AC_DEFINE([REENTRANT], [1])]) 48 [AC_DEFINE([REENTRANT], [1])])
49 49
50AC_USE_SYSTEM_EXTENSIONS
50AC_PROG_CC 51AC_PROG_CC
51AC_PROG_CPP 52AC_PROG_CPP
52AC_PROG_INSTALL 53AC_PROG_INSTALL
@@ -56,12 +57,22 @@ AC_TYPE_UINT16_T
56AC_TYPE_UINT32_T 57AC_TYPE_UINT32_T
57AC_TYPE_UINT64_T 58AC_TYPE_UINT64_T
58AC_TYPE_UINTPTR_T 59AC_TYPE_UINTPTR_T
60AC_TYPE_SIZE_T
61AC_TYPE_SSIZE_T
59AC_TYPE_PID_T 62AC_TYPE_PID_T
60 63
61AC_HEADER_STDBOOL 64AC_HEADER_STDBOOL
62AC_CHECK_FUNCS([getpagesize stpcpy stpncpy]) 65AC_CHECK_FUNCS([getpagesize stpcpy stpncpy])
63AC_CHECK_DECLS([stpcpy, stpncpy]) 66AC_CHECK_DECLS([stpcpy, stpncpy])
64AC_CHECK_HEADERS([sys/param.h]) dnl for MIN and MAX 67AC_CHECK_FUNC([process_vm_readv],
68 [AC_CHECK_FUNC([process_vm_writev],
69 [AC_CHECK_DECL([process_vm_readv],
70 [AC_DEFINE([HAVE_PROCESS_VM], [1],
71 [Define to 1 if process_vm_readv is available.])],
72 [], [[
73#include <sys/uio.h>
74 ]])])])
75AC_CHECK_HEADERS([sys/param.h sys/uio.h])
65 76
66AH_BOTTOM([ 77AH_BOTTOM([
67#ifdef HAVE_STDBOOL_H 78#ifdef HAVE_STDBOOL_H
diff --git a/exec/trace.c b/exec/trace.c
index cb0839c9cd9..8d107696423 100644
--- a/exec/trace.c
+++ b/exec/trace.c
@@ -42,6 +42,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
42#include <linux/elf.h> /* for NT_* */ 42#include <linux/elf.h> /* for NT_* */
43#endif /* __aarch64__ */ 43#endif /* __aarch64__ */
44 44
45#ifdef HAVE_SYS_UIO_H
46#include <sys/uio.h> /* for process_vm_readv */
47#endif /* HAVE_SYS_UIO_H */
48
45 49
46 50
47/* Program tracing functions. 51/* Program tracing functions.
@@ -122,7 +126,10 @@ static struct exec_tracee *tracing_processes;
122 126
123 127
124/* Read N bytes from TRACEE's memory, starting at the specified user 128/* Read N bytes from TRACEE's memory, starting at the specified user
125 ADDRESS. Return its contents in BUFFER. */ 129 ADDRESS. Return its contents in BUFFER.
130
131 If there are unreadable pages within ADDRESS + N, the contents of
132 BUFFER after the first such page becomes undefined. */
126 133
127static void 134static void
128read_memory (struct exec_tracee *tracee, char *buffer, 135read_memory (struct exec_tracee *tracee, char *buffer,
@@ -130,6 +137,25 @@ read_memory (struct exec_tracee *tracee, char *buffer,
130{ 137{
131 USER_WORD word, n_words, n_bytes, i; 138 USER_WORD word, n_words, n_bytes, i;
132 long rc; 139 long rc;
140#ifdef HAVE_PROCESS_VM
141 struct iovec iov, remote;
142
143 /* If `process_vm_readv' is available, use it instead. */
144
145 iov.iov_base = buffer;
146 iov.iov_len = n;
147 remote.iov_base = (void *) address;
148 remote.iov_len = n;
149
150 /* Return immediately if successful. As long as some bytes were
151 read, consider the read to have been a success. */
152
153 if (n <= SSIZE_MAX
154 && ((size_t) process_vm_readv (tracee->pid, &iov, 1,
155 &remote, 1, 0) != -1))
156 return;
157
158#endif /* HAVE_PROCESS_VM */
133 159
134 /* First, read entire words from the tracee. */ 160 /* First, read entire words from the tracee. */
135 n_words = n & ~(sizeof (USER_WORD) - 1); 161 n_words = n & ~(sizeof (USER_WORD) - 1);
@@ -248,6 +274,22 @@ user_copy (struct exec_tracee *tracee, const unsigned char *buffer,
248{ 274{
249 USER_WORD start, end, word; 275 USER_WORD start, end, word;
250 unsigned char *bytes; 276 unsigned char *bytes;
277#ifdef HAVE_PROCESS_VM
278 struct iovec iov, remote;
279
280 /* Try to use `process_vm_writev' if possible, but fall back to
281 ptrace if something bad happens. */
282
283 iov.iov_base = (void *) buffer;
284 iov.iov_len = n;
285 remote.iov_base = (void *) address;
286 remote.iov_len = n;
287
288 if (n <= SSIZE_MAX
289 && ((size_t) process_vm_writev (tracee->pid, &iov, 1,
290 &remote, 1, 0) == n))
291 return 0;
292#endif /* HAVE_PROCESS_VM */
251 293
252 /* Calculate the start and end positions for the write. */ 294 /* Calculate the start and end positions for the write. */
253 295