Re: [committed][gdb/testsuite] Make gdb.base/dbx.exp more robust

Tom de Vries
2020-06-11T14:52:25Z

On 11-06-2020 16:39, Simon Marchi wrote:
> On 2020-06-11 8:11 a.m., Tom de Vries wrote:
>> [ was: Re: [PATCH 3/3][gdb/testsuite] Warn about leaked global array ]
>>
>> On 04-06-2020 13:40, Tom de Vries wrote:
>>>> BTW, global variables alone aren't the full scope of the
>>>> bleeding between testcases. There's also the case of
>>>> testcases overriding procedures, like gdb.base/dbx.exp,
>>>> but those are perhaps rare enough that we can continue
>>>> handling it "manually" as before.
>>> AFAICT, that test-case does an effort to undo the override, though I'm
>>> not sure how certain it is that the undo will be executed.
>>
>> I've committed patch below to make sure the undo is executed (and
>> similar for GDBFLAGS).
>>
>> Thanks,
>> - Tom
>>
>
> Ah! That reminded me that I had a patch I had forgotten about that did something
> similar:
>
> https://sourceware.org/pipermail/gdb-patches/2020-May/169109.html
>

Sorry, didn't notice that one.

> I'm fine with your version.

Right, I see the solutions are really the same.

> One nit: you have an unnecessary return at the end of
> the with_override proc.

Um, if I add this code to a random test-case:
...
diff --git a/gdb/testsuite/gdb.ada/O2_float_param.exp
b/gdb/testsuite/gdb.ada/O2_float_param.exp
index 09ebeec405..31c36c9cde 100644
--- a/gdb/testsuite/gdb.ada/O2_float_param.exp
+++ b/gdb/testsuite/gdb.ada/O2_float_param.exp
@@ -29,3 +29,17 @@ runto "increment"

gdb_test "frame" \
"#0\\s+callee\\.increment \\(val(=val@entry)?=99\\.0,
msg=\\.\\.\\.\\).*"
+
+proc foo { } {
+ return 1
+}
+
+proc foo_2 {} {
+ return 2
+}
+
+set res [foo]
+puts "RES: $res"
+
+set res [with_override foo foo_2 foo]
+puts "RES: $res"
...

And run it, I get:
...
RES: 1
RES: 2
...
but if I remove the return at the end of with_override, I get instead:
...
Running
/data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/O2_float_param.exp ...
RES: 1
RES:
...

So, I'm not sure why you say that it's not necessary.

Thanks,
- Tom