From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30277 invoked by alias); 13 Mar 2013 19:34:03 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 30230 invoked by uid 306); 13 Mar 2013 19:33:59 -0000 Date: Wed, 13 Mar 2013 19:34:00 -0000 Message-ID: <20130313193359.30214.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/operator-new-delete: update README.archer X-Git-Refname: refs/heads/tromey/operator-new-delete X-Git-Reftype: branch X-Git-Oldrev: fa32dc9d2276dd1602b2c296f768ffb533232ab3 X-Git-Newrev: 46e210c07d4ffe7e7885032ac005bec2545c36f0 X-SW-Source: 2013-q1/txt/msg00256.txt.bz2 List-Id: The branch, tromey/operator-new-delete has been updated via 46e210c07d4ffe7e7885032ac005bec2545c36f0 (commit) via af09cb52a2d6771475b1bc116ecacccb50b115c7 (commit) from fa32dc9d2276dd1602b2c296f768ffb533232ab3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 46e210c07d4ffe7e7885032ac005bec2545c36f0 Author: Tom Tromey Date: Wed Mar 13 13:33:38 2013 -0600 update README.archer commit af09cb52a2d6771475b1bc116ecacccb50b115c7 Author: Tom Tromey Date: Wed Mar 13 13:33:07 2013 -0600 add test to count number of destructor invocations ----------------------------------------------------------------------- Summary of changes: README.archer | 3 --- gdb/testsuite/gdb.cp/new.cc | 9 +++++++++ gdb/testsuite/gdb.cp/new.exp | 36 +++++++++++++++++++----------------- 3 files changed, 28 insertions(+), 20 deletions(-) First 500 lines of diff: diff --git a/README.archer b/README.archer index 6dfb9a9..32cd4c7 100644 --- a/README.archer +++ b/README.archer @@ -18,6 +18,3 @@ It is incomplete: * syntax for calling a destructor explicitly do we need to handle this specially? cannot be used with an implicit "this", must always be qualified -* needs a test for the number of times a destructor is called for - arrays (don't need this for constructor since we can just print the - array and see) diff --git a/gdb/testsuite/gdb.cp/new.cc b/gdb/testsuite/gdb.cp/new.cc index 9b78e25..99fa5f5 100644 --- a/gdb/testsuite/gdb.cp/new.cc +++ b/gdb/testsuite/gdb.cp/new.cc @@ -21,6 +21,9 @@ enum what_operator int whatop = WHATOP_INVALID; +// Number of times a destructor is invoked. +int dcount; + void *operator new (std::size_t size) { whatop = WHATOP_GLOBAL; @@ -50,6 +53,7 @@ struct Simple int x; Simple() : x (7) { } Simple (int y) : x (y) { } + ~Simple() { ++dcount; } }; struct Derived : public Simple @@ -133,6 +137,7 @@ struct Base virtual ~Base() { + ++dcount; } }; @@ -146,6 +151,7 @@ struct DerivedFromBase : public Base ~DerivedFromBase() { + ++dcount; } }; @@ -157,6 +163,7 @@ struct VDerived : public virtual Base ~VDerived() { + ++dcount; } }; @@ -168,6 +175,7 @@ struct VDerived2 : public VDerived, public virtual Base ~VDerived2() { + ++dcount; } }; @@ -179,6 +187,7 @@ int keep_stuff () delete new Base; delete new VDerived; delete new VDerived2; + delete new Simple; } int main () diff --git a/gdb/testsuite/gdb.cp/new.exp b/gdb/testsuite/gdb.cp/new.exp index d292b94..54e1b4d 100644 --- a/gdb/testsuite/gdb.cp/new.exp +++ b/gdb/testsuite/gdb.cp/new.exp @@ -32,22 +32,22 @@ if ![runto_main] then { gdb_breakpoint [gdb_get_line_number "Stop here"] gdb_continue_to_breakpoint Stop -set op_count 0 - -proc check_op {name value} { - global op_count - - gdb_test "print whatop == ($value)" " = true" "check settings - $name" - - # For debugging. - # gdb_test "print (enum what_operator) whatop" " = .*" \ - # "debug print whatop #$op_count" - - # Mildly lame that this ends up in the test results. - gdb_test_no_output "set variable whatop = WHATOP_INVALID" \ - "reset whatop #$op_count" - - incr op_count +proc check_op {name value {dcount ""}} { + with_test_prefix $name { + gdb_test "print whatop == ($value)" " = true" "check settings" + + if {$dcount != ""} { + gdb_test "print dcount" " = $dcount" "check destructor count" + } + + # For debugging. + # gdb_test "print (enum what_operator) whatop" " = .*" \ + # "debug print whatop" + + # Mildly lame that these end up in the test results. + gdb_test_no_output "set variable whatop = WHATOP_INVALID" "reset whatop" + gdb_test_no_output "set variable dcount = 0" "reset dcount" + } } gdb_test "print \$an_int = new int" " = .int .. $hex" @@ -138,7 +138,9 @@ gdb_test "print delete \$simple" " = void" check_op "delete Simple" {WHATOP_GLOBAL | WHATOP_DELETE} gdb_test "print delete\[\] \$simple_array" " = void" -check_op "delete Simple array" {WHATOP_GLOBAL | WHATOP_DELETE | WHATOP_ARRAY} +check_op "delete Simple array" \ + {WHATOP_GLOBAL | WHATOP_DELETE | WHATOP_ARRAY} \ + 7 gdb_test "print delete \$derived" " = void" check_op "delete Derived" {WHATOP_GLOBAL | WHATOP_DELETE} hooks/post-receive -- Repository for Project Archer.