OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [dump.exp] - Diff between revs 24 and 157

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 24 Rev 157
# Copyright 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
# Copyright 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# 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
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
# along with this program.  If not, see .
# Please email any bugs, comments, and/or additions to this file to:
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# bug-gdb@prep.ai.mit.edu
# This file was written by Michael Snyder (msnyder@redhat.com)
# This file was written by Michael Snyder (msnyder@redhat.com)
# This is a test for the gdb command "dump".
# This is a test for the gdb command "dump".
if $tracelevel then {
if $tracelevel then {
        strace $tracelevel
        strace $tracelevel
}
}
set prms_id 0
set prms_id 0
set bug_id 0
set bug_id 0
set testfile "dump"
set testfile "dump"
set srcfile  ${testfile}.c
set srcfile  ${testfile}.c
set binfile  ${objdir}/${subdir}/${testfile}
set binfile  ${objdir}/${subdir}/${testfile}
set options  {debug}
set options  {debug}
set is64bitonly "no"
set is64bitonly "no"
set endian "auto"
set endian "auto"
if [istarget "alpha*-*-*"] then {
if [istarget "alpha*-*-*"] then {
    # SREC etc cannot handle 64-bit addresses.  Force the test
    # SREC etc cannot handle 64-bit addresses.  Force the test
    # program into the low 31 bits of the address space.
    # program into the low 31 bits of the address space.
    lappend options "additional_flags=-Wl,-taso"
    lappend options "additional_flags=-Wl,-taso"
}
}
if {[istarget "ia64*-*-*"] || [istarget "hppa64-*-*"]} then {
if {[istarget "ia64*-*-*"] || [istarget "hppa64-*-*"]} then {
    set is64bitonly "yes"
    set is64bitonly "yes"
}
}
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
     untested dump.exp
     untested dump.exp
     return -1
     return -1
}
}
# Start with a fresh gdb.
# Start with a fresh gdb.
gdb_exit
gdb_exit
gdb_start
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_load ${binfile}
# Clean up any stale output files from previous test runs
# Clean up any stale output files from previous test runs
remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
# Test help (FIXME:)
# Test help (FIXME:)
# Run target program until data structs are initialized.
# Run target program until data structs are initialized.
if { ! [ runto checkpoint1 ] } then {
if { ! [ runto checkpoint1 ] } then {
    untested dump.exp
    untested dump.exp
    return -1
    return -1
}
}
# Get the endianness for the later use with endianless formats.
# Get the endianness for the later use with endianless formats.
send_gdb "show endian\n"
send_gdb "show endian\n"
gdb_expect {
gdb_expect {
    -re ".* (big|little) endian.*$gdb_prompt $" {
    -re ".* (big|little) endian.*$gdb_prompt $" {
        set endian $expect_out(1,string)
        set endian $expect_out(1,string)
        pass "endianness: $endian"
        pass "endianness: $endian"
    }
    }
    default {
    default {
        fail "(timeout) getting target endianness"
        fail "(timeout) getting target endianness"
    }
    }
}
}
# Now generate some dump files.
# Now generate some dump files.
proc make_dump_file { command msg } {
proc make_dump_file { command msg } {
  global gdb_prompt
  global gdb_prompt
    send_gdb "${command}\n"
    send_gdb "${command}\n"
    gdb_expect {
    gdb_expect {
        -re ".*\[Ee\]rror.*$gdb_prompt $"      { fail $msg }
        -re ".*\[Ee\]rror.*$gdb_prompt $"      { fail $msg }
        -re ".*\[Ww\]arning.*$gdb_prompt $"    { fail $msg }
        -re ".*\[Ww\]arning.*$gdb_prompt $"    { fail $msg }
        -re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg }
        -re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg }
        -re ".*$gdb_prompt $" { pass $msg }
        -re ".*$gdb_prompt $" { pass $msg }
        timeout                                { fail "$msg (timeout)" }
        timeout                                { fail "$msg (timeout)" }
    }
    }
}
}
make_dump_file "dump val intarr1.bin intarray" \
make_dump_file "dump val intarr1.bin intarray" \
        "dump array as value, default"
        "dump array as value, default"
make_dump_file "dump val intstr1.bin intstruct" \
make_dump_file "dump val intstr1.bin intstruct" \
        "dump struct as value, default"
        "dump struct as value, default"
make_dump_file "dump bin val intarr1b.bin intarray" \
make_dump_file "dump bin val intarr1b.bin intarray" \
        "dump array as value, binary"
        "dump array as value, binary"
make_dump_file "dump bin val intstr1b.bin intstruct" \
make_dump_file "dump bin val intstr1b.bin intstruct" \
        "dump struct as value, binary"
        "dump struct as value, binary"
make_dump_file "dump srec val intarr1.srec intarray" \
make_dump_file "dump srec val intarr1.srec intarray" \
        "dump array as value, srec"
        "dump array as value, srec"
make_dump_file "dump srec val intstr1.srec intstruct" \
make_dump_file "dump srec val intstr1.srec intstruct" \
        "dump struct as value, srec"
        "dump struct as value, srec"
make_dump_file "dump ihex val intarr1.ihex intarray" \
make_dump_file "dump ihex val intarr1.ihex intarray" \
        "dump array as value, intel hex"
        "dump array as value, intel hex"
make_dump_file "dump ihex val intstr1.ihex intstruct" \
make_dump_file "dump ihex val intstr1.ihex intstruct" \
        "dump struct as value, intel hex"
        "dump struct as value, intel hex"
make_dump_file "dump tekhex val intarr1.tekhex intarray" \
make_dump_file "dump tekhex val intarr1.tekhex intarray" \
        "dump array as value, tekhex"
        "dump array as value, tekhex"
make_dump_file "dump tekhex val intstr1.tekhex intstruct" \
make_dump_file "dump tekhex val intstr1.tekhex intstruct" \
        "dump struct as value, tekhex"
        "dump struct as value, tekhex"
proc capture_value { expression args } {
proc capture_value { expression args } {
    global gdb_prompt
    global gdb_prompt
    global expect_out
    global expect_out
    set output_string ""
    set output_string ""
    if {[llength $args] > 0} {
    if {[llength $args] > 0} {
        # Convert $args into a simple string.
        # Convert $args into a simple string.
        set test "[join $args]; capture $expression"
        set test "[join $args]; capture $expression"
    } {
    } {
        set test "capture $expression"
        set test "capture $expression"
    }
    }
    gdb_test_multiple "print ${expression}" "$test" {
    gdb_test_multiple "print ${expression}" "$test" {
        -re "\\$\[0-9\]+ = (\[^\r\n\]+).*$gdb_prompt $" {
        -re "\\$\[0-9\]+ = (\[^\r\n\]+).*$gdb_prompt $" {
            set output_string "$expect_out(1,string)"
            set output_string "$expect_out(1,string)"
            pass "$test"
            pass "$test"
        }
        }
        -re "(Cannot access memory at address \[^\r\n\]+).*$gdb_prompt $" {
        -re "(Cannot access memory at address \[^\r\n\]+).*$gdb_prompt $" {
            # Even a failed value is valid
            # Even a failed value is valid
            set output_string "$expect_out(1,string)"
            set output_string "$expect_out(1,string)"
            pass "$test"
            pass "$test"
        }
        }
    }
    }
    return $output_string
    return $output_string
}
}
set array_start  [capture_value "/x &intarray\[0\]"]
set array_start  [capture_value "/x &intarray\[0\]"]
set array_end    [capture_value "/x &intarray\[32\]"]
set array_end    [capture_value "/x &intarray\[32\]"]
set struct_start [capture_value "/x &intstruct"]
set struct_start [capture_value "/x &intstruct"]
set struct_end   [capture_value "/x &intstruct + 1"]
set struct_end   [capture_value "/x &intstruct + 1"]
set array_val    [capture_value "intarray"]
set array_val    [capture_value "intarray"]
set struct_val   [capture_value "intstruct"]
set struct_val   [capture_value "intstruct"]
make_dump_file "dump mem intarr2.bin $array_start $array_end" \
make_dump_file "dump mem intarr2.bin $array_start $array_end" \
        "dump array as memory, default"
        "dump array as memory, default"
make_dump_file "dump  mem intstr2.bin $struct_start $struct_end" \
make_dump_file "dump  mem intstr2.bin $struct_start $struct_end" \
        "dump struct as memory, default"
        "dump struct as memory, default"
make_dump_file "dump bin mem intarr2b.bin $array_start $array_end" \
make_dump_file "dump bin mem intarr2b.bin $array_start $array_end" \
        "dump array as memory, binary"
        "dump array as memory, binary"
make_dump_file "dump bin mem intstr2b.bin $struct_start $struct_end" \
make_dump_file "dump bin mem intstr2b.bin $struct_start $struct_end" \
        "dump struct as memory, binary"
        "dump struct as memory, binary"
make_dump_file "dump srec mem intarr2.srec $array_start $array_end" \
make_dump_file "dump srec mem intarr2.srec $array_start $array_end" \
        "dump array as memory, srec"
        "dump array as memory, srec"
make_dump_file "dump srec mem intstr2.srec $struct_start $struct_end" \
make_dump_file "dump srec mem intstr2.srec $struct_start $struct_end" \
        "dump struct as memory, srec"
        "dump struct as memory, srec"
make_dump_file "dump ihex mem intarr2.ihex $array_start $array_end" \
make_dump_file "dump ihex mem intarr2.ihex $array_start $array_end" \
        "dump array as memory, ihex"
        "dump array as memory, ihex"
make_dump_file "dump ihex mem intstr2.ihex $struct_start $struct_end" \
make_dump_file "dump ihex mem intstr2.ihex $struct_start $struct_end" \
        "dump struct as memory, ihex"
        "dump struct as memory, ihex"
make_dump_file "dump tekhex mem intarr2.tekhex $array_start $array_end" \
make_dump_file "dump tekhex mem intarr2.tekhex $array_start $array_end" \
        "dump array as memory, tekhex"
        "dump array as memory, tekhex"
make_dump_file "dump tekhex mem intstr2.tekhex $struct_start $struct_end" \
make_dump_file "dump tekhex mem intstr2.tekhex $struct_start $struct_end" \
        "dump struct as memory, tekhex"
        "dump struct as memory, tekhex"
# test complex expressions
# test complex expressions
make_dump_file \
make_dump_file \
        "dump srec mem intarr3.srec &intarray \(char *\) &intarray + sizeof intarray" \
        "dump srec mem intarr3.srec &intarray \(char *\) &intarray + sizeof intarray" \
        "dump array as mem, srec, expressions"
        "dump array as mem, srec, expressions"
# Now start a fresh gdb session, and reload the saved value files.
# Now start a fresh gdb session, and reload the saved value files.
gdb_exit
gdb_exit
gdb_start
gdb_start
gdb_file_cmd ${binfile}
gdb_file_cmd ${binfile}
# Now fix the endianness at the correct state.
# Now fix the endianness at the correct state.
send_gdb "set endian $endian\n"
send_gdb "set endian $endian\n"
gdb_expect {
gdb_expect {
    -re ".* (big|little) endian.*$gdb_prompt $" {
    -re ".* (big|little) endian.*$gdb_prompt $" {
        pass "setting $endian endianness"
        pass "setting $endian endianness"
    }
    }
    default {
    default {
        fail "(timeout) setting $endian endianness"
        fail "(timeout) setting $endian endianness"
    }
    }
}
}
# Reload saved values one by one, and compare.
# Reload saved values one by one, and compare.
if { ![string compare $array_val \
if { ![string compare $array_val \
           [capture_value "intarray" "file binfile"]] } then {
           [capture_value "intarray" "file binfile"]] } then {
    fail "start with intarray un-initialized"
    fail "start with intarray un-initialized"
} else {
} else {
    pass "start with intarray un-initialized"
    pass "start with intarray un-initialized"
}
}
if { ![string compare $struct_val \
if { ![string compare $struct_val \
           [capture_value "intstruct" "file binfile"]] } then {
           [capture_value "intstruct" "file binfile"]] } then {
    fail "start with intstruct un-initialized"
    fail "start with intstruct un-initialized"
} else {
} else {
    pass "start with intstruct un-initialized"
    pass "start with intstruct un-initialized"
}
}
proc test_reload_saved_value { filename msg oldval newval } {
proc test_reload_saved_value { filename msg oldval newval } {
    global gdb_prompt
    global gdb_prompt
    gdb_file_cmd $filename
    gdb_file_cmd $filename
    if { ![string compare $oldval \
    if { ![string compare $oldval \
               [capture_value $newval "$msg"]] } then {
               [capture_value $newval "$msg"]] } then {
        pass "$msg; value restored ok"
        pass "$msg; value restored ok"
    } else {
    } else {
        fail "$msg; value restored ok"
        fail "$msg; value restored ok"
    }
    }
}
}
proc test_restore_saved_value { restore_args msg oldval newval } {
proc test_restore_saved_value { restore_args msg oldval newval } {
    global gdb_prompt
    global gdb_prompt
    gdb_test "restore $restore_args" \
    gdb_test "restore $restore_args" \
        "Restoring .*" \
        "Restoring .*" \
        "$msg; file restored ok"
        "$msg; file restored ok"
    if { ![string compare $oldval \
    if { ![string compare $oldval \
               [capture_value $newval "$msg"]] } then {
               [capture_value $newval "$msg"]] } then {
        pass "$msg; value restored ok"
        pass "$msg; value restored ok"
    } else {
    } else {
        fail "$msg; value restored ok"
        fail "$msg; value restored ok"
    }
    }
}
}
# srec format can not be loaded for 64-bit-only platforms
# srec format can not be loaded for 64-bit-only platforms
if ![string compare $is64bitonly "no"] then {
if ![string compare $is64bitonly "no"] then {
  test_reload_saved_value "intarr1.srec" "reload array as value, srec" \
  test_reload_saved_value "intarr1.srec" "reload array as value, srec" \
        $array_val "intarray"
        $array_val "intarray"
  test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \
  test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \
  test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \
        $array_val "intarray"
        $array_val "intarray"
  test_reload_saved_value "intstr2.srec" "reload struct as memory, srec" \
  test_reload_saved_value "intstr2.srec" "reload struct as memory, srec" \
        $struct_val "intstruct"
        $struct_val "intstruct"
}
}
# ihex format can not be loaded for 64-bit-only platforms
# ihex format can not be loaded for 64-bit-only platforms
if ![string compare $is64bitonly "no"] then {
if ![string compare $is64bitonly "no"] then {
  test_reload_saved_value "intarr1.ihex" "reload array as value, intel hex" \
  test_reload_saved_value "intarr1.ihex" "reload array as value, intel hex" \
        $array_val "intarray"
        $array_val "intarray"
  test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \
  test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \
  test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \
        $array_val "intarray"
        $array_val "intarray"
  test_reload_saved_value "intstr2.ihex" "reload struct as memory, intel hex" \
  test_reload_saved_value "intstr2.ihex" "reload struct as memory, intel hex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
}
}
# tekhex format can not be loaded for 64-bit-only platforms
# tekhex format can not be loaded for 64-bit-only platforms
if ![string compare $is64bitonly "no"] then {
if ![string compare $is64bitonly "no"] then {
  test_reload_saved_value "intarr1.tekhex" "reload array as value, tekhex" \
  test_reload_saved_value "intarr1.tekhex" "reload array as value, tekhex" \
        $array_val "intarray"
        $array_val "intarray"
  test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \
  test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \
  test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \
        $array_val "intarray"
        $array_val "intarray"
  test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \
  test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
}
}
# Start a fresh gdb session
# Start a fresh gdb session
gdb_exit
gdb_exit
gdb_start
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_load ${binfile}
# Run to main.
# Run to main.
if { ! [ runto_main ] } then {
if { ! [ runto_main ] } then {
    untested dump.exp
    untested dump.exp
    return -1
    return -1
}
}
if { ![string compare $array_val \
if { ![string compare $array_val \
           [capture_value "intarray" "load binfile"]] } then {
           [capture_value "intarray" "load binfile"]] } then {
    fail "start with intarray un-initialized, runto main"
    fail "start with intarray un-initialized, runto main"
} else {
} else {
    pass "start with intarray un-initialized, runto main"
    pass "start with intarray un-initialized, runto main"
}
}
if { ![string compare $struct_val \
if { ![string compare $struct_val \
           [capture_value "intstruct" "load binfile"]] } then {
           [capture_value "intstruct" "load binfile"]] } then {
    fail "start with intstruct un-initialized, runto main"
    fail "start with intstruct un-initialized, runto main"
} else {
} else {
    pass "start with intstruct un-initialized, runto main"
    pass "start with intstruct un-initialized, runto main"
}
}
if ![string compare $is64bitonly "no"] then {
if ![string compare $is64bitonly "no"] then {
  test_restore_saved_value "intarr1.srec" "array as value, srec" \
  test_restore_saved_value "intarr1.srec" "array as value, srec" \
        $array_val "intarray"
        $array_val "intarray"
  test_restore_saved_value "intstr1.srec" "struct as value, srec" \
  test_restore_saved_value "intstr1.srec" "struct as value, srec" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  gdb_test "print zero_all ()" "void" "zero all"
  gdb_test "print zero_all ()" "void" "zero all"
  test_restore_saved_value "intarr2.srec" "array as memory, srec" \
  test_restore_saved_value "intarr2.srec" "array as memory, srec" \
        $array_val "intarray"
        $array_val "intarray"
  test_restore_saved_value "intstr2.srec" "struct as memory, srec" \
  test_restore_saved_value "intstr2.srec" "struct as memory, srec" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr1.ihex" "array as value, ihex" \
  test_restore_saved_value "intarr1.ihex" "array as value, ihex" \
        $array_val "intarray"
        $array_val "intarray"
  test_restore_saved_value "intstr1.ihex" "struct as value, ihex" \
  test_restore_saved_value "intstr1.ihex" "struct as value, ihex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr2.ihex" "array as memory, ihex" \
  test_restore_saved_value "intarr2.ihex" "array as memory, ihex" \
        $array_val "intarray"
        $array_val "intarray"
  test_restore_saved_value "intstr2.ihex" "struct as memory, ihex" \
  test_restore_saved_value "intstr2.ihex" "struct as memory, ihex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr1.tekhex" "array as value, tekhex" \
  test_restore_saved_value "intarr1.tekhex" "array as value, tekhex" \
        $array_val "intarray"
        $array_val "intarray"
  test_restore_saved_value "intstr1.tekhex" "struct as value, tekhex" \
  test_restore_saved_value "intstr1.tekhex" "struct as value, tekhex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr2.tekhex" "array as memory, tekhex" \
  test_restore_saved_value "intarr2.tekhex" "array as memory, tekhex" \
        $array_val "intarray"
        $array_val "intarray"
  test_restore_saved_value "intstr2.tekhex" "struct as memory, tekhex" \
  test_restore_saved_value "intstr2.tekhex" "struct as memory, tekhex" \
        $struct_val "intstruct"
        $struct_val "intstruct"
}
}
gdb_test "print zero_all ()" ""
gdb_test "print zero_all ()" ""
test_restore_saved_value "intarr1.bin binary $array_start" \
test_restore_saved_value "intarr1.bin binary $array_start" \
        "array as value, binary" \
        "array as value, binary" \
        $array_val "intarray"
        $array_val "intarray"
test_restore_saved_value "intstr1.bin binary $struct_start" \
test_restore_saved_value "intstr1.bin binary $struct_start" \
        "struct as value, binary" \
        "struct as value, binary" \
        $struct_val "intstruct"
        $struct_val "intstruct"
gdb_test "print zero_all ()" ""
gdb_test "print zero_all ()" ""
test_restore_saved_value "intarr2.bin binary $array_start" \
test_restore_saved_value "intarr2.bin binary $array_start" \
        "array as memory, binary" \
        "array as memory, binary" \
        $array_val "intarray"
        $array_val "intarray"
test_restore_saved_value "intstr2.bin binary $struct_start" \
test_restore_saved_value "intstr2.bin binary $struct_start" \
        "struct as memory, binary" \
        "struct as memory, binary" \
        $struct_val "intstruct"
        $struct_val "intstruct"
# test restore with offset.
# test restore with offset.
set array2_start   [capture_value "/x &intarray2\[0\]"]
set array2_start   [capture_value "/x &intarray2\[0\]"]
set struct2_start  [capture_value "/x &intstruct2"]
set struct2_start  [capture_value "/x &intstruct2"]
set array2_offset  \
set array2_offset  \
        [capture_value "(char *) &intarray2 - (char *) &intarray"]
        [capture_value "(char *) &intarray2 - (char *) &intarray"]
set struct2_offset \
set struct2_offset \
        [capture_value "(char *) &intstruct2 - (char *) &intstruct"]
        [capture_value "(char *) &intstruct2 - (char *) &intstruct"]
gdb_test "print zero_all ()" ""
gdb_test "print zero_all ()" ""
if ![string compare $is64bitonly "no"] then {
if ![string compare $is64bitonly "no"] then {
  test_restore_saved_value "intarr1.srec $array2_offset" \
  test_restore_saved_value "intarr1.srec $array2_offset" \
        "array copy, srec" \
        "array copy, srec" \
        $array_val "intarray2"
        $array_val "intarray2"
  test_restore_saved_value "intstr1.srec $struct2_offset" \
  test_restore_saved_value "intstr1.srec $struct2_offset" \
        "struct copy, srec" \
        "struct copy, srec" \
        $struct_val "intstruct2"
        $struct_val "intstruct2"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr1.ihex $array2_offset" \
  test_restore_saved_value "intarr1.ihex $array2_offset" \
        "array copy, ihex" \
        "array copy, ihex" \
        $array_val "intarray2"
        $array_val "intarray2"
  test_restore_saved_value "intstr1.ihex $struct2_offset" \
  test_restore_saved_value "intstr1.ihex $struct2_offset" \
        "struct copy, ihex" \
        "struct copy, ihex" \
        $struct_val "intstruct2"
        $struct_val "intstruct2"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr1.tekhex $array2_offset" \
  test_restore_saved_value "intarr1.tekhex $array2_offset" \
        "array copy, tekhex" \
        "array copy, tekhex" \
        $array_val "intarray2"
        $array_val "intarray2"
  test_restore_saved_value "intstr1.tekhex $struct2_offset" \
  test_restore_saved_value "intstr1.tekhex $struct2_offset" \
        "struct copy, tekhex" \
        "struct copy, tekhex" \
        $struct_val "intstruct2"
        $struct_val "intstruct2"
}
}
gdb_test "print zero_all ()" ""
gdb_test "print zero_all ()" ""
test_restore_saved_value "intarr1.bin binary $array2_start" \
test_restore_saved_value "intarr1.bin binary $array2_start" \
        "array copy, binary" \
        "array copy, binary" \
        $array_val "intarray2"
        $array_val "intarray2"
test_restore_saved_value "intstr1.bin binary $struct2_start" \
test_restore_saved_value "intstr1.bin binary $struct2_start" \
        "struct copy, binary" \
        "struct copy, binary" \
        $struct_val "intstruct2"
        $struct_val "intstruct2"
#
#
# test restore with start/stop addresses.
# test restore with start/stop addresses.
#
#
# For this purpose, we will restore just the third element of the array,
# For this purpose, we will restore just the third element of the array,
# and check to see that adjacent elements are not modified.
# and check to see that adjacent elements are not modified.
#
#
# We will need the address and offset of the third and fourth elements.
# We will need the address and offset of the third and fourth elements.
#
#
set element3_start  [capture_value "/x &intarray\[3\]"]
set element3_start  [capture_value "/x &intarray\[3\]"]
set element4_start  [capture_value "/x &intarray\[4\]"]
set element4_start  [capture_value "/x &intarray\[4\]"]
set element3_offset \
set element3_offset \
        [capture_value "/x (char *) &intarray\[3\] - (char *) &intarray\[0\]"]
        [capture_value "/x (char *) &intarray\[3\] - (char *) &intarray\[0\]"]
set element4_offset \
set element4_offset \
        [capture_value "/x (char *) &intarray\[4\] - (char *) &intarray\[0\]"]
        [capture_value "/x (char *) &intarray\[4\] - (char *) &intarray\[0\]"]
if ![string compare $is64bitonly "no"] then {
if ![string compare $is64bitonly "no"] then {
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr1.srec 0 $element3_start $element4_start" \
  test_restore_saved_value "intarr1.srec 0 $element3_start $element4_start" \
        "array partial, srec" 4 "intarray\[3\]"
        "array partial, srec" 4 "intarray\[3\]"
  gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
  gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
  gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 1"
  gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 1"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr1.ihex 0 $element3_start $element4_start" \
  test_restore_saved_value "intarr1.ihex 0 $element3_start $element4_start" \
        "array partial, ihex" 4 "intarray\[3\]"
        "array partial, ihex" 4 "intarray\[3\]"
  gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
  gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
  gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 2"
  gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 2"
  gdb_test "print zero_all ()" ""
  gdb_test "print zero_all ()" ""
  test_restore_saved_value "intarr1.tekhex 0 $element3_start $element4_start" \
  test_restore_saved_value "intarr1.tekhex 0 $element3_start $element4_start" \
        "array partial, tekhex" 4 "intarray\[3\]"
        "array partial, tekhex" 4 "intarray\[3\]"
  gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 3"
  gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 3"
  gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 3"
  gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 3"
}
}
gdb_test "print zero_all ()" ""
gdb_test "print zero_all ()" ""
test_restore_saved_value \
test_restore_saved_value \
    "intarr1.bin binary $array_start $element3_offset $element4_offset" \
    "intarr1.bin binary $array_start $element3_offset $element4_offset" \
    "array partial, binary" 4 "intarray\[3\]"
    "array partial, binary" 4 "intarray\[3\]"
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4"
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4"
if ![string compare $is64bitonly "no"] then {
if ![string compare $is64bitonly "no"] then {
  gdb_test "print zero_all ()" "" ""
  gdb_test "print zero_all ()" "" ""
  # restore with expressions
  # restore with expressions
  test_restore_saved_value \
  test_restore_saved_value \
        "intarr3.srec ${array2_start}-${array_start} &intarray\[3\] &intarray\[4\]" \
        "intarr3.srec ${array2_start}-${array_start} &intarray\[3\] &intarray\[4\]" \
        "array partial with expressions" 4 "intarray2\[3\]"
        "array partial with expressions" 4 "intarray2\[3\]"
  gdb_test "print intarray2\[2\] == 0" " = 1" "element 2 not changed, == 4"
  gdb_test "print intarray2\[2\] == 0" " = 1" "element 2 not changed, == 4"
  gdb_test "print intarray2\[4\] == 0" " = 1" "element 4 not changed, == 4"
  gdb_test "print intarray2\[4\] == 0" " = 1" "element 4 not changed, == 4"
}
}
# clean up files
# clean up files
remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.