Fix coredump-filter.exp by correctly unsetting array (was: Re: [rfc] Fix PR 18208: update /proc/pid/coredump_filter by c code)

Message ID 87mw1g1fp2.fsf_-_@redhat.com
State New, archived
Headers

Commit Message

Sergio Durigan Junior May 7, 2015, 5:05 p.m. UTC
  On Thursday, May 07 2015, Luis Machado wrote:

> Besides that, without the conditional block i also see a problem with
> the existing testcase using coredump_var_addr as an array but
> declaring it as a regular variable. It causes a number of errors. Did
> you notice that? Maybe it is specific to a certain version of expect.
>
> # Obtain the address of each variable that will be checked on each
> # case.
> set coredump_var_addr ""
> foreach item $all_anon_corefiles {
>     foreach name [list [lindex $item 3] [lindex $item 4]] {
>         set test "print/x $name"
>         gdb_test_multiple $test $test {
>             -re " = \($hex\)\r\n$gdb_prompt $" {
>                 set coredump_var_addr($name) $expect_out(1,string)
>             }
>         }
>     }
> }

Thanks for catching this.

This is because of the discussion on:

  <https://sourceware.org/ml/gdb-patches/2015-04/msg00452.html>

And the patch:

  <https://sourceware.org/ml/gdb-patches/2015-04/msg00979.html>

It seems it is not possible to "clear" the variable using "" and then
use as an array.  I think the best way would be to call 'unset
-nocomplain' in this case.  The following patch does this.  With it
applied, the test fully passes on Fedora 20 x86_64 native.

WDYT?
  

Comments

Yao Qi May 8, 2015, 11:57 a.m. UTC | #1
Sergio Durigan Junior <sergiodj@redhat.com> writes:

> It seems it is not possible to "clear" the variable using "" and then
> use as an array.  I think the best way would be to call 'unset
> -nocomplain' in this case.  The following patch does this.  With it
> applied, the test fully passes on Fedora 20 x86_64 native.
>
> WDYT?

Your patch is fine by me.
  
Sergio Durigan Junior May 8, 2015, 5:23 p.m. UTC | #2
On Friday, May 08 2015, Yao Qi wrote:

> Sergio Durigan Junior <sergiodj@redhat.com> writes:
>
>> It seems it is not possible to "clear" the variable using "" and then
>> use as an array.  I think the best way would be to call 'unset
>> -nocomplain' in this case.  The following patch does this.  With it
>> applied, the test fully passes on Fedora 20 x86_64 native.
>>
>> WDYT?
>
> Your patch is fine by me.

Thanks, pushed.

  <https://sourceware.org/ml/gdb-cvs/2015-05/msg00031.html>
  f7797074a5dc314f8922d2e90c1a4ea04b189c36
  

Patch

diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp
index 72f756a..c601939 100644
--- a/gdb/testsuite/gdb.base/coredump-filter.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter.exp
@@ -170,7 +170,7 @@  gdb_test_multiple "print/x &main" "getting main's address" {
 
 # Obtain the address of each variable that will be checked on each
 # case.
-set coredump_var_addr ""
+unset -nocomplain coredump_var_addr
 foreach item $all_anon_corefiles {
     foreach name [list [lindex $item 3] [lindex $item 4]] {
 	set test "print/x $name"