aboutsummaryrefslogtreecommitdiff
path: root/gdb/darwin-nat.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-07-05 21:50:12 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2018-07-05 21:50:18 -0400
commit6821842f15efaec045d9e38f115af01ddffdaede (patch)
tree2e64115941ffb6d85ebb15f0104e9965cb8bd7c5 /gdb/darwin-nat.c
parentbb11866d6a635fadb9285d18e2fb819d2de2c28c (diff)
downloadbinutils-6821842f15efaec045d9e38f115af01ddffdaede.zip
binutils-6821842f15efaec045d9e38f115af01ddffdaede.tar.gz
binutils-6821842f15efaec045d9e38f115af01ddffdaede.tar.bz2
darwin: Silence syscall deprecated declaration warning
This patch silences this warning: /Users/simark/src/binutils-gdb/gdb/darwin-nat.c:839:10: error: 'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported; please switch to a supported interface. For SYS_kdebug_trace use kdebug_signpost(). [-Werror,-Wdeprecated-declarations] res = syscall (SYS___pthread_kill, thread->gdb_port, nsignal); ^ /usr/include/unistd.h:745:6: note: 'syscall' has been explicitly marked deprecated here int syscall(int, ...); ^ The comment of the new pthread_kill function explains why we use the syscall function directly. include/ChangeLog: * diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS): Define for clang. gdb/ChangeLog: * darwin-nat.c (darwin_pthread_kill): New function. (darwin_resume_thread): Use darwin_pthread_kill.
Diffstat (limited to 'gdb/darwin-nat.c')
-rw-r--r--gdb/darwin-nat.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 5aed285..bb46cfb 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -809,13 +809,24 @@ darwin_send_reply (struct inferior *inf, darwin_thread_t *thread)
priv->pending_messages--;
}
+/* Wrapper around the __pthread_kill syscall. We use this instead of the
+ pthread_kill function to be able to send a signal to any kind of thread,
+ including GCD threads. */
+
+static int
+darwin_pthread_kill (darwin_thread_t *thread, int nsignal)
+{
+ DIAGNOSTIC_PUSH;
+ DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS;
+ int res = syscall (SYS___pthread_kill, thread->gdb_port, nsignal);
+ DIAGNOSTIC_POP;
+ return res;
+}
+
static void
darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
int step, int nsignal)
{
- kern_return_t kret;
- int res;
-
inferior_debug
(3, _("darwin_resume_thread: state=%d, thread=0x%x, step=%d nsignal=%d\n"),
thread->msg_state, thread->gdb_port, step, nsignal);
@@ -827,8 +838,8 @@ darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
&& thread->event.ex_data[0] == EXC_SOFT_SIGNAL)
{
/* Either deliver a new signal or cancel the signal received. */
- res = PTRACE (PT_THUPDATE, inf->pid,
- (caddr_t) (uintptr_t) thread->gdb_port, nsignal);
+ int res = PTRACE (PT_THUPDATE, inf->pid,
+ (caddr_t) (uintptr_t) thread->gdb_port, nsignal);
if (res < 0)
inferior_debug (1, _("ptrace THUP: res=%d\n"), res);
}
@@ -836,7 +847,7 @@ darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
{
/* Note: ptrace is allowed only if the process is stopped.
Directly send the signal to the thread. */
- res = syscall (SYS___pthread_kill, thread->gdb_port, nsignal);
+ int res = darwin_pthread_kill (thread, nsignal);
inferior_debug (4, _("darwin_resume_thread: kill 0x%x %d: %d\n"),
thread->gdb_port, nsignal, res);
thread->signaled = 1;
@@ -856,7 +867,7 @@ darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
break;
case DARWIN_STOPPED:
- kret = thread_resume (thread->gdb_port);
+ kern_return_t kret = thread_resume (thread->gdb_port);
MACH_CHECK_ERROR (kret);
thread->msg_state = DARWIN_RUNNING;