Skip to content

Commit

Permalink
debuginfo: Fix gdbr-check expectations of formatting
Browse files Browse the repository at this point in the history
This was a largely automated process, driven by the hack of a shell
script below.  The process to generate the patch was to repeatedly run
the script until the changes reached a fixed-point.

```bash

set -euo pipefail

O=$(mktemp)
./x.py test src/test/debuginfo 2>&1 | tee $O || true

awk '
function escape_pattern(pat,   safe) {
  safe = pat
  gsub(/[][^$.*?+{}\\()|]/, "\\\\&", safe)
  return safe
}

BEGIN { p = 0; n = 0; }

/---- \[debuginfo-gdb\]/ {
	if (p == 1) {
		printf("%s|%s|%s\n", src, error, expected);
	}
	src = $3;
	p = 1;
	n = 0;
	name = "";
}

n == 1 && $0 ~ name {
	expected = $0;
	n = 0;
}

/error: line not found in debugger output/ {
	error = substr($0,43);
	split(error, pieces);
	name = escape_pattern(pieces[1]);
	print "Found " name " in: " $0 > "/dev/stderr"
	n = 1;
}

END { printf("%s|%s|%s\n", src, error, expected); }
' $O |
while read l; do
	SRC="$(echo "$l" | cut -d'|' -f1 | sed 's/debuginfo-gdb/debuginfo/')"
	ERR="$(echo "$l" | cut -d'|' -f2)"
	V="$(echo "$ERR" | cut -d' ' -f1 | sed 's/\$/\\$/g')"
	EX="$(echo "$l" | cut -d'|' -f3)"
	if echo "$EX" | grep '^\$' > /dev/null; then
		echo $SRC
		sed -ri '/\/\/ gdbr-check:'"$V"' /s|(// gdbr-check:).*|\1'"$EX"'|' src/test/$SRC
	else
		# this is a bit questionable
		EX="$(echo "$l" | cut -d'|' -f2)"
		sed -ri '/\/\/ gdbr-check:'"$V"' /s|(// gdbr-check:).*|\1'"$EX"'|' src/test/$SRC
		echo $SRC: Failed to patch with: $l
	fi
done

echo $O
```
  • Loading branch information
amboar committed Feb 14, 2017
1 parent 0df87d9 commit 67bffe3
Show file tree
Hide file tree
Showing 49 changed files with 233 additions and 233 deletions.
4 changes: 2 additions & 2 deletions src/test/debuginfo/associated-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// gdb-command:print arg
// gdbg-check:$1 = {b = -1, b1 = 0}
// gdbr-check:$1 = associated_types::Struct<i32> {b: -1, b1: 0}
// gdbr-check:$1 = Struct<i32> = {b = -1, b1 = 0}
// gdb-command:continue

// gdb-command:print inferred
Expand All @@ -32,7 +32,7 @@

// gdb-command:print arg
// gdbg-check:$5 = {__0 = 4, __1 = 5}
// gdbr-check:$5 = (4, 5)
// gdbr-check:$5 = {4, 5}
// gdb-command:continue

// gdb-command:print a
Expand Down
6 changes: 3 additions & 3 deletions src/test/debuginfo/borrowed-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

// gdb-command:print *the_a_ref
// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
// gdbr-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452}
// gdbr-check:$1 = TheA = {x = 0, y = 8970181431921507452}

// gdb-command:print *the_b_ref
// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
// gdbr-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153)
// gdbr-check:$2 = TheB = {0, 286331153, 286331153}

// gdb-command:print *univariant_ref
// gdbg-check:$3 = {{__0 = 4820353753753434}}
// gdbr-check:$3 = borrowed_enum::Univariant::TheOnlyCase(4820353753753434)
// gdbr-check:$3 = TheOnlyCase = {4820353753753434}


// === LLDB TESTS ==================================================================================
Expand Down
6 changes: 3 additions & 3 deletions src/test/debuginfo/borrowed-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// gdb-command:print *stack_val_ref
// gdbg-check:$1 = {x = 10, y = 23.5}
// gdbr-check:$1 = borrowed_struct::SomeStruct {x: 10, y: 23.5}
// gdbr-check:$1 = SomeStruct = {x = 10, y = 23.5}

// gdb-command:print *stack_val_interior_ref_1
// gdb-check:$2 = 10
Expand All @@ -27,11 +27,11 @@

// gdb-command:print *ref_to_unnamed
// gdbg-check:$4 = {x = 11, y = 24.5}
// gdbr-check:$4 = borrowed_struct::SomeStruct {x: 11, y: 24.5}
// gdbr-check:$4 = SomeStruct = {x = 11, y = 24.5}

// gdb-command:print *unique_val_ref
// gdbg-check:$5 = {x = 13, y = 26.5}
// gdbr-check:$5 = borrowed_struct::SomeStruct {x: 13, y: 26.5}
// gdbr-check:$5 = SomeStruct = {x = 13, y = 26.5}

// gdb-command:print *unique_val_interior_ref_1
// gdb-check:$6 = 13
Expand Down
6 changes: 3 additions & 3 deletions src/test/debuginfo/borrowed-tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

// gdb-command:print *stack_val_ref
// gdbg-check:$1 = {__0 = -14, __1 = -19}
// gdbr-check:$1 = (-14, -19)
// gdbr-check:$1 = {-14, -19}

// gdb-command:print *ref_to_unnamed
// gdbg-check:$2 = {__0 = -15, __1 = -20}
// gdbr-check:$2 = (-15, -20)
// gdbr-check:$2 = {-15, -20}

// gdb-command:print *unique_val_ref
// gdbg-check:$3 = {__0 = -17, __1 = -22}
// gdbr-check:$3 = (-17, -22)
// gdbr-check:$3 = {-17, -22}


// === LLDB TESTS ==================================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// gdb-check:$1 = 1
// gdb-command:print *b
// gdbg-check:$2 = {__0 = 2, __1 = 3.5}
// gdbr-check:$2 = (2, 3.5)
// gdbr-check:$2 = {2, 3.5}


// === LLDB TESTS ==================================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/test/debuginfo/boxed-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

// gdb-command:print *unique
// gdbg-check:$1 = {x = 99, y = 999, z = 9999, w = 99999}
// gdbr-check:$1 = boxed_struct::StructWithSomePadding {x: 99, y: 999, z: 9999, w: 99999}
// gdbr-check:$1 = StructWithSomePadding = {x = 99, y = 999, z = 9999, w = 99999}

// gdb-command:print *unique_dtor
// gdbg-check:$2 = {x = 77, y = 777, z = 7777, w = 77777}
// gdbr-check:$2 = boxed_struct::StructWithDestructor {x: 77, y: 777, z: 7777, w: 77777}
// gdbr-check:$2 = StructWithDestructor = {x = 77, y = 777, z = 7777, w = 77777}


// === LLDB TESTS ==================================================================================
Expand Down
10 changes: 5 additions & 5 deletions src/test/debuginfo/by-value-non-immediate-argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

// gdb-command:print s
// gdbg-check:$1 = {a = 1, b = 2.5}
// gdbr-check:$1 = by_value_non_immediate_argument::Struct {a: 1, b: 2.5}
// gdbr-check:$1 = Struct = {a = 1, b = 2.5}
// gdb-command:continue

// gdb-command:print x
// gdbg-check:$2 = {a = 3, b = 4.5}
// gdbr-check:$2 = by_value_non_immediate_argument::Struct {a: 3, b: 4.5}
// gdbr-check:$2 = Struct = {a = 3, b = 4.5}
// gdb-command:print y
// gdb-check:$3 = 5
// gdb-command:print z
Expand All @@ -33,17 +33,17 @@

// gdb-command:print a
// gdbg-check:$5 = {__0 = 7, __1 = 8, __2 = 9.5, __3 = 10.5}
// gdbr-check:$5 = (7, 8, 9.5, 10.5)
// gdbr-check:$5 = {7, 8, 9.5, 10.5}
// gdb-command:continue

// gdb-command:print a
// gdbg-check:$6 = {__0 = 11.5, __1 = 12.5, __2 = 13, __3 = 14}
// gdbr-check:$6 = by_value_non_immediate_argument::Newtype (11.5, 12.5, 13, 14)
// gdbr-check:$6 = Newtype = {11.5, 12.5, 13, 14}
// gdb-command:continue

// gdb-command:print x
// gdbg-check:$7 = {{RUST$ENUM$DISR = Case1, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$7 = by_value_non_immediate_argument::Enum::Case1{x: 0, y: 8970181431921507452}
// gdbr-check:$7 = Case1 = {x = 0, y = 8970181431921507452}
// gdb-command:continue


Expand Down
4 changes: 2 additions & 2 deletions src/test/debuginfo/by-value-self-argument-in-trait-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

// gdb-command:print self
// gdbg-check:$2 = {x = 2222, y = 3333}
// gdbr-check:$2 = by_value_self_argument_in_trait_impl::Struct {x: 2222, y: 3333}
// gdbr-check:$2 = Struct = {x = 2222, y = 3333}
// gdb-command:continue

// gdb-command:print self
// gdbg-check:$3 = {__0 = 4444.5, __1 = 5555, __2 = 6666, __3 = 7777.5}
// gdbr-check:$3 = (4444.5, 5555, 6666, 7777.5)
// gdbr-check:$3 = {4444.5, 5555, 6666, 7777.5}
// gdb-command:continue


Expand Down
14 changes: 7 additions & 7 deletions src/test/debuginfo/c-style-enum-in-composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@

// gdb-command:print tuple_interior_padding
// gdbg-check:$1 = {__0 = 0, __1 = OneHundred}
// gdbr-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred)
// gdbr-check:$1 = {0, c_style_enum_in_composite::AnEnum::OneHundred}

// gdb-command:print tuple_padding_at_end
// gdbg-check:$2 = {__0 = {__0 = 1, __1 = OneThousand}, __1 = 2}
// gdbr-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2)
// gdbr-check:$2 = {{1, c_style_enum_in_composite::AnEnum::OneThousand}, 2}

// gdb-command:print tuple_different_enums
// gdbg-check:$3 = {__0 = OneThousand, __1 = MountainView, __2 = OneMillion, __3 = Vienna}
// gdbr-check:$3 = (c_style_enum_in_composite::AnEnum::OneThousand, c_style_enum_in_composite::AnotherEnum::MountainView, c_style_enum_in_composite::AnEnum::OneMillion, c_style_enum_in_composite::AnotherEnum::Vienna)
// gdbr-check:$3 = {c_style_enum_in_composite::AnEnum::OneThousand, c_style_enum_in_composite::AnotherEnum::MountainView, c_style_enum_in_composite::AnEnum::OneMillion, c_style_enum_in_composite::AnotherEnum::Vienna}

// gdb-command:print padded_struct
// gdbg-check:$4 = {a = 3, b = OneMillion, c = 4, d = Toronto, e = 5}
// gdbr-check:$4 = c_style_enum_in_composite::PaddedStruct {a: 3, b: c_style_enum_in_composite::AnEnum::OneMillion, c: 4, d: c_style_enum_in_composite::AnotherEnum::Toronto, e: 5}
// gdbr-check:$4 = PaddedStruct = {a = 3, b = c_style_enum_in_composite::AnEnum::OneMillion, c = 4, d = c_style_enum_in_composite::AnotherEnum::Toronto, e = 5}

// gdb-command:print packed_struct
// gdbg-check:$5 = {a = 6, b = OneHundred, c = 7, d = Vienna, e = 8}
// gdbr-check:$5 = c_style_enum_in_composite::PackedStruct {a: 6, b: c_style_enum_in_composite::AnEnum::OneHundred, c: 7, d: c_style_enum_in_composite::AnotherEnum::Vienna, e: 8}
// gdbr-check:$5 = PackedStruct = {a = 6, b = c_style_enum_in_composite::AnEnum::OneHundred, c = 7, d = c_style_enum_in_composite::AnotherEnum::Vienna, e = 8}

// gdb-command:print non_padded_struct
// gdbg-check:$6 = {a = OneMillion, b = MountainView, c = OneThousand, d = Toronto}
// gdbr-check:$6 = c_style_enum_in_composite::NonPaddedStruct {a: c_style_enum_in_composite::AnEnum::OneMillion, b: c_style_enum_in_composite::AnotherEnum::MountainView, c: c_style_enum_in_composite::AnEnum::OneThousand, d: c_style_enum_in_composite::AnotherEnum::Toronto}
// gdbr-check:$6 = NonPaddedStruct = {a = c_style_enum_in_composite::AnEnum::OneMillion, b = c_style_enum_in_composite::AnotherEnum::MountainView, c = c_style_enum_in_composite::AnEnum::OneThousand, d = c_style_enum_in_composite::AnotherEnum::Toronto}

// gdb-command:print struct_with_drop
// gdbg-check:$7 = {__0 = {a = OneHundred, b = Vienna}, __1 = 9}
// gdbr-check:$7 = (c_style_enum_in_composite::StructWithDrop {a: c_style_enum_in_composite::AnEnum::OneHundred, b: c_style_enum_in_composite::AnotherEnum::Vienna}, 9)
// gdbr-check:$7 = {StructWithDrop = {a = c_style_enum_in_composite::AnEnum::OneHundred, b = c_style_enum_in_composite::AnotherEnum::Vienna}, 9}

// === LLDB TESTS ==================================================================================

Expand Down
4 changes: 2 additions & 2 deletions src/test/debuginfo/cross-crate-spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern crate cross_crate_spans;

// gdb-command:print result
// gdbg-check:$1 = {__0 = 17, __1 = 17}
// gdbr-check:$1 = (17, 17)
// gdbr-check:$1 = {17, 17}
// gdb-command:print a_variable
// gdb-check:$2 = 123456789
// gdb-command:print another_variable
Expand All @@ -35,7 +35,7 @@ extern crate cross_crate_spans;

// gdb-command:print result
// gdbg-check:$4 = {__0 = 1212, __1 = 1212}
// gdbr-check:$4 = (1212, 1212)
// gdbr-check:$4 = {1212, 1212}
// gdb-command:print a_variable
// gdb-check:$5 = 123456789
// gdb-command:print another_variable
Expand Down
16 changes: 8 additions & 8 deletions src/test/debuginfo/destructured-fn-argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
// gdb-check:$6 = 5
// gdb-command:print b
// gdbg-check:$7 = {__0 = 6, __1 = 7}
// gdbr-check:$7 = (6, 7)
// gdbr-check:$7 = {6, 7}
// gdb-command:continue

// gdb-command:print h
// gdb-check:$8 = 8
// gdb-command:print i
// gdbg-check:$9 = {a = 9, b = 10}
// gdbr-check:$9 = destructured_fn_argument::Struct {a: 9, b: 10}
// gdbr-check:$9 = Struct = {a = 9, b = 10}
// gdb-command:print j
// gdb-check:$10 = 11
// gdb-command:continue
Expand All @@ -68,7 +68,7 @@
// gdb-check:$17 = 20
// gdb-command:print r
// gdbg-check:$18 = {a = 21, b = 22}
// gdbr-check:$18 = destructured_fn_argument::Struct {a: 21, b: 22}
// gdbr-check:$18 = Struct = {a = 21, b = 22}
// gdb-command:continue

// gdb-command:print s
Expand Down Expand Up @@ -99,12 +99,12 @@

// gdb-command:print aa
// gdbg-check:$30 = {__0 = 34, __1 = 35}
// gdbr-check:$30 = (34, 35)
// gdbr-check:$30 = {34, 35}
// gdb-command:continue

// gdb-command:print bb
// gdbg-check:$31 = {__0 = 36, __1 = 37}
// gdbr-check:$31 = (36, 37)
// gdbr-check:$31 = {36, 37}
// gdb-command:continue

// gdb-command:print cc
Expand All @@ -113,19 +113,19 @@

// gdb-command:print dd
// gdbg-check:$33 = {__0 = 40, __1 = 41, __2 = 42}
// gdbr-check:$33 = (40, 41, 42)
// gdbr-check:$33 = {40, 41, 42}
// gdb-command:continue

// gdb-command:print *ee
// gdbg-check:$34 = {__0 = 43, __1 = 44, __2 = 45}
// gdbr-check:$34 = (43, 44, 45)
// gdbr-check:$34 = {43, 44, 45}
// gdb-command:continue

// gdb-command:print *ff
// gdb-check:$35 = 46
// gdb-command:print gg
// gdbg-check:$36 = {__0 = 47, __1 = 48}
// gdbr-check:$36 = (47, 48)
// gdbr-check:$36 = {47, 48}
// gdb-command:continue

// gdb-command:print *hh
Expand Down
4 changes: 2 additions & 2 deletions src/test/debuginfo/destructured-for-loop-variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@

// gdb-command:print simple_struct_ident
// gdbg-check:$23 = {x = 3537, y = 35437.5, z = true}
// gdbr-check:$23 = destructured_for_loop_variable::Struct {x: 3537, y: 35437.5, z: true}
// gdbr-check:$23 = Struct = {x = 3537, y = 35437.5, z = true}
// gdb-command:continue

// gdb-command:print simple_tuple_ident
// gdbg-check:$24 = {__0 = 34903493, __1 = 232323}
// gdbr-check:$24 = (34903493, 232323)
// gdbr-check:$24 = {34903493, 232323}
// gdb-command:continue

// === LLDB TESTS ==================================================================================
Expand Down
16 changes: 8 additions & 8 deletions src/test/debuginfo/destructured-local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
// gdb-check:$6 = 5
// gdb-command:print g
// gdbg-check:$7 = {__0 = 6, __1 = 7}
// gdbr-check:$7 = (6, 7)
// gdbr-check:$7 = {6, 7}

// gdb-command:print h
// gdb-check:$8 = 8
// gdb-command:print i
// gdbg-check:$9 = {a = 9, b = 10}
// gdbr-check:$9 = destructured_local::Struct {a: 9, b: 10}
// gdbr-check:$9 = Struct = {a = 9, b = 10}
// gdb-command:print j
// gdb-check:$10 = 11

Expand All @@ -61,7 +61,7 @@
// gdb-check:$17 = 20
// gdb-command:print r
// gdbg-check:$18 = {a = 21, b = 22}
// gdbr-check:$18 = destructured_local::Struct {a: 21, b: 22}
// gdbr-check:$18 = Struct = {a = 21, b = 22}

// gdb-command:print s
// gdb-check:$19 = 24
Expand Down Expand Up @@ -89,29 +89,29 @@

// gdb-command:print aa
// gdbg-check:$30 = {__0 = 34, __1 = 35}
// gdbr-check:$30 = (34, 35)
// gdbr-check:$30 = {34, 35}

// gdb-command:print bb
// gdbg-check:$31 = {__0 = 36, __1 = 37}
// gdbr-check:$31 = (36, 37)
// gdbr-check:$31 = {36, 37}

// gdb-command:print cc
// gdb-check:$32 = 38

// gdb-command:print dd
// gdbg-check:$33 = {__0 = 40, __1 = 41, __2 = 42}
// gdbr-check:$33 = (40, 41, 42)
// gdbr-check:$33 = {40, 41, 42}

// gdb-command:print *ee
// gdbg-check:$34 = {__0 = 43, __1 = 44, __2 = 45}
// gdbr-check:$34 = (43, 44, 45)
// gdbr-check:$34 = {43, 44, 45}

// gdb-command:print *ff
// gdb-check:$35 = 46

// gdb-command:print gg
// gdbg-check:$36 = {__0 = 47, __1 = 48}
// gdbr-check:$36 = (47, 48)
// gdbr-check:$36 = {47, 48}

// gdb-command:print *hh
// gdb-check:$37 = 50
Expand Down
10 changes: 5 additions & 5 deletions src/test/debuginfo/evec-in-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@

// gdb-command:print no_padding1
// gdbg-check:$1 = {x = {0, 1, 2}, y = -3, z = {4.5, 5.5}}
// gdbr-check:$1 = evec_in_struct::NoPadding1 {x: [0, 1, 2], y: -3, z: [4.5, 5.5]}
// gdbr-check:$1 = NoPadding1 = {x = [0, 1, 2], y = -3, z = [4.5, 5.5]}
// gdb-command:print no_padding2
// gdbg-check:$2 = {x = {6, 7, 8}, y = {{9, 10}, {11, 12}}}
// gdbr-check:$2 = evec_in_struct::NoPadding2 {x: [6, 7, 8], y: [[9, 10], [11, 12]]}
// gdbr-check:$2 = NoPadding2 = {x = [6, 7, 8], y = [[9, 10], [11, 12]]}

// gdb-command:print struct_internal_padding
// gdbg-check:$3 = {x = {13, 14}, y = {15, 16}}
// gdbr-check:$3 = evec_in_struct::StructInternalPadding {x: [13, 14], y: [15, 16]}
// gdbr-check:$3 = StructInternalPadding = {x = [13, 14], y = [15, 16]}

// gdb-command:print single_vec
// gdbg-check:$4 = {x = {17, 18, 19, 20, 21}}
// gdbr-check:$4 = evec_in_struct::SingleVec {x: [17, 18, 19, 20, 21]}
// gdbr-check:$4 = SingleVec = {x = [17, 18, 19, 20, 21]}

// gdb-command:print struct_padded_at_end
// gdbg-check:$5 = {x = {22, 23}, y = {24, 25}}
// gdbr-check:$5 = evec_in_struct::StructPaddedAtEnd {x: [22, 23], y: [24, 25]}
// gdbr-check:$5 = StructPaddedAtEnd = {x = [22, 23], y = [24, 25]}


// === LLDB TESTS ==================================================================================
Expand Down
Loading

0 comments on commit 67bffe3

Please sign in to comment.