summaryrefslogtreecommitdiff
path: root/system/gdb/stopcode-lock.patch
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-02-18 15:56:31 +0000
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-02-18 15:56:31 +0000
commitbb886cdf194314220ef69427ee63e46184ad4b39 (patch)
treee87e859f566265665b3f44b742d78ffd748c5fd7 /system/gdb/stopcode-lock.patch
parent0e3e59ad2dc03b679a70bf7e1dd5833b3afc8d75 (diff)
downloadpackages-bb886cdf194314220ef69427ee63e46184ad4b39.tar.gz
packages-bb886cdf194314220ef69427ee63e46184ad4b39.tar.bz2
packages-bb886cdf194314220ef69427ee63e46184ad4b39.tar.xz
packages-bb886cdf194314220ef69427ee63e46184ad4b39.zip
system/gdb: fix lock on target fork
Diffstat (limited to 'system/gdb/stopcode-lock.patch')
-rw-r--r--system/gdb/stopcode-lock.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/system/gdb/stopcode-lock.patch b/system/gdb/stopcode-lock.patch
new file mode 100644
index 000000000..6a4e3d855
--- /dev/null
+++ b/system/gdb/stopcode-lock.patch
@@ -0,0 +1,75 @@
+From: Andrew Burgess <andrew.burgess@embecosm.com>
+Date: Tue, 3 Jul 2018 18:02:48 +0000 (+0100)
+Subject: gdb: Avoid using W_STOPCODE(0) as this is ambiguous on MIPS
+X-Git-Tag: users/ARM/embedded-binutils-master-2018q4~1172
+X-Git-Url: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff_plain;h=953473375500a809fbb3eca3efa4dbb670c3a32f
+
+gdb: Avoid using W_STOPCODE(0) as this is ambiguous on MIPS
+
+The MIPS target supports 127 signals, and this can create an ambiguity
+in process wait statuses. A status value of 0x007f could potentially
+indicate a process that has exited with signal 127, or a process that
+has stopped with signal 0.
+
+In uClibc-ng the interpretation of 0x007f is that the process has
+exited with signal 127 rather than stopped with signal 0, and so,
+WIFSTOPPED (W_STOPCODE (0)) will be false rather than true as it would
+be on most other platforms.
+
+Given that it's pretty easy to avoid using W_STOPCODE (0), lets do that.
+
+gdb/ChangeLog:
+
+ * linux-nat.c (linux_nat_target::follow_fork): Avoid using
+ 'W_STOPCODE (0)' as this could be ambiguous.
+---
+
+diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
+index 86d3dfd..d2c88ad 100644
+--- a/gdb/linux-nat.c
++++ b/gdb/linux-nat.c
+@@ -445,7 +445,6 @@ linux_nat_target::follow_fork (int follow_child, int detach_fork)
+ if (!follow_child)
+ {
+ struct lwp_info *child_lp = NULL;
+- int status = W_STOPCODE (0);
+ int has_vforked;
+ ptid_t parent_ptid, child_ptid;
+ int parent_pid, child_pid;
+@@ -465,6 +464,8 @@ linux_nat_target::follow_fork (int follow_child, int detach_fork)
+ /* Detach new forked process? */
+ if (detach_fork)
+ {
++ int child_stop_signal = 0;
++ bool detach_child = true;
+ struct cleanup *old_chain = make_cleanup (delete_lwp_cleanup,
+ child_lp);
+
+@@ -484,18 +485,24 @@ linux_nat_target::follow_fork (int follow_child, int detach_fork)
+ if (!gdbarch_software_single_step_p (target_thread_architecture
+ (parent_ptid)))
+ {
++ int status;
++
+ linux_disable_event_reporting (child_pid);
+ if (ptrace (PTRACE_SINGLESTEP, child_pid, 0, 0) < 0)
+ perror_with_name (_("Couldn't do single step"));
+ if (my_waitpid (child_pid, &status, 0) < 0)
+ perror_with_name (_("Couldn't wait vfork process"));
++ else
++ {
++ detach_child = WIFSTOPPED (status);
++ child_stop_signal = WSTOPSIG (status);
++ }
+ }
+
+- if (WIFSTOPPED (status))
++ if (detach_child)
+ {
+- int signo;
++ int signo = child_stop_signal;
+
+- signo = WSTOPSIG (status);
+ if (signo != 0
+ && !signal_pass_state (gdb_signal_from_host (signo)))
+ signo = 0;