From 6432ec65a8822246db5bcede0c6bd3ed0e464a0b Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 8 Dec 2017 22:44:10 +0000 Subject: [PATCH] cc-with-tweaks.sh: Use gdb-add-index.sh With DWARF-5 .debug_names, the commands to add the index to the symbol file are more complicated, as now also .debug_str needs to be modified. Currently, contrib/cc-with-tweaks.sh calls objcopy to handle the '-i' option instead of using contrib/gdb-add-index.sh which basically does the same. To help with .debug_names, this commit makes contrib/cc-with-tweaks.sh reuse contrib/gdb-add-index.sh instead. A problem this ran into is whether contrib/cc-with-tweaks.sh should fail or not when no index is produced. Currently, contrib/cc-with-tweaks.sh is more quiet (=successful) than contrib/gdb-add-index.sh and so with no further changes testsuite runs with an index would "regress". This commit tries to keep the behavior unchanged. Some cases still error with: Ada is not currently supported by the index But some cases (such as some trivial gdb.dwarf2/ testcases with no DWARF data to index) produce no index while the testcases still PASS now instead of: -PASS: gdb.arch/i386-bp_permanent.exp: stack pointer value matches +gdb compile failed, gdb-add-index.sh: No index was created for gdb/testsuite.unix.-m64/outputs/gdb.arch/i386-bp_permanent/i386-bp_permanent +gdb-add-index.sh: [Was there no debuginfo? Was there already an index?] +UNTESTED: gdb.arch/i386-bp_permanent.exp: failed to compile gdb/ChangeLog 2017-12-08 Jan Kratochvil Pedro Alves * contrib/cc-with-tweaks.sh: Change interpreter to bash, incl. initial comment. (GDB_ADD_INDEX): New variable. <$want_index>: Call $GDB_ADD_INDEX. --- gdb/ChangeLog | 8 +++++++ gdb/contrib/cc-with-tweaks.sh | 40 ++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 26cf18edb89..e90a3f01b3c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2017-12-08 Jan Kratochvil + Pedro Alves + + * contrib/cc-with-tweaks.sh: Change interpreter to bash, incl. initial + comment. + (GDB_ADD_INDEX): New variable. + <$want_index>: Call $GDB_ADD_INDEX. + 2017-12-08 Sergio Durigan Junior * dtrace-probe.c (dtrace_process_dof_probe): Do not declare a new diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh index 7d39c00d210..a65fef8993b 100755 --- a/gdb/contrib/cc-with-tweaks.sh +++ b/gdb/contrib/cc-with-tweaks.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/usr/bin/env bash # Wrapper around gcc to tweak the output in various ways when running # the testsuite. @@ -27,8 +27,8 @@ # # bash$ cd $objdir/gdb/testsuite # bash$ runtest \ -# CC_FOR_TARGET="/bin/sh $srcdir/gdb/contrib/cc-with-tweaks.sh ARGS gcc" \ -# CXX_FOR_TARGET="/bin/sh $srcdir/gdb/contrib/cc-with-tweaks.sh ARGS g++" +# CC_FOR_TARGET="/bin/bash $srcdir/gdb/contrib/cc-with-tweaks.sh ARGS gcc" \ +# CXX_FOR_TARGET="/bin/bash $srcdir/gdb/contrib/cc-with-tweaks.sh ARGS g++" # # For documentation on Fission and dwp files: # http://gcc.gnu.org/wiki/DebugFission @@ -47,6 +47,7 @@ # If nothing is given, no changes are made myname=cc-with-tweaks.sh +mydir=`dirname "$0"` if [ -z "$GDB" ] then @@ -93,6 +94,20 @@ while [ $# -gt 0 ]; do shift done +if [ "$want_index" = true ] +then + if [ -z "$GDB_ADD_INDEX" ] + then + if [ -f $mydir/gdb-add-index.sh ] + then + GDB_ADD_INDEX="$mydir/gdb-add-index.sh" + else + echo "$myname: unable to find usable contrib/gdb-add-index.sh" >&2 + exit 1 + fi + fi +fi + for arg in "$@" do if [ "$next_is_output_file" = "yes" ] @@ -152,20 +167,11 @@ if [ "$want_objcopy_compress" = true ]; then fi if [ "$want_index" = true ]; then - $GDB --batch-silent -nx -ex "set auto-load no" -ex "file $output_file" -ex "save gdb-index $output_dir" - rc=$? - [ $rc != 0 ] && exit $rc - - # GDB might not always create an index. Cope. - if [ -f "$index_file" ] - then - $OBJCOPY --add-section .gdb_index="$index_file" \ - --set-section-flags .gdb_index=readonly \ - "$output_file" "$output_file" - rc=$? - else - rc=0 - fi + # Filter out these messages which would stop dejagnu testcase run: + # echo "$myname: No index was created for $file" 1>&2 + # echo "$myname: [Was there no debuginfo? Was there already an index?]" 1>&2 + GDB=$GDB $GDB_ADD_INDEX "$output_file" 2>&1|grep -v "^${GDB_ADD_INDEX##*/}: " >&2 + rc=${PIPESTATUS[0]} [ $rc != 0 ] && exit $rc fi -- 2.30.2