From patchwork Wed Jan 31 13:53:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 25711 Received: (qmail 1256 invoked by alias); 31 Jan 2018 13:53:31 -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 1242 invoked by uid 89); 31 Jan 2018 13:53:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jan 2018 13:53:24 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A84F4F1B2; Wed, 31 Jan 2018 13:53:23 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B1B9620BA; Wed, 31 Jan 2018 13:53:22 +0000 (UTC) Subject: [pushed] gdb: Fix remote-sim/MinGW/Darwin builds (Re: [PATCH] Per-inferior target_terminal state, fix PR gdb/13211, more) To: Christophe Lyon References: <1512416651-6970-1-git-send-email-palves@redhat.com> <447fdbde-e596-1153-85c7-251a5a767499@redhat.com> <34130916-a57c-48be-60a7-c87ac2f02137@redhat.com> Cc: GDB Patches From: Pedro Alves Message-ID: <326e6e81-347b-c804-a167-83a6f46feacc@redhat.com> Date: Wed, 31 Jan 2018 13:53:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <34130916-a57c-48be-60a7-c87ac2f02137@redhat.com> On 01/31/2018 12:32 PM, Pedro Alves wrote: > On 01/31/2018 09:27 AM, Christophe Lyon wrote: >> This caused GDB to fail to build for arm-none-eabi targets >> ../../../gdb/remote-sim.c: In function 'void init_gdbsim_ops()': >> ../../../gdb/remote-sim.c:1342:27: error: invalid conversion from >> 'void (*)(target_ops*, ptid_t)' to 'void (*)(target_ops*)' >> [-fpermissive] >> gdbsim_ops.to_interrupt = gdbsim_interrupt; >> ^ >> make[2]: *** [remote-sim.o] Error 1 >> make[2]: *** Waiting for unfinished jobs.... >> ../../../gdb/cli/cli-cmds.c: In function 'void complete_command(const >> char*, int)': >> ../../../gdb/cli/cli-cmds.c:304:48: warning: 'word' may be used >> uninitialized in this function [-Wmaybe-uninitialized] >> get_max_completions_reached_message ()); >> ^ >> ../../../gdb/cli/cli-cmds.c:277:71: warning: 'tracker' may be used >> uninitialized in this function [-Wmaybe-uninitialized] >> = tracker->build_completion_result (word, word - arg, strlen (arg)); >> >> (building in an Ubuntu Trusty container) >> >> Can you fix it ? > > Sorry about that. Don't know how I missed this to_interrupt > implementation. And windows-nat.c too. I'll take a look. This should fix it. I've pushed it. From f6cfb42730ed37bfb32cb27ef627df930f437f08 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 31 Jan 2018 13:45:06 +0000 Subject: [PATCH] gdb: Fix remote-sim/MinGW/Darwin builds The recent commit e671cd59 ("Per-inferior target_terminal state, fix PR gdb/13211, more") missed adjusting a few targets to the new target_ops->to_interrupt interface, breaking the build for those targets. This fixes it. Note: remote-sim doesn't really support async execution, so I don't think gdbsim_interrupt is ever reached via target_interrupt. (It is reached via gdbsim_cntrl_c though). The inflow.c changes are a bit ugly, but they're just doing what other parts of the file already do to handle the same missing functions. Targets that don't have 'kill', like mingw have their own target_ops->to_interrupt implementation, so it's fine to make child_interrupt be a nop. gdb/ChangeLog: 2018-01-31 Pedro Alves * darwin-nat.c (darwin_interrupt): Remove ptid_t parameter. * inflow.c (child_terminal_save_inferior): Wrap reference to tcgetpgrp in HAVE_TERMIOS_H. (child_interrupt, child_pass_ctrlc): Wrap references to signal in _WIN32. * remote-sim.c (gdbsim_interrupt): Remove ptid_t parameter and always iterate over all inferiors. (gdbsim_cntrl_c): Adjust. * windows-nat.c (windows_interrupt): Remove 'ptid_t' parameter. --- gdb/darwin-nat.c | 4 ++-- gdb/inflow.c | 6 ++++++ gdb/remote-sim.c | 23 ++++------------------- gdb/windows-nat.c | 4 ++-- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 7a862cdeae4..e98ac6c5486 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -83,7 +83,7 @@ #define PTRACE(CMD, PID, ADDR, SIG) \ darwin_ptrace(#CMD, CMD, (PID), (ADDR), (SIG)) -static void darwin_interrupt (struct target_ops *self, ptid_t); +static void darwin_interrupt (struct target_ops *self); static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal signal); @@ -1342,7 +1342,7 @@ darwin_wait_to (struct target_ops *ops, } static void -darwin_interrupt (struct target_ops *self, ptid_t t) +darwin_interrupt (struct target_ops *self) { struct inferior *inf = current_inferior (); darwin_inferior *priv = get_darwin_inferior (inf); diff --git a/gdb/inflow.c b/gdb/inflow.c index 7c5e9047030..d971543a281 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -469,7 +469,9 @@ child_terminal_save_inferior (struct target_ops *self) xfree (tinfo->ttystate); tinfo->ttystate = serial_get_tty_state (stdin_serial); +#ifdef HAVE_TERMIOS_H tinfo->process_group = tcgetpgrp (0); +#endif #ifdef F_GETFL tinfo->tflags = fcntl (0, F_GETFL, 0); @@ -563,7 +565,9 @@ child_interrupt (struct target_ops *self) either Ctrl-C or with kill(3) with negative PID) sends a SIGINT to each process in the process group, and we may not be debugging all processes in the process group. */ +#ifndef _WIN32 kill (resumed->inf->pid, SIGINT); +#endif } } @@ -606,7 +610,9 @@ child_pass_ctrlc (struct target_ops *self) { gdb_assert (inf->pid != 0); +#ifndef _WIN32 kill (inf->pid, SIGINT); +#endif return; } } diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index aed7a34b42c..2f8fb68634e 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -86,7 +86,7 @@ static void gdbsim_files_info (struct target_ops *target); static void gdbsim_mourn_inferior (struct target_ops *target); -static void gdbsim_interrupt (struct target_ops *self, ptid_t ptid); +static void gdbsim_interrupt (struct target_ops *self); void simulator_command (char *args, int from_tty); @@ -920,24 +920,9 @@ gdbsim_interrupt_inferior (struct inferior *inf, void *arg) } static void -gdbsim_interrupt (struct target_ops *self, ptid_t ptid) +gdbsim_interrupt (struct target_ops *self) { - struct sim_inferior_data *sim_data; - - if (ptid_equal (ptid, minus_one_ptid)) - { - iterate_over_inferiors (gdbsim_interrupt_inferior, NULL); - } - else - { - struct inferior *inf = find_inferior_ptid (ptid); - - if (inf == NULL) - error (_("Can't stop pid %d. No inferior found."), - ptid_get_pid (ptid)); - - gdbsim_interrupt_inferior (inf, NULL); - } + iterate_over_inferiors (gdbsim_interrupt_inferior, NULL); } /* GDB version of os_poll_quit callback. @@ -961,7 +946,7 @@ gdb_os_poll_quit (host_callback *p) static void gdbsim_cntrl_c (int signo) { - gdbsim_interrupt (NULL, minus_one_ptid); + gdbsim_interrupt (NULL); } static ptid_t diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 5fb143e00db..f849f1f3221 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -201,7 +201,7 @@ typedef enum #define DEBUG_MEM(x) if (debug_memory) printf_unfiltered x #define DEBUG_EXCEPT(x) if (debug_exceptions) printf_unfiltered x -static void windows_interrupt (struct target_ops *self, ptid_t); +static void windows_interrupt (struct target_ops *self); static int windows_thread_alive (struct target_ops *, ptid_t); static void windows_kill_inferior (struct target_ops *); @@ -2777,7 +2777,7 @@ windows_mourn_inferior (struct target_ops *ops) ^C on the controlling terminal. */ static void -windows_interrupt (struct target_ops *self, ptid_t ptid) +windows_interrupt (struct target_ops *self) { DEBUG_EVENTS (("gdb: GenerateConsoleCtrlEvent (CTRLC_EVENT, 0)\n")); CHECK (GenerateConsoleCtrlEvent (CTRL_C_EVENT, current_event.dwProcessId));