public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-11320] libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064] Date: Thu, 27 Apr 2023 23:04:29 +0000 (GMT) [thread overview] Message-ID: <20230427230429.1D3003856DEA@sourceware.org> (raw) https://gcc.gnu.org/g:cc75195ee8811d6c48f05727c170916c0adc227b commit r10-11320-gcc75195ee8811d6c48f05727c170916c0adc227b Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Mar 10 11:06:25 2023 +0000 libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064] libstdc++-v3/ChangeLog: PR libstdc++/109064 * python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker): Remove self-recursion in __init__. Add missing _supports. * testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count() and unique(). Diff: --- libstdc++-v3/python/libstdcxx/v6/xmethods.py | 5 ++++- libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index 2617c189e40..cd535fb5ed6 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -730,7 +730,7 @@ class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker): "Implements std::shared_ptr<T>::use_count()" def __init__(self, elem_type): - SharedPtrUseCountWorker.__init__(self, elem_type) + pass def get_arg_types(self): return None @@ -738,6 +738,9 @@ class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker): def get_result_type(self, obj): return gdb.lookup_type('long') + def _supports(self, method_name): + return True + def __call__(self, obj): refcounts = obj['_M_refcount']['_M_pi'] return refcounts['_M_use_count'] if refcounts else 0 diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc index 05fdd57ec3f..e7a79d67d59 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc @@ -36,6 +36,8 @@ main () std::shared_ptr<x_struct[3]> s(new x_struct[2]{ {92}, {115} }); + auto qq = q; + // { dg-final { note-test *p 10 } } // { dg-final { regexp-test p.get() 0x.* } } @@ -66,6 +68,11 @@ main () // { dg-final { whatis-test s.get() "x_struct \*" } } // { dg-final { whatis-test s\[1].y int } } +// { dg-final { note-test p.use_count() 1 } } +// { dg-final { note-test p.unique() true } } +// { dg-final { note-test q.use_count() 2 } } +// { dg-final { note-test q.unique() false } } + return 0; // Mark SPOT }
reply other threads:[~2023-04-27 23:04 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230427230429.1D3003856DEA@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.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: linkBe 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).