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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.arch/] [pa-nullify.exp] - Diff between revs 227 and 816

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

Rev 227 Rev 816
# Copyright 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
# Copyright 2004, 2007, 2008, 2009, 2010 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 .
#
#
# This file is part of the gdb testsuite.
# This file is part of the gdb testsuite.
if $tracelevel {
if $tracelevel {
    strace $tracelevel
    strace $tracelevel
}
}
set prms_id 0
set prms_id 0
set bug_id 0
set bug_id 0
# Test handling of nullified instructions for the pa target.
# Test handling of nullified instructions for the pa target.
switch -glob -- [istarget] {
switch -glob -- [istarget] {
    "hppa-*-*" {
    "hppa-*-*" {
        set testfile "pa-nullify"
        set testfile "pa-nullify"
    }
    }
    "hppa64-*-*" {
    "hppa64-*-*" {
        set testfile "pa64-nullify"
        set testfile "pa64-nullify"
    }
    }
    "*" {
    "*" {
        verbose "Skipping hppa nullification tests."
        verbose "Skipping hppa nullification tests."
        return
        return
    }
    }
}
}
set srcfile ${testfile}.s
set srcfile ${testfile}.s
set binfile ${objdir}/${subdir}/${testfile}
set binfile ${objdir}/${subdir}/${testfile}
set gcorefile ${objdir}/${subdir}/${testfile}.gcore
set gcorefile ${objdir}/${subdir}/${testfile}.gcore
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } {
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] != "" } {
    unsupported "Testcase compile failed."
    unsupported "Testcase compile failed."
    return -1
    return -1
}
}
gdb_exit
gdb_exit
gdb_start
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_load ${binfile}
# In the first test, we do a "step" on a function whose last instruction
# In the first test, we do a "step" on a function whose last instruction
# contains a branch-with-nullify.  The instruction in the delay slot belongs
# contains a branch-with-nullify.  The instruction in the delay slot belongs
# to the next function.  We verify that when we step off the first function
# to the next function.  We verify that when we step off the first function
# that we end up back at the caller and not at the second instruction.
# that we end up back at the caller and not at the second instruction.
gdb_breakpoint foo
gdb_breakpoint foo
gdb_test "run" "Breakpoint 1, .* in foo.*" "Breakpoint at foo"
gdb_test "run" "Breakpoint 1, .* in foo.*" "Breakpoint at foo"
set test "stepi till main"
set test "stepi till main"
gdb_test_multiple "stepi" "${test}" {
gdb_test_multiple "stepi" "${test}" {
  -re ".*in foo.*$gdb_prompt $" {
  -re ".*in foo.*$gdb_prompt $" {
    send_gdb "stepi\n"
    send_gdb "stepi\n"
    exp_continue -continue_timer
    exp_continue -continue_timer
  }
  }
  -re ".*in bar.*$gdb_prompt $" {
  -re ".*in bar.*$gdb_prompt $" {
    fail $test
    fail $test
  }
  }
  -re ".*in main.*$gdb_prompt $" {
  -re ".*in main.*$gdb_prompt $" {
    pass $test
    pass $test
  }
  }
}
}
# In the second test, we verify that we can get a proper backtrace
# In the second test, we verify that we can get a proper backtrace
# even when we are in a nullified instruction that belongs to the next function.
# even when we are in a nullified instruction that belongs to the next function.
# We also verify that when stepping over a branch-with-nullify insn that we
# We also verify that when stepping over a branch-with-nullify insn that we
# stay on the same insn for two steps.
# stay on the same insn for two steps.
proc get_addr_of_sym { sym } {
proc get_addr_of_sym { sym } {
  set addr 0
  set addr 0
  global gdb_prompt
  global gdb_prompt
  global hex
  global hex
  set test "get address of $sym"
  set test "get address of $sym"
  gdb_test_multiple "print $sym" $test {
  gdb_test_multiple "print $sym" $test {
    -re ".*($hex) <$sym>.*$gdb_prompt $" {
    -re ".*($hex) <$sym>.*$gdb_prompt $" {
      set addr $expect_out(1,string)
      set addr $expect_out(1,string)
      pass $test
      pass $test
    }
    }
  }
  }
  return $addr
  return $addr
}
}
if { ! [ runto_main ] } then { gdb_suppress_tests; }
if { ! [ runto_main ] } then { gdb_suppress_tests; }
set foo [get_addr_of_sym "foo"]
set foo [get_addr_of_sym "foo"]
set bar [get_addr_of_sym "bar"]
set bar [get_addr_of_sym "bar"]
set foo_last "(bar - 4)"
set foo_last "(bar - 4)"
gdb_breakpoint "*$foo_last"
gdb_breakpoint "*$foo_last"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*"
gdb_test "backtrace" "in foo.*in main.*" "Backtrace from last insn in foo"
gdb_test "backtrace" "in foo.*in main.*" "Backtrace from last insn in foo"
gdb_test "stepi" "in foo.*" "stepi to nullified instruction stays in foo"
gdb_test "stepi" "in foo.*" "stepi to nullified instruction stays in foo"
gdb_test "backtrace" "in foo.*in main.*" "Backtrace from nullified insn"
gdb_test "backtrace" "in foo.*in main.*" "Backtrace from nullified insn"
gdb_test "stepi" "in main.*" "stepi to main"
gdb_test "stepi" "in main.*" "stepi to main"
# In the third test, we verify that backtraces from nullified instructions
# In the third test, we verify that backtraces from nullified instructions
# work even in coredumps
# work even in coredumps
proc gen_core { test } {
proc gen_core { test } {
  global gcorefile
  global gcorefile
  global gdb_prompt
  global gdb_prompt
  set gcore_works 0
  set gcore_works 0
  set escapedfilename [string_to_regexp $gcorefile]
  set escapedfilename [string_to_regexp $gcorefile]
  # gcore is not yet implemented for HPUX
  # gcore is not yet implemented for HPUX
  setup_xfail hppa*-*-hpux*
  setup_xfail hppa*-*-hpux*
  gdb_test_multiple "gcore $gcorefile" "$test: gcore" {
  gdb_test_multiple "gcore $gcorefile" "$test: gcore" {
    -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
    -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
      pass "$test: gcore"
      pass "$test: gcore"
      set gcore_works 1
      set gcore_works 1
    }
    }
    -re "Undefined command.*$gdb_prompt $" {
    -re "Undefined command.*$gdb_prompt $" {
      fail "$test: gcore (undefined command)"
      fail "$test: gcore (undefined command)"
    }
    }
    -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
    -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
      fail "$test: gcore (can't create corefile)"
      fail "$test: gcore (can't create corefile)"
    }
    }
  }
  }
  return $gcore_works
  return $gcore_works
}
}
proc test_core_bt { test } {
proc test_core_bt { test } {
  global gcorefile
  global gcorefile
  gdb_test "core $gcorefile" "Core was generated by.*" \
  gdb_test "core $gcorefile" "Core was generated by.*" \
    "$test: load core file" "A program is being debugged already.*" "y"
    "$test: load core file" "A program is being debugged already.*" "y"
  gdb_test "backtrace" ".*in foo.*in main.*" "$test: backtrace in gcore"
  gdb_test "backtrace" ".*in foo.*in main.*" "$test: backtrace in gcore"
}
}
set test "core at last insn in foo"
set test "core at last insn in foo"
if { ! [ runto_main ] } then { gdb_suppress_tests; }
if { ! [ runto_main ] } then { gdb_suppress_tests; }
gdb_breakpoint "*$foo_last"
gdb_breakpoint "*$foo_last"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
if [gen_core $test] {
if [gen_core $test] {
  test_core_bt $test
  test_core_bt $test
}
}
set test "core at nullified insn"
set test "core at nullified insn"
if { ! [ runto_main ] } then { gdb_suppress_tests; }
if { ! [ runto_main ] } then { gdb_suppress_tests; }
gdb_breakpoint "*$foo_last"
gdb_breakpoint "*$foo_last"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
gdb_test "stepi" ".*in foo.*" "$test: step to nullified instruction"
gdb_test "stepi" ".*in foo.*" "$test: step to nullified instruction"
if [gen_core $test] {
if [gen_core $test] {
  test_core_bt $test
  test_core_bt $test
}
}
 
 

powered by: WebSVN 2.1.0

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