1139825Simp# Copyright 2015-2020 Free Software Foundation, Inc.
2117119Stmm
386234Stmm# This program is free software; you can redistribute it and/or modify
486234Stmm# it under the terms of the GNU General Public License as published by
586234Stmm# the Free Software Foundation; either version 3 of the License, or
686234Stmm# (at your option) any later version.
786234Stmm#
886234Stmm# This program is distributed in the hope that it will be useful,
986234Stmm# but WITHOUT ANY WARRANTY; without even the implied warranty of
1086234Stmm# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1186234Stmm# GNU General Public License for more details.
1286234Stmm#
1386234Stmm# You should have received a copy of the GNU General Public License
1486234Stmm# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1586234Stmmload_lib dwarf.exp
1686234Stmm
1786234Stmm# This test can only be run on targets which support DWARF-2 and use gas.
1886234Stmmif {![dwarf2_support]} {
1986234Stmm    return 0
2086234Stmm}
2186234Stmm
2286234Stmmif { [skip_cplus_tests] } { continue }
2386234Stmm
2486234Stmmstandard_testfile main.c staticvirtual-dw.S
2586234Stmm
2686234Stmm# Make DWARF for the test.
2786234Stmmset asm_file [standard_output_file $srcfile2]
2886234StmmDwarf::assemble $asm_file {
2986234Stmm    cu {} {
30115417Stmm	compile_unit {{language @DW_LANG_C_plus_plus}} {
31115417Stmm	    structure_type {
32117119Stmm		{name S}
3386234Stmm		{byte_size 1 DW_FORM_sdata}
34117119Stmm	    } {
3586234Stmm		subprogram {
3686234Stmm		    {low_pc 0x1000 addr}
37117119Stmm		    {high_pc 0x2000 addr}
38117119Stmm		    {name ~S}
39117119Stmm		    {external 1 flag}
40117119Stmm		    {virtuality @DW_VIRTUALITY_virtual}
4186234Stmm		    {vtable_elem_location {const1u 1} SPECIAL_expr}
42117119Stmm		}
4386234Stmm	    }
4486234Stmm	}
45117119Stmm    }
4686234Stmm}
4786234Stmm
4886234Stmmif { [prepare_for_testing "failed to prepare" ${testfile} \
49117119Stmm	  [list $srcfile $asm_file] {nodebug}] } {
5086234Stmm    return -1
5186234Stmm}
5286234Stmm
53117119Stmm# gdb/18021: The test below would cause GDB to crash.
5486234Stmm# Depending on whether the target maps memory at address 0x1000,
5586234Stmm# on success this may either print something like
56117119Stmm#   $1 = {void (void)} 0x1000 <.*>
57117119Stmm# or
58117119Stmm#   Cannot access memory at address 0x1000
59117119Stmmgdb_test "p S::~S" "0x1000.*"
60117119Stmm