From patchwork Fri Jul 6 01:53:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 28253 Received: (qmail 119681 invoked by alias); 6 Jul 2018 01:53:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 119560 invoked by uid 89); 6 Jul 2018 01:53:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=8567, inf, priv, __pthread_kill X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jul 2018 01:53:36 +0000 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 4XORI8LKOJVWxxxX (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 05 Jul 2018 21:53:26 -0400 (EDT) Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 2BB19440E6C; Thu, 5 Jul 2018 21:53:26 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org, binutils@sourceware.org Cc: Simon Marchi Subject: [pushed] darwin: Silence syscall deprecated declaration warning Date: Thu, 5 Jul 2018 21:53:20 -0400 Message-Id: <20180706015320.15705-1-simon.marchi@polymtl.ca> X-IsSubscribed: yes FYI, I pushed this patch. I considered the diagnostics.h bits obvious enough. 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. --- gdb/ChangeLog | 5 +++++ gdb/darwin-nat.c | 25 ++++++++++++++++++------- include/ChangeLog | 5 +++++ include/diagnostics.h | 6 ++++++ 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 39165f7cf4be..17146e810a37 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-07-05 Simon Marchi + + * darwin-nat.c (darwin_pthread_kill): New function. + (darwin_resume_thread): Use darwin_pthread_kill. + 2018-07-05 Tom de Vries * macroexp.c (macro_buffer) : New member function. diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 5aed285ad461..bb46cfbfcfa5 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; diff --git a/include/ChangeLog b/include/ChangeLog index de808014ac46..e7d6d6657f31 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2018-07-05 Simon Marchi + + * diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS): + Define for clang. + 2018-07-02 Maciej W. Rozycki PR tdep/8282 diff --git a/include/diagnostics.h b/include/diagnostics.h index 4a674106dc01..34fc01b85bd4 100644 --- a/include/diagnostics.h +++ b/include/diagnostics.h @@ -35,6 +35,8 @@ #if defined (__clang__) /* clang */ # define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move") +# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \ + DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations") # define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \ DIAGNOSTIC_IGNORE ("-Wdeprecated-register") # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \ @@ -56,6 +58,10 @@ # define DIAGNOSTIC_IGNORE_SELF_MOVE #endif +#ifndef DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS +# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS +#endif + #ifndef DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER # define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER #endif