mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-19 01:19:41 +08:00
gdb-add-index: add --help and --version options
Update the gdb-add-index script to offer --help and --version options. The script currently accepts the argument '-dwarf-5' with a single leading '-'. As two '--' is more common for long options, the preferred argument form is now '--dwarf-5', the docs have been updated, and the new help text uses this form. For backward compatibility, the old '-dwarf-5' form is still accepted. The new arguments are '--help' or '-h', but I also accept '-help' for consistency with '-dwarf-5'. And likewise for the version argument. Handling of the gdb-add-index script is done basically the same as for gcore and gstack; we use config.status to create a .in file within the build directory, which is then processed by the Makefile to create the final script. The difference with gdb-add-index is that I left the original script as gdb/contrib/gdb-add-index.sh rather than renaming it to something like gdb/contrib/gdb-add-index-1.in, which is how gcore and gstack are handled (though they are not in the contrib directory). The reason for this is that the contrib/cc-with-tweaks.sh script looks for gdb-add-index.sh within the gdb/contrib/ source directory. As the only reason we process gdb-add-index.sh into the build directory is to support the PKGVERSION and VERSION variables, allowing cc-with-tweaks to continue using the unprocessed version seems harmless, and avoids having to change cc-with-tweaks.sh at all. I tested that I can still run tests using the cc-with-gdb-index target board, and that the installed gdb-add-index script correctly shows a version number when asked. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32325 Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -1956,7 +1956,7 @@ generated_files = \
|
||||
# Flags needed to compile Python code
|
||||
PYTHON_CFLAGS = @PYTHON_CFLAGS@
|
||||
|
||||
all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb gcore gstack
|
||||
all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb gcore gstack gdb-add-index
|
||||
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=$(SUBDIRS)" subdir_do
|
||||
|
||||
# Rule for compiling .c files in the top-level gdb directory.
|
||||
@@ -2135,7 +2135,7 @@ install-only: $(CONFIG_INSTALL)
|
||||
else \
|
||||
true ; \
|
||||
fi ; \
|
||||
$(INSTALL_SCRIPT) $(srcdir)/contrib/gdb-add-index.sh \
|
||||
$(INSTALL_SCRIPT) gdb-add-index \
|
||||
$(DESTDIR)$(bindir)/$$transformed_name
|
||||
@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
|
||||
|
||||
@@ -2355,7 +2355,10 @@ jit-reader.h: $(srcdir)/jit-reader.in config.status
|
||||
gstack.in gcore.in: %.in : $(srcdir)/%-1.in config.status
|
||||
$(ECHO_GEN) $(SHELL) config.status $(SILENT_FLAG) $@
|
||||
|
||||
gstack gcore: % : %.in version.c
|
||||
gdb-add-index.in : $(srcdir)/contrib/gdb-add-index.sh config.status
|
||||
$(ECHO_GEN) $(SHELL) config.status $(SILENT_FLAG) $@
|
||||
|
||||
gstack gcore gdb-add-index: % : %.in version.c
|
||||
$(ECHO_GEN) \
|
||||
vv=`grep 'version\[\] = ' version.c | grep -o '".*"' | tr -d \"`; \
|
||||
sed -e "s,@VERSION@,$$vv," $< > $@
|
||||
|
||||
7
gdb/NEWS
7
gdb/NEWS
@@ -26,9 +26,10 @@
|
||||
|
||||
* Linux checkpoint code has been updated to work with multiple inferiors.
|
||||
|
||||
* The gcore script now has a -v or --version option, which prints the
|
||||
version number, and then exits. As well as a -h or --help option,
|
||||
which prints each options and a brief description.
|
||||
* The gcore and gdb-add-index scripts now have a -v or --version
|
||||
option, which prints the version number, and then exits. As well as
|
||||
a -h or --help option, which prints each options and a brief
|
||||
description.
|
||||
|
||||
* New commands
|
||||
|
||||
|
||||
3
gdb/configure
vendored
3
gdb/configure
vendored
@@ -33779,6 +33779,8 @@ ac_config_files="$ac_config_files gcore.in:gcore-1.in"
|
||||
|
||||
ac_config_files="$ac_config_files gstack.in:gstack-1.in"
|
||||
|
||||
ac_config_files="$ac_config_files gdb-add-index.in:contrib/gdb-add-index.sh"
|
||||
|
||||
ac_config_files="$ac_config_files Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile"
|
||||
|
||||
|
||||
@@ -34880,6 +34882,7 @@ do
|
||||
"nm.h") CONFIG_LINKS="$CONFIG_LINKS nm.h:$GDB_NM_FILE" ;;
|
||||
"gcore.in") CONFIG_FILES="$CONFIG_FILES gcore.in:gcore-1.in" ;;
|
||||
"gstack.in") CONFIG_FILES="$CONFIG_FILES gstack.in:gstack-1.in" ;;
|
||||
"gdb-add-index.in") CONFIG_FILES="$CONFIG_FILES gdb-add-index.in:contrib/gdb-add-index.sh" ;;
|
||||
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
||||
"gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;;
|
||||
"gdb-gdb.py") CONFIG_FILES="$CONFIG_FILES gdb-gdb.py" ;;
|
||||
|
||||
@@ -2280,6 +2280,7 @@ GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME])
|
||||
GDB_AC_TRANSFORM([gcore], [GCORE_TRANSFORM_NAME])
|
||||
AC_CONFIG_FILES([gcore.in:gcore-1.in])
|
||||
AC_CONFIG_FILES([gstack.in:gstack-1.in])
|
||||
AC_CONFIG_FILES([gdb-add-index.in:contrib/gdb-add-index.sh])
|
||||
AC_CONFIG_FILES([Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -22,16 +22,73 @@ GDB=${GDB:=gdb}
|
||||
OBJCOPY=${OBJCOPY:=objcopy}
|
||||
READELF=${READELF:=readelf}
|
||||
|
||||
PKGVERSION=@PKGVERSION@
|
||||
VERSION=@VERSION@
|
||||
|
||||
myname="${0##*/}"
|
||||
|
||||
print_usage() {
|
||||
prefix="Usage: $myname"
|
||||
echo "$prefix [-h|--help] [-v|--version] [--dwarf-5] FILENAME"
|
||||
}
|
||||
|
||||
print_try_help() {
|
||||
echo "Try '$myname --help' for more information."
|
||||
}
|
||||
|
||||
print_help() {
|
||||
print_usage
|
||||
echo
|
||||
echo "Add a .gdb_index section to FILENAME to facilitate faster debug"
|
||||
echo "information loading by GDB."
|
||||
echo
|
||||
echo " -h, --help Print this message then exit."
|
||||
echo " -v, --version Print version information then exit."
|
||||
echo " --dwarf-5 Add the DWARF-5 style .debug_names section"
|
||||
echo " instead of .gdb_index."
|
||||
}
|
||||
|
||||
print_version() {
|
||||
echo "GNU gdb-add-index (${PKGVERSION}) ${VERSION}"
|
||||
}
|
||||
|
||||
dwarf5=""
|
||||
if [ "$1" = "-dwarf-5" ]; then
|
||||
dwarf5="$1"
|
||||
|
||||
# Parse options.
|
||||
until
|
||||
opt=$1
|
||||
case ${opt} in
|
||||
--dwarf-5 | -dwarf-5)
|
||||
dwarf5="-dwarf-5"
|
||||
;;
|
||||
|
||||
--help | -help | -h)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--version | -version | -v)
|
||||
print_version
|
||||
exit 0
|
||||
;;
|
||||
|
||||
-?*)
|
||||
print_try_help 1>&2
|
||||
exit 2
|
||||
;;
|
||||
|
||||
*)
|
||||
# No arguments remaining.
|
||||
;;
|
||||
esac
|
||||
# Break from loop if the first character of OPT is not '-'.
|
||||
[ "x$(printf %.1s "$opt")" != "x-" ]
|
||||
do
|
||||
shift
|
||||
fi
|
||||
done
|
||||
|
||||
if test $# != 1; then
|
||||
echo "usage: $myname [-dwarf-5] FILE" 1>&2
|
||||
print_try_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -51643,7 +51643,7 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
|
||||
@c man title gdb-add-index Add index files to speed up GDB
|
||||
|
||||
@c man begin SYNOPSIS gdb-add-index
|
||||
gdb-add-index [-dwarf-5] @var{filename}
|
||||
gdb-add-index [-h | --help] [-v | --version] [--dwarf-5] @var{filename}
|
||||
@c man end
|
||||
|
||||
@c man begin DESCRIPTION gdb-add-index
|
||||
@@ -51661,8 +51661,8 @@ which use ELF binaries and DWARF debug information (i.e., sections
|
||||
named @code{.debug_*}).
|
||||
|
||||
By default @command{gdb-add-index} will add a pre-DWARF 5
|
||||
@code{.gdb_index} section to @var{filename}. With @option{-dwarf-5}
|
||||
DWARF 5 sections are added instead.
|
||||
@code{.gdb_index} section to @var{filename}. With @option{--dwarf-5}
|
||||
the DWARF 5 section @code{.debug_names} is added instead.
|
||||
|
||||
@var{filename} must be writable.
|
||||
|
||||
@@ -51686,9 +51686,16 @@ the @value{GDBN} manual in node @code{Index Files}
|
||||
|
||||
@c man begin OPTIONS gdb-add-index
|
||||
@table @env
|
||||
@item -dwarf-5
|
||||
@item --dwarf-5
|
||||
Add DWARF 5 sections instead of previous @code{.gdb_index} section.
|
||||
|
||||
@item --help
|
||||
@itemx -h
|
||||
List all options, with brief explanations.
|
||||
|
||||
@item --version
|
||||
@itemx -v
|
||||
Print version information and then exit.
|
||||
@end table
|
||||
@c man end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user