aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2013-03-10 18:07:57 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2013-03-10 18:07:57 +0000
commit61a31a67699c3604f4e0edbd6cbc0e0e9cc772cc (patch)
tree8f31be0d42de90954be0297c04a158d4c4bdf9ef /gdb/common
parent05c56a9d39c46c42fa32adf1604432cede705528 (diff)
downloadgdb-61a31a67699c3604f4e0edbd6cbc0e0e9cc772cc.zip
gdb-61a31a67699c3604f4e0edbd6cbc0e0e9cc772cc.tar.gz
gdb-61a31a67699c3604f4e0edbd6cbc0e0e9cc772cc.tar.bz2
gdb/
* common/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Call also kill for CHILD, ignore PTRACE_KILL errors, move the inner block variable kill_status to outer block.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/linux-ptrace.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/gdb/common/linux-ptrace.c b/gdb/common/linux-ptrace.c
index e1001c6..d5ac061 100644
--- a/gdb/common/linux-ptrace.c
+++ b/gdb/common/linux-ptrace.c
@@ -74,7 +74,7 @@ linux_ptrace_test_ret_to_nx (void)
pid_t child, got_pid;
gdb_byte *return_address, *pc;
long l;
- int status;
+ int status, kill_status;
return_address = mmap (NULL, 2, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
@@ -177,32 +177,24 @@ linux_ptrace_test_ret_to_nx (void)
}
pc = (void *) (uintptr_t) l;
- if (ptrace (PTRACE_KILL, child, NULL, NULL) != 0)
+ kill (child, SIGKILL);
+ ptrace (PTRACE_KILL, child, NULL, NULL);
+
+ errno = 0;
+ got_pid = waitpid (child, &kill_status, 0);
+ if (got_pid != child)
{
- warning (_("linux_ptrace_test_ret_to_nx: Cannot PTRACE_KILL: %s"),
- strerror (errno));
+ warning (_("linux_ptrace_test_ret_to_nx: "
+ "PTRACE_KILL waitpid returned %ld: %s"),
+ (long) got_pid, strerror (errno));
return;
}
- else
+ if (!WIFSIGNALED (kill_status))
{
- int kill_status;
-
- errno = 0;
- got_pid = waitpid (child, &kill_status, 0);
- if (got_pid != child)
- {
- warning (_("linux_ptrace_test_ret_to_nx: "
- "PTRACE_KILL waitpid returned %ld: %s"),
- (long) got_pid, strerror (errno));
- return;
- }
- if (!WIFSIGNALED (kill_status))
- {
- warning (_("linux_ptrace_test_ret_to_nx: "
- "PTRACE_KILL status %d is not WIFSIGNALED!"),
- status);
- return;
- }
+ warning (_("linux_ptrace_test_ret_to_nx: "
+ "PTRACE_KILL status %d is not WIFSIGNALED!"),
+ status);
+ return;
}
/* + 1 is there as x86* stops after the 'int3' instruction. */