Blame SOURCES/gdb-rhbz1518243-gcore-VM_DONTDUMP-3of5.patch

5144ac
commit cd93789b89f55355d3eeda6c31ed7bd0ed318acd
5144ac
Author: Sergio Lopez <slp@redhat.com>
5144ac
Date:   Mon Dec 4 09:17:14 2017 +0100
5144ac
5144ac
    Implement "-a" command line option for gcore
5144ac
    
5144ac
    With the new "-a" command line option, the user may request gcore to
5144ac
    actually dump all present memory mappings. The actual effect of this
5144ac
    argument is OS dependent.
5144ac
    
5144ac
    On GNU/Linux, it will disable use-coredump-filter and enable
5144ac
    dump-excluded-mappings.
5144ac
    
5144ac
    gdb/ChangeLog:
5144ac
    2017-11-29  Sergio Lopez  <slp@redhat.com>
5144ac
    
5144ac
            * gcore.in: Add "-a" command line option for instructing gdb to
5144ac
            dump all memory mappings (OS dependent).
5144ac
5144ac
Index: gdb-7.6.1/gdb/gcore.in
5144ac
===================================================================
5144ac
--- gdb-7.6.1.orig/gdb/gcore.in	2017-12-06 20:57:13.444335680 +0100
5144ac
+++ gdb-7.6.1/gdb/gcore.in	2017-12-06 20:57:20.437380926 +0100
5144ac
@@ -20,27 +20,39 @@
5144ac
 # It starts up gdb, attaches to the given PID and invokes the gcore command.
5144ac
 #
5144ac
 
5144ac
-if [ "$#" -eq "0" ]
5144ac
-then
5144ac
-    echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
5144ac
-    exit 2
5144ac
-fi
5144ac
-
5144ac
 # Need to check for -o option, but set default basename to "core".
5144ac
 name=core
5144ac
 
5144ac
-if [ "$1" = "-o" ]
5144ac
-then
5144ac
-    if [ "$#" -lt "3" ]
5144ac
-    then
5144ac
-	# Not enough arguments.
5144ac
-	echo "usage:  @GCORE_TRANSFORM_NAME@ [-o filename] pid"
5144ac
-	exit 2
5144ac
-    fi
5144ac
-    name=$2
5144ac
+# When the -a option is present, this may hold additional commands
5144ac
+# to ensure gdb dumps all mappings (OS dependent).
5144ac
+dump_all_cmds=()
5144ac
+
5144ac
+while getopts :ao: opt; do
5144ac
+    case $opt in
5144ac
+        a)
5144ac
+            case $OSTYPE in
5144ac
+                linux*)
5144ac
+                    dump_all_cmds=("-ex" "set use-coredump-filter off")
5144ac
+                    dump_all_cmds+=("-ex" "set dump-excluded-mappings on")
5144ac
+                    ;;
5144ac
+            esac
5144ac
+            ;;
5144ac
+        o)
5144ac
+            name=$OPTARG
5144ac
+            ;;
5144ac
+        *)
5144ac
+            echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o filename] pid"
5144ac
+            exit 2
5144ac
+            ;;
5144ac
+    esac
5144ac
+done
5144ac
+
5144ac
+shift $((OPTIND-1))
5144ac
 
5144ac
-    # Shift over to start of pid list
5144ac
-    shift; shift
5144ac
+if [ "$#" -eq "0" ]
5144ac
+then
5144ac
+    echo "usage:  @GCORE_TRANSFORM_NAME@ [-a] [-o filename] pid"
5144ac
+    exit 2
5144ac
 fi
5144ac
 
5144ac
 # Initialise return code.
5144ac
@@ -53,6 +65,7 @@
5144ac
 	# available but not accessible as GDB would get stopped on SIGTTIN.
5144ac
 	@GDB_TRANSFORM_NAME@ 
5144ac
 	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
5144ac
+	    "${dump_all_cmds[@]}" \
5144ac
 	    -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
5144ac
 
5144ac
 	if [ -r $name.$pid ] ; then