Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [RFC 3/3] Update test cases
Date: Fri, 14 Oct 2016 10:53:00 -0000	[thread overview]
Message-ID: <1476442387-17291-4-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1476442387-17291-1-git-send-email-yao.qi@linaro.org>

If "func" means the function descriptor,

- the compare like "$pc == func" makes no sense,

- "x/2i func+10" shows the instructions on func function descriptor
   address + 10, there shouldn't be any instructions,

- "p func_label - func" no longer shows the offset from function func
   to label func_label.

gdb/testsuite:

2016-10-14  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/break-fun-addr.exp: Test whether $pc is in the start
	of function main.
	* gdb.base/breakpoint-in-ro-region.exp (get_function_bounds): Use
	function start address rather than function name.
	* gdb.base/examine-backward.exp: Stop using "x/i main".
	* gdb.mi/mi-var-cmd.exp: Match possible function descriptor
	address in the output.
	* lib/dwarf.exp (function_range): Use function address instead of
	function name.
	* lib/gdb.exp (get_var_address): Match possible function descriptor
	address in the output.
---
 gdb/testsuite/gdb.base/break-fun-addr.exp          | 4 ++--
 gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp | 2 +-
 gdb/testsuite/gdb.base/examine-backward.exp        | 3 ++-
 gdb/testsuite/gdb.mi/mi-var-cmd.exp                | 4 ++--
 gdb/testsuite/lib/dwarf.exp                        | 5 +++--
 gdb/testsuite/lib/gdb.exp                          | 3 ++-
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break-fun-addr.exp b/gdb/testsuite/gdb.base/break-fun-addr.exp
index e8bed3f..ec4aeb5 100644
--- a/gdb/testsuite/gdb.base/break-fun-addr.exp
+++ b/gdb/testsuite/gdb.base/break-fun-addr.exp
@@ -57,7 +57,7 @@ with_test_prefix "${binfile1}" {
              "run to breakpoint at *main"
 
     # Verify also that we stopped at the start of the function...
-    gdb_test "p \$pc == main" " = 1"
+    gdb_test "x/i \$pc" "<main>:.*"
 }
 
 set testfile2 "break-fun-addr2"
@@ -80,5 +80,5 @@ with_test_prefix "${binfile2}" {
              "Breakpoint.* main \\(\\) at .*$srcfile2:.*" \
              "run to breakpoint at *main"
 
-    gdb_test "p \$pc == main" " = 1"
+    gdb_test "x/i \$pc" "<main>:.*"
 }
diff --git a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
index 0c954c8..d4b2529 100644
--- a/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
+++ b/gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
@@ -76,7 +76,7 @@ proc get_function_bounds {function func_lo func_hi} {
 
     # Account for the size of the last instruction.
     set test "get hi address of $function"
-    gdb_test_multiple "x/2i $function+$size" $test {
+    gdb_test_multiple "x/2i $lo+$size" $test {
 	-re ".*$hex <$function\\+$size>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" {
 	    set hi $expect_out(1,string)
 	    pass $test
diff --git a/gdb/testsuite/gdb.base/examine-backward.exp b/gdb/testsuite/gdb.base/examine-backward.exp
index e03cbfd..16a74c7 100644
--- a/gdb/testsuite/gdb.base/examine-backward.exp
+++ b/gdb/testsuite/gdb.base/examine-backward.exp
@@ -301,7 +301,8 @@ with_test_prefix "backward disassemble general" {
     set length_to_examine {1 2 3 4 10}
     set disassmbly {}
 
-    gdb_test "x/i main" "0x\[0-9a-fA-F\]+ <main>:\t.*" \
+    set main_addr [get_var_address "main"]
+    gdb_test "x/i $main_addr" "0x\[0-9a-fA-F\]+ <main>:\t.*" \
         "move the current position to main (x/i)"
     gdb_test "x/-i" "0x\[0-9a-fA-F\]+ <main>:\t.*" \
         "move the current position to main (x/-i)"
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index 558cd6c..af7307d 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
@@ -349,7 +349,7 @@ mi_gdb_test "-var-assign ldouble 5.333318284590435" \
 	"assign to ldouble"
 
 mi_gdb_test "-var-assign func do_block_tests" \
-	"\\^done,value=\"$hex <do_block_tests>\"" \
+	"\\^done,value=\"(@$hex: )?$hex <do_block_tests>\"" \
 	"assign to func"
 
 mi_gdb_test "-var-assign lsimple.character 'd'" \
@@ -373,7 +373,7 @@ mi_gdb_test "-var-update *" \
 # pointer before comparing with the existing value, 
 # and does not incorrectly make the value as changed.
 mi_gdb_test "-var-assign func do_block_tests" \
-	"\\^done,value=\"$hex <do_block_tests>\"" \
+	"\\^done,value=\"(@$hex: )?$hex <do_block_tests>\"" \
 	"assign same value to func"
 
 mi_gdb_test "-var-update *" \
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 717cbb0..c328c9f 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -127,8 +127,9 @@ proc function_range { func src } {
 
     # Compute the label offset, and we can get the function start address
     # by "${func}_label - $func_label_offset".
+    set func_addr [get_var_address ${func}]
     set func_label_offset ""
-    set test "p ${func}_label - ${func}"
+    set test "p/d ${func}_label - ${func_addr}"
     gdb_test_multiple $test $test {
 	-re ".* = ($decimal)\r\n$gdb_prompt $" {
 	    set func_label_offset $expect_out(1,string)
@@ -151,7 +152,7 @@ proc function_range { func src } {
     } else {
 	set func_pattern "$func\\+$func_length"
     }
-    set test "x/2i $func+$func_length"
+    set test "x/2i $func_addr+$func_length"
     gdb_test_multiple $test $test {
 	-re ".*($hex) <$func_pattern>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" {
 	    set start $expect_out(1,string)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 378eea0..364ee46 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5595,9 +5595,10 @@ proc get_var_address { var } {
     # $1 = (int *) 0x0
     # $5 = (int (*)()) 0
     # $6 = (int (*)()) 0x24 <function_bar>
+    # $7 = (int (*)()) @x12: 0x24 <function_bar>
 
     gdb_test_multiple "print &${var}" "get address of ${var}" {
-	-re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
+	-re "\\\$\[0-9\]+ = \\(.*\\)(?: @$hex:)? (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
 	{
 	    pass "get address of ${var}"
 	    if { $expect_out(1,string) == "0" } {
-- 
1.9.1


      parent reply	other threads:[~2016-10-14 10:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14 10:53 [PATCH 0/3] Fix gdb.base/func-ptrs.exp fails in ppc64 and arm thumb mode Yao Qi
2016-10-14 10:53 ` [PATCH 1/3] Use get_var_address in test cases Yao Qi
2016-10-14 10:53 ` [RFC 2/3] Record function descriptor address instead of function address in value Yao Qi
2016-10-14 17:35   ` Simon Marchi
2016-10-17 11:40     ` Yao Qi
2016-10-17 15:40       ` Simon Marchi
2016-10-17 15:51   ` Ulrich Weigand
2016-10-18  2:27     ` Maciej W. Rozycki
2016-10-18 13:03       ` Yao Qi
2016-10-28 16:20       ` Yao Qi
2017-10-03 18:12         ` Maciej W. Rozycki
2017-10-04 21:25           ` Yao Qi
2016-10-28 16:10     ` Yao Qi
2016-10-28 18:41       ` Ulrich Weigand
2016-10-14 10:53 ` Yao Qi [this message]

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=1476442387-17291-4-git-send-email-yao.qi@linaro.org \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /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