Discussion:
[Bug gdb/15812] New: catch death by SIGKILL
palves at redhat dot com
2013-08-01 16:48:15 UTC
Permalink
http://sourceware.org/bugzilla/show_bug.cgi?id=15812

Bug ID: 15812
Summary: catch death by SIGKILL
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: palves at redhat dot com

Normally on can't catch SIGKILL, but with PTRACE_O_TRACEEXIT we can get an
event before the process is killed by the kernel. This hack shows it
triggering:

---

gdb/linux-nat.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 45a6e5f..87aeacb 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -580,6 +580,8 @@ linux_enable_event_reporting (ptid_t ptid)
if (linux_supports_tracevforkdone (pid))
current_ptrace_options |= PTRACE_O_TRACEVFORKDONE;

+ current_ptrace_options |= PTRACE_O_TRACEEXIT;
+
/* Do not enable PTRACE_O_TRACEEXIT until GDB is more prepared to support
read-only process state. */

@@ -2493,6 +2495,13 @@ linux_handle_extended_wait (struct lwp_info *lp, int
status,
return 1;
}

+ if (event == PTRACE_EVENT_EXIT)
+ {
+ ourstatus->kind = TARGET_WAITKIND_STOPPED;
+ ourstatus->value.sig = GDB_SIGNAL_TRAP;
+ return 0;
+ }
+
internal_error (__FILE__, __LINE__,
_("unknown ptrace event %d"), event);
}

-----------------------------


<shell 1:>
$ gdb sleep 1000
$ run
...

<shell 2:>
$ kill -SIGKILL `pidof sleep`


<shell 1:>
Program received signal SIGTRAP, Trace/breakpoint trap.
0x000000323d4ba6d0 in __nanosleep_nocancel () at
../sysdeps/unix/syscall-template.S:82
82 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) c
Continuing.

Program terminated with signal SIGKILL, Killed.
The program no longer exists.
(gdb) q

Sounds like we do have a use case for "catch exit" where "catch syscall"
wouldn't work.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at redhat dot com
2013-08-01 17:45:42 UTC
Permalink
http://sourceware.org/bugzilla/show_bug.cgi?id=15812

Tom Tromey <tromey at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at redhat dot com

--- Comment #1 from Tom Tromey <tromey at redhat dot com> ---
I've pushed my current "catch exit" branch to archer.git tromey/catch-exit.

IIRC, it works ok for native, though I haven't tried it recently. I
never finished the remote bits. There are also some lingering FIXMEs
and the like. The README.archer describes the current state.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-15 19:30:23 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=15812

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
This branch is on my github now in case someone wants
to resurrect it.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...