This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Improved pretty printing for smart pointers
- From: Tom Tromey <tromey at redhat dot com>
- To: Michael Marte <informarte at freenet dot de>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 07 May 2013 12:43:08 -0600
- Subject: Re: Improved pretty printing for smart pointers
- References: <201304240808 dot 07062 dot informarte at freenet dot de> <201304271618 dot 10211 dot informarte at freenet dot de> <878v41746s dot fsf at fleche dot redhat dot com> <201304302242 dot 25711 dot informarte at freenet dot de>
>>>>> "Michael" == Michael Marte <informarte@freenet.de> writes:
Michael> I took your advice into account, see the attached patch.
Michael> Notice that I also improved pretty printing for weak pointers:
Michael> * no children when there are no reference counters
Michael> * no managed value node when use count is zero
I think it looks pretty reasonable overall.
Michael> def to_string (self):
[...]
Michael> + refCounts = self.val['_M_refcount']['_M_pi']
Michael> + if refCounts != 0:
Michael> + useCount = refCounts['_M_use_count']
Michael> + weakCount = refCounts['_M_weak_count']
Michael> + if useCount == 0:
Michael> + state = 'expired, weak count = %d' % weakCount
Michael> else:
Michael> - state = 'count %d, weak %d' % (usecount, weakcount - 1)
Michael> - return '%s (%s) %s' % (self.typename, state, self.val['_M_ptr'])
Michael> + state = 'use count = %d, weak count = %d' % (useCount, weakCount)
Michael> + managedValue = self.val['_M_ptr']
Michael> + return '%s<%s> (%s) to %s' % (self.typename, str(managedValue.type.target()), state, managedValue)
This seems to duplicate some data from 'children' in 'to_string'.
That seems like it would give ugly output.
Does it pass the test suite?
If so, it seems like perhaps a new test would be warranted.
You'll need a copyright assignment if you don't have one already.
It needs a ChangeLog entry.
Tom