summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-12-12 00:02:05 +0000
committerEnrico Granata <egranata@apple.com>2013-12-12 00:02:05 +0000
commit2c3f14055173f49827e6b03cbf5e2eb7cffa8aec (patch)
tree3e7a4c6dcc0ccbb74f9c18cbeb5fd85ab25abff7
parent5d0fb1ea1c316333e072eaaacf29975998546357 (diff)
downloadbcm5719-llvm-2c3f14055173f49827e6b03cbf5e2eb7cffa8aec.tar.gz
bcm5719-llvm-2c3f14055173f49827e6b03cbf5e2eb7cffa8aec.zip
<rdar://problem/15640353>
Add an hook for the test suite into the OSX-only CrashReporter "App-specific info" This allows the test suite to set the crash info to the name and file location of every test as the test gets executed If the test suite crashes, the crash log will then report which test is the culprit, even when not using verbose mode This only works on OSX, and defaults to not doing anything on other platforms, but OS/platform-specific invocations can be devised by each individual platform llvm-svn: 197095
-rw-r--r--lldb/test/crashinfo.c66
-rwxr-xr-xlldb/test/crashinfo.sobin0 -> 9648 bytes
-rwxr-xr-xlldb/test/dotest.py20
3 files changed, 86 insertions, 0 deletions
diff --git a/lldb/test/crashinfo.c b/lldb/test/crashinfo.c
new file mode 100644
index 00000000000..229919258ec
--- /dev/null
+++ b/lldb/test/crashinfo.c
@@ -0,0 +1,66 @@
+/******************************************************************************
+ The LLVM Compiler Infrastructure
+
+ This file is distributed under the University of Illinois Open Source
+ License. See LICENSE.TXT for details.
+ ******************************************************************************
+
+* This C file vends a simple interface to set the Application Specific Info
+* on Mac OS X through Python. To use, compile as a dylib, import crashinfo
+* and call crashinfo.setCrashReporterDescription("hello world")
+* The testCrashReporterDescription() API is simply there to let you test that this
+* is doing what it is intended to do without having to actually cons up a crash
+*
+* WARNING: LLDB is using the prebuilt crashinfo.so rather than rebuilding this
+* from scratch each time - rebuild manually if you need to change this module
+******************************************************************************/
+
+#include <Python/Python.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+extern void *__crashreporter_info__;
+
+asm(".desc ___crashreporter_info__, 0x10");
+
+static PyObject* setCrashReporterDescription(PyObject* self, PyObject* string)
+{
+ if (__crashreporter_info__)
+ {
+ free(__crashreporter_info__);
+ __crashreporter_info__ = NULL;
+ }
+
+ if (string && PyString_Check(string))
+ {
+ Py_ssize_t size = PyString_Size(string);
+ char* data = PyString_AsString(string);
+ if (size && data)
+ {
+ __crashreporter_info__ = malloc(size);
+ memcpy(__crashreporter_info__,data,size+1);
+ return Py_True;
+ }
+ }
+ return Py_False;
+}
+
+static PyObject* testCrashReporterDescription(PyObject*self, PyObject* arg)
+{
+ int* ptr = 0;
+ *ptr = 1;
+ return Py_None;
+}
+
+static PyMethodDef crashinfo_methods[] = {
+ {"setCrashReporterDescription", setCrashReporterDescription, METH_O},
+ {"testCrashReporterDescription", testCrashReporterDescription, METH_O},
+ {NULL, NULL}
+};
+
+void initcrashinfo()
+{
+ (void) Py_InitModule("crashinfo", crashinfo_methods);
+}
+
diff --git a/lldb/test/crashinfo.so b/lldb/test/crashinfo.so
new file mode 100755
index 00000000000..b72658ba6f7
--- /dev/null
+++ b/lldb/test/crashinfo.so
Binary files differ
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py
index 54440aacdae..4e7fe0a9871 100755
--- a/lldb/test/dotest.py
+++ b/lldb/test/dotest.py
@@ -29,6 +29,7 @@ import subprocess
import sys
import textwrap
import time
+import inspect
import unittest2
if sys.version_info >= (2, 7):
@@ -376,6 +377,17 @@ def validate_categories(categories):
result.append(category)
return result
+def setCrashInfoHook_Mac(text):
+ import crashinfo
+ crashinfo.setCrashReporterDescription(text)
+
+# implement this in some suitable way for your platform, and then bind it
+# to setCrashInfoHook
+def setCrashInfoHook_NonMac(text):
+ pass
+
+setCrashInfoHook = None
+
def parseOptionsAndInitTestdirs():
"""Initialize the list of directories containing our unittest scripts.
@@ -422,6 +434,7 @@ def parseOptionsAndInitTestdirs():
global lldb_platform_name
global lldb_platform_url
global lldb_platform_working_dir
+ global setCrashInfoHook
do_help = False
@@ -535,6 +548,11 @@ def parseOptionsAndInitTestdirs():
else:
archs = [platform_machine]
+ if platform_system == 'Darwin':
+ setCrashInfoHook = setCrashInfoHook_Mac
+ else:
+ setCrashInfoHook = setCrashInfoHook_NonMac
+
if args.categoriesList:
categoriesList = set(validate_categories(args.categoriesList))
useCategories = True
@@ -1558,6 +1576,8 @@ for ia in range(len(archs) if iterArchs else 1):
def startTest(self, test):
if self.shouldSkipBecauseOfCategories(test):
self.hardMarkAsSkipped(test)
+ global setCrashInfoHook
+ setCrashInfoHook("%s at %s" % (str(test),inspect.getfile(test.__class__)))
self.counter += 1
test.test_number = self.counter
if self.showAll:
OpenPOWER on IntegriCloud