[RFC 3/3] Update test cases

Yao Qi
2016-10-14T10:53:29Z

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" " :.*"
}

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" " :.*"
}
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\]+ :\t.*" \
+ set main_addr [get_var_address "main"]
+ gdb_test "x/i $main_addr" "0x\[0-9a-fA-F\]+ :\t.*" \
"move the current position to main (x/i)"
gdb_test "x/-i" "0x\[0-9a-fA-F\]+ :\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