From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19194 invoked by alias); 21 Jun 2011 10:58:40 -0000 Received: (qmail 19186 invoked by uid 22791); 21 Jun 2011 10:58:40 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Jun 2011 10:58:26 +0000 Received: (qmail 20269 invoked from network); 21 Jun 2011 10:58:25 -0000 Received: from unknown (HELO ?192.168.0.101?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 21 Jun 2011 10:58:25 -0000 Message-ID: <4E00794D.708@codesourcery.com> Date: Tue, 21 Jun 2011 10:58:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [patch 1/2] Fixes to gdb.base/dump.exp: get value from address instead of name References: <4E007587.2050304@codesourcery.com> In-Reply-To: <4E007587.2050304@codesourcery.com> Content-Type: multipart/mixed; boundary="------------010308040909070207010101" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-06/txt/msg00280.txt.bz2 This is a multi-part message in MIME format. --------------010308040909070207010101 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-length: 904 On 06/21/2011 06:42 PM, Yao Qi wrote: > - 2 Start gdb, and reload these dump files. Compare results in dump > files are same as them in memory. In session 2, memory contents are looked for by symbols names. However, the address of the same symbol may be on different addresses in session 1 and session 2, so many tests will fail. This patch is to fix these fails in this way. In gdb session 1, when dump file is being produced, get the address of struct and array, along with their type. In gdb session 2, when dump file is loaded, look for memory contents via address we recorded in session 1. IMO, the intention of tests in this gdb session is to test that "gdb is able to load these dump files, and read the correct memory contents from them", so it doesn't matter too much that gdb get them via name or address. I think the semantics of this part of tests is not changed. -- Yao (齐尧) --------------010308040909070207010101 Content-Type: text/x-patch; name="0015-fix-for-test_reload_saved_value.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0015-fix-for-test_reload_saved_value.patch" Content-length: 3694 2011-06-21 Yao Qi gdb/testsuite/ * gdb.base/dump.exp (capture_value_with_type): New. Get value from address instead of name. --- gdb/testsuite/gdb.base/dump.exp | 46 ++++++++++++++++++++++++++++---------- 1 files changed, 34 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp index 1f307f4..7042abc 100644 --- a/gdb/testsuite/gdb.base/dump.exp +++ b/gdb/testsuite/gdb.base/dump.exp @@ -152,6 +152,25 @@ proc capture_value { expression args } { return $output_string } +proc capture_value_with_type { expression } { + global gdb_prompt + global expect_out + + set test "capture type of $expression" + set output_string "" + gdb_test_multiple "p ${expression}" $test { + -re "\\$\[0-9\]+ = .*$gdb_prompt $" { + if [regexp { \(.*\).*[0-9]+} $expect_out(0,string) output_string] { + pass "$test $output_string" + } else { + fail "$test unable to match regexp" + } + } + } + + return $output_string +} + set array_start [capture_value "/x &intarray\[0\]"] set array_end [capture_value "/x &intarray\[32\]"] set struct_start [capture_value "/x &intstruct"] @@ -160,6 +179,9 @@ set struct_end [capture_value "/x &intstruct + 1"] set array_val [capture_value "intarray"] set struct_val [capture_value "intstruct"] +set array_ptr_type [capture_value_with_type "&intarray"] +set struct_ptr_type [capture_value_with_type "&intstruct"] + make_dump_file "dump mem intarr2.bin $array_start $array_end" \ "dump array as memory, default" @@ -255,38 +277,38 @@ proc test_restore_saved_value { restore_args msg oldval newval } { # srec format can not be loaded for 64-bit-only platforms if ![string compare $is64bitonly "no"] then { test_reload_saved_value "intarr1.srec" "reload array as value, srec" \ - $array_val "intarray" + $array_val "\*$array_ptr_type" test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \ - $struct_val "intstruct" + $struct_val "\*$struct_ptr_type" test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \ - $array_val "intarray" + $array_val "\*$array_ptr_type" test_reload_saved_value "intstr2.srec" "reload struct as memory, srec" \ - $struct_val "intstruct" + $struct_val "\*$struct_ptr_type" } # ihex format can not be loaded for 64-bit-only platforms if ![string compare $is64bitonly "no"] then { test_reload_saved_value "intarr1.ihex" "reload array as value, intel hex" \ - $array_val "intarray" + $array_val "\*$array_ptr_type" test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \ - $struct_val "intstruct" + $struct_val "\*$struct_ptr_type" test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \ - $array_val "intarray" + $array_val "\*$array_ptr_type" test_reload_saved_value "intstr2.ihex" "reload struct as memory, intel hex" \ - $struct_val "intstruct" + $struct_val "\*$struct_ptr_type" } # tekhex format can not be loaded for 64-bit-only platforms if ![string compare $is64bitonly "no"] then { test_reload_saved_value "intarr1.tekhex" "reload array as value, tekhex" \ - $array_val "intarray" + $array_val "\*$array_ptr_type" test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \ - $struct_val "intstruct" + $struct_val "\*$struct_ptr_type" test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \ - $array_val "intarray" + $array_val "\*$array_ptr_type" test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \ - $struct_val "intstruct" + $struct_val "\*$struct_ptr_type" } # Start a fresh gdb session -- 1.7.0.4 --------------010308040909070207010101--