File: enhanced-debugging.patch

package info (click to toggle)
tbb 2020.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,844 kB
  • sloc: cpp: 142,989; ansic: 11,007; makefile: 1,367; python: 860; asm: 517; sh: 406; javascript: 215; lisp: 198; objc: 176; pascal: 65
file content (57 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Author: Steve Capper
Last-Update: 2017-07-29 13:26:08 +0100
Description: Enhance debugging

--- /dev/null
+++ b/build/gdb_shell.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Run some tests through gdb, we rely on a hack to detect whether or
+# or not the run completed successfully. $_exitcode will be set if the
+# test finishes without breaking.
+#
+# If the test breaks, we dump a full backtrace. Then return with an
+# error to ensure that the build stops.
+
+programname=$1
+shift
+args=$@
+
+$programname $args
+rc=$?
+if [ "$rc" -eq "0" ]; then
+    exit 0
+fi
+
+echo "Unit test failed: rc=$rc, attempting to re-run with gdb and post-mortem."
+
+temp_file=$(mktemp)
+
+cat >$temp_file <<EOF
+set pagination off
+set \$_exitcode=3142
+r $args
+if \$_exitcode==3142
+    bt full
+    info proc mappings
+    quit -1
+end
+quit
+EOF
+
+gdb $programname -x $temp_file
+rc=$?
+rm $temp_file
+exit $rc
--- a/build/Makefile.tbbmalloc
+++ b/build/Makefile.tbbmalloc
@@ -39,6 +39,8 @@
 ORIG_INCLUDES:=$(INCLUDES)
 ORIG_LINK_MALLOC.LIB:=$(LINK_MALLOC.LIB)
 
+run_cmd = sh ../gdb_shell.sh
+
 #------------------------------------------------------
 # Define rules for making the TBBMalloc shared library.
 #------------------------------------------------------