Patchwork contrib/gdb-add-index.sh -dwarf-5

login
register
mail settings
Submitter Jan Kratochvil
Date June 30, 2018, 7:36 p.m.
Message ID <20180630193651.GA3127041@host1.jankratochvil.net>
Download mbox | patch
Permalink /patch/28175/
State New
Headers show

Comments

Jan Kratochvil - June 30, 2018, 7:36 p.m.
Hi,

------------------------------------------------------------------------------
(gdb) help save gdb-index
Save a gdb-index file.
Usage: save gdb-index [-dwarf-5] DIRECTORY

No options create one file with .gdb-index extension for pre-DWARF-5
compatible .gdb_index section.  With -dwarf-5 creates two files with
extension .debug_names and .debug_str for DWARF-5 .debug_names section.
------------------------------------------------------------------------------

But gdb-add-index command provides no way how to pass the -dwarf-5 option.

OK for check-in?


Jan
2018-06-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* contrib/gdb-add-index.sh ($dwarf5): New, use it.
Simon Marchi - July 7, 2018, 2:38 p.m.
On 2018-06-30 03:36 PM, Jan Kratochvil wrote:
> Hi,
> 
> ------------------------------------------------------------------------------
> (gdb) help save gdb-index
> Save a gdb-index file.
> Usage: save gdb-index [-dwarf-5] DIRECTORY
> 
> No options create one file with .gdb-index extension for pre-DWARF-5
> compatible .gdb_index section.  With -dwarf-5 creates two files with
> extension .debug_names and .debug_str for DWARF-5 .debug_names section.
> ------------------------------------------------------------------------------
> 
> But gdb-add-index command provides no way how to pass the -dwarf-5 option.
> 
> OK for check-in?
> 
> 
> Jan
> 

Hi Jan,

That LGTM.  But could you maybe update the "usage" line to include the
optional -dwarf-5 argument?

  echo "usage: $myname [-dwarf-5] FILE" 1>&2

Maybe some day this will evolve in a proper --help.

Simon

Patch

diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
index 71146966ab..0aab234f7c 100755
--- a/gdb/contrib/gdb-add-index.sh
+++ b/gdb/contrib/gdb-add-index.sh
@@ -23,6 +23,12 @@  OBJCOPY=${OBJCOPY:=objcopy}
 
 myname="${0##*/}"
 
+dwarf5=""
+if [ "$1" = "-dwarf-5" ]; then
+    dwarf5="$1"
+    shift
+fi
+
 if test $# != 1; then
     echo "usage: $myname FILE" 1>&2
     exit 1
@@ -48,7 +54,7 @@  rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr
 trap "rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr" 0
 
 $GDB --batch -nx -iex 'set auto-load no' \
-    -ex "file $file" -ex "save gdb-index $dir" || {
+    -ex "file $file" -ex "save gdb-index $dwarf5 $dir" || {
     # Just in case.
     status=$?
     echo "$myname: gdb error generating index for $file" 1>&2