From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21217 invoked by alias); 21 Nov 2009 17:12:48 -0000 Received: (qmail 21204 invoked by uid 22791); 21 Nov 2009 17:12:46 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 21 Nov 2009 17:11:42 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 3FDB610D29; Sat, 21 Nov 2009 17:11:40 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id 7A66D104DF; Sat, 21 Nov 2009 17:11:39 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1NBtUn-0007Gp-GQ; Sat, 21 Nov 2009 12:11:38 -0500 Date: Sat, 21 Nov 2009 17:12:00 -0000 From: Daniel Jacobowitz To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [RFA 1/3] dwarf2_physname - cpexprs.exp Message-ID: <20091121171137.GA23208@caradoc.them.org> Mail-Followup-To: Keith Seitz , gdb-patches@sourceware.org References: <4B070525.4030107@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B070525.4030107@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes 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-11/txt/msg00464.txt.bz2 On Fri, Nov 20, 2009 at 01:07:49PM -0800, Keith Seitz wrote: > Running these tests on CVS HEAD currently gives (go ahead, try it: I > dare you :-): My previous test run I botched patch application and didn't have this test. I ran it seperately and found some problems. print base1::base1(int) $2 = {base1 *(base1 * const, int)} 0x9944 (gdb) FAIL: gdb.cp/cpexprs.exp: print base1::base1(int) I know what this one is - constructors on ARM return "this". The test expects void. So this one is just a pattern matching problem. print base::operator/= A syntax error in expression, near `'. (gdb) FAIL: gdb.cp/cpexprs.exp: print base::operator/= This one is caused by using gdb_load, but not running the test to main. If you have debug info for your startup code, and gdb_load connects to your target, you'll end up in the language (asm or C) of your startup code. I suggest an additional runto_main at the start of the test so that the parsing language is C++. That yields the attached incremental patch. The ctor/dtor bits are an interesting question; we could canonicalize the type, but I don't think it's necessary (or clear what to canonicalize *to*). All 18 of the other fails in the GCC multilibs are of the form: list base::overload(base&) const Junk at end of line specification. (gdb) FAIL: gdb.cp/cpexprs.exp: list base::overload(base&) const What might that be? Each RealView multilib has 309 failures. A sample: -$1 = {void (const base1 * const)} 0x999c -(gdb) PASS: gdb.cp/cpexprs.exp: print base1::a_function +$1 = {void (const base1 *)} 0x11614 +(gdb) FAIL: gdb.cp/cpexprs.exp: print base1::a_function This tests for exact output on something which is up to the vagaries of the producer :-( So this will require even more similar hacks. RealView is my example here, but expect similar changes between GCC versions. And there's: print flubber -$64 = {void (void)} 0xa100 ()> -(gdb) PASS: gdb.cp/cpexprs.exp: print flubber +No symbol "flubber" in current context. +(gdb) FAIL: gdb.cp/cpexprs.exp: print flubber Something seems to be broken in RealView templates, but that's not a problem with the test. So with this incremental patch (or something similar), and whatever the "Junk at end of arguments" issue turns out to be, these new tests look OK. -- Daniel Jacobowitz CodeSourcery 2009-11-21 Daniel Jacobowitz * gdb.cp/cpexprs.exp (escape): Delete. Change all callers to use string_to_regexp. (ctor, dtor): New functions. Use them to match constructor and destructor function types. (Top level): Use runto_main. --- gdb/testsuite/gdb.cp/cpexprs.exp | 117 +++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 48 deletions(-) Index: gdb-mainline/gdb/testsuite/gdb.cp/cpexprs.exp =================================================================== --- gdb-mainline.orig/gdb/testsuite/gdb.cp/cpexprs.exp 2009-11-21 08:16:14.000000000 -0800 +++ gdb-mainline/gdb/testsuite/gdb.cp/cpexprs.exp 2009-11-21 08:58:40.000000000 -0800 @@ -31,26 +31,13 @@ proc test_breakpoint {func} { } else { gdb_breakpoint "$func" set i [expr {[string last : $func] + 1}] - set efunc [escape [string range $func $i end]] + set efunc [string_to_regexp [string range $func $i end]] gdb_test "continue" \ "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \ "continue to $func" } } -# Escape expect-reserved characters in the string -proc escape {string} { - regsub -all {\*} $string {\*} string - regsub -all {\(} $string {\(} string - regsub -all {\)} $string {\)} string - regsub -all {\]} $string {\]} string - regsub -all {\[} $string {\[} string - regsub -all {\+} $string {\+} string - regsub -all {\^} $string {\^} string - regsub -all {\!} $string {\!} string - return $string -} - # Add a function to the list of tested functions # FUNC is the name of the function (which will be passed to gdb commands) # TYPE is the type of the function, as expected from the "print" command @@ -76,11 +63,11 @@ proc add {func type print lst} { set print [regsub {\(void\)} $print {()}] set all_functions($func,print) \ - "$CONVAR = {[escape $type]} $ADDR <[escape $print].*>" + "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>" if {$lst == "-"} { set lst "$func" } - set all_functions($func,list) ".*// [escape $lst]" + set all_functions($func,list) ".*// [string_to_regexp $lst]" } proc get {func cmd} { @@ -145,34 +132,63 @@ add {base2::a_function} \ - # Constructors + +# On targets using the ARM EABI, the constructor is expected to return +# "this". +proc ctor { type arglist } { + if { [istarget arm*-*eabi*] } { + set ret "$type *" + } else { + set ret "void " + } + if { $arglist != "" } { + set arglist ", $arglist" + } + return "${ret}($type * const$arglist)" +} + add {derived::derived} \ - {void (derived * const)} \ + [ctor derived ""] \ - \ - add {base1::base1(void)} \ - {void (base1 * const, const void ** const)} \ + [ctor base1 "const void ** const"] \ - \ - add {base1::base1(int)} \ - {void (base1 * const, int)} \ + [ctor base1 "int"] \ - \ - add {base2::base2} \ - {void (base2 * const, const void ** const)} \ + [ctor base2 "const void ** const"] \ - \ - add {base::base(void)} \ - {void (base * const)} \ + [ctor base ""] \ - \ - add {base::base(int)} \ - {void (base * const, int)} \ - - \ + [ctor base "int"] \ - \ + - # Destructors + +# On targets using the ARM EABI, some destructors are expected +# to return "this". Others are void. For internal reasons, +# GCC returns void * instead of $type *; RealView appears to do +# the same. +proc dtor { type } { + if { [istarget arm*-*eabi*] } { + set ret "void *" + } else { + set ret "void " + } + return "${ret}($type * const)" +} + add {base::~base} \ - {void (base * const)} \ + [dtor base] \ - \ - @@ -499,19 +515,19 @@ add {tclass::do_something} \ - \ {tclass::do_something} add {policy1::policy} \ - {void (policy > * const, int)} \ + [ctor "policy >" "int"] \ {policy >::policy} \ {policy::policy} add {policy2::policy} \ - {void (policy > * const, int)} \ + [ctor "policy >" int] \ {policy >::policy} \ {policy::policy} add {policy3::policy} \ - {void (policy > * const, int)} \ + [ctor "policy >" "int"] \ {policy >::policy} \ {policy::policy} add {policy4::policy} \ - {void (policy > * const, int)} \ + [ctor "policy >" "int"] \ {policy >::policy} \ {policy::policy} add {policy1::function} \ @@ -531,83 +547,83 @@ add {policy4::function} \ {operation_4::function} \ {operation_4::function} add {policyd >::policyd} \ - {void (policyd > * const, int)} \ + [ctor "policyd >" "int"] \ - \ {policyd::policyd} add {policyd1::policyd} \ - {void (policyd > * const, int)} \ + [ctor "policyd >" "int"] \ {policyd >::policyd} \ {policyd::policyd} add {policyd >::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ - \ {policyd::~policyd} add {policyd1::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ {policyd >::~policyd} \ {policyd::~policyd} add {policyd >::policyd} \ - {void (policyd > * const, long)} \ + [ctor "policyd >" "long"] \ - \ {policyd::policyd} add {policyd2::policyd} \ - {void (policyd > * const, long)} \ + [ctor "policyd >" "long"] \ {policyd >::policyd} \ {policyd::policyd} add {policyd >::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ - \ {policyd::~policyd} add {policyd2::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ {policyd >::~policyd} \ {policyd::~policyd} add {policyd >::policyd} \ - {void (policyd > * const, char)} \ + [ctor "policyd >" "char"] \ - \ {policyd::policyd} add {policyd3::policyd} \ - {void (policyd > * const, char)} \ + [ctor "policyd >" "char"] \ {policyd >::policyd} \ {policyd::policyd} add {policyd >::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ - \ {policyd::~policyd} add {policyd3::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ {policyd >::~policyd} \ {policyd::~policyd} add {policyd >::policyd} \ - {void (policyd > * const, base)} \ + [ctor "policyd >" "base"] \ - \ {policyd::policyd} add {policyd4::policyd} \ - {void (policyd > * const, base)} \ + [ctor "policyd >" "base"] \ {policyd >::policyd} \ {policyd::policyd} add {policyd >::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ - \ {policyd::~policyd} add {policyd4::~policyd} \ - {void (policyd > * const)} \ + [dtor "policyd >"] \ {policyd >::~policyd} \ {policyd::~policyd} add {policyd, operation_1 > >::policyd} \ - {void (policyd, operation_1 > > * const, tclass)} \ + [ctor "policyd, operation_1 > >" "tclass"] \ - \ {policyd::policyd} add {policyd5::policyd} \ - {void (policyd, operation_1 > > * const, tclass)} \ + [ctor "policyd, operation_1 > >" "tclass"] \ {policyd, operation_1 > >::policyd} \ {policyd::policyd} add {policyd, operation_1 > >::~policyd} \ - {void (policyd, operation_1 > > * const)} \ + [dtor "policyd, operation_1 > >"] \ - \ {policyd::~policyd} add {policyd5::~policyd} \ - {void (policyd, operation_1 > > * const)} \ + [dtor "policyd, operation_1 > >"] \ {policyd, operation_1 > >::~policyd} \ {policyd::~policyd} add {policyd >::function} \ @@ -679,6 +695,11 @@ gdb_start gdb_reinitialize_dir [file join $srcdir $subdir] gdb_load $binfile +if {![runto_main]} { + perror "couldn't run to breakpoint" + continue +} + # Set the listsize to one. This will help with testing "list". gdb_test "set listsize 1"