Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch 1/2] Fixes to gdb.base/dump.exp: get value from address instead of name
Date: Thu, 23 Jun 2011 10:28:00 -0000	[thread overview]
Message-ID: <4E031526.6040309@codesourcery.com> (raw)
In-Reply-To: <m339j1kh00.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

On 06/22/2011 11:44 PM, Tom Tromey wrote:
>>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

> 
> Yao> +proc capture_value_with_type { expression } {
> 
> I don't fully understand this proc.  Some comments would help.
> 

Sorry about that.  Some comments are added in new patch.

> Yao> +	    if [regexp { \(.*\).*[0-9]+} $expect_out(0,string) output_string] {
> 
> Is [0-9]+ really correct?
> I would have thought the results would be in hex.

Oh, you are right.  Fixed.

> This would be a good spot for a comment describing the expected output.
> 

Comment is added.

> Yao> +		pass "$test $output_string"
> Yao> +	    } else {
> Yao> +		fail "$test unable to match regexp"
> Yao> +	    }
> 
> Passes and fails should use the same text.

Fixed.

patch 2/2 is unchanged.

-- 
Yao (齐尧)

[-- Attachment #2: 0017-fix-for-test_reload_saved_value.patch --]
[-- Type: text/x-patch, Size: 4109 bytes --]

	gdb/testsuite/
	* gdb.base/dump.exp (capture_pointer_with_type): New.
	Get value from address instead of name.

---
 gdb/testsuite/gdb.base/dump.exp |   55 ++++++++++++++++++++++++++++++--------
 1 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index 1f307f4..15bb249 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -152,6 +152,34 @@ proc capture_value { expression args } {
     return $output_string
 }
 
+# POINTER is a pointer and this proc captures the value of POINTER along
+# with POINTER's type.  For example, POINTER is "&intarray", this proc will
+# call "p &intarray", capture "(int (*)[32]) 0x804a0e0", and return this
+# string.
+
+proc capture_pointer_with_type { pointer } {
+    global gdb_prompt
+    global expect_out
+
+    set test "capture type of pointer $pointer"
+    set output_string ""
+    gdb_test_multiple "p ${pointer}" $test {
+	-re "\\$\[0-9\]+ = .*$gdb_prompt $" {
+	    # Expected output of "p ${pointer}" is like "$7 = (int (*)[32]) 0x804a0e0",
+	    # and we want to extract "(int (*)[32]) 0x804a0e0" from it via
+	    # following regexp.
+	    if [regexp { \(.*\).*[a-fA-F0-9]+} $expect_out(0,string) output_string] {
+		# OUTPUT_STRING is expected to be like "(int (*)[32]) 0x804a0e0".
+		pass "$test"
+	    } else {
+		fail "$test"
+	    }
+	}
+    }
+
+    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 +188,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_pointer_with_type "&intarray"]
+set struct_ptr_type [capture_pointer_with_type "&intstruct"]
+
 make_dump_file "dump mem intarr2.bin $array_start $array_end" \
 	"dump array as memory, default"
 
@@ -255,38 +286,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


  reply	other threads:[~2011-06-23 10:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21 10:42 [patch 0/2] Fixes to gdb.base/dump.exp Yao Qi
2011-06-21 10:58 ` [patch 1/2] Fixes to gdb.base/dump.exp: get value from address instead of name Yao Qi
2011-06-22 15:45   ` Tom Tromey
2011-06-23 10:28     ` Yao Qi [this message]
2011-07-01 14:16       ` Yao Qi
2011-07-01 14:23         ` Tom Tromey
2011-07-01 16:51           ` [committed] " Yao Qi
2011-06-21 11:05 ` [patch 2/2] Fixes to gdb.base/dump.exp: Combine dump and restore in a single session Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E031526.6040309@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox