From patchwork Wed Oct 18 13:17:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Frants X-Patchwork-Id: 23671 Received: (qmail 29965 invoked by alias); 18 Oct 2017 13:17:48 -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 29494 invoked by uid 89); 18 Oct 2017 13:17:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=pixel, Hx-languages-length:3107 X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 13:17:42 +0000 Received: by mail-wm0-f67.google.com with SMTP id q124so10020436wmb.0 for ; Wed, 18 Oct 2017 06:17:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1+hQfNObJ70NGVEfgyREjoBAh8kngjE1/4G31Rvt5x0=; b=J6Jep72cubSj33I4JKP/LX6EFZqLJc5bzHJQw/9TEu01JZMV3rb5mjYr2JeDolhQU2 rjwKBuycS6nQ7u5F3xy/Rqw37azDID63eK27aZvvxUiVI8GMMkf+0l8v5dS8Helox37f 0IGOqc6ukb/Gkc8JA61uNf55ARynYzMqaaf9Luz+fkHTj3kjB1cVtQ8kJ5K9l2aC4beE ugxBRezUD9vzQlN1W8+YoHm0h+LT9QhAySvCGCkxCQPyZhnWMAkI9DaJ8gg8QUYXL0uF TyyP+HqCo85oAKqh7wK1ndiku5uKq7vjylSJUNkYvoZjYa6miVu8u7X/hIUfoptiVgVX AnVA== X-Gm-Message-State: AMCzsaVWlx8GUx0vaGnlngJff177BWapreWrXkB3QfQjEuRBAJIZb/A9 zP4BBLXR48UtaV36H9cTuRjA/65I/w0= X-Google-Smtp-Source: AOwi7QDNTpcGj1zMll5Dc7QqOXnQmE1EJRyU0PyFk+yfqjWClwWoep7gBuTDs4ymZT15vRC3MjroWg== X-Received: by 10.80.176.38 with SMTP id i35mr21637767edd.156.1508332659779; Wed, 18 Oct 2017 06:17:39 -0700 (PDT) Received: from centos7dev.localdomain ([213.207.96.130]) by smtp.gmail.com with ESMTPSA id t20sm10293137edd.75.2017.10.18.06.17.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Oct 2017 06:17:39 -0700 (PDT) From: Patrick Frants To: gdb-patches@sourceware.org Cc: Patrick Frants Subject: [PATCH 2/2] Add unit test for bug 13669 "Infinite recursion in cp_print_value_fields" Date: Wed, 18 Oct 2017 15:17:29 +0200 Message-Id: <20171018131729.23137-2-osscontribute@gmail.com> In-Reply-To: <20171018131729.23137-1-osscontribute@gmail.com> References: <20171018131729.23137-1-osscontribute@gmail.com> --- gdb/testsuite/gdb.cp/printstaticrecursion.cc | 65 +++++++++++++++++++++++++++ gdb/testsuite/gdb.cp/printstaticrecursion.exp | 41 +++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 gdb/testsuite/gdb.cp/printstaticrecursion.cc create mode 100644 gdb/testsuite/gdb.cp/printstaticrecursion.exp diff --git a/gdb/testsuite/gdb.cp/printstaticrecursion.cc b/gdb/testsuite/gdb.cp/printstaticrecursion.cc new file mode 100644 index 0000000000..17312e6982 --- /dev/null +++ b/gdb/testsuite/gdb.cp/printstaticrecursion.cc @@ -0,0 +1,65 @@ +#include +using namespace std; +//// Pixel + +class Pixel +{ + int m_red; + +public: + Pixel() + : m_red(0) + {} + + // Static instances of Pixel + static const Pixel sm_black; +}; + +const Pixel Pixel::sm_black; + + +//// BlendState + +class BlendState +{ + Pixel m_blendColour; + + // Static instances of BlendState + static const BlendState sm_alphaBlending; +}; + +const BlendState BlendState::sm_alphaBlending; + + +//// Context + +class Context +{ + BlendState m_blendStack; + + // Static instances of Context + static Context * sm_instance; +public: + static Context & instance(); +}; + +Context * Context::sm_instance; + +Context & Context::instance() +{ + sm_instance = new Context; + + Context & ref = *sm_instance; + return ref; /* break-here */ +} + +// + }}} + + + +int main() +{ + Context & context = Context::instance(); + + return 0; +} \ No newline at end of file diff --git a/gdb/testsuite/gdb.cp/printstaticrecursion.exp b/gdb/testsuite/gdb.cp/printstaticrecursion.exp new file mode 100644 index 0000000000..37e3fed05f --- /dev/null +++ b/gdb/testsuite/gdb.cp/printstaticrecursion.exp @@ -0,0 +1,41 @@ +# Copyright 2008-2017 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 . + + +if { [skip_cplus_tests] } { continue } + +standard_testfile printstaticrecursion.cc + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info "c++"] { + untested "couldn't find a valid c++ compiler" + return -1 +} + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { + return -1 +} + +if ![runto_main] then { + perror "couldn't run to main" + continue +} + +gdb_breakpoint ${srcfile}:[gdb_get_line_number "break-here"] +gdb_continue_to_breakpoint "Continue to first breakpoint" +gdb_test "finish" +gdb_exit +return 0