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