⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inherit.exp

📁 gdb-6.8 Linux下的调试程序 最新版本
💻 EXP
📖 第 1 页 / 共 2 页
字号:
# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003,# 2004, 2006, 2007, 2008 Free Software Foundation, Inc.# 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# the Free Software Foundation; either version 3 of the License, or# (at your option) any later version.## 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.## You should have received a copy of the GNU General Public License# along with this program.  If not, see <http://www.gnu.org/licenses/>.# This file was written by Fred Fish. (fnf@cygnus.com)# And rewritten by Michael Chastain. (mec.gnu@mindspring.com)set ws  "\[\r\n\t \]+"set nl  "\[\r\n\]+"set vhn "\\$\[0-9\]+"if $tracelevel then {    strace $tracelevel}if { [skip_cplus_tests] } { continue }load_lib "cp-support.exp"set testfile "inherit"set srcfile misc.ccset binfile ${objdir}/${subdir}/${testfile}if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {     untested inherit.exp     return -1}# Single inheritance, print type definitions.proc test_ptype_si { } {    global gdb_prompt    global ws    global nl    # A simple class.    cp_test_ptype_class \	"ptype A" "ptype A (FIXME)" "class" "A" \	{	    { field public "int a;" }	    { field public "int x;" }	}    cp_test_ptype_class "ptype class A" "ptype class A (FIXME)" "class" "A" ibid    cp_test_ptype_class "ptype g_A" "ptype g_A (FIXME)" "class" "A" ibid    # A derived class.    cp_test_ptype_class \	"ptype B" "" "class" "B" \	{	    { base         "public A" }	    { field public "int b;" }	    { field public "int x;" }	}    cp_test_ptype_class "ptype class B" "" "class" "B" ibid    cp_test_ptype_class "ptype g_B" "" "class" "B" ibid    # Another derived class.    cp_test_ptype_class \	"ptype C" "" "class" "C" \	{	    { base         "public A" }	    { field public "int c;" }	    { field public "int x;" }	}    cp_test_ptype_class "ptype class C" "" "class" "C" ibid    cp_test_ptype_class "ptype g_C" "" "class" "C" ibid    # A structure with no tag.    # TODO: move this mess into a separate file, and re-specify    # which results are PASS, KFAIL, XFAIL, and FAIL.    set re_tag		"tagless_struct"    set XX_tag		"\\._1"    set re_class	"(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)"    set XX_class	"(class $XX_tag \{${ws}public:|struct $XX_tag \{)"    set re_fields	"int one;${ws}int two;"    set re_synth_gcc_23	"$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);"    set XX_synth_gcc_23	"($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);"    set name "ptype tagless struct"    gdb_test_multiple "ptype tagless_struct" $name {	-re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {	    # gcc 2.95.3 -gdwarf-2	    pass "$name"	}	-re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {	    # gcc 2.95.3 -gstabs+	    pass "$name"	}	-re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {	    # gcc 3.3.4 -gdwarf-2	    # gcc 3.4.1 -gdwarf-2	    # gcc HEAD 2004-07-31 -gdwarf-2	    # gcc HEAD 2004-07-31 -gstabs+	    pass "$name"	}	-re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {	    # gcc 3.3.4 -gstabs+	    # gcc 3.4.1 -gstabs+	    pass "$name"	}    }    set name "ptype variable of type tagless struct"    gdb_test_multiple "ptype v_tagless" $name {	-re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {	    # gcc 2.95.3 -gdwarf-2	    pass "$name"	}	-re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {	    # gcc 2.95.3 -gstabs+	    pass "$name"	}	-re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {	    # gcc 3.3.4 -gdwarf-2	    # gcc 3.4.1 -gdwarf-2	    # gcc HEAD 2004-07-31 -gdwarf-2	    # gcc HEAD 2004-07-31 -gstabs+	    pass "$name"	}	-re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {	    # gcc 3.3.4 -gstabs+	    # gcc 3.4.1 -gstabs+	    pass "$name"	}    }}# Multiple inheritance, print type definitions.proc test_ptype_mi { } {    # A class with two bases.    cp_test_ptype_class \	"ptype D" "" "class" "D" \	{	    { base         "public B" }	    { base         "public C" }	    { field public "int d;" }	    { field public "int x;" }	}    cp_test_ptype_class "ptype class D" "" "class" "D" ibid    cp_test_ptype_class "ptype g_D" "" "class" "D" ibid    # A class derived from the previous class.    cp_test_ptype_class \	"ptype E" "" "class" "E" \	{	    { base         "public D" }	    { field public "int e;" }	    { field public "int x;" }	}    cp_test_ptype_class "ptype class E" "" "class" "E" ibid    cp_test_ptype_class "ptype g_E" "" "class" "E" ibid}# Single virtual inheritance, print type definitions.proc test_ptype_vi { } {    # class vA    cp_test_ptype_class \	"ptype vA" "" "class" "vA" \	{	    { field public "int va;" }	    { field public "int vx;" }	}    cp_test_ptype_class "ptype class vA" "" "class" "vA" ibid    cp_test_ptype_class "ptype g_vA" "" "class" "vA" ibid    # class vB    cp_test_ptype_class \	"ptype vB" "" "class" "vB" \	{	    { base         "public virtual vA" }	    { vbase        "vA" }	    { field public "int vb;" }	    { field public "int vx;" }	}    cp_test_ptype_class "ptype class vB" "" "class" "vB" ibid    cp_test_ptype_class "ptype g_vB" "" "class" "vB" ibid    # class vC    cp_test_ptype_class \	"ptype vC" "" "class" "vC" \	{	    { base         "public virtual vA" }	    { vbase        "vA" }	    { field public "int vc;" }	    { field public "int vx;" }	}    cp_test_ptype_class "ptype class vC" "" "class" "vC" ibid    cp_test_ptype_class "ptype g_vC" "" "class" "vC" ibid}# Multiple virtual inheritance, print type definitions.proc test_ptype_mvi { } {    # class vD    cp_test_ptype_class \	"ptype vD" "" "class" "vD" \	{	    { base         "public virtual vB" }	    { base         "public virtual vC" }	    { vbase        "vC" }	    { vbase        "vB" }	    { field public "int vd;" }	    { field public "int vx;" }	}    cp_test_ptype_class "ptype class vD" "" "class" "vD" ibid    cp_test_ptype_class "ptype g_vD" "" "class" "vD" ibid    # class vE    cp_test_ptype_class \	"ptype vE" "" "class" "vE" \	{	    { base         "public virtual vD" }	    { vbase        "vD" }	    { field public "int ve;" }	    { field public "int vx;" }	}    cp_test_ptype_class "ptype class vE" "" "class" "vE" ibid    cp_test_ptype_class "ptype g_vE" "" "class" "vE" ibid}# Single inheritance, print individual members.proc test_print_si_members { } {    global vhn    # Print all members of g_A using fully qualified form.    gdb_test "print g_A.A::a" "$vhn = 1"    gdb_test "print g_A.A::x" "$vhn = 2"    # Print members of g_A using nonambiguous compact form.    gdb_test "print g_A.a" "$vhn = 1"    gdb_test "print g_A.x" "$vhn = 2"    # Print all members of g_B using fully qualified form.    gdb_test "print g_B.A::a" "$vhn = 3"    gdb_test "print g_B.A::x" "$vhn = 4"    gdb_test "print g_B.B::b" "$vhn = 5"    gdb_test "print g_B.B::x" "$vhn = 6"    # Print members of g_B using nonambiguous compact form.    gdb_test "print g_B.a" "$vhn = 3"    gdb_test "print g_B.b" "$vhn = 5"    gdb_test "print g_B.x" "$vhn = 6"    # Print all members of g_C using fully qualified form.    gdb_test "print g_C.A::a" "$vhn = 7"    gdb_test "print g_C.A::x" "$vhn = 8"    gdb_test "print g_C.C::c" "$vhn = 9"    gdb_test "print g_C.C::x" "$vhn = 10"    # Print members of g_C using nonambiguous compact form.    gdb_test "print g_C.a" "$vhn = 7"    gdb_test "print g_C.c" "$vhn = 9"    gdb_test "print g_C.x" "$vhn = 10"}# Single inheritance, print complete classes.proc test_print_si_classes { } {    global vhn    # Print all members of g_A, g_B, g_C.    gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}"    gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}"    gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}"}# Multiple inheritance, print individual members.proc test_print_mi_members {} {    global gdb_prompt    global nl    global vhn    # Print all members of g_A.    gdb_test "print g_A.A::a" "$vhn = 1"    gdb_test "print g_A.A::x" "$vhn = 2"    # Print all members of g_B.    gdb_test "print g_B.A::a" "$vhn = 3"    gdb_test "print g_B.A::x" "$vhn = 4"    gdb_test "print g_B.B::b" "$vhn = 5"    gdb_test "print g_B.B::x" "$vhn = 6"    # Print all members of g_C.    gdb_test "print g_C.A::a" "$vhn = 7"    gdb_test "print g_C.A::x" "$vhn = 8"    gdb_test "print g_C.C::c" "$vhn = 9"    gdb_test "print g_C.C::x" "$vhn = 10"    # Print all members of g_D.    #    # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb    # should detect these.  There are no ways to PASS these tests    # because I don't know what the gdb message will be.  -- chastain    # 2004-01-27.    set name "print g_D.A::a"    gdb_test_multiple "print g_D.A::a" $name {	-re "$vhn = (15|11)$nl$gdb_prompt $" {	    kfail "gdb/68" "print g_D.A::a"	}    }    set name "print g_D.A::x"    gdb_test_multiple "print g_D.A::x" $name {	-re "$vhn = (16|12)$nl$gdb_prompt $" {	    kfail "gdb/68" "print g_D.A::x"	}    }    gdb_test "print g_D.B::b" "$vhn = 13"    gdb_test "print g_D.B::x" "$vhn = 14"    gdb_test "print g_D.C::c" "$vhn = 17"    gdb_test "print g_D.C::x" "$vhn = 18"    gdb_test "print g_D.D::d" "$vhn = 19"    gdb_test "print g_D.D::x" "$vhn = 20"    # Print all members of g_E.    # g_E.A::a and g_E.A::x are ambiguous.    set name "print g_E.A::a"    gdb_test_multiple "print g_E.A::a" $name {	-re "$vhn = (21|25)$nl$gdb_prompt $" {	    kfail "gdb/68" "print g_E.A::a"	}    }    set name "print g_E.A::x"    gdb_test_multiple "print g_E.A::x" $name {	-re "$vhn = (26|22)$nl$gdb_prompt $" {	    kfail "gdb/68" "print g_E.A::x"	}    }    gdb_test "print g_E.B::b" "$vhn = 23"    gdb_test "print g_E.B::x" "$vhn = 24"    gdb_test "print g_E.C::c" "$vhn = 27"    gdb_test "print g_E.C::x" "$vhn = 28"    gdb_test "print g_E.D::d" "$vhn = 29"    gdb_test "print g_E.D::x" "$vhn = 30"    gdb_test "print g_E.E::e" "$vhn = 31"    gdb_test "print g_E.E::x" "$vhn = 32"}# Multiple inheritance, print individual member types.proc test_print_mi_member_types {} {    global gdb_prompt    global nl    global vhn    # Print the types of some members of g_D without qualifying them.    gdb_test "ptype g_D.b" "type = int"    gdb_test "ptype g_D.c" "type = int"    gdb_test "ptype g_D.d" "type = int"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -