-# Copyright 2002-2018 Free Software Foundation, Inc.
+# Copyright 2002-2020 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x0\[\r\n\]+\\(y or n\\) " \
"y"
-# Print the addresses of static variables.
-set static_foo_addr [get_var_address static_foo]
-set static_bar_addr [get_var_address static_bar]
+with_test_prefix "print addresses, static vars" {
+ # Print the addresses of static variables.
+ set static_foo_addr [get_var_address static_foo]
+ set static_bar_addr [get_var_address static_bar]
+}
# Make sure they have different addresses.
if { "${static_foo_addr}" == "${static_bar_addr}" } {
pass "static variables have different addresses"
}
-# Print the addresses of global variables.
-set global_foo_addr [get_var_address global_foo]
-set global_bar_addr [get_var_address global_bar]
+with_test_prefix "print addresses, global vars" {
+ # Print the addresses of global variables.
+ set global_foo_addr [get_var_address global_foo]
+ set global_bar_addr [get_var_address global_bar]
+}
# Make sure they have different addresses.
if { "${global_foo_addr}" == "${global_bar_addr}" } {
pass "global variables have different addresses"
}
-# Print the addresses of functions.
-set function_foo_addr [get_var_address function_foo]
-set function_bar_addr [get_var_address function_bar]
+with_test_prefix "print addresses, functions" {
+ # Print the addresses of functions.
+ set function_foo_addr [get_var_address function_foo]
+ set function_bar_addr [get_var_address function_bar]
+}
# Make sure they have different addresses.
if { "${function_foo_addr}" == "${function_bar_addr}" } {
"Reading symbols from ${binfile}\.\.\." \
"symbol-file with offset"
-# Make sure the address of a static variable is moved by offset.
-set new_static_foo_addr [get_var_address static_foo]
-gdb_assert {${new_static_foo_addr} == ${static_foo_addr} + $offset} \
- "static variable foo is moved by offset"
+with_test_prefix "static vars" {
+ # Make sure the address of a static variable is moved by offset.
+ set new_static_foo_addr [get_var_address static_foo]
+ gdb_assert {${new_static_foo_addr} == ${static_foo_addr} + $offset} \
+ "static variable foo is moved by offset"
+}
-# Make sure the address of a global variable is moved by offset.
-set new_global_foo_addr [get_var_address global_foo]
-gdb_assert {${new_global_foo_addr} == ${global_foo_addr} + $offset} \
- "global variable foo is moved by offset"
+with_test_prefix "global vars" {
+ # Make sure the address of a global variable is moved by offset.
+ set new_global_foo_addr [get_var_address global_foo]
+ gdb_assert {${new_global_foo_addr} == ${global_foo_addr} + $offset} \
+ "global variable foo is moved by offset"
+}
-# Make sure the address of a function is moved by offset.
-set new_function_foo_addr [get_var_address function_foo]
-gdb_assert {${new_function_foo_addr} == ${function_foo_addr} + $offset} \
- "function foo is moved by offset"
+with_test_prefix "functions" {
+ # Make sure the address of a function is moved by offset.
+ set new_function_foo_addr [get_var_address function_foo]
+ gdb_assert {${new_function_foo_addr} == ${function_foo_addr} + $offset} \
+ "function foo is moved by offset"
+}
# Load the object using add-symbol-file with an offset and check that
# all addresses are moved by that offset.
"add symbol table from file \".*${testfile}\\.o\" with all sections offset by $offset\[\r\n\]+\\(y or n\\) " \
"y"
-# Make sure the address of a static variable is moved by offset.
-set new_static_foo_addr [get_var_address static_foo]
-gdb_assert { ${new_static_foo_addr} == ${static_foo_addr} + $offset } \
- "static variable foo is moved by offset"
+with_test_prefix "static scope, 2nd" {
+ # Make sure the address of a static variable is moved by offset.
+ set new_static_foo_addr [get_var_address static_foo]
+ gdb_assert { ${new_static_foo_addr} == ${static_foo_addr} + $offset } \
+ "static variable foo is moved by offset"
+}
-# Make sure the address of a global variable is moved by offset.
-set new_global_foo_addr [get_var_address global_foo]
-gdb_assert { ${new_global_foo_addr} == ${global_foo_addr} + $offset } \
- "global variable foo is moved by offset"
+with_test_prefix "global vars, 2nd" {
+ # Make sure the address of a global variable is moved by offset.
+ set new_global_foo_addr [get_var_address global_foo]
+ gdb_assert { ${new_global_foo_addr} == ${global_foo_addr} + $offset } \
+ "global variable foo is moved by offset"
+}
-# Make sure the address of a function is moved by offset.
-set new_function_foo_addr [get_var_address function_foo]
-gdb_assert { ${new_function_foo_addr} == ${function_foo_addr} + $offset } \
- "function foo is moved by offset"
+with_test_prefix "functions, 2nd" {
+ # Make sure the address of a function is moved by offset.
+ set new_function_foo_addr [get_var_address function_foo]
+ gdb_assert { ${new_function_foo_addr} == ${function_foo_addr} + $offset } \
+ "function foo is moved by offset"
+}
# Re-load the object giving an explicit address for .text
"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = ${text}\[\r\n\]+with other sections offset by ${offset}\[\r\n\]+\\(y or n\\) " \
"y"
-# Make sure function has a different addresses now.
-set function_foo_addr [get_var_address function_foo]
-gdb_assert { ${function_foo_addr} != ${new_function_foo_addr} } \
- "function foo has a different address"
+with_test_prefix "functions, 3rd" {
+ # Make sure function has a different addresses now.
+ set function_foo_addr [get_var_address function_foo]
+ gdb_assert { ${function_foo_addr} != ${new_function_foo_addr} } \
+ "function foo has a different address"
+}
# Re-load the object giving an explicit address for .data
"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.data_addr = ${data}\[\r\n\]+with other sections offset by ${offset}\[\r\n\]+\\(y or n\\) " \
"y"
-# Make sure variable has a different addresses now.
-set global_foo_addr [get_var_address global_foo]
-gdb_assert { ${global_foo_addr} != ${new_global_foo_addr} } \
- "global variable foo has a different address"
+with_test_prefix "global vars, 3rd" {
+ # Make sure variable has a different addresses now.
+ set global_foo_addr [get_var_address global_foo]
+ gdb_assert { ${global_foo_addr} != ${new_global_foo_addr} } \
+ "global variable foo has a different address"
+}
# Now try loading the object as an exec-file; we should be able to print
# the values of variables after we do this.