From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12441 invoked by alias); 24 Sep 2009 16:41:30 -0000 Received: (qmail 12432 invoked by uid 22791); 24 Sep 2009 16:41:27 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Sep 2009 16:41:20 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 96A8C2BABC3 for ; Thu, 24 Sep 2009 12:41:18 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id i5wJqxcNs56v for ; Thu, 24 Sep 2009 12:41:18 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 073072BABBC for ; Thu, 24 Sep 2009 12:41:18 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 248B1F593C; Thu, 24 Sep 2009 09:41:15 -0700 (PDT) Date: Thu, 24 Sep 2009 16:41:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: gdb.objc/objcdecode.exp test error.. Message-ID: <20090924164115.GA2112@adacore.com> References: <8ba6bed40903051731s41c9183aha18af51113f3c0ea@mail.gmail.com> <20090306173345.GI3744@adacore.com> <200903061913.43419.pedro@codesourcery.com> <8ba6bed40903070407q3e91f0ffs6fc67b2b9c329081@mail.gmail.com> <8ba6bed40903080716k3fbeb56t5605aef1864b26a3@mail.gmail.com> <20090923231317.GA18470@adacore.com> <8ba6bed40909232348j47027093of7a2bafb8120e5ce@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline In-Reply-To: <8ba6bed40909232348j47027093of7a2bafb8120e5ce@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-09/txt/msg00746.txt.bz2 --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 113 For the record, here is the patch that Matt sent me privately when he realized he forgot to attach it. -- Joel --LZvS9be/3tNcYl/X Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-New-objc-tests.patch" Content-length: 10208 >From ad407eb015bbdde409cbcdf98f116b9ea949644a Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Wed, 23 Sep 2009 22:48:41 -0700 Subject: [PATCH] New objc tests. 2009-09-23 Matt Rice * gdb.objc/ambiguous.exp: New objc tests for 8343 with shared libs. * gdb.objc/ambiguous.m: New objc file. * gdb.objc/objcdecode.exp: Additional objc tests for 8343. * gdb.objc/objcdecode2.m: New objc file. * gdb.objc/objcdecode3.m: New objc file. * lib/gdb.exp (gdb_continue_to_breakpoint): Handle internal error. --- gdb/testsuite/gdb.objc/ambiguous.exp | 119 +++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.objc/ambiguous.m | 35 ++++++++++ gdb/testsuite/gdb.objc/objcdecode.exp | 43 ++++++++++-- gdb/testsuite/gdb.objc/objcdecode2.m | 20 ++++++ gdb/testsuite/gdb.objc/objcdecode3.m | 19 +++++ gdb/testsuite/lib/gdb.exp | 5 ++ 6 files changed, 233 insertions(+), 8 deletions(-) create mode 100644 gdb/testsuite/gdb.objc/ambiguous.exp create mode 100644 gdb/testsuite/gdb.objc/ambiguous.m create mode 100644 gdb/testsuite/gdb.objc/objcdecode2.m create mode 100644 gdb/testsuite/gdb.objc/objcdecode3.m diff --git a/gdb/testsuite/gdb.objc/ambiguous.exp b/gdb/testsuite/gdb.objc/ambiguous.exp new file mode 100644 index 0000000..aefc7f7 --- /dev/null +++ b/gdb/testsuite/gdb.objc/ambiguous.exp @@ -0,0 +1,119 @@ +# Copyright 2009 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 . + +# This file tests breakpoints on ambiguous expressions in C and Obj-C symbols +# And their affects across shared libraries. + +# This file was written by Matt Rice (ratmice@gmail.com) + +if $tracelevel then { + strace $tracelevel +} + +proc gdb_reinitialize {} { + global prms_id + global bug_id + global subdir + global srcdir + global binfile + + 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 + +} + +set testfile "objcdecode2" +set srcfile ${testfile}.m +set binfile ${objdir}/${subdir}/lib${testfile}.so +set lib_flags [list debug additional_flags=[list -g -fPIC -I${srcdir}/${subdir}] ] + +if {[gdb_compile_shlib "${srcdir}/${subdir}/${srcfile}" "${binfile}" $lib_flags] != "" } { + return -1 +} + +set testfile "objcdecode3" +set srcfile ${testfile}.m +set binfile ${objdir}/${subdir}/lib${testfile}.so +set decode3_binfile $binfile + +if {[gdb_compile_shlib "${srcdir}/${subdir}/${srcfile}" "${binfile}" $lib_flags] != "" } { + return -1 +} + + +set testfile "ambiguous" +set srcfile ${testfile}.m +set binfile ${objdir}/${subdir}/${testfile} +set ambig_opts [list debug additional_flags=[list -g \ + -DSHLIB_NAME=\"$decode3_binfile\" \ + -L${objdir}/${subdir} \ + -Wl,-rpath,${objdir}/${subdir} \ + -ldl -lobjcdecode2 \ + -I${srcdir}/${subdir}] ] + +if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${ambig_opts}] != "" } { + return -1 +} + +gdb_reinitialize + +set name "setup ambiguous expression" +gdb_test "break foo" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*" $name + +gdb_run_cmd +set name "loading shlib with breakpoint on ambiguous expr" +setup_kfail "*-*-*" gdb/8343 +gdb_test "" "Breakpoint \[0-9\]+, foo \\\(\\\) at .*" $name + +set name "breakpoint on ambiguous objc method after shlib" +gdb_test "break foo" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*" $name + +gdb_continue_to_breakpoint "foo class implementation" + +gdb_reinitialize + +gdb_test "set breakpoint pending on" "" +gdb_test "break -\[DecodeShlib bar\]" ".*not defined.*" + +gdb_test "run" \ +"Breakpoint \[0-9\]+, -\\\[DecodeShlib bar\\\] \\\(.*\\\) at .*" \ +"break on bar class implementation" + +setup_kfail "*-*-*" gdb/8343 +gdb_continue_to_breakpoint "bar category implementation" + +# i'm not sure why this reacts differently than the above tests +# using pending breakpoints but it does: therefore i've added it +# even though they appear quite similar. +gdb_reinitialize + +if ![runto_main] { + fail "unable to run to main" +} + +gdb_test "break bar" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*" $name + +gdb_continue_to_breakpoint "bar class implementation" +setup_kfail "*-*-*" gdb/8343 +gdb_continue_to_breakpoint "bar category implementation" + +return 0 diff --git a/gdb/testsuite/gdb.objc/ambiguous.m b/gdb/testsuite/gdb.objc/ambiguous.m new file mode 100644 index 0000000..fb59919 --- /dev/null +++ b/gdb/testsuite/gdb.objc/ambiguous.m @@ -0,0 +1,35 @@ +#include +#include +#include + +#ifdef __WIN32__ +#include +#define dlopen(name, mode) LoadLibrary (name) +#define dlerror() "an error occurred" +#else +#include +#endif + +void foo() +{ + printf("function implementation\n"); +} + +int main() +{ + void *handle; + id obj = [DecodeShlib new]; + + foo(); + [obj foo]; + + [obj bar]; /* class implementation */ + + handle = dlopen(SHLIB_NAME, RTLD_LAZY); + if (!handle) + fprintf(stderr, "error calling dlopen: %s\n", dlerror()); + + [obj foo]; /* category implementation */ + + return 0; +} diff --git a/gdb/testsuite/gdb.objc/objcdecode.exp b/gdb/testsuite/gdb.objc/objcdecode.exp index b751fb9..317f050 100644 --- a/gdb/testsuite/gdb.objc/objcdecode.exp +++ b/gdb/testsuite/gdb.objc/objcdecode.exp @@ -33,14 +33,12 @@ if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [ return -1 } -proc do_objc_tests {} { +proc gdb_reinitialize {} { 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 @@ -54,12 +52,13 @@ proc do_objc_tests {} { } -do_objc_tests +gdb_reinitialize # # Break on multiply defined method (PR objc/1236) # -set name "break on multiply defined method" +set name "break on multiply defined method using multiple-symbols ask" +gdb_test "set multiple-symbols ask" "" gdb_test_multiple "break multipleDef" $name \ { -re "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] -.Decode multipleDef. at .*\r\n\\\[3\\\] multipleDef at .*\r\n> $" { @@ -67,10 +66,10 @@ gdb_test_multiple "break multipleDef" $name \ exp_continue } -re "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*\r\n$gdb_prompt $" { pass $name } - -re ".*$gdb_prompt $" { kfail "gdb/1236" $name } + -re ".*$gdb_prompt $" { kfail "gdb/8343" $name } } -set name "continue after break on multiply defined symbol" +set name "run after setting breakpoints on multiply defined symbol" gdb_run_cmd gdb_test_multiple "" $name \ { @@ -79,8 +78,36 @@ gdb_test_multiple "" $name \ } -re "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] -.Decode multipleDef. at .*\r\n\\\[3\\\] multipleDef at .*\r\n> $" { send_gdb "0\n" - kfail "gdb/1238" $name + kfail "gdb/8343" $name # gdb is in a bad state here. # It would be difficult to do any more tests after this. } } + +gdb_reinitialize +if ![runto_main] { fail "Can't run to main" } + +gdb_test "set multiple-symbols all" ".*" "setup multiple-symbols all" +gdb_test "break multipleDef" \ +"Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*" \ +"break on multiply defined symbol with multiple-symbols all after main" + +set name "can hit multiply defined breakpoint on function after main" +gdb_continue_to_breakpoint "function multipleDef" + +set name "can hit multiply defined breakpoint on objc method after main" +gdb_continue_to_breakpoint "method multipleDef" + +gdb_reinitialize + +gdb_test "break multipleDef" \ +"Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*" \ +"break on multiply defined symbol with multiple-symbols all before main" + +setup_kfail "*-*-*" gdb/8343 +gdb_run_cmd +gdb_test "" \ +"Breakpoint \[0-9\]+, multipleDef \\\(\\\) at .*" \ +"can hit multiply defined breakpoint on function before main" + +gdb_continue_to_breakpoint "can hit multiply defined breakpoint on method before main" diff --git a/gdb/testsuite/gdb.objc/objcdecode2.m b/gdb/testsuite/gdb.objc/objcdecode2.m new file mode 100644 index 0000000..4860c54 --- /dev/null +++ b/gdb/testsuite/gdb.objc/objcdecode2.m @@ -0,0 +1,20 @@ +#include +#include + +@implementation DecodeShlib + +- foo +{ + printf("foo class implementation\n"); +} + +- bar +{ + printf("bar class implementation\n"); +} + +- (const char *) myDescription +{ + return "DecodeShlib gdb test object"; +} +@end diff --git a/gdb/testsuite/gdb.objc/objcdecode3.m b/gdb/testsuite/gdb.objc/objcdecode3.m new file mode 100644 index 0000000..97f6e4f --- /dev/null +++ b/gdb/testsuite/gdb.objc/objcdecode3.m @@ -0,0 +1,19 @@ +#include +#include + +@interface DecodeShlib(CategoryInShlib) +@end + +@implementation DecodeShlib(CategoryInShlib) + +- foo +{ + printf("foo category implementation\n"); +} + +- bar +{ + printf("bar category implementation\n"); +} + +@end diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0c93a73..4f33486 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -474,6 +474,11 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} { -re ".*$gdb_prompt $" { fail $full_name } + -re ".*A problem internal to GDB has been detected" { + fail "$full_name (GDB internal error)" + gdb_internal_error_resync + } + timeout { fail "$full_name (timeout)" } -- 1.6.2.5 --LZvS9be/3tNcYl/X--