From patchwork Thu Jun 12 18:23:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siva Chandra Reddy X-Patchwork-Id: 1475 Received: (qmail 1013 invoked by alias); 12 Jun 2014 18:23:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 1004 invoked by uid 89); 12 Jun 2014 18:23:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f51.google.com Received: from mail-wg0-f51.google.com (HELO mail-wg0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 12 Jun 2014 18:23:13 +0000 Received: by mail-wg0-f51.google.com with SMTP id x12so1599237wgg.34 for ; Thu, 12 Jun 2014 11:23:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=ZAauksGw1oAveUcbE1E6GOF2TbSG2R8VXW5gGiXMMGU=; b=BBdaAbSFQtvTfe9aN/S9eAg4MW2nd4sxNdQhdlHxjwl49xP65M4t6AzGfsLPIQbhog kU+5TQ7Yx0BGcSQhwgsxRIawMC4A9s1v+Ifh7xGx+xAozOHXmU9HETnpY54NAqGivz+B cXZtnxGWDOr9c+xzsfLQw3NLrKgU9YBo+gSGdSNfsMTS1gHC7GW1nAdUW+OnlI/OU8tn kMJSdPWM+EpDvZ7fO96Y605GKPjKrIi4sSwptwmiB7DuNywWGju6zDNmBXt7gFLzZjiC 39yB/Kg3u79uWvUmOepUfsDeYDDDT6feV23hWMzTFFG1VnowWqYuTAwJmnoj4rp9EQqt IgPw== X-Gm-Message-State: ALoCoQlA+H7oVYXtlKN9clrXgtR1UPbraHQlwwrkldNxTeqAGcdRyoWYuWWW/LfcuyiblwTHaaZn MIME-Version: 1.0 X-Received: by 10.180.84.132 with SMTP id z4mr9124692wiy.14.1402597390509; Thu, 12 Jun 2014 11:23:10 -0700 (PDT) Received: by 10.217.50.137 with HTTP; Thu, 12 Jun 2014 11:23:10 -0700 (PDT) Date: Thu, 12 Jun 2014 11:23:10 -0700 Message-ID: Subject: [PATCH v3] Fix for PR gdb/17017 From: Siva Chandra To: gdb-patches Cc: Pedro Alves X-IsSubscribed: yes The attached patch fixes PR 17017 along the lines suggested by Pedro here: https://sourceware.org/ml/gdb-patches/2014-06/msg00212.html It does not use get_integer_valueof as suggested by Pedro as he pointed out in his review of v2 that we will then have to enclose some of the tests in with_test_prefix to make the names unique: https://sourceware.org/ml/gdb-patches/2014-06/msg00308.html What I have done in v3 is to use the idea of testing C++ method invocation by testing the value of a global var from Pedro's first suggestion, but tested the value of the global var using gdb_test instead of get_integer_valueof. ChangeLog testsuite/ 2014-06-12 Siva Chandra Reddy PR gdb/17017 * gdb.python/py-xmethods.cc: Add global function call counters and increment them in their respective functions. Remove "cout" statements. * gdb.python/py-xmethods.exp: Make tests check the global function call counters instead of depending on inferior IO. diff --git a/gdb/testsuite/gdb.python/py-xmethods.cc b/gdb/testsuite/gdb.python/py-xmethods.cc index 96637d8..96389fd 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.cc +++ b/gdb/testsuite/gdb.python/py-xmethods.cc @@ -15,10 +15,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include - -using namespace std; - namespace dop { @@ -35,24 +31,30 @@ public: A::~A () { } +int a_plus_a = 0; + int A::operator+ (const A &obj) { - cout << "From CC :" << endl; + a_plus_a++; return a + obj.a; } +int a_minus_a = 0; + int A::operator- (const A &obj) { - cout << "From CC :" << endl; + a_minus_a++; return a - obj.a; } +int a_geta = 0; + int A::geta (void) { - cout << "From CC A::geta:" << endl; + a_geta++; return a; } @@ -62,10 +64,12 @@ public: virtual int geta (void); }; +int b_geta = 0; + int B::geta (void) { - cout << "From CC B::geta:" << endl; + b_geta++; return 2 * a; } @@ -100,30 +104,36 @@ class G T t; }; +int g_size_diff = 0; + template template int G::size_diff () { - cout << "From CC G<>::size_diff:" << endl; + g_size_diff++; return sizeof (T1) - sizeof (T); } +int g_size_mul = 0; + template template int G::size_mul () { - cout << "From CC G<>::size_mul:" << endl; + g_size_mul++; return M * sizeof (T); } +int g_mul = 0; + template template T G::mul (const T1 t1) { - cout << "From CC G<>::mul:" << endl; + g_mul++; return t1 * t; } diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp index 97b6ffa..a455a7a 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.exp +++ b/gdb/testsuite/gdb.python/py-xmethods.exp @@ -40,25 +40,45 @@ gdb_breakpoint [gdb_get_line_number "Break here."] gdb_continue_to_breakpoint "Break here" ".*Break here.*" # Tests before loading the debug methods. -gdb_test "p a1 + a2" "From CC .*15" "Before: a1 + a2" -gdb_test "p a2 - a1" "From CC .*5" "Before: a1 - a2" -gdb_test "p b1 - a1" "From CC .*25" "Before: b1 - a1" -gdb_test "p a1.geta()" "From CC A::geta.*5" "Before: a1.geta()" +gdb_test "p a1 + a2" ".* = 15" "Before: a1 + a2" +gdb_test "p a_plus_a" ".* = 1" "Before: a_plus_a 1" + +gdb_test "p a2 - a1" ".* = 5" "Before: a2 - a1" +gdb_test "p a_minus_a" ".* = 1" "Before: a_minus_a 1" + +gdb_test "p b1 - a1" ".* = 25" "Before: b1 - a1" +gdb_test "p a_minus_a" ".* = 2" "Before: a_minus_a 2" + +gdb_test "p a1.geta()" ".* = 5" "Before: a1.geta()" +gdb_test "p a_geta" ".* = 1" "Before: a_geta 1" + gdb_test "p ++a1" "No symbol.*" "Before: ++a1" gdb_test "p a1.getarrayind(5)" "Couldn't find method.*" \ "Before: a1.getarrayind(5)" -gdb_test "p a_ptr->geta()" "From CC B::geta.*60" "Before: a_ptr->geta()" -gdb_test "p e.geta()" "From CC A::geta.*100" "Before: e.geta()" -gdb_test "p g.size_diff()" "From CC G<>::size_diff.*" \ - "Before: g.size_diff()" + +gdb_test "p a_ptr->geta()" ".* = 60" "Before: a_ptr->geta()" +gdb_test "p b_geta" ".* = 1" "Before: b_geta 1" + +gdb_test "p e.geta()" ".* = 100" "Before: e.geta()" +gdb_test "p a_geta" ".* = 2" "Before: a_geta 2" + +# Since g.size_diff operates of sizes of int and float, do not check for +# actual result value as it could be different on different platforms. +gdb_test "p g.size_diff()" ".*" "Before: call g.size_diff()" +gdb_test "p g_size_diff" ".* = 2" "Before: g_size_diff 2" + gdb_test "p g.size_diff()" "Couldn't find method.*" \ "Before: g.size_diff()" -gdb_test "p g.size_mul<2>()" "From CC G<>::size_mul.*" \ - "Before: g.size_mul<2>()" + +gdb_test "p g.size_mul<2>()" ".*" "Before: g.size_mul<2>()" +gdb_test "p g_size_mul" ".* = 2" "Before: g_size_mul 2" + gdb_test "p g.size_mul<5>()" "Couldn't find method.*" \ "Before: g.size_mul<5>()" -gdb_test "p g.mul(2.0)" "From CC G<>::mul.*" \ - "Before: g.mul(2.0)" + +gdb_test "p g.mul(2.0)" ".* = 10" "Before: g.mul(2.0)" +gdb_test "p g_mul" ".* = 2" "Before: g_mul 2" + gdb_test "p g.mul('a')" "Couldn't find method.*" \ "Before: g.mul('a')" @@ -67,9 +87,15 @@ gdb_test_no_output "source ${xmethods_script}" "load the script file" # Tests after loading debug methods. gdb_test "p a1 + a2" "From Python .*15" "After: a1 + a2" -gdb_test "p a2 - a1" "From CC .*5" "After: a1 - a2" + +gdb_test "p a2 - a1" ".* = 5" "After: a2 - a1" +gdb_test "p a_minus_a" ".* = 3" "After: a_minus_a 3" + gdb_test "p b1 + a1" "From Python .*35" "After: b1 + a1" -gdb_test "p b1 - a1" "From CC .*25" "After: b1 - a1" + +gdb_test "p b1 - a1" ".* = 25" "After: b1 - a1" +gdb_test "p a_minus_a" ".* = 4" "After: a_minus_a 4" + gdb_test "p a1.geta()" "From Python .*5" "After: a1.geta()" gdb_test "p ++a1" "From Python .*6" "After: ++a1" gdb_test "p a1.getarrayind(5)" "From Python .*5" \