public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Patrick Frants <osscontribute@gmail.com>
To: gdb-patches@sourceware.org
Cc: Patrick Frants <osscontribute@gmail.com>
Subject: [PATCH 2/2] Add unit test for bug 13669 "Infinite recursion in cp_print_value_fields"
Date: Wed, 18 Oct 2017 13:17:00 -0000	[thread overview]
Message-ID: <20171018131729.23137-2-osscontribute@gmail.com> (raw)
In-Reply-To: <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 <new>
+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 <http://www.gnu.org/licenses/>.
+
+
+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
-- 
2.14.0

  reply	other threads:[~2017-10-18 13:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18 13:17 [PATCH 1/2] In cp_print_value_fields() obey dont_print_statmem=1 explicitly passed from cp_print_static_field() Patrick Frants
2017-10-18 13:17 ` Patrick Frants [this message]
2017-10-18 13:39 ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171018131729.23137-2-osscontribute@gmail.com \
    --to=osscontribute@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).