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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.cp/] [exception.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 1997, 1998, 2004, 2005, 2007, 2008, 2009, 2010
# Copyright 1997, 1998, 2004, 2005, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
# 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.
# tests for exception-handling support
# tests for exception-handling support
# Written by Satish Pai  1997-07-23
# Written by Satish Pai  1997-07-23
# Rewritten by Michael Chastain  2004-01-08
# Rewritten by Michael Chastain  2004-01-08
# This file used to have two copies of the tests with different
# This file used to have two copies of the tests with different
# compiler flags for hp-ux.  Instead, the user should set CXXOPTS
# compiler flags for hp-ux.  Instead, the user should set CXXOPTS
# or run runtest with --target_board unix/gdb:debug_flags="..."
# or run runtest with --target_board unix/gdb:debug_flags="..."
# to choose the compiler flags.
# to choose the compiler flags.
#
#
# The interesting compiler flags are: "aCC +A -Wl,-a,-archive" .
# The interesting compiler flags are: "aCC +A -Wl,-a,-archive" .
# Static-linked executables use a different mechanism to get the
# Static-linked executables use a different mechanism to get the
# address of the notification hook in the C++ support library.
# address of the notification hook in the C++ support library.
# TODO: this file has many absolute line numbers.
# TODO: this file has many absolute line numbers.
# Replace them with gdb_get_line_number.
# Replace them with gdb_get_line_number.
set ws  "\[\r\n\t \]+"
set ws  "\[\r\n\t \]+"
set nl  "\[\r\n\]+"
set nl  "\[\r\n\]+"
if $tracelevel then {
if $tracelevel then {
    strace $tracelevel
    strace $tracelevel
}
}
if { [skip_cplus_tests] } { continue }
if { [skip_cplus_tests] } { continue }
# On SPU this test fails because the executable exceeds local storage size.
# On SPU this test fails because the executable exceeds local storage size.
if { [istarget "spu*-*-*"] } {
if { [istarget "spu*-*-*"] } {
        return 0
        return 0
}
}
set testfile "exception"
set testfile "exception"
set srcfile ${testfile}.cc
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
     untested exception.exp
     untested exception.exp
     return -1
     return -1
}
}
# Start with a fresh gdb
# Start with a fresh gdb
set prms_id 0
set prms_id 0
set bug_id 0
set bug_id 0
gdb_exit
gdb_exit
gdb_start
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_load ${binfile}
# Set a catch catchpoint
# Set a catch catchpoint
gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \
gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \
    "catch catch (before inferior run)"
    "catch catch (before inferior run)"
# Set a throw catchpoint
# Set a throw catchpoint
gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
    "catch throw (before inferior run)"
    "catch throw (before inferior run)"
# The catchpoints should be listed in the list of breakpoints.
# The catchpoints should be listed in the list of breakpoints.
# In case of a statically linked test, we won't have a pending breakpoint.
# In case of a statically linked test, we won't have a pending breakpoint.
# Hence we allow for both an address or "". If we ever become able
# Hence we allow for both an address or "". If we ever become able
# to tell whether the target is linked statically or not, we can be more
# to tell whether the target is linked statically or not, we can be more
# precise and require exact output.
# precise and require exact output.
set addr "\(|$hex\)"
set addr "\(|$hex\)"
set re_head     "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
set re_head     "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
set re_2_bp     "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch"
set re_2_bp     "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch"
set re_3_bp     "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw"
set re_3_bp     "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw"
set name "info breakpoints (before inferior run)"
set name "info breakpoints (before inferior run)"
gdb_test_multiple "info breakpoints" $name {
gdb_test_multiple "info breakpoints" $name {
    -re "$re_head${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
    -re "$re_head${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
    -re ".*$gdb_prompt $"
    -re ".*$gdb_prompt $"
      {
      {
        fail $name
        fail $name
      }
      }
}
}
gdb_test "tbreak main" "Temporary breakpoint 3.*" \
gdb_test "tbreak main" "Temporary breakpoint 3.*" \
    "Set temporary breakpoint at main"
    "Set temporary breakpoint at main"
set ok 0
set ok 0
gdb_run_cmd
gdb_run_cmd
gdb_test_multiple "" "Run to main" {
gdb_test_multiple "" "Run to main" {
    -re "Temporary breakpoint 3,.*$gdb_prompt $" {
    -re "Temporary breakpoint 3,.*$gdb_prompt $" {
        pass "Run to main"
        pass "Run to main"
        set ok 1
        set ok 1
    }
    }
}
}
if { !$ok } {
if { !$ok } {
    continue
    continue
}
}
set addr "$hex"
set addr "$hex"
set re_head     "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
set re_head     "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
set re_2_bp     "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch"
set re_2_bp     "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch"
set re_3_bp     "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw"
set re_3_bp     "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw"
set name "info breakpoints (after inferior run)"
set name "info breakpoints (after inferior run)"
gdb_test_multiple "info breakpoints" $name {
gdb_test_multiple "info breakpoints" $name {
    -re "$re_head${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
    -re "$re_head${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
    -re ".*$gdb_prompt $"
    -re ".*$gdb_prompt $"
      {
      {
        send_user "\n---\n$expect_out(buffer)\n---\n"
        send_user "\n---\n$expect_out(buffer)\n---\n"
        fail $name
        fail $name
      }
      }
}
}
# Get the first exception thrown
# Get the first exception thrown
set name "continue to first throw"
set name "continue to first throw"
gdb_test_multiple "continue" $name {
gdb_test_multiple "continue" $name {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# Backtrace from the throw point.
# Backtrace from the throw point.
# This should get to user code.
# This should get to user code.
set name "backtrace after first throw"
set name "backtrace after first throw"
gdb_test_multiple "backtrace" $name {
gdb_test_multiple "backtrace" $name {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# Continue to the catch.
# Continue to the catch.
set name "continue to first catch"
set name "continue to first catch"
gdb_test_multiple "continue" $name {
gdb_test_multiple "continue" $name {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# Backtrace from the catch point.
# Backtrace from the catch point.
# This should get to user code.
# This should get to user code.
set name "backtrace after first catch"
set name "backtrace after first catch"
gdb_test_multiple "backtrace" $name {
gdb_test_multiple "backtrace" $name {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# Continue to second throw.
# Continue to second throw.
set name "continue to second throw"
set name "continue to second throw"
gdb_test_multiple "continue" $name {
gdb_test_multiple "continue" $name {
    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# Backtrace from the throw point.
# Backtrace from the throw point.
# This should get to user code.
# This should get to user code.
set name "backtrace after second throw"
set name "backtrace after second throw"
gdb_test_multiple "backtrace" $name {
gdb_test_multiple "backtrace" $name {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_throw.*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# Continue to second catch.
# Continue to second catch.
set name "continue to second catch"
set name "continue to second catch"
gdb_test_multiple "continue" $name {
gdb_test_multiple "continue" $name {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" {
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# Backtrace from the catch point.
# Backtrace from the catch point.
# This should get to user code.
# This should get to user code.
set name "backtrace after second catch"
set name "backtrace after second catch"
gdb_test_multiple "backtrace" $name {
gdb_test_multiple "backtrace" $name {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
    -re ".*#\[0-9\]+${ws}($hex in |)__cxa_begin_catch.*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
        pass $name
    }
    }
}
}
# That is all for now.
# That is all for now.
#
#
# The original code had:
# The original code had:
#
#
#    continue to re-throw ; backtrace
#    continue to re-throw ; backtrace
#    continue to catch    ; backtrace
#    continue to catch    ; backtrace
#    continue to throw out of main
#    continue to throw out of main
#
#
# The problem is that "re-throw" does not show a throw; only a catch.
# The problem is that "re-throw" does not show a throw; only a catch.
# I do not know if this is because of a bug, or because the generated
# I do not know if this is because of a bug, or because the generated
# code is optimized for a throw into the same function.
# code is optimized for a throw into the same function.
#
#
# -- chastain 2004-01-09
# -- chastain 2004-01-09
 
 

powered by: WebSVN 2.1.0

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