This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/15812] New: catch death by SIGKILL


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]