ubsan: bpf: left shift cannot be represented in type 'DI' (aka 'long')
[deliverable/binutils-gdb.git] / gdb / contrib / cc-with-tweaks.sh
index a65fef8993be08c449ff279ca8b7653b7f08ceaf..98c4f89afc9be60f45b44045802a9b9589bc6ca0 100755 (executable)
@@ -2,7 +2,7 @@
 # Wrapper around gcc to tweak the output in various ways when running
 # the testsuite.
 
-# Copyright (C) 2010-2017 Free Software Foundation, Inc.
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
@@ -42,7 +42,8 @@
 # -Z invoke objcopy --compress-debug-sections
 # -z compress using dwz
 # -m compress using dwz -m
-# -i make an index
+# -i make an index (.gdb_index)
+# -n make a dwarf5 index (.debug_names)
 # -p create .dwp files (Fission), you need to also use gcc option -gsplit-dwarf
 # If nothing is given, no changes are made
 
@@ -77,6 +78,7 @@ next_is_output_file=no
 output_file=a.out
 
 want_index=false
+index_options=""
 want_dwz=false
 want_multi=false
 want_dwp=false
@@ -87,6 +89,7 @@ while [ $# -gt 0 ]; do
        -Z) want_objcopy_compress=true ;;
        -z) want_dwz=true ;;
        -i) want_index=true ;;
+       -n) want_index=true; index_options=-dwarf-5;;
        -m) want_multi=true ;;
        -p) want_dwp=true ;;
        *) break ;;
@@ -160,6 +163,12 @@ then
     exit 1
 fi
 
+get_tmpdir ()
+{
+    tmpdir=$(dirname "$output_file")/.tmp
+    mkdir -p "$tmpdir"
+}
+
 if [ "$want_objcopy_compress" = true ]; then
     $OBJCOPY --compress-debug-sections "$output_file"
     rc=$?
@@ -170,16 +179,50 @@ if [ "$want_index" = true ]; then
     # 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
+    GDB=$GDB $GDB_ADD_INDEX $index_options "$output_file" 2>&1 \
+       | grep -v "^${GDB_ADD_INDEX##*/}: " >&2
     rc=${PIPESTATUS[0]}
     [ $rc != 0 ] && exit $rc
 fi
 
 if [ "$want_dwz" = true ]; then
-    $DWZ "$output_file" > /dev/null 2>&1
+    # Validate dwz's result by checking if the executable was modified.
+    cp "$output_file" "${output_file}.copy"
+    $DWZ "$output_file" > /dev/null
+    cmp "$output_file" "$output_file.copy" > /dev/null
+    cmp_rc=$?
+    rm -f "${output_file}.copy"
+
+    case $cmp_rc in
+    0)
+       echo "$myname: dwz did not modify ${output_file}."
+        exit 1
+       ;;
+    1)
+       # File was modified, great.
+       ;;
+    *)
+       # Other cmp error, it presumably has already printed something on
+       # stderr.
+       exit 1
+       ;;
+    esac
 elif [ "$want_multi" = true ]; then
+    get_tmpdir
+    dwz_file=$tmpdir/$(basename "$output_file").dwz
+    # Remove the dwz output file if it exists, so we don't mistake it for a
+    # new file in case dwz fails.
+    rm -f "$dwz_file"
+
     cp $output_file ${output_file}.alt
-    $DWZ -m ${output_file}.dwz "$output_file" ${output_file}.alt > /dev/null 2>&1
+    $DWZ -m "$dwz_file" "$output_file" ${output_file}.alt > /dev/null
+    rm -f ${output_file}.alt
+
+    # Validate dwz's work by checking if the expected output file exists.
+    if [ ! -f "$dwz_file" ]; then
+       echo "$myname: dwz file $dwz_file missing."
+       exit 1
+    fi
 fi
 
 if [ "$want_dwp" = true ]; then
This page took 0.024965 seconds and 4 git commands to generate.