public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/15812] New: catch death by SIGKILL
@ 2013-08-01 16:48 palves at redhat dot com
  2013-08-01 17:45 ` [Bug gdb/15812] " tromey at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: palves at redhat dot com @ 2013-08-01 16:48 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gdb/15812] catch death by SIGKILL
  2013-08-01 16:48 [Bug gdb/15812] New: catch death by SIGKILL palves at redhat dot com
@ 2013-08-01 17:45 ` tromey at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: tromey at redhat dot com @ 2013-08-01 17:45 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-01 17:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01 16:48 [Bug gdb/15812] New: catch death by SIGKILL palves at redhat dot com
2013-08-01 17:45 ` [Bug gdb/15812] " tromey at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).