* [PATCH] find-debuginfo.sh: Add --help, --version and man page.
@ 2021-04-29 22:46 Mark Wielaard
2021-04-29 23:06 ` Dmitry V. Levin
0 siblings, 1 reply; 5+ messages in thread
From: Mark Wielaard @ 2021-04-29 22:46 UTC (permalink / raw)
To: debugedit; +Cc: Mark Wielaard
Add a --version and --help option to find-debuginfo.sh and use that to
generate a manual page.
* .gitignore: Add find-debuginfo.sh.1
* Makefile.am (dist_man_MANS): Add find-debuginfo.sh.1
(find-debuginfo.sh.1): New make rule.
* scripts/find-debuginfo.sh (help): New function.
Handle --version and --help.
https://sourceware.org/bugzilla/show_bug.cgi?id=27641
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
.gitignore | 2 +
Makefile.am | 7 +-
scripts/find-debuginfo.sh | 157 ++++++++++++++++++++++----------------
3 files changed, 99 insertions(+), 67 deletions(-)
diff --git a/.gitignore b/.gitignore
index d41ec64..3e81e87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,8 @@ debugedit.1
sepdebugcrcfix
sepdebugcrcfix.1
+find-debuginfo.sh.1
+
atconfig
atlocal
package.m4
diff --git a/Makefile.am b/Makefile.am
index de7c51d..b26d238 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,7 +39,7 @@ sepdebugcrcfix_CFLAGS = @LIBELF_CFLAGS@ $(AM_CFLAGS)
sepdebugcrcfix_LDADD = @LIBELF_LIBS@
# Manual pages are generated for dist
-dist_man_MANS = debugedit.1 sepdebugcrcfix.1
+dist_man_MANS = debugedit.1 sepdebugcrcfix.1 find-debuginfo.sh.1
debugedit.1: tools/debugedit.c $(top_srcdir)/configure.ac
$(MAKE) $(AM_MAKEFLAGS) debugedit$(EXEEXT)
@@ -53,6 +53,11 @@ sepdebugcrcfix.1: tools/sepdebugcrcfix.c $(top_srcdir)/configure.ac
--name='fixes CRC for separate .debug files' \
./sepdebugcrcfix$(EXEEXT)
+find-debuginfo.sh.1: scripts/find-debuginfo.sh $(top_srcdir)/configure.ac
+ $(HELP2MAN) -N --output=$@ \
+ --name='finds debuginfo and processes it' \
+ $(top_srcdir)/scripts/find-debuginfo.sh
+
noinst_HEADERS= tools/ansidecl.h \
tools/hashtab.h \
tools/md5.h \
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 3d736e0..ebad647 100755
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -17,72 +17,83 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
-# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
-# [--keep-section SECTION] [--remove-section SECTION]
-# [--g-libs]
-# [-j N] [--jobs N]
-# [-o debugfiles.list]
-# [-S debugsourcefiles.list]
-# [--run-dwz] [--dwz-low-mem-die-limit N]
-# [--dwz-max-die-limit N]
-# [--dwz-single-file-mode]
-# [--build-id-seed SEED]
-# [--unique-debug-suffix SUFFIX]
-# [--unique-debug-src-base BASE]
-# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
-# [builddir]
-#
-# The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
-# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
-# Options -g and --g-libs are mutually exclusive.
-# The -r flag says to use eu-strip --reloc-debug-sections.
-# Use --keep-section SECTION or --remove-section SECTION to explicitly
-# keep a (non-allocated) section in the main executable or explicitly
-# remove it into the .debug file. SECTION is an extended wildcard pattern.
-# Both options can be given more than once.
-#
-# The --strict-build-id flag says to exit with failure status if
-# any ELF binary processed fails to contain a build-id note.
-# The -m flag says to include a .gnu_debugdata section in the main binary.
-# The -i flag says to include a .gdb_index section in the .debug file.
-# The -n flag says to not recompute the build-id.
-#
-# The -j, --jobs N option will spawn N processes to do the debuginfo
-# extraction in parallel.
-#
-# A single -o switch before any -l or -p switches simply renames
-# the primary output file from debugfiles.list to something else.
-# A -o switch that follows a -p switch or some -l switches produces
-# an additional output file with the debuginfo for the files in
-# the -l filelist file, or whose names match the -p pattern.
-# The -p argument is an grep -E -style regexp matching the a file name,
-# and must not use anchors (^ or $).
-#
-# The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
-# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
-# provide detailed limits. See dwz(1) -l and -L option for details.
-# Use --dwz-single-file-mode to disable multi-file mode, see dwz(1) -m
-# for more details.
-
-#
-# If --build-id-seed SEED is given then debugedit is called to
-# update the build-ids it finds adding the SEED as seed to recalculate
-# the build-id hash. This makes sure the build-ids in the ELF files
-# are unique between versions and releases of the same package.
-# (Use --build-id-seed "%{VERSION}-%{RELEASE}".)
-#
-# If --unique-debug-suffix SUFFIX is given then the debug files created
-# for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug
-# are unique between package version, release and architecture.
-# (Use --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}".)
-#
-# If --unique-debug-src-base BASE is given then the source directory
-# will be called /usr/debug/src/<BASE>. This makes sure the debug source
-# directories are unique between package version, release and architecture.
-# (Use --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}".)
-#
-# All file names in switches are relative to builddir (. if not given).
-#
+help()
+{
+ echo "Usage: find-debuginfo.sh [OPTION]... [builddir]"
+ echo "automagically generates debug info and file lists"
+ echo
+ echo "Options:"
+ echo "[--strict-build-id] [-g] [-r] [-m] [-i] [-n]"
+ echo "[--keep-section SECTION] [--remove-section SECTION]"
+ echo "[--g-libs]"
+ echo "[-j N] [--jobs N]"
+ echo "[-o debugfiles.list]"
+ echo "[-S debugsourcefiles.list]"
+ echo "[--run-dwz] [--dwz-low-mem-die-limit N]"
+ echo "[--dwz-max-die-limit N]"
+ echo "[--dwz-single-file-mode]"
+ echo "[--build-id-seed SEED]"
+ echo "[--unique-debug-suffix SUFFIX]"
+ echo "[--unique-debug-src-base BASE]"
+ echo "[[-l filelist]... [-p 'pattern'] -o debuginfo.list]"
+ echo "[builddir]"
+ echo
+ echo "The -g flag says to use strip -g instead of full strip on DSOs or EXEs."
+ echo "The --g-libs flag says to use strip -g instead of full strip ONLY on"
+ echo "DSOs. Options -g and --g-libs are mutually exclusive."
+ echo
+ echo "The -r flag says to use eu-strip --reloc-debug-sections."
+ echo
+ echo "Use --keep-section SECTION or --remove-section SECTION to explicitly"
+ echo "keep a (non-allocated) section in the main executable or explicitly"
+ echo "remove it into the .debug file. SECTION is an extended wildcard"
+ echo "pattern. Both options can be given more than once."
+ echo
+ echo "The --strict-build-id flag says to exit with failure status if"
+ echo "any ELF binary processed fails to contain a build-id note."
+ echo
+ echo "The -m flag says to include a .gnu_debugdata section in the main"
+ echo "binary."
+ echo
+ echo "The -i flag says to include a .gdb_index section in the .debug file."
+ echo
+ echo "The -n flag says to not recompute the build-id."
+ echo
+ echo "The -j, --jobs N option will spawn N processes to do the debuginfo"
+ echo "extraction in parallel."
+ echo
+ echo "A single -o switch before any -l or -p switches simply renames"
+ echo "the primary output file from debugfiles.list to something else."
+ echo "A -o switch that follows a -p switch or some -l switches produces"
+ echo "an additional output file with the debuginfo for the files in"
+ echo "the -l filelist file, or whose names match the -p pattern."
+ echo "The -p argument is an grep -E -style regexp matching the a file name,"
+ echo "and must not use anchors (^ or $)."
+ echo
+ echo "The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility"
+ echo "if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit"
+ echo "provide detailed limits. See dwz(1) -l and -L option for details."
+ echo "Use --dwz-single-file-mode to disable multi-file mode, see dwz(1) -m"
+ echo "for more details."
+ echo
+ echo "If --build-id-seed SEED is given then debugedit is called to"
+ echo "update the build-ids it finds adding the SEED as seed to recalculate"
+ echo "the build-id hash. This makes sure the build-ids in the ELF files"
+ echo "are unique between versions and releases of the same package."
+ echo "(Use --build-id-seed \"%{VERSION}-%{RELEASE}\".)"
+ echo
+ echo "If --unique-debug-suffix SUFFIX is given then the debug files created"
+ echo "for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug"
+ echo "are unique between package version, release and architecture."
+ echo "(Use --unique-debug-suffix \"-%{VERSION}-%{RELEASE}.%{_arch}\".)"
+ echo
+ echo "If --unique-debug-src-base BASE is given then the source directory"
+ echo "will be called /usr/debug/src/<BASE>. This makes sure the debug source"
+ echo "dirs are unique between package version, release and achitecture (Use"
+ echo "--unique-debug-src-base \"%{name}-%{VERSION}-%{RELEASE}.%{_arch}\")"
+ echo
+ echo "All file names in switches are relative to builddir ('.' if not given)."
+}
# Figure out where we are installed so we can call other helper scripts.
lib_rpm_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -129,6 +140,9 @@ unique_debug_src_base=
# Number of parallel jobs to spawn
n_jobs=1
+# exit early on --version or --help
+done=false
+
BUILDDIR=.
out=debugfiles.list
srcout=
@@ -223,6 +237,14 @@ while [ $# -gt 0 ]; do
srcout=$2
shift
;;
+ --version)
+ echo "debugedit find-debuginfo.sh"
+ done=true;
+ ;;
+ --help)
+ help
+ done=true
+ ;;
*)
BUILDDIR=$1
shift
@@ -232,6 +254,9 @@ while [ $# -gt 0 ]; do
shift
done
+# version or help given
+if [ "$done" = "true" ]; then exit 0; fi
+
if test -n "$build_id_seed" -a "$no_recompute_build_id" = "true"; then
echo >&2 "*** ERROR: --build-id-seed (unique build-ids) and -n (do not recompute build-id) cannot be used together"
exit 2
--
2.18.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] find-debuginfo.sh: Add --help, --version and man page.
2021-04-29 22:46 [PATCH] find-debuginfo.sh: Add --help, --version and man page Mark Wielaard
@ 2021-04-29 23:06 ` Dmitry V. Levin
2021-04-30 12:10 ` Mark Wielaard
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry V. Levin @ 2021-04-29 23:06 UTC (permalink / raw)
To: Mark Wielaard; +Cc: debugedit
On Fri, Apr 30, 2021 at 12:46:04AM +0200, Mark Wielaard wrote:
> Add a --version and --help option to find-debuginfo.sh and use that to
> generate a manual page.
[...]
> diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
> index 3d736e0..ebad647 100755
> --- a/scripts/find-debuginfo.sh
> +++ b/scripts/find-debuginfo.sh
> @@ -17,72 +17,83 @@
> # You should have received a copy of the GNU General Public License
> # along with this program; if not, see <http://www.gnu.org/licenses/>
>
> -# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
> -# [--keep-section SECTION] [--remove-section SECTION]
> -# [--g-libs]
> -# [-j N] [--jobs N]
> -# [-o debugfiles.list]
> -# [-S debugsourcefiles.list]
> -# [--run-dwz] [--dwz-low-mem-die-limit N]
> -# [--dwz-max-die-limit N]
> -# [--dwz-single-file-mode]
> -# [--build-id-seed SEED]
> -# [--unique-debug-suffix SUFFIX]
> -# [--unique-debug-src-base BASE]
> -# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
> -# [builddir]
> -#
> -# The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
> -# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
> -# Options -g and --g-libs are mutually exclusive.
> -# The -r flag says to use eu-strip --reloc-debug-sections.
> -# Use --keep-section SECTION or --remove-section SECTION to explicitly
> -# keep a (non-allocated) section in the main executable or explicitly
> -# remove it into the .debug file. SECTION is an extended wildcard pattern.
> -# Both options can be given more than once.
> -#
> -# The --strict-build-id flag says to exit with failure status if
> -# any ELF binary processed fails to contain a build-id note.
> -# The -m flag says to include a .gnu_debugdata section in the main binary.
> -# The -i flag says to include a .gdb_index section in the .debug file.
> -# The -n flag says to not recompute the build-id.
> -#
> -# The -j, --jobs N option will spawn N processes to do the debuginfo
> -# extraction in parallel.
> -#
> -# A single -o switch before any -l or -p switches simply renames
> -# the primary output file from debugfiles.list to something else.
> -# A -o switch that follows a -p switch or some -l switches produces
> -# an additional output file with the debuginfo for the files in
> -# the -l filelist file, or whose names match the -p pattern.
> -# The -p argument is an grep -E -style regexp matching the a file name,
> -# and must not use anchors (^ or $).
> -#
> -# The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
> -# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
> -# provide detailed limits. See dwz(1) -l and -L option for details.
> -# Use --dwz-single-file-mode to disable multi-file mode, see dwz(1) -m
> -# for more details.
> -
> -#
> -# If --build-id-seed SEED is given then debugedit is called to
> -# update the build-ids it finds adding the SEED as seed to recalculate
> -# the build-id hash. This makes sure the build-ids in the ELF files
> -# are unique between versions and releases of the same package.
> -# (Use --build-id-seed "%{VERSION}-%{RELEASE}".)
> -#
> -# If --unique-debug-suffix SUFFIX is given then the debug files created
> -# for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug
> -# are unique between package version, release and architecture.
> -# (Use --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}".)
> -#
> -# If --unique-debug-src-base BASE is given then the source directory
> -# will be called /usr/debug/src/<BASE>. This makes sure the debug source
> -# directories are unique between package version, release and architecture.
> -# (Use --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}".)
> -#
> -# All file names in switches are relative to builddir (. if not given).
> -#
> +help()
> +{
> + echo "Usage: find-debuginfo.sh [OPTION]... [builddir]"
> + echo "automagically generates debug info and file lists"
> + echo
> + echo "Options:"
> + echo "[--strict-build-id] [-g] [-r] [-m] [-i] [-n]"
> + echo "[--keep-section SECTION] [--remove-section SECTION]"
> + echo "[--g-libs]"
> + echo "[-j N] [--jobs N]"
> + echo "[-o debugfiles.list]"
> + echo "[-S debugsourcefiles.list]"
> + echo "[--run-dwz] [--dwz-low-mem-die-limit N]"
> + echo "[--dwz-max-die-limit N]"
> + echo "[--dwz-single-file-mode]"
> + echo "[--build-id-seed SEED]"
> + echo "[--unique-debug-suffix SUFFIX]"
> + echo "[--unique-debug-src-base BASE]"
> + echo "[[-l filelist]... [-p 'pattern'] -o debuginfo.list]"
> + echo "[builddir]"
> + echo
> + echo "The -g flag says to use strip -g instead of full strip on DSOs or EXEs."
> + echo "The --g-libs flag says to use strip -g instead of full strip ONLY on"
> + echo "DSOs. Options -g and --g-libs are mutually exclusive."
> + echo
> + echo "The -r flag says to use eu-strip --reloc-debug-sections."
> + echo
> + echo "Use --keep-section SECTION or --remove-section SECTION to explicitly"
> + echo "keep a (non-allocated) section in the main executable or explicitly"
> + echo "remove it into the .debug file. SECTION is an extended wildcard"
> + echo "pattern. Both options can be given more than once."
> + echo
> + echo "The --strict-build-id flag says to exit with failure status if"
> + echo "any ELF binary processed fails to contain a build-id note."
> + echo
> + echo "The -m flag says to include a .gnu_debugdata section in the main"
> + echo "binary."
> + echo
> + echo "The -i flag says to include a .gdb_index section in the .debug file."
> + echo
> + echo "The -n flag says to not recompute the build-id."
> + echo
> + echo "The -j, --jobs N option will spawn N processes to do the debuginfo"
> + echo "extraction in parallel."
> + echo
> + echo "A single -o switch before any -l or -p switches simply renames"
> + echo "the primary output file from debugfiles.list to something else."
> + echo "A -o switch that follows a -p switch or some -l switches produces"
> + echo "an additional output file with the debuginfo for the files in"
> + echo "the -l filelist file, or whose names match the -p pattern."
> + echo "The -p argument is an grep -E -style regexp matching the a file name,"
> + echo "and must not use anchors (^ or $)."
> + echo
> + echo "The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility"
> + echo "if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit"
> + echo "provide detailed limits. See dwz(1) -l and -L option for details."
> + echo "Use --dwz-single-file-mode to disable multi-file mode, see dwz(1) -m"
> + echo "for more details."
> + echo
> + echo "If --build-id-seed SEED is given then debugedit is called to"
> + echo "update the build-ids it finds adding the SEED as seed to recalculate"
> + echo "the build-id hash. This makes sure the build-ids in the ELF files"
> + echo "are unique between versions and releases of the same package."
> + echo "(Use --build-id-seed \"%{VERSION}-%{RELEASE}\".)"
> + echo
> + echo "If --unique-debug-suffix SUFFIX is given then the debug files created"
> + echo "for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug"
> + echo "are unique between package version, release and architecture."
> + echo "(Use --unique-debug-suffix \"-%{VERSION}-%{RELEASE}.%{_arch}\".)"
> + echo
> + echo "If --unique-debug-src-base BASE is given then the source directory"
> + echo "will be called /usr/debug/src/<BASE>. This makes sure the debug source"
> + echo "dirs are unique between package version, release and achitecture (Use"
> + echo "--unique-debug-src-base \"%{name}-%{VERSION}-%{RELEASE}.%{_arch}\")"
> + echo
> + echo "All file names in switches are relative to builddir ('.' if not given)."
> +}
I suggest to use "cat" instead of multiple echoes, e.g.
cat <<-'EOF'
Usage: find-debuginfo.sh [OPTION]... [builddir]
automagically generates debug info and file lists
Options:
[...]
--unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}")
All file names in switches are relative to builddir ('.' if not given).
EOF
--
ldv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] find-debuginfo.sh: Add --help, --version and man page.
2021-04-29 23:06 ` Dmitry V. Levin
@ 2021-04-30 12:10 ` Mark Wielaard
2021-04-30 12:19 ` Dmitry V. Levin
0 siblings, 1 reply; 5+ messages in thread
From: Mark Wielaard @ 2021-04-30 12:10 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: debugedit
[-- Attachment #1: Type: text/plain, Size: 535 bytes --]
Hi Dmitry,
On Fri, 2021-04-30 at 02:06 +0300, Dmitry V. Levin wrote:
> I suggest to use "cat" instead of multiple echoes, e.g.
>
> cat <<-'EOF'
> Usage: find-debuginfo.sh [OPTION]... [builddir]
> automagically generates debug info and file lists
>
> Options:
> [...]
> --unique-debug-src-base "%{name}-%{VERSION}-
> %{RELEASE}.%{_arch}")
>
> All file names in switches are relative to builddir ('.' if not
> given).
> EOF
Yes, that is obviously much nicer.
Updated patch attached.
Thanks,
Mark
[-- Attachment #2: 0001-find-debuginfo.sh-Add-help-version-and-man-page.patch --]
[-- Type: text/x-patch, Size: 9622 bytes --]
From 477a1c56237f91c959b538e3512e5628920bd4c8 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Fri, 30 Apr 2021 00:42:23 +0200
Subject: [PATCH] find-debuginfo.sh: Add --help, --version and man page.
Add a --version and --help option to find-debuginfo.sh and use that to
generate a manual page.
* .gitignore: Add find-debuginfo.sh.1
* Makefile.am (dist_man_MANS): Add find-debuginfo.sh.1
(find-debuginfo.sh.1): New make rule.
* scripts/find-debuginfo.sh (help): New function.
Handle --version and --help.
https://sourceware.org/bugzilla/show_bug.cgi?id=27641
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
.gitignore | 2 +
Makefile.am | 7 +-
scripts/find-debuginfo.sh | 158 ++++++++++++++++++++++----------------
3 files changed, 100 insertions(+), 67 deletions(-)
diff --git a/.gitignore b/.gitignore
index d41ec64..3e81e87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,8 @@ debugedit.1
sepdebugcrcfix
sepdebugcrcfix.1
+find-debuginfo.sh.1
+
atconfig
atlocal
package.m4
diff --git a/Makefile.am b/Makefile.am
index de7c51d..b26d238 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,7 +39,7 @@ sepdebugcrcfix_CFLAGS = @LIBELF_CFLAGS@ $(AM_CFLAGS)
sepdebugcrcfix_LDADD = @LIBELF_LIBS@
# Manual pages are generated for dist
-dist_man_MANS = debugedit.1 sepdebugcrcfix.1
+dist_man_MANS = debugedit.1 sepdebugcrcfix.1 find-debuginfo.sh.1
debugedit.1: tools/debugedit.c $(top_srcdir)/configure.ac
$(MAKE) $(AM_MAKEFLAGS) debugedit$(EXEEXT)
@@ -53,6 +53,11 @@ sepdebugcrcfix.1: tools/sepdebugcrcfix.c $(top_srcdir)/configure.ac
--name='fixes CRC for separate .debug files' \
./sepdebugcrcfix$(EXEEXT)
+find-debuginfo.sh.1: scripts/find-debuginfo.sh $(top_srcdir)/configure.ac
+ $(HELP2MAN) -N --output=$@ \
+ --name='finds debuginfo and processes it' \
+ $(top_srcdir)/scripts/find-debuginfo.sh
+
noinst_HEADERS= tools/ansidecl.h \
tools/hashtab.h \
tools/md5.h \
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 3d736e0..5ea57ca 100755
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -17,72 +17,84 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
-# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
-# [--keep-section SECTION] [--remove-section SECTION]
-# [--g-libs]
-# [-j N] [--jobs N]
-# [-o debugfiles.list]
-# [-S debugsourcefiles.list]
-# [--run-dwz] [--dwz-low-mem-die-limit N]
-# [--dwz-max-die-limit N]
-# [--dwz-single-file-mode]
-# [--build-id-seed SEED]
-# [--unique-debug-suffix SUFFIX]
-# [--unique-debug-src-base BASE]
-# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
-# [builddir]
-#
-# The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
-# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
-# Options -g and --g-libs are mutually exclusive.
-# The -r flag says to use eu-strip --reloc-debug-sections.
-# Use --keep-section SECTION or --remove-section SECTION to explicitly
-# keep a (non-allocated) section in the main executable or explicitly
-# remove it into the .debug file. SECTION is an extended wildcard pattern.
-# Both options can be given more than once.
-#
-# The --strict-build-id flag says to exit with failure status if
-# any ELF binary processed fails to contain a build-id note.
-# The -m flag says to include a .gnu_debugdata section in the main binary.
-# The -i flag says to include a .gdb_index section in the .debug file.
-# The -n flag says to not recompute the build-id.
-#
-# The -j, --jobs N option will spawn N processes to do the debuginfo
-# extraction in parallel.
-#
-# A single -o switch before any -l or -p switches simply renames
-# the primary output file from debugfiles.list to something else.
-# A -o switch that follows a -p switch or some -l switches produces
-# an additional output file with the debuginfo for the files in
-# the -l filelist file, or whose names match the -p pattern.
-# The -p argument is an grep -E -style regexp matching the a file name,
-# and must not use anchors (^ or $).
-#
-# The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
-# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
-# provide detailed limits. See dwz(1) -l and -L option for details.
-# Use --dwz-single-file-mode to disable multi-file mode, see dwz(1) -m
-# for more details.
-
-#
-# If --build-id-seed SEED is given then debugedit is called to
-# update the build-ids it finds adding the SEED as seed to recalculate
-# the build-id hash. This makes sure the build-ids in the ELF files
-# are unique between versions and releases of the same package.
-# (Use --build-id-seed "%{VERSION}-%{RELEASE}".)
-#
-# If --unique-debug-suffix SUFFIX is given then the debug files created
-# for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug
-# are unique between package version, release and architecture.
-# (Use --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}".)
-#
-# If --unique-debug-src-base BASE is given then the source directory
-# will be called /usr/debug/src/<BASE>. This makes sure the debug source
-# directories are unique between package version, release and architecture.
-# (Use --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}".)
-#
-# All file names in switches are relative to builddir (. if not given).
-#
+help()
+{
+ cat <<EOF
+Usage: find-debuginfo.sh [OPTION]... [builddir]
+automagically generates debug info and file lists
+
+Options:
+[--strict-build-id] [-g] [-r] [-m] [-i] [-n]
+[--keep-section SECTION] [--remove-section SECTION]
+[--g-libs]
+[-j N] [--jobs N]
+[-o debugfiles.list]
+[-S debugsourcefiles.list]
+[--run-dwz] [--dwz-low-mem-die-limit N]
+[--dwz-max-die-limit N]
+[--dwz-single-file-mode]
+[--build-id-seed SEED]
+[--unique-debug-suffix SUFFIX]
+[--unique-debug-src-base BASE]
+[[-l filelist]... [-p 'pattern'] -o debuginfo.list]
+[builddir]
+
+The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
+The --g-libs flag says to use strip -g instead of full strip ONLY on
+DSOs. Options -g and --g-libs are mutually exclusive.
+
+The -r flag says to use eu-strip --reloc-debug-sections.
+
+Use --keep-section SECTION or --remove-section SECTION to explicitly
+keep a (non-allocated) section in the main executable or explicitly
+remove it into the .debug file. SECTION is an extended wildcard
+pattern. Both options can be given more than once.
+
+The --strict-build-id flag says to exit with failure status if
+any ELF binary processed fails to contain a build-id note.
+
+The -m flag says to include a .gnu_debugdata section in the main binary.
+
+The -i flag says to include a .gdb_index section in the .debug file.
+
+The -n flag says to not recompute the build-id.
+
+The -j, --jobs N option will spawn N processes to do the debuginfo
+extraction in parallel.
+
+A single -o switch before any -l or -p switches simply renames
+the primary output file from debugfiles.list to something else.
+A -o switch that follows a -p switch or some -l switches produces
+an additional output file with the debuginfo for the files in
+the -l filelist file, or whose names match the -p pattern.
+The -p argument is an grep -E -style regexp matching the a file name,
+and must not use anchors (^ or $).
+
+The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
+if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
+provide detailed limits. See dwz(1) -l and -L option for details.
+Use --dwz-single-file-mode to disable multi-file mode, see dwz(1) -m
+for more details.
+
+If --build-id-seed SEED is given then debugedit is called to
+update the build-ids it finds adding the SEED as seed to recalculate
+the build-id hash. This makes sure the build-ids in the ELF files
+are unique between versions and releases of the same package.
+(Use --build-id-seed \"%{VERSION}-%{RELEASE}\".)
+
+If --unique-debug-suffix SUFFIX is given then the debug files created
+for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug
+are unique between package version, release and architecture.
+(Use --unique-debug-suffix \"-%{VERSION}-%{RELEASE}.%{_arch}\".)
+
+If --unique-debug-src-base BASE is given then the source directory
+will be called /usr/debug/src/<BASE>. This makes sure the debug source
+dirs are unique between package version, release and achitecture (Use
+--unique-debug-src-base \"%{name}-%{VERSION}-%{RELEASE}.%{_arch}\")
+
+All file names in switches are relative to builddir ('.' if not given).
+EOF
+}
# Figure out where we are installed so we can call other helper scripts.
lib_rpm_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -129,6 +141,9 @@ unique_debug_src_base=
# Number of parallel jobs to spawn
n_jobs=1
+# exit early on --version or --help
+done=false
+
BUILDDIR=.
out=debugfiles.list
srcout=
@@ -223,6 +238,14 @@ while [ $# -gt 0 ]; do
srcout=$2
shift
;;
+ --version)
+ echo "debugedit find-debuginfo.sh"
+ done=true;
+ ;;
+ --help)
+ help
+ done=true
+ ;;
*)
BUILDDIR=$1
shift
@@ -232,6 +255,9 @@ while [ $# -gt 0 ]; do
shift
done
+# version or help given
+if [ "$done" = "true" ]; then exit 0; fi
+
if test -n "$build_id_seed" -a "$no_recompute_build_id" = "true"; then
echo >&2 "*** ERROR: --build-id-seed (unique build-ids) and -n (do not recompute build-id) cannot be used together"
exit 2
--
2.18.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] find-debuginfo.sh: Add --help, --version and man page.
2021-04-30 12:10 ` Mark Wielaard
@ 2021-04-30 12:19 ` Dmitry V. Levin
2021-04-30 12:37 ` Mark Wielaard
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry V. Levin @ 2021-04-30 12:19 UTC (permalink / raw)
To: Mark Wielaard; +Cc: debugedit
Hi Mark,
On Fri, Apr 30, 2021 at 02:10:14PM +0200, Mark Wielaard wrote:
> Hi Dmitry,
>
> On Fri, 2021-04-30 at 02:06 +0300, Dmitry V. Levin wrote:
> > I suggest to use "cat" instead of multiple echoes, e.g.
> >
> > cat <<-'EOF'
> > Usage: find-debuginfo.sh [OPTION]... [builddir]
> > automagically generates debug info and file lists
> >
> > Options:
> > [...]
> > --unique-debug-src-base "%{name}-%{VERSION}-
> > %{RELEASE}.%{_arch}")
> >
> > All file names in switches are relative to builddir ('.' if not
> > given).
> > EOF
>
> Yes, that is obviously much nicer.
It would look even nicer if EOF was quoted, e.g. 'EOF'.
From bash manual page:
"If any part of word is quoted, the delimiter is the result of quote
removal on word, and the lines in the here-document are not expanded."
[...]
> +--unique-debug-src-base \"%{name}-%{VERSION}-%{RELEASE}.%{_arch}\")
I suggest to quote EOF once and forget about quoting anything in the whole
text.
--
ldv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] find-debuginfo.sh: Add --help, --version and man page.
2021-04-30 12:19 ` Dmitry V. Levin
@ 2021-04-30 12:37 ` Mark Wielaard
0 siblings, 0 replies; 5+ messages in thread
From: Mark Wielaard @ 2021-04-30 12:37 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: debugedit
Hi Dmitry,
On Fri, 2021-04-30 at 15:19 +0300, Dmitry V. Levin wrote:
> It would look even nicer if EOF was quoted, e.g. 'EOF'.
> From bash manual page:
> "If any part of word is quoted, the delimiter is the result of quote
> removal on word, and the lines in the here-document are not
> expanded."
>
> [...]
> > +--unique-debug-src-base \"%{name}-%{VERSION}-
> > %{RELEASE}.%{_arch}\")
>
> I suggest to quote EOF once and forget about quoting anything in the
> whole text.
You are right again, the current escaping looks ugly in the --help
text. I fixed it like you suggested:
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index 5ea57ca..4f7ebef 100755
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -19,7 +19,7 @@
help()
{
- cat <<EOF
+ cat <<'EOF'
Usage: find-debuginfo.sh [OPTION]... [builddir]
automagically generates debug info and file lists
@@ -80,17 +80,17 @@ If --build-id-seed SEED is given then debugedit is
called to
update the build-ids it finds adding the SEED as seed to recalculate
the build-id hash. This makes sure the build-ids in the ELF files
are unique between versions and releases of the same package.
-(Use --build-id-seed \"%{VERSION}-%{RELEASE}\".)
+(Use --build-id-seed "%{VERSION}-%{RELEASE}".)
If --unique-debug-suffix SUFFIX is given then the debug files created
for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure
.debug
are unique between package version, release and architecture.
-(Use --unique-debug-suffix \"-%{VERSION}-%{RELEASE}.%{_arch}\".)
+(Use --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}".)
If --unique-debug-src-base BASE is given then the source directory
will be called /usr/debug/src/<BASE>. This makes sure the debug
source
dirs are unique between package version, release and achitecture (Use
---unique-debug-src-base \"%{name}-%{VERSION}-%{RELEASE}.%{_arch}\")
+--unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}")
All file names in switches are relative to builddir ('.' if not
given).
EOF
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-30 12:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 22:46 [PATCH] find-debuginfo.sh: Add --help, --version and man page Mark Wielaard
2021-04-29 23:06 ` Dmitry V. Levin
2021-04-30 12:10 ` Mark Wielaard
2021-04-30 12:19 ` Dmitry V. Levin
2021-04-30 12:37 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).