Browse Source

Minimalist breakpad implementation.

Client-side implementation.

TODO: Need to automatically disable it for unit tests.

Review URL: http://codereview.chromium.org/444009

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@33681 0039d316-1c4b-4281-b951-d872f2087c98
maruel@chromium.org 15 năm trước cách đây
mục cha
commit
ada4c65e1c
5 tập tin đã thay đổi với 47 bổ sung0 xóa
  1. 39 0
      breakpad.py
  2. 2 0
      drover.py
  3. 2 0
      gcl.py
  4. 2 0
      gclient.py
  5. 2 0
      git_cl_hooks.py

+ 39 - 0
breakpad.py

@@ -0,0 +1,39 @@
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Breakpad for Python.
+
+Sends a notification when a process stops on an exception."""
+
+import atexit
+import getpass
+import urllib
+import traceback
+import sys
+
+
+def SendStack(stack, url='http://chromium-status.appspot.com/breakpad'):
+  print 'Do you want to send a crash report [y/N]? ',
+  if sys.stdin.read(1).lower() == 'y':
+    try:
+      params = {
+          'args': sys.argv,
+          'stack': stack,
+          'user': getpass.getuser(),
+      }
+      request = urllib.urlopen(url, urllib.urlencode(params))
+      print request.read()
+      request.close()
+    except IOError:
+      print('There was a failure while trying to send the stack trace. Too bad.')
+
+
+@atexit.register
+def CheckForException():
+  if 'test' in sys.modules['__main__'].__file__:
+    # Probably a unit test.
+    return
+  last_tb = getattr(sys, 'last_traceback', None)
+  if last_tb:
+    SendStack(''.join(traceback.format_tb(last_tb)))

+ 2 - 0
drover.py

@@ -9,6 +9,8 @@ import subprocess
 import sys
 import webbrowser
 
+import breakpad
+
 USAGE = """
 WARNING: Please use this tool in an empty directory
 (or at least one that you don't mind clobbering.)

+ 2 - 0
gcl.py

@@ -18,6 +18,8 @@ import tempfile
 import upload
 import urllib2
 
+import breakpad
+
 # gcl now depends on gclient.
 from scm import SVN
 import gclient_utils

+ 2 - 0
gclient.py

@@ -78,6 +78,8 @@ import sys
 import urlparse
 import urllib
 
+import breakpad
+
 import gclient_scm
 import gclient_utils
 

+ 2 - 0
git_cl_hooks.py

@@ -7,6 +7,8 @@ import re
 import subprocess
 import sys
 
+import breakpad
+
 import presubmit_support
 import scm