+2015-12-04 Josh Stone <jistone@redhat.com>
+
+ * target.h (struct target_ops) <arch_setup>: Rename to ...
+ (struct target_ops) <post_create_inferior>: ... this.
+ (target_arch_setup): Rename to ...
+ (target_post_create_inferior): ... this, calling post_create_inferior.
+ * server.c (start_inferior): Update target_arch_setup calls to
+ target_post_create_inferior.
+ * linux-low.c (linux_low_ptrace_options): Forward declare.
+ (linux_arch_setup): Update its comment for general use.
+ (linux_post_create_inferior): New, run arch_setup and setup ptrace.
+ (struct linux_target_ops): Use linux_post_create_inferior.
+ * lynx-low.c (struct lynx_target_ops): Update arch_setup stub comment
+ to post_create_inferior.
+ * nto-low.c (struct nto_target_ops): Likewise.
+ * spu-low.c (struct spu_target_ops): Likewise.
+ * win32-low.c (struct win32_target_ops): Likewise.
+
2015-12-03 Antoine Tremblay <antoine.tremblay@ericsson.com>
* linux-arm-low.c: Remove duplicate arch/arm.h include.
static int kill_lwp (unsigned long lwpid, int signo);
static void enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info);
static void complete_ongoing_step_over (void);
+static int linux_low_ptrace_options (int attached);
/* When the event-loop is doing a step-over, this points at the thread
being stepped. */
static CORE_ADDR get_pc (struct lwp_info *lwp);
-/* Implement the arch_setup target_ops method. */
+/* Call the target arch_setup function on the current thread. */
static void
linux_arch_setup (void)
return pid;
}
+/* Implement the post_create_inferior target_ops method. */
+
+static void
+linux_post_create_inferior (void)
+{
+ struct lwp_info *lwp = get_thread_lwp (current_thread);
+
+ linux_arch_setup ();
+
+ if (lwp->must_set_ptrace_flags)
+ {
+ struct process_info *proc = current_process ();
+ int options = linux_low_ptrace_options (proc->attached);
+
+ linux_enable_event_reporting (lwpid_of (current_thread), options);
+ lwp->must_set_ptrace_flags = 0;
+ }
+}
+
/* Attach to an inferior process. Returns 0 on success, ERRNO on
error. */
static struct target_ops linux_target_ops = {
linux_create_inferior,
- linux_arch_setup,
+ linux_post_create_inferior,
linux_attach,
linux_kill,
linux_detach,
static struct target_ops lynx_target_ops = {
lynx_create_inferior,
- NULL, /* arch_setup */
+ NULL, /* post_create_inferior */
lynx_attach,
lynx_kill,
lynx_detach,
static struct target_ops nto_target_ops = {
nto_create_inferior,
- NULL, /* arch_setup */
+ NULL, /* post_create_inferior */
nto_attach,
nto_kill,
nto_detach,
}
while (last_status.value.sig != GDB_SIGNAL_TRAP);
}
- target_arch_setup ();
+ target_post_create_inferior ();
return signal_pid;
}
(assuming success). */
last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0);
- target_arch_setup ();
+ target_post_create_inferior ();
if (last_status.kind != TARGET_WAITKIND_EXITED
&& last_status.kind != TARGET_WAITKIND_SIGNALLED)
static struct target_ops spu_target_ops = {
spu_create_inferior,
- NULL, /* arch_setup */
+ NULL, /* post_create_inferior */
spu_attach,
spu_kill,
spu_detach,
int (*create_inferior) (char *program, char **args);
- /* Architecture-specific setup. */
- void (*arch_setup) (void);
+ /* Do additional setup after a new process is created, including
+ exec-wrapper completion. */
+ void (*post_create_inferior) (void);
/* Attach to a running process.
#define create_inferior(program, args) \
(*the_target->create_inferior) (program, args)
-#define target_arch_setup() \
- do \
- { \
- if (the_target->arch_setup != NULL) \
- (*the_target->arch_setup) (); \
+#define target_post_create_inferior() \
+ do \
+ { \
+ if (the_target->post_create_inferior != NULL) \
+ (*the_target->post_create_inferior) (); \
} while (0)
#define myattach(pid) \
static struct target_ops win32_target_ops = {
win32_create_inferior,
- NULL, /* arch_setup */
+ NULL, /* post_create_inferior */
win32_attach,
win32_kill,
win32_detach,
+2015-12-04 Josh Stone <jistone@redhat.com>
+
+ * gdb.base/catch-fork-static.exp: New.
+
2015-12-03 Yao Qi <yao.qi@linaro.org>
* gdb.base/sizeof.c: Don't include stdio.h and
--- /dev/null
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# 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 <http://www.gnu.org/licenses/>.
+
+# Test that "catch fork" works on static executables.
+
+# For instance, on Linux we need PTRACE_O_TRACEFORK set before the program
+# reaches the fork. GDBserver was only setting flags when it reached the first
+# stop *after* arch_setup. In a dynamic executable there is often a swbreak in
+# ld.so probes before reaching main, and ptrace flags were set then. But a
+# static executable would just keep running and never catch the fork.
+
+if { [is_remote target] || ![isnative] } then {
+ continue
+}
+
+# Until "catch fork" is implemented on other targets...
+#
+if { ![istarget "hppa*-hp-hpux*"] && ![istarget "*-*-linux*"]
+ && ![istarget "*-*-openbsd*"] } then {
+ continue
+}
+
+# Reusing foll-fork.c since it's a simple forking program.
+standard_testfile foll-fork.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile \
+ {additional_flags=-static}] } {
+ return -1
+}
+
+gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)"
+
+gdb_run_cmd
+gdb_test "" \
+ "Catchpoint \[0-9\]* \\(forked process \[0-9\]*\\),.*" \
+ "run to fork"