📄 classes.exp
字号:
global hp_aCC_compiler # print the object send_gdb "print obj_with_enum\n" gdb_expect { -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" } -re "$gdb_prompt $" { fail "print obj_with_enum (1)" } timeout { fail "(timeout) print obj_with_enum (1)" } } send_gdb "next\n" gdb_expect { -re "$gdb_prompt $" { pass "next" } timeout { fail "(timeout) next" } } # print the object again send_gdb "print obj_with_enum\n" gdb_expect { -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" } -re "$gdb_prompt $" { fail "print obj_with_enum (2)" } timeout { fail "(timeout) print obj_with_enum (2)" } } # print out the enum member send_gdb "print obj_with_enum.priv_enum\n" gdb_expect { -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" } -re "$gdb_prompt $" { fail "print obj_with_enum.priv_enum" } timeout { fail "(timeout) print obj_with_enum.priv_enum" } } # ptype on the enum member # The third success case is a little dubious, but it's not clear what # ought to be required of a ptype on a private enum... -sts 19990324 send_gdb "ptype obj_with_enum.priv_enum\n" gdb_expect { -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } -re "type = enum PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } -re "type = enum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" } -re "$gdb_prompt $" { fail "ptype obj_with_enum.priv_enum" } timeout { fail "(timeout) ptype obj_with_enum.priv_enum" } } # ptype on the object send_gdb "ptype obj_with_enum\n" gdb_expect { -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)ClassWithEnum::PrivEnum priv_enum;\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { pass "ptype obj_with_enum" } -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)PrivEnum priv_enum;\r\n\[ \t\]*int x;.*\\}\r\n$gdb_prompt $" { # NOTE: carlton/2003-02-28: One could certainly argue that # this output is acceptable: PrivEnum is a member of # ClassWithEnum, so there's no need to explicitly qualify # its name with "ClassWithEnum::". The truth, though, is # that GDB is simply forgetting that PrivEnum is a member # of ClassWithEnum, so we do that output for a bad reason # instead of a good reason. Under stabs, we probably # can't get this right; under DWARF-2, we can. kfail "gdb/57" "ptype obj_with_enum" } -re "$gdb_prompt $" { fail "ptype obj_with_enum" } timeout { fail "(timeout) ptype obj_with_enum" } } # We'll do this test twice, because of a parser bug: see # PR gdb/826. send_gdb "print (ClassWithEnum::PrivEnum) 42\n" gdb_expect { -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" } -re "A parse error in expression, near `42'.\r\n$gdb_prompt $" { kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42" } -re "$gdb_prompt $" { fail "print (ClassWithEnum::PrivEnum) 42" } timeout { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" } } send_gdb "print ('ClassWithEnum::PrivEnum') 42\n" gdb_expect { -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print ('ClassWithEnum::PrivEnum') 42" } -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.\r\n$gdb_prompt $" { kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" } -re "$gdb_prompt $" { fail "print ('ClassWithEnum::PrivEnum') 42" } timeout { fail "(timeout) print ('ClassWithEnum::PrivEnum') 42" } }}## Pointers to class members#proc test_pointers_to_class_members {} { global gdb_prompt global decimal global nl gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z" gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x" gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x" send_gdb "print (int)&Bar::y == 2*sizeof(int)\n" gdb_expect { -re ".* = true$nl$gdb_prompt $" { pass "print (int)&Bar::y == 2*sizeof(int)" } -re "There is no field named y.*$gdb_prompt $" { setup_xfail "*-*-*" fail "print (int)&Bar::y == 2*sizeof(int)" } -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" } timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return } } send_gdb "next 2\n" setup_xfail "*-*-*" gdb_expect { -re "$decimal\[ \t\]+inheritance3 \[)(\]+;$nl$gdb_prompt $" {} -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return } } clear_xfail "*-*-*" gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)"}## Test static members.#proc test_static_members {} { global gdb_prompt global hex global nl send_gdb "print Foo::st\n" gdb_expect { -re ".* = 100$nl$gdb_prompt $" { pass "print Foo::st" } -re "There is no field named st.*$gdb_prompt $" { setup_xfail "*-*-*" fail "print Foo::st" } -re ".*$gdb_prompt $" { fail "print Foo::st" } timeout { fail "print Foo::st (timeout)" ; return } } send_gdb "set foo.st = 200\n" gdb_expect { -re ".*$gdb_prompt $" {} } send_gdb "print bar.st\n" gdb_expect { -re ".* = 200$nl$gdb_prompt $" { pass "print bar.st" } -re "There is no member( or method|) named st.*$gdb_prompt $" { setup_xfail "*-*-*" fail "print bar.st" } -re ".*$gdb_prompt $" { fail "print bar.st" } timeout { fail "print bar.st (timeout)" ; return } } send_gdb "print &foo.st\n" gdb_expect { -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { pass "print &foo.st" } -re "There is no member( or method|) named st.*$gdb_prompt $" { setup_xfail "*-*-*" fail "print &foo.st" } -re ".*$gdb_prompt $" { fail "print &foo.st" } timeout { fail "print &foo.st (timeout)" ; return } } set got_bar_st 0 send_gdb "print &Bar::st\n" gdb_expect { -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" { pass "print &Bar::st" set got_bar_st 1 } -re "There is no field named st.*$gdb_prompt $" { setup_xfail "*-*-*" fail "print &Bar::st" } -re ".*$gdb_prompt $" { fail "print &Bar::st" } timeout { fail "print &Bar::st (timeout)" ; return } } if $got_bar_st then { gdb_test "print *\$" ".* = 200" "print *\$" } gdb_test "set print static-members off" "" gdb_test "print csi" \ "{x = 10, y = 20}" \ "print csi without static members" gdb_test "print cnsi" \ "{x = 30, y = 40}" \ "print cnsi without static members" gdb_test "set print static-members on" "" gdb_test "print csi" \ "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \ "print csi with static members" gdb_test "print cnsi" \ "{x = 30, y = 40, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>, static yy = {z = 5, static xx = {x = 1, y = 2, static null = <same as static member of an already seen type>, static yy = <same as static member of an already seen type>}}}, static yy = <same as static member of an already seen type>}" \ "print cnsi with static members"}proc do_tests {} { global prms_id global bug_id global subdir global objdir global srcdir global binfile global gdb_prompt set prms_id 0 set bug_id 0 # Start with a fresh gdb. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load $binfile send_gdb "set language c++\n" gdb_expect -re "$gdb_prompt $" send_gdb "set width 0\n" gdb_expect -re "$gdb_prompt $" runto_main test_ptype_class_objects if [ runto 'inheritance2' ] then { test_non_inherited_member_access test_wrong_class_members test_nonexistent_members test_method_param_class } gdb_breakpoint enums2 if [ gdb_continue "enums2(\\(\\)|)" ]==0 then { gdb_test "finish" "" "" test_enums } if [istarget "mips-idt-*"] then { # Restart because IDT/SIM runs out of file descriptors. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load $binfile } if [ runto_main ] then { test_pointers_to_class_members test_static_members } if [istarget "mips-idt-*"] then { # Restart because IDT/SIM runs out of file descriptors. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load $binfile } if [ runto marker_reg1 ] then { gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" send_gdb "print v.method ()\n" gdb_expect { -re "= 82.*$gdb_prompt $" { pass "calling method for small class" } -re "Address requested for identifier .v. which is in register.*$gdb_prompt $" { setup_xfail "*-*-*" 2972 fail "calling method for small class" } -re ".*$gdb_prompt $" { fail "calling method for small class" } timeout { fail "calling method for small class (timeout)" } eof { fail "calling method for small class (eof)" } } }}do_testssend_gdb "maint demangle inheritance1__Fv\n"gdb_expect { -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" } -re ".*$gdb_prompt $" { fail "demangle" } timeout { fail "(timeout) demangle" }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -