From f0f9e75a824dcd0053ae4e8f9aaf8056aa1a8bc5 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 21 Jul 2020 10:25:42 +0200 Subject: [PATCH] [gdb/testsuite] Make inline-locals.c deterministic When running testcase gdb.opt/inline-locals.exp on openSUSE Tumbleweed, I get: ... (gdb) info locals^M array = {0 , 15775231, 0, 194, 0, -11497, 32767, 4199061, \ 0, 0, 0, 0, 0, 4198992, 0, 4198432, 0}^M (gdb) FAIL: gdb.opt/inline-locals.exp: info locals above bar 2 ... Fix this by: - completely initializing array before printing any value - updating the pattern to match "array = {0 }" Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-21 Tom de Vries * gdb.opt/inline-locals.c (init_array): New func. (func1): Use init_array. * gdb.opt/inline-locals.exp: Update pattern. --- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.opt/inline-locals.c | 9 +++++++++ gdb/testsuite/gdb.opt/inline-locals.exp | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a68c272188c..f395665b132 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-07-21 Tom de Vries + + * gdb.opt/inline-locals.c (init_array): New func. + (func1): Use init_array. + * gdb.opt/inline-locals.exp: Update pattern. + 2020-07-21 Tom de Vries * gdb.debuginfod/fetch_src_and_symbols.exp: Use save_vars for env diff --git a/gdb/testsuite/gdb.opt/inline-locals.c b/gdb/testsuite/gdb.opt/inline-locals.c index 8fb91946fa1..143a09ebc18 100644 --- a/gdb/testsuite/gdb.opt/inline-locals.c +++ b/gdb/testsuite/gdb.opt/inline-locals.c @@ -29,9 +29,18 @@ volatile int *array_p; void bar(void); +void +init_array (int *array, int n) +{ + int i; + for (i = 0; i < n; ++i) + array[i] = 0; +} + inline ATTR int func1(int arg1) { int array[64]; + init_array (array, 64); array_p = array; array[0] = result; array[1] = arg1; diff --git a/gdb/testsuite/gdb.opt/inline-locals.exp b/gdb/testsuite/gdb.opt/inline-locals.exp index 8104b0f5b73..841f1772096 100644 --- a/gdb/testsuite/gdb.opt/inline-locals.exp +++ b/gdb/testsuite/gdb.opt/inline-locals.exp @@ -43,7 +43,7 @@ if { ! $no_frames } { "backtrace from bar 2" gdb_test "up" "#1 .*func1 .* at .*" "up from bar 2" gdb_test "info frame" ".*inlined into frame.*" "func1 inlined 2" - set pass_re "array = {$decimal, \[^\r\n\]*}" + set pass_re "array = \\{0 \\}" set kfail_re [multi_line $pass_re \ "array = { }"] gdb_test_multiple "info locals" "info locals above bar 2" { -- 2.30.2