From patchwork Tue Oct 1 18:07:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34767 Received: (qmail 29360 invoked by alias); 1 Oct 2019 18:07:32 -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 29350 invoked by uid 89); 1 Oct 2019 18:07:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=obs, OBS X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2019 18:07:29 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D995A117FB0; Tue, 1 Oct 2019 14:07:27 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MsFvFSJlUchL; Tue, 1 Oct 2019 14:07:27 -0400 (EDT) Received: from murgatroyd.Home (75-166-72-156.hlrn.qwest.net [75.166.72.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 843E9117ABD; Tue, 1 Oct 2019 14:07:27 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2] Fix type of startup_with_shell in gdbserver Date: Tue, 1 Oct 2019 12:07:22 -0600 Message-Id: <20191001180722.14143-1-tromey@adacore.com> MIME-Version: 1.0 startup_with_shell was changed to be of "bool" type, but I noticed that the definition in gdbserver disagreed. This disagreement caused some regressions on a big-endian machine. This patch removes the redundant declaration and definition of startup_with_shell and ensures that such clashes will be diagnosed. This moves the declaration to common-inferior.h, and introduces a new common-inferior.c, as suggested by Pedro. gdb/ChangeLog 2019-10-01 Tom Tromey * Makefile.in (COMMON_SFILES): Add common-inferior.c. * gdbsupport/common-inferior.c: New file. * infcmd.c (startup_with_shell): Don't define. * nat/fork-inferior.h (startup_with_shell): Don't declare. * gdbsupport/common-inferior.h (startup_with_shell): Declare. * inferior.h (startup_with_shell): Don't declare. gdb/gdbserver/ChangeLog 2019-10-01 Tom Tromey * Makefile.in (SFILES): Add common-inferior.c. (OBS): Add common-inferior.o. * server.c (startup_with_shell): Don't define. --- gdb/ChangeLog | 9 +++++++++ gdb/Makefile.in | 1 + gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/Makefile.in | 2 ++ gdb/gdbserver/server.c | 6 ------ gdb/gdbsupport/common-inferior.c | 26 ++++++++++++++++++++++++++ gdb/gdbsupport/common-inferior.h | 20 ++++++++++++++++++++ gdb/infcmd.c | 4 ---- gdb/inferior.h | 19 ------------------- gdb/nat/fork-inferior.h | 20 -------------------- 10 files changed, 64 insertions(+), 49 deletions(-) create mode 100644 gdb/gdbsupport/common-inferior.c diff --git a/gdb/Makefile.in b/gdb/Makefile.in index d6282636752..81bed9085ac 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -953,6 +953,7 @@ COMMON_SFILES = \ gdbsupport/cleanups.c \ gdbsupport/common-debug.c \ gdbsupport/common-exceptions.c \ + gdbsupport/common-inferior.c \ gdbsupport/common-regcache.c \ gdbsupport/common-utils.c \ gdbsupport/errors.c \ diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index ca0a4cbd10f..d79424b5ac3 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -203,6 +203,7 @@ SFILES = \ $(srcdir)/gdbsupport/cleanups.c \ $(srcdir)/gdbsupport/common-debug.c \ $(srcdir)/gdbsupport/common-exceptions.c \ + $(srcdir)/gdbsupport/common-inferior.c \ $(srcdir)/gdbsupport/common-regcache.c \ $(srcdir)/gdbsupport/common-utils.c \ $(srcdir)/gdbsupport/errors.c \ @@ -248,6 +249,7 @@ OBS = \ gdbsupport/cleanups.o \ gdbsupport/common-debug.o \ gdbsupport/common-exceptions.o \ + gdbsupport/common-inferior.o \ gdbsupport/job-control.o \ gdbsupport/common-regcache.o \ gdbsupport/common-utils.o \ diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 67e8e3e54de..8ee551828dc 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -67,12 +67,6 @@ char *current_directory; static gdb_environ our_environ; -/* Start the inferior using a shell. */ - -/* We always try to start the inferior using a shell. */ - -int startup_with_shell = 1; - int server_waiting; static int extended_protocol; diff --git a/gdb/gdbsupport/common-inferior.c b/gdb/gdbsupport/common-inferior.c new file mode 100644 index 00000000000..3a7c873f1e6 --- /dev/null +++ b/gdb/gdbsupport/common-inferior.c @@ -0,0 +1,26 @@ +/* Functions to deal with the inferior being executed on GDB or + GDBserver. + + Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "gdbsupport/common-defs.h" +#include "gdbsupport/common-inferior.h" + +/* See common-inferior.h. */ + +bool startup_with_shell = true; diff --git a/gdb/gdbsupport/common-inferior.h b/gdb/gdbsupport/common-inferior.h index 72e4bd9eac3..77d4ad93d35 100644 --- a/gdb/gdbsupport/common-inferior.h +++ b/gdb/gdbsupport/common-inferior.h @@ -38,4 +38,24 @@ extern const char *get_inferior_cwd (); the directory. */ extern void set_inferior_cwd (const char *cwd); +/* Whether to start up the debuggee under a shell. + + If startup-with-shell is set, GDB's "run" will attempt to start up + the debuggee under a shell. This also happens when using GDBserver + under extended remote mode. + + This is in order for argument-expansion to occur. E.g., + + (gdb) run * + + The "*" gets expanded by the shell into a list of files. + + While this is a nice feature, it may be handy to bypass the shell + in some cases. To disable this feature, do "set startup-with-shell + false". + + The catch-exec traps expected during start-up will be one more if + the target is started up with a shell. */ +extern bool startup_with_shell; + #endif /* COMMON_COMMON_INFERIOR_H */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index dc82ef043fe..4d42f75b63a 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -103,10 +103,6 @@ enum stop_stack_kind stop_stack_dummy; int stopped_by_random_signal; -/* See inferior.h. */ - -bool startup_with_shell = true; - /* Accessor routines. */ diff --git a/gdb/inferior.h b/gdb/inferior.h index 3a64a7cfeae..43f0417e629 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -227,25 +227,6 @@ extern struct value *get_return_value (struct value *function, extern void prepare_execution_command (struct target_ops *target, int background); -/* Whether to start up the debuggee under a shell. - - If startup-with-shell is set, GDB's "run" will attempt to start up - the debuggee under a shell. - - This is in order for argument-expansion to occur. E.g., - - (gdb) run * - - The "*" gets expanded by the shell into a list of files. - - While this is a nice feature, it may be handy to bypass the shell - in some cases. To disable this feature, do "set startup-with-shell - false". - - The catch-exec traps expected during start-up will be one more if - the target is started up with a shell. */ -extern bool startup_with_shell; - /* Nonzero if stopped due to completion of a stack dummy routine. */ extern enum stop_stack_kind stop_stack_dummy; diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h index 065496c3827..0a76ff82d31 100644 --- a/gdb/nat/fork-inferior.h +++ b/gdb/nat/fork-inferior.h @@ -54,26 +54,6 @@ extern ptid_t startup_inferior (pid_t pid, int ntraps, struct target_waitstatus *mystatus, ptid_t *myptid); -/* Whether to start up the debuggee under a shell. - - If startup-with-shell is set, GDB's "run" will attempt to start up - the debuggee under a shell. This also happens when using GDBserver - under extended remote mode. - - This is in order for argument-expansion to occur. E.g., - - (gdb) run * - - The "*" gets expanded by the shell into a list of files. - - While this is a nice feature, it may be handy to bypass the shell - in some cases. To disable this feature, do "set startup-with-shell - false". - - The catch-exec traps expected during start-up will be one more if - the target is started up with a shell. */ -extern bool startup_with_shell; - /* Perform any necessary tasks before a fork/vfork takes place. ARGS is a string containing all the arguments received by the inferior. This function is mainly used by fork_inferior. */