public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org, Victor Leschuk <vleschuk@accesssoftek.com>
Subject: [PATCH v3.1 1/5] cc-with-tweaks.sh: Use gdb-add-index.sh
Date: Sat, 01 Jul 2017 15:23:00 -0000	[thread overview]
Message-ID: <20170701152310.GA5857@host1.jankratochvil.net> (raw)
In-Reply-To: <fd30321fc7432811710371236c0faf26@polymtl.ca>

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

On Thu, 29 Jun 2017 21:40:32 +0200, Simon Marchi wrote:
> On 2017-06-19 22:55, Jan Kratochvil wrote:
> > +if [ "$want_index" = true ]; then
> > +  if [ -z "$GDB_ADD_INDEX" ]
> > +  then
> 
> Nit: use the same style ("then" on same line or next line) for all ifs.

Done.


> > +      if [ -f ./contrib/gdb-add-index.sh ]
> > +      then
> > +	  GDB_ADD_INDEX="./contrib/gdb-add-index.sh"
> > +      elif [ -f ../contrib/gdb-add-index.sh ]
> > +      then
> > +	  GDB_ADD_INDEX="../contrib/gdb-add-index.sh"
> > +      elif [ -f ../../contrib/gdb-add-index.sh ]
> > +      then
> > +	  GDB_ADD_INDEX="../../contrib/gdb-add-index.sh"
> > +      else
> > +	  echo "$myname: unable to find usable contrib/gdb-add-index.sh" >&2
> > +	  exit 1
> > +      fi
> > +  fi
> > +fi
> 
> This strategy doesn't work for out of tree builds.

I use it always with explicit $GDB_ADD_INDEX so this auto-detection does not
really matter to me:
	https://git.jankratochvil.net/?p=nethome.git;a=commitdiff;h=44099fb634eca7837d30ab9b6afde0ec2838f705


> Perhaps cooking up
> something based on $0 would be better?  I see that the GDB variable is
> auto-detected the same way, but the gdb binary is found in the build
> directory, so it works for the tests, whereas gdb-add-index.sh is in the
> source directory.
> 
> I think it would still be nice to improve how GDB is auto-detected (in
> another patch),

OK, I believe that is unrelated to this patchset.  I am fine to always specify
all the tools explicitly.


> Is PIPESTATUS bash specific?  If so, we should probably change the
> interpreter to
> 
> #!/usr/bin/env bash
> 
> The CC/CXX_FOR_TARGET variables in cc-with-tweaks.exp also use /bin/sh
> explicitly, I think it those can just be removed.

Done.


Thanks,
Jan

[-- Attachment #2: Type: message/rfc822, Size: 4281 bytes --]

From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH] cc-with-tweaks.sh: Use gdb-add-index.sh
Date: Wed, 28 Jun 2017 23:07:25 +0200

Hi,

currently contrib/cc-with-tweaks.sh is calling for its -i option objcopy itself
instead of using contrib/gdb-add-index.sh which does the same.

With DWARF-5 .debug_names the commands are more complicated (as now also
.debug_str needs to be modified) and so I have decided to rather reuse
contrib/gdb-add-index.sh instead of duplicating its code
in contrib/cc-with-tweaks.sh.

The problem is when no index is produced whether contrib/cc-with-tweaks.sh
should fail or not.  As originally contrib/cc-with-tweaks.sh was more quiet
(=successful) than contrib/gdb-add-index.sh and so after this patch the
testsuite runs with an index would "regress".  I have tried 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 /quadgdb/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


Jan


gdb/ChangeLog
2017-05-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* contrib/cc-with-tweaks.sh: Change interpreter to bash, incl. initial
	comment.
	(t, GDB_ADD_INDEX): New variables.
	<$want_index>: Call $GDB_ADD_INDEX.
---
 gdb/contrib/cc-with-tweaks.sh | 47 +++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh
index 7d39c00..ae52e1d 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
@@ -74,6 +74,8 @@ DWP=${DWP:-dwp}
 have_link=unknown
 next_is_output_file=no
 output_file=a.out
+t=/tmp/cc-with-tweaks.$$
+rm -f $t
 
 want_index=false
 want_dwz=false
@@ -93,6 +95,26 @@ while [ $# -gt 0 ]; do
     shift
 done
 
+if [ "$want_index" = true ]
+then
+    if [ -z "$GDB_ADD_INDEX" ]
+    then
+	if [ -f ./contrib/gdb-add-index.sh ]
+	then
+	    GDB_ADD_INDEX="./contrib/gdb-add-index.sh"
+	elif [ -f ../contrib/gdb-add-index.sh ]
+	then
+	    GDB_ADD_INDEX="../contrib/gdb-add-index.sh"
+	elif [ -f ../../contrib/gdb-add-index.sh ]
+	then
+	    GDB_ADD_INDEX="../../contrib/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 +174,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.9.4

  reply	other threads:[~2017-07-01 15:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19 20:55 [PATCH v3 0/5] DWARF-5: .debug_names index Jan Kratochvil
2017-06-19 20:55 ` [PATCH v3 1/5] cc-with-tweaks.sh: Use gdb-add-index.sh Jan Kratochvil
2017-06-29 19:40   ` Simon Marchi
2017-07-01 15:23     ` Jan Kratochvil [this message]
2017-12-08 23:43       ` [PATCH v3.1 " Pedro Alves
2017-06-19 20:55 ` [PATCH v3 2/5] DWARF-5: .debug_names index producer Jan Kratochvil
2017-06-20 15:19   ` Eli Zaretskii
2017-06-22 18:35     ` [PATCH v3.1 " Jan Kratochvil
2017-06-22 19:18       ` Eli Zaretskii
2017-06-22 20:03         ` [PATCH v3.2 " Jan Kratochvil
2017-12-08 23:51           ` Pedro Alves
2017-12-12 15:38             ` Jan Kratochvil
2017-12-31  3:52             ` Simon Marchi
2017-06-19 20:56 ` [PATCH v3 4/5] Refactor: Move some generic code out of .gdb_index code Jan Kratochvil
2017-12-08 23:53   ` Pedro Alves
2017-06-19 20:56 ` [PATCH v3 5/5] DWARF-5: .debug_names index consumer Jan Kratochvil
2017-06-28 21:21   ` [PATCH v3.1 " Jan Kratochvil
2017-07-02 14:30     ` [PATCH v3.2 " Jan Kratochvil
2017-12-08 23:59       ` Pedro Alves
2017-12-09  0:07         ` [pushed] Add gdb::hash_enum (Re: [PATCH v3.2 5/5] DWARF-5: .debug_names index consumer) Pedro Alves
2017-12-12 16:52         ` [PATCH v3.2 5/5] DWARF-5: .debug_names index consumer Jan Kratochvil
2017-12-13 21:57           ` [patch] DWARF-5 .debug_names DW_IDX_type_unit fix [Re: [PATCH v3.2 5/5] DWARF-5: .debug_names index consumer] Jan Kratochvil
2017-12-13 22:16             ` Pedro Alves
2017-12-13 23:03               ` Pedro Alves
2017-12-14  9:03                 ` [commit] " Jan Kratochvil
2017-06-19 20:56 ` [PATCH v3 3/5] Code cleanup: dwarf2_initialize_objfile return value Jan Kratochvil
2017-12-08 23:52   ` Pedro Alves
2017-12-11 13:04     ` Yao Qi
2017-12-11 13:20       ` Pedro Alves
2017-12-11 14:00         ` Pedro Alves
2017-12-11 15:08           ` [pushed] Unbreak build for non-ELF ports (Re: [PATCH v3 3/5] Code cleanup: dwarf2_initialize_objfile return value) Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170701152310.GA5857@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=vleschuk@accesssoftek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).