emaste created this revision.
emaste added a reviewer: labath.
emaste added a subscriber: lldb-commits.

https://reviews.llvm.org/D26315

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh


Index: 
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh
===================================================================
--- 
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh
+++ 
packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh
@@ -1,4 +1,30 @@
-#! /bin/bash
+#! /bin/sh
+
+linux_check_core_pattern()
+{
+    if grep -q '^|' </proc/sys/kernel/core_pattern; then
+        cat <<EOF
+Your system uses a crash report tool ($(cat /proc/sys/kernel/core_pattern)). 
Core files
+will not be generated.  Please reset /proc/sys/kernel/core_pattern (requires 
root
+privileges) to enable core generation.
+EOF
+        exit 1
+    fi
+}
+
+OS=$(uname -s)
+case "$OS" in
+FreeBSD)
+    core_pattern=$(sysctl -n kern.corefile)
+    ;;
+Linux)
+    core_pattern=$(cat /proc/sys/kernel/core_pattern)
+    ;;
+*)
+    echo "OS $OS not supported" >&2
+    exit 1
+    ;;
+esac
 
 set -e -x
 
@@ -10,13 +36,8 @@
     exit 1
 fi
 
-if grep -q '^|' </proc/sys/kernel/core_pattern; then
-    cat <<EOF
-Your system uses a crash report tool ($(cat /proc/sys/kernel/core_pattern)). 
Core files
-will not be generated.  Please reset /proc/sys/kernel/core_pattern (requires 
root
-privileges) to enable core generation.
-EOF
-    exit 1
+if [ "$OS" = Linux ]; then
+    linux_check_core_pattern
 fi
 
 ulimit -c 1000
@@ -33,7 +54,7 @@
 
 cat <<EOF
 Executable file is in a.out.
-Core file will be saved according to pattern $(cat 
/proc/sys/kernel/core_pattern).
+Core file will be saved according to pattern $core_pattern.
 EOF
 
 ulimit -s 8 # Decrease stack size to 8k => smaller core files.


Index: packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh
===================================================================
--- packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh
+++ packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh
@@ -1,4 +1,30 @@
-#! /bin/bash
+#! /bin/sh
+
+linux_check_core_pattern()
+{
+    if grep -q '^|' </proc/sys/kernel/core_pattern; then
+        cat <<EOF
+Your system uses a crash report tool ($(cat /proc/sys/kernel/core_pattern)). Core files
+will not be generated.  Please reset /proc/sys/kernel/core_pattern (requires root
+privileges) to enable core generation.
+EOF
+        exit 1
+    fi
+}
+
+OS=$(uname -s)
+case "$OS" in
+FreeBSD)
+    core_pattern=$(sysctl -n kern.corefile)
+    ;;
+Linux)
+    core_pattern=$(cat /proc/sys/kernel/core_pattern)
+    ;;
+*)
+    echo "OS $OS not supported" >&2
+    exit 1
+    ;;
+esac
 
 set -e -x
 
@@ -10,13 +36,8 @@
     exit 1
 fi
 
-if grep -q '^|' </proc/sys/kernel/core_pattern; then
-    cat <<EOF
-Your system uses a crash report tool ($(cat /proc/sys/kernel/core_pattern)). Core files
-will not be generated.  Please reset /proc/sys/kernel/core_pattern (requires root
-privileges) to enable core generation.
-EOF
-    exit 1
+if [ "$OS" = Linux ]; then
+    linux_check_core_pattern
 fi
 
 ulimit -c 1000
@@ -33,7 +54,7 @@
 
 cat <<EOF
 Executable file is in a.out.
-Core file will be saved according to pattern $(cat /proc/sys/kernel/core_pattern).
+Core file will be saved according to pattern $core_pattern.
 EOF
 
 ulimit -s 8 # Decrease stack size to 8k => smaller core files.
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to