This is the mail archive of the
mailing list for the GCC project.
Re: [patch libstdc++] Add xmethods for std::vector and std::unique_ptr
- From: Siva Chandra <sivachandra at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Jul 2014 06:35:05 -0700
- Subject: Re: [patch libstdc++] Add xmethods for std::vector and std::unique_ptr
- Authentication-results: sourceware.org; auth=none
- References: <CAGyQ6gxpgbnNobkdKeOD5jGQRbo7KG4wbe5XXyf_eMvNW1k9Aw at mail dot gmail dot com> <87ha32v3vr dot fsf at fleche dot redhat dot com> <CAGyQ6gxWEdHKkt-QKbS8CTORG6=85mXoQQKyGcaKrEcKzwUjCQ at mail dot gmail dot com>
On Mon, Jun 30, 2014 at 6:07 PM, Siva Chandra <firstname.lastname@example.org> wrote:
> On Mon, Jun 30, 2014 at 8:00 AM, Tom Tromey <email@example.com> wrote:
>>>>>>> "Siva" == Siva Chandra <firstname.lastname@example.org> writes:
>> Siva> +# Load the xmethods.
>> Siva> +from libstdcxx.v6.xmethods import register_libstdcxx_xmethods
>> Siva> +register_libstdcxx_xmethods (gdb.current_objfile ())
>> I don't think any addition to the hook file should be needed.
> I removed it in the attached patch.
>> Siva> + # The object to be returned is the 0-th element in the tuple _m_t.
>> Siva> + # The following retrieves the 0-th element of this tuple.
>> Siva> + _m_t_base = _m_t[_m_t.type.fields()] # std::tuple has a single base
>> Siva> + # class and no data members.
>> Siva> + for f in _m_t_base.type.fields():
>> Siva> + # The object is embedded in the _Head_base<> base class of
>> Siva> + # _m_t_base.
>> Siva> + if f.is_base_class and f.name.find('std::_Head_base<') == 0:
>> Siva> + _head_base = _m_t_base[f]
>> Did you investigate sharing any code with the printers?
>> If so, why did you choose not to?
>> If not, could you please look into that?
> I have considered this. I tried to be too smart in the above snippet.
> But, look at the attached patch; All that can be replaced by a simple
> one-liner. In which case, would trying to make it common for
> prettyprinters and xmethods become an overkill? For std::vector, I do
> not think there is an overlap between xmethods and prettyprinters. I
> will keep this in mind for future xmethods though.
> 2014-06-30 Siva Chandra Reddy <email@example.com>
> * python/libstdcxx/v6/xmethods.py: New file.
> * testsuite/lib/gdb-test.exp (gdb_version_check_xmethods): New
> (gdb-test): New optional argument LOAD_XMETHODS. Load xmethods
> python script if LOAD_XMETHODS is true.
> * testsuite/libstdc++-xmethods/unique_ptr.cc: New file.
> * testsuite/libstdc++-xmethods/vector.cc: New file.
> * testsuite/libstdc++-xmethods/xmethods.exp: New file.