2018-01-01 05:43:02 +01:00
|
|
|
# Copyright 2002-2018 Free Software Foundation, Inc.
|
2002-03-29 02:19:11 +01:00
|
|
|
|
|
|
|
# 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
|
2007-08-23 20:14:19 +02:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2002-03-29 02:19:11 +01:00
|
|
|
# (at your option) any later version.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
2002-03-29 02:19:11 +01:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
2002-03-29 02:19:11 +01:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 20:14:19 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-03-29 02:19:11 +01:00
|
|
|
|
|
|
|
# This file was written by Michael Snyder (msnyder@redhat.com)
|
|
|
|
# This is a test for the gdb command "dump".
|
|
|
|
|
|
|
|
|
test suite update - gdb.base/[cd]
Convert files gdb.base/[cd]*.exp to use standard_output_file et al.
* call-ar-st.exp, call-rt-st.exp, call-sc.exp,
call-signal-resume.exp, call-strs.exp, callexit.exp,
callfuncs.exp, catch-load.exp, catch-syscall.exp, charset.exp,
checkpoint.exp, chng-syms.exp, code-expr.exp, code_elim.exp,
commands.exp, completion.exp, complex.exp, cond-expr.exp,
condbreak.exp, consecutive.exp, constvars.exp, corefile.exp,
ctxobj.exp, cursal.exp, cvexpr.exp, dbx.exp, default.exp,
define.exp, del.exp, detach.exp, dfp-test.exp, display.exp,
dmsym.exp, dump.exp, dup-sect.exp: Use standard_testfile,
standard_output_file, prepare_for_testing, clean_restart.
2013-06-27 20:49:03 +02:00
|
|
|
standard_testfile
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-06-02 17:51:24 +02:00
|
|
|
set options {debug}
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
set is64bitonly "no"
|
2007-07-30 14:24:22 +02:00
|
|
|
set endian "auto"
|
2003-08-28 20:01:50 +02:00
|
|
|
|
2003-06-02 17:51:24 +02:00
|
|
|
if [istarget "alpha*-*-*"] then {
|
|
|
|
# SREC etc cannot handle 64-bit addresses. Force the test
|
|
|
|
# program into the low 31 bits of the address space.
|
|
|
|
lappend options "additional_flags=-Wl,-taso"
|
|
|
|
}
|
|
|
|
|
2009-06-17 20:49:37 +02:00
|
|
|
if {[istarget "spu*-*-*"]} then {
|
|
|
|
# The internal address format used for the combined Cell/B.E.
|
|
|
|
# debugger requires 64-bit.
|
|
|
|
set is64bitonly "yes"
|
|
|
|
}
|
|
|
|
|
2003-06-02 17:51:24 +02:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
|
2016-12-01 21:47:50 +01:00
|
|
|
untested "failed to compile"
|
2006-08-10 07:27:22 +02:00
|
|
|
return -1
|
2002-03-29 02:19:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Start with a fresh gdb.
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2009-07-09 22:30:59 +02:00
|
|
|
|
|
|
|
gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \
|
|
|
|
"inaccessible memory is reported"
|
|
|
|
|
2002-03-29 02:19:11 +01:00
|
|
|
gdb_load ${binfile}
|
|
|
|
|
2013-07-06 04:36:46 +02:00
|
|
|
# Check the address of a variable. If it is bigger than 32-bit,
|
|
|
|
# assume our target has 64-bit addresses that are not supported by SREC,
|
|
|
|
# IHEX and TEKHEX. We skip those tests then.
|
|
|
|
set max_32bit_address "0xffffffff"
|
|
|
|
set data_address [get_hexadecimal_valueof "&intarray" 0x100000000]
|
|
|
|
if {${data_address} > ${max_32bit_address}} then {
|
|
|
|
set is64bitonly "yes"
|
|
|
|
}
|
|
|
|
|
2002-03-29 02:19:11 +01:00
|
|
|
# Clean up any stale output files from previous test runs
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
set filenames {}
|
|
|
|
set all_files {
|
|
|
|
intarr1.bin intarr1b.bin intarr1.ihex
|
2015-04-22 23:52:36 +02:00
|
|
|
intarr1.srec intarr1.tekhex intarr1.verilog
|
|
|
|
intarr2.bin intarr2b.bin intarr2.ihex
|
|
|
|
intarr2.srec intarr2.tekhex intarr2.verilog
|
|
|
|
intstr1.bin intstr1b.bin intstr1.ihex
|
|
|
|
intstr1.srec intstr1.tekhex intstr1.verilog
|
|
|
|
intstr2.bin intstr2b.bin intstr2.ihex
|
|
|
|
intstr2.srec intstr2.tekhex intstr2.verilog
|
|
|
|
intarr3.srec
|
2013-08-23 20:18:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# This loop sets variables dynamically -- each name listed in
|
|
|
|
# $ALL_FILES is both a file name and a variable name.
|
|
|
|
foreach file $all_files {
|
|
|
|
if {[is_remote host]} {
|
|
|
|
set this_name $file
|
|
|
|
} else {
|
|
|
|
set this_name [standard_output_file $file]
|
|
|
|
}
|
|
|
|
|
|
|
|
lappend filenames [set ${file} $this_name]
|
|
|
|
}
|
|
|
|
|
|
|
|
remote_exec host "rm -f $filenames"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
|
|
|
# Test help (FIXME:)
|
|
|
|
|
|
|
|
# Run target program until data structs are initialized.
|
|
|
|
|
|
|
|
if { ! [ runto checkpoint1 ] } then {
|
2016-12-01 21:47:50 +01:00
|
|
|
untested "couldn't run to checkpoint"
|
2006-08-10 07:27:22 +02:00
|
|
|
return -1
|
2002-03-29 02:19:11 +01:00
|
|
|
}
|
|
|
|
|
2007-07-30 14:24:22 +02:00
|
|
|
# Get the endianness for the later use with endianless formats.
|
|
|
|
|
2017-06-13 15:20:26 +02:00
|
|
|
set endian [get_endianness]
|
2007-07-30 14:24:22 +02:00
|
|
|
|
2002-03-29 02:19:11 +01:00
|
|
|
# Now generate some dump files.
|
|
|
|
|
|
|
|
proc make_dump_file { command msg } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
2010-05-25 00:06:59 +02:00
|
|
|
gdb_test_multiple "${command}" "$msg" {
|
2002-03-29 02:19:11 +01:00
|
|
|
-re ".*\[Ee\]rror.*$gdb_prompt $" { fail $msg }
|
|
|
|
-re ".*\[Ww\]arning.*$gdb_prompt $" { fail $msg }
|
|
|
|
-re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg }
|
2010-05-25 00:06:59 +02:00
|
|
|
-re ".*$gdb_prompt $" { pass $msg }
|
2002-03-29 02:19:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump val [set intarr1.bin] intarray" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as value, default"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump val [set intstr1.bin] intstruct" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as value, default"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump bin val [set intarr1b.bin] intarray" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as value, binary"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump bin val [set intstr1b.bin] intstruct" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as value, binary"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump srec val [set intarr1.srec] intarray" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as value, srec"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump srec val [set intstr1.srec] intstruct" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as value, srec"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump ihex val [set intarr1.ihex] intarray" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as value, intel hex"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump ihex val [set intstr1.ihex] intstruct" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as value, intel hex"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump tekhex val [set intarr1.tekhex] intarray" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as value, tekhex"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump tekhex val [set intstr1.tekhex] intstruct" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as value, tekhex"
|
|
|
|
|
2015-04-22 23:52:36 +02:00
|
|
|
make_dump_file "dump verilog val [set intarr1.verilog] intarray" \
|
2016-11-11 16:42:37 +01:00
|
|
|
"dump array as value, verilog"
|
2015-04-22 23:52:36 +02:00
|
|
|
|
|
|
|
make_dump_file "dump verilog val [set intstr1.verilog] intstruct" \
|
2016-11-11 16:42:37 +01:00
|
|
|
"dump struct as value, verilog"
|
2015-04-22 23:52:36 +02:00
|
|
|
|
2004-08-02 05:13:56 +02:00
|
|
|
proc capture_value { expression args } {
|
2002-03-29 02:19:11 +01:00
|
|
|
global gdb_prompt
|
|
|
|
global expect_out
|
|
|
|
|
|
|
|
set output_string ""
|
2004-08-02 05:13:56 +02:00
|
|
|
if {[llength $args] > 0} {
|
2013-06-06 21:00:13 +02:00
|
|
|
# Convert $args into a simple string and don't use EXPRESSION
|
|
|
|
# in the test name.
|
|
|
|
set test "[join $args]; capture"
|
2004-08-02 05:13:56 +02:00
|
|
|
} {
|
|
|
|
set test "capture $expression"
|
|
|
|
}
|
|
|
|
gdb_test_multiple "print ${expression}" "$test" {
|
|
|
|
-re "\\$\[0-9\]+ = (\[^\r\n\]+).*$gdb_prompt $" {
|
|
|
|
set output_string "$expect_out(1,string)"
|
|
|
|
pass "$test"
|
2002-03-29 02:19:11 +01:00
|
|
|
}
|
2004-08-02 05:13:56 +02:00
|
|
|
-re "(Cannot access memory at address \[^\r\n\]+).*$gdb_prompt $" {
|
|
|
|
# Even a failed value is valid
|
|
|
|
set output_string "$expect_out(1,string)"
|
|
|
|
pass "$test"
|
2002-03-29 02:19:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $output_string
|
|
|
|
}
|
|
|
|
|
2011-07-01 18:42:42 +02:00
|
|
|
# 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 " \\(.*\\).* 0x\[0-9a-fA-F\]+" $expect_out(0,string) output_string] {
|
|
|
|
# OUTPUT_STRING is expected to be like "(int (*)[32]) 0x804a0e0".
|
|
|
|
pass "$test"
|
|
|
|
} else {
|
|
|
|
fail "$test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output_string
|
|
|
|
}
|
|
|
|
|
2002-03-29 02:19:11 +01:00
|
|
|
set array_start [capture_value "/x &intarray\[0\]"]
|
|
|
|
set array_end [capture_value "/x &intarray\[32\]"]
|
|
|
|
set struct_start [capture_value "/x &intstruct"]
|
|
|
|
set struct_end [capture_value "/x &intstruct + 1"]
|
|
|
|
|
|
|
|
set array_val [capture_value "intarray"]
|
|
|
|
set struct_val [capture_value "intstruct"]
|
|
|
|
|
2011-07-01 18:42:42 +02:00
|
|
|
set array_ptr_type [capture_pointer_with_type "&intarray"]
|
|
|
|
set struct_ptr_type [capture_pointer_with_type "&intstruct"]
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump mem [set intarr2.bin] $array_start $array_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as memory, default"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump mem [set intstr2.bin] $struct_start $struct_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as memory, default"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump bin mem [set intarr2b.bin] $array_start $array_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as memory, binary"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump bin mem [set intstr2b.bin] $struct_start $struct_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as memory, binary"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump srec mem [set intarr2.srec] $array_start $array_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as memory, srec"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump srec mem [set intstr2.srec] $struct_start $struct_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as memory, srec"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump ihex mem [set intarr2.ihex] $array_start $array_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as memory, ihex"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump ihex mem [set intstr2.ihex] $struct_start $struct_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as memory, ihex"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump tekhex mem [set intarr2.tekhex] $array_start $array_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as memory, tekhex"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
make_dump_file "dump tekhex mem [set intstr2.tekhex] $struct_start $struct_end" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump struct as memory, tekhex"
|
|
|
|
|
2015-04-22 23:52:36 +02:00
|
|
|
make_dump_file "dump verilog mem [set intarr2.verilog] $array_start $array_end" \
|
|
|
|
"dump array as memory, verilog"
|
|
|
|
|
|
|
|
make_dump_file "dump verilog mem [set intstr2.verilog] $struct_start $struct_end" \
|
|
|
|
"dump struct as memory, verilog"
|
|
|
|
|
2002-03-29 02:19:11 +01:00
|
|
|
# test complex expressions
|
|
|
|
make_dump_file \
|
2013-08-23 20:18:01 +02:00
|
|
|
"dump srec mem [set intarr3.srec] &intarray \(char *\) &intarray + sizeof intarray" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"dump array as mem, srec, expressions"
|
|
|
|
|
|
|
|
proc test_restore_saved_value { restore_args msg oldval newval } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
gdb_test "restore $restore_args" \
|
2004-08-02 05:13:56 +02:00
|
|
|
"Restoring .*" \
|
|
|
|
"$msg; file restored ok"
|
|
|
|
if { ![string compare $oldval \
|
|
|
|
[capture_value $newval "$msg"]] } then {
|
|
|
|
pass "$msg; value restored ok"
|
2002-03-29 02:19:11 +01:00
|
|
|
} else {
|
2004-08-02 05:13:56 +02:00
|
|
|
fail "$msg; value restored ok"
|
2002-03-29 02:19:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
if ![string compare $is64bitonly "no"] then {
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2011-07-01 18:42:42 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.srec]" "array as value, srec" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.srec]" "struct as value, srec" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$struct_val "intstruct"
|
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
gdb_test "print zero_all ()" "void" "zero all"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr2.srec]" "array as memory, srec" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr2.srec]" "struct as memory, srec" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$struct_val "intstruct"
|
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.ihex]" "array as value, ihex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.ihex]" "struct as value, ihex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$struct_val "intstruct"
|
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr2.ihex]" "array as memory, ihex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr2.ihex]" "struct as memory, ihex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$struct_val "intstruct"
|
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.tekhex]" "array as value, tekhex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.tekhex]" "struct as value, tekhex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$struct_val "intstruct"
|
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr2.tekhex]" "array as memory, tekhex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr2.tekhex]" "struct as memory, tekhex" \
|
2002-03-29 02:19:11 +01:00
|
|
|
$struct_val "intstruct"
|
2003-08-28 20:01:50 +02:00
|
|
|
}
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.bin] binary $array_start" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"array as value, binary" \
|
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.bin] binary $struct_start" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"struct as value, binary" \
|
|
|
|
$struct_val "intstruct"
|
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr2.bin] binary $array_start" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"array as memory, binary" \
|
|
|
|
$array_val "intarray"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr2.bin] binary $struct_start" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"struct as memory, binary" \
|
|
|
|
$struct_val "intstruct"
|
|
|
|
|
|
|
|
# test restore with offset.
|
|
|
|
|
|
|
|
set array2_start [capture_value "/x &intarray2\[0\]"]
|
|
|
|
set struct2_start [capture_value "/x &intstruct2"]
|
|
|
|
set array2_offset \
|
2004-02-18 05:15:46 +01:00
|
|
|
[capture_value "(char *) &intarray2 - (char *) &intarray"]
|
2002-03-29 02:19:11 +01:00
|
|
|
set struct2_offset \
|
2004-02-18 05:15:46 +01:00
|
|
|
[capture_value "(char *) &intstruct2 - (char *) &intstruct"]
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
|
|
|
|
if ![string compare $is64bitonly "no"] then {
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.srec] $array2_offset" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"array copy, srec" \
|
|
|
|
$array_val "intarray2"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.srec] $struct2_offset" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"struct copy, srec" \
|
|
|
|
$struct_val "intstruct2"
|
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.ihex] $array2_offset" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"array copy, ihex" \
|
|
|
|
$array_val "intarray2"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.ihex] $struct2_offset" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"struct copy, ihex" \
|
|
|
|
$struct_val "intstruct2"
|
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.tekhex] $array2_offset" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"array copy, tekhex" \
|
|
|
|
$array_val "intarray2"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.tekhex] $struct2_offset" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"struct copy, tekhex" \
|
|
|
|
$struct_val "intstruct2"
|
2003-08-28 20:01:50 +02:00
|
|
|
}
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.bin] binary $array2_start" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"array copy, binary" \
|
|
|
|
$array_val "intarray2"
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intstr1.bin] binary $struct2_start" \
|
2002-03-29 02:19:11 +01:00
|
|
|
"struct copy, binary" \
|
|
|
|
$struct_val "intstruct2"
|
|
|
|
|
|
|
|
#
|
|
|
|
# test restore with start/stop addresses.
|
|
|
|
#
|
|
|
|
# For this purpose, we will restore just the third element of the array,
|
|
|
|
# and check to see that adjacent elements are not modified.
|
|
|
|
#
|
|
|
|
# We will need the address and offset of the third and fourth elements.
|
|
|
|
#
|
|
|
|
|
|
|
|
set element3_start [capture_value "/x &intarray\[3\]"]
|
|
|
|
set element4_start [capture_value "/x &intarray\[4\]"]
|
|
|
|
set element3_offset \
|
|
|
|
[capture_value "/x (char *) &intarray\[3\] - (char *) &intarray\[0\]"]
|
|
|
|
set element4_offset \
|
|
|
|
[capture_value "/x (char *) &intarray\[4\] - (char *) &intarray\[0\]"]
|
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
if ![string compare $is64bitonly "no"] then {
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.srec] 0 $element3_start $element4_start" \
|
2004-08-02 05:13:56 +02:00
|
|
|
"array partial, srec" 4 "intarray\[3\]"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
|
|
|
|
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 1"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.ihex] 0 $element3_start $element4_start" \
|
2004-08-02 05:13:56 +02:00
|
|
|
"array partial, ihex" 4 "intarray\[3\]"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
|
|
|
|
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 2"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_restore_saved_value "[set intarr1.tekhex] 0 $element3_start $element4_start" \
|
2004-08-02 05:13:56 +02:00
|
|
|
"array partial, tekhex" 4 "intarray\[3\]"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 3"
|
|
|
|
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 3"
|
|
|
|
}
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "print zero_all ()" ".*"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
|
|
|
test_restore_saved_value \
|
2013-08-23 20:18:01 +02:00
|
|
|
"[set intarr1.bin] binary $array_start $element3_offset $element4_offset" \
|
2004-08-02 05:13:56 +02:00
|
|
|
"array partial, binary" 4 "intarray\[3\]"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
|
|
|
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
|
|
|
|
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4"
|
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
if ![string compare $is64bitonly "no"] then {
|
2010-06-09 00:58:03 +02:00
|
|
|
gdb_test "print zero_all ()" ".*" ""
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
# restore with expressions
|
|
|
|
test_restore_saved_value \
|
2013-08-23 20:18:01 +02:00
|
|
|
"[set intarr3.srec] (char*)${array2_start}-(char*)${array_start} &intarray\[3\] &intarray\[4\]" \
|
2004-08-02 05:13:56 +02:00
|
|
|
"array partial with expressions" 4 "intarray2\[3\]"
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2003-08-28 20:01:50 +02:00
|
|
|
gdb_test "print intarray2\[2\] == 0" " = 1" "element 2 not changed, == 4"
|
|
|
|
gdb_test "print intarray2\[4\] == 0" " = 1" "element 4 not changed, == 4"
|
|
|
|
}
|
2002-03-29 02:19:11 +01:00
|
|
|
|
2011-07-01 18:42:42 +02:00
|
|
|
|
|
|
|
# Now start a fresh gdb session, and reload the saved value files.
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_file_cmd ${binfile}
|
|
|
|
|
|
|
|
# Now fix the endianness at the correct state.
|
|
|
|
|
|
|
|
gdb_test_multiple "set endian $endian" "set endianness" {
|
|
|
|
-re ".* (big|little) endian.*$gdb_prompt $" {
|
|
|
|
pass "setting $endian endianness"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Reload saved values one by one, and compare.
|
|
|
|
|
|
|
|
if { ![string compare $array_val \
|
2013-06-06 21:00:13 +02:00
|
|
|
[capture_value "intarray" "file binfile; intarray"]] } then {
|
2011-07-01 18:42:42 +02:00
|
|
|
fail "start with intarray un-initialized"
|
|
|
|
} else {
|
|
|
|
pass "start with intarray un-initialized"
|
|
|
|
}
|
|
|
|
|
|
|
|
if { ![string compare $struct_val \
|
2013-06-06 21:00:13 +02:00
|
|
|
[capture_value "intstruct" "file binfile; intstruct"]] } then {
|
2011-07-01 18:42:42 +02:00
|
|
|
fail "start with intstruct un-initialized"
|
|
|
|
} else {
|
|
|
|
pass "start with intstruct un-initialized"
|
|
|
|
}
|
|
|
|
|
|
|
|
proc test_reload_saved_value { filename msg oldval newval } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
gdb_file_cmd $filename
|
|
|
|
if { ![string compare $oldval \
|
|
|
|
[capture_value $newval "$msg"]] } then {
|
|
|
|
pass "$msg; value restored ok"
|
|
|
|
} else {
|
|
|
|
fail "$msg; value restored ok"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# srec format can not be loaded for 64-bit-only platforms
|
|
|
|
if ![string compare $is64bitonly "no"] then {
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intarr1.srec]" "reload array as value, srec" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$array_val "\*$array_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intstr1.srec]" "reload struct as value, srec" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$struct_val "\*$struct_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intarr2.srec]" "reload array as memory, srec" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$array_val "\*$array_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intstr2.srec]" "reload struct as memory, srec" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$struct_val "\*$struct_ptr_type"
|
|
|
|
}
|
|
|
|
|
|
|
|
# ihex format can not be loaded for 64-bit-only platforms
|
|
|
|
if ![string compare $is64bitonly "no"] then {
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intarr1.ihex]" \
|
|
|
|
"reload array as value, intel hex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$array_val "\*$array_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intstr1.ihex]" \
|
|
|
|
"reload struct as value, intel hex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$struct_val "\*$struct_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intarr2.ihex]" \
|
|
|
|
"reload array as memory, intel hex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$array_val "\*$array_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intstr2.ihex]" \
|
|
|
|
"reload struct as memory, intel hex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$struct_val "\*$struct_ptr_type"
|
|
|
|
}
|
|
|
|
|
|
|
|
# tekhex format can not be loaded for 64-bit-only platforms
|
|
|
|
if ![string compare $is64bitonly "no"] then {
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intarr1.tekhex]" \
|
|
|
|
"reload array as value, tekhex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$array_val "\*$array_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intstr1.tekhex]" \
|
|
|
|
"reload struct as value, tekhex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$struct_val "\*$struct_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intarr2.tekhex]" \
|
|
|
|
"reload array as memory, tekhex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$array_val "\*$array_ptr_type"
|
2013-08-23 20:18:01 +02:00
|
|
|
test_reload_saved_value "[set intstr2.tekhex]" \
|
|
|
|
"reload struct as memory, tekhex" \
|
2011-07-01 18:42:42 +02:00
|
|
|
$struct_val "\*$struct_ptr_type"
|
|
|
|
}
|
|
|
|
|
2002-03-29 02:19:11 +01:00
|
|
|
# clean up files
|
|
|
|
|
2013-08-23 20:18:01 +02:00
|
|
|
remote_exec host "rm -f $filenames"
|