Package: gdb
Version: 8.1-4
Severity: normal
Tags: patch

Hello:

Current man page says "write core file to filename instead of
core.pid" but the real outcome is that dump is written to
filename.pid. Probably because it's not just a single PID, but a list
of PIDs, which neither man page nor -h talk about.

While checking what was going on, I found -a is not documented in man
page, and script has not comment at all about what it really does
(options are found in 10.19 of info docs, it toggles two defaults,
Linux only).

Suggestions:

- change man page and -h output to say "pid[s]".

- support single PID with exact filename (no .pid extension). If you
  can get a list of PIDs, you can also probably do the loop, so the
  feature isn't so helpful but more importantly it disallows things
  like '-o >( gzip - > "path/${PID}.gz" )' (on the fly compression) or
  '-o "$T"' (a safe T created by tempfile(1)).

- fix man page for -o "write core file to filename if one PID, or
  filename.pid if multiple PIDs, instead of default core.pid".

- fix man page for -a (point to info? small text explaining?).

See patch for the script changes.

Thanks,
GSR.
 

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.17.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages gdb depends on:
ii  libbabeltrace1  1.5.5-1
ii  libc6           2.27-5
ii  libexpat1       2.2.1-1
ii  libipt1         1.5-1
ii  liblzma5        5.2.2-1.3
ii  libncursesw6    6.1+20180210-2
ii  libpython3.6    3.6.5-9
ii  libreadline7    7.0-1
ii  libtinfo6       6.1+20180210-2
ii  zlib1g          1:1.2.11.dfsg-1

Versions of packages gdb recommends:
pn  libc-dbg  <none>

Versions of packages gdb suggests:
ii  gdb-doc    8.1-1
pn  gdbserver  <none>

-- no debconf information
--- bin/gcore	2018-07-26 00:49:09.671883982 +0200
+++ /usr/bin/gcore	2018-07-23 04:55:10.000000000 +0200
@@ -41,7 +41,7 @@
             name=$OPTARG
             ;;
         *)
-            echo "usage:  gcore [-a] [-o filename] pid[s]"
+            echo "usage:  gcore [-a] [-o filename] pid"
             exit 2
             ;;
     esac
@@ -51,7 +51,7 @@
 
 if [ "$#" -eq "0" ]
 then
-    echo "usage:  gcore [-a] [-o filename] pid[s]"
+    echo "usage:  gcore [-a] [-o filename] pid"
     exit 2
 fi
 
@@ -95,24 +95,17 @@
 # Loop through pids
 for pid in "$@"
 do
-	# If single dump, allow total control of output file with -o
-	if [ "$#" -eq 1 -a "$name" != "core" ] ; then
-	    path="$name"
-	else
-	    path="$name.$pid"
-	fi
-
 	# `</dev/null' to avoid touching interactive terminal if it is
 	# available but not accessible as GDB would get stopped on SIGTTIN.
 	"$binary_path/gdb" </dev/null --nx --batch \
 	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
 	    "${dump_all_cmds[@]}" \
-	    -ex "attach $pid" -ex "gcore $path" -ex detach -ex quit
+	    -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit
 
-	if [ -r "$path" ] ; then
+	if [ -r "$name.$pid" ] ; then
 	    rc=0
 	else
-	    echo "gcore: failed to create $path"
+	    echo "gcore: failed to create $name.$pid"
 	    rc=1
 	    break
 	fi

Reply via email to