This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: [python] refactor pretty-printing, again
- From: Paul Pluzhnikov <ppluzhnikov at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Project Archer <archer at sourceware dot org>
- Date: Tue, 11 Nov 2008 18:56:20 -0800
- Subject: Re: [python] refactor pretty-printing, again
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1226458583; bh=15SOGwRipQ9gssP9ikerXw39atQ=;h=DomainKey-Signature:MIME-Version:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type: Content-Transfer-Encoding; b=Qt8tyUx0Vzkcg9uYsuA2imIRcZ+KzwZ+eWyUEdkBJi4EWLf/l/2XOI/EYuw4sI05uiRD4PpI/a6//Ti0NmZJlQ==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=mime-version:in-reply-to:references:date:message-id:subject:from:to:cc:content-type:content-transfer-encoding;b=uGRY4Q7muMszAkTlK0Ttkw4tvCN3MGQ986a9DgfcbBvtQORlQrxSo1Pt91DEYOIPRd4mfYjEHa8SejTuCdOk1Q==
- References: <m3zlk5emnd.fsf@fleche.redhat.com>
On Tue, Nov 11, 2008 at 5:52 PM, Tom Tromey <tromey@redhat.com> wrote:
> This patch refactors pretty-printing again.
>
> Now, formatting is done in C rather than in Python. This made it
> simpler to handle the recursion case. Recursing is needed, rather
> than string-izing, to make indentation work out nicely in the 'pretty'
> case.
This would also make "mixed" printing easier, wouldn't it?
> I got rid of the value_print hook. Perhaps this was overly eager of
> me -- now we print references more verbosely. Paul, let me know what
> you think. This is easily restored if needed.
I like the indentation and layout consistency :)
But I don't like references :(
In "normal" usage, when "vs" is a std::vector<std::string>, you get:
(gdb) p vs
$1 = std::vector of length 2, capacity 2 = {[0] = 0x404028 "Hello",
[1] = 0x404078 "World"}
(gdb) p vs[0]
$2 = (std::basic_string<char, std::char_traits<char>,
std::allocator<char> > &) 0x404028 "Hello"
Not so pretty ... Though definitely better than 'raw':
(gdb) p/r vs[0]
$3 = (std::basic_string<char, std::char_traits<char>,
std::allocator<char> > &) @0x404090: {static npos =
18446744073709551615,
_M_dataplus = {<std::allocator<char>> =
{<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data
fields>}, _M_p = 0x404028 "Hello"}}
I wonder if printing the reference (and the address of string)
should be controlled by a separate 'print reftype on/off',
'print arrayaddr on/off', or some such?
--
Paul Pluzhnikov