public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Chris Moller <cmoller@redhat.com>
Cc: "gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [patch] pr10659  	pretty-printing: Display vectors of vectors as matrix
Date: Thu, 27 May 2010 21:20:00 -0000	[thread overview]
Message-ID: <m31vcxf3oi.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4BFEA148.7000409@redhat.com> (Chris Moller's message of "Thu, 27	May 2010 12:43:52 -0400")

>>>>> "Chris" == Chris Moller <cmoller@redhat.com> writes:

Chris> This patch adds the mechanism for gdb to respond to "matrix" hints
Chris> from printers.py.

Thanks.

Chris> (Just to exercise the testcase, the patch includes
Chris> a patched version of printers.py to src/gdb/testsuite/gdb.python.  It
Chris> can be removed once the patched printers.py is generally available.)

This is not ok.  This part of the test suite ought to be independent
from the C++ compiler in use.  Instead, write some new code (C is fine)
and an associated printer to exercise the new code in GDB.  There are
other examples of this in gdb.python.

Chris> Question:  pr10659.exp yields:
Chris>    +ERROR: no fileid for qcore
Chris>    +ERROR: Couldn't send python print 'test' to GDB.
Chris>    +UNRESOLVED: gdb.python/pr10659.exp: verify python support
Chris> The actual tests pass, but I haven't the slightest idea how to get rid
Chris> of those errors or even if it's necessary to do so.

skip_python_tests requires a running gdb, so it must come after
prepare_for_testing.

Chris> +  pretty = (is_array || is_matrix)
Chris> +    ? options->prettyprint_arrays : options->pretty;

Wrong formatting.

Chris> +  if (is_matrix && recurse == 0)
Chris> +    fputs_filtered ("\n", stream);

I suspect this is not correct in the !pretty case.
Maybe for !pretty the matrix stuff should just be disabled, I don't see
what it would add.

Chris> +      else if (is_matrix) ;	/* Force a do-nothing.  */

Formatting.  Plus it is better to use empty braces with a comment
between, to emphasize the emptiness.

Chris> +  static int is_matrix = 0;

There has to be a better way.  Static locals like this are generally
bad.

One idea would be a new field in value_print_options.  This may be
slightly difficult depending on how recursion is done in some cases.

Chris> -  is_py_none = print_string_repr (printer, hint, stream, recurse,
Chris> -				  options, language, gdbarch);
Chris> +  is_py_none = is_matrix ? 1 : print_string_repr (printer, hint, stream,
Chris> +						  recurse, options,
Chris> +						  language, gdbarch);

What is the rationale for this change?

Chris> +  if (recurse == 0) is_matrix = 0;

Formatting.  Note also that this approach is not error-safe.  You need a
cleanup.  (Though with the value_print_options approach you won't,
because you can make a new local copy.)

Chris> RCS file: testsuite/gdb.python/printers.py
Chris> diff -N testsuite/gdb.python/printers.py
[...]
Chris> +print "in printers.py"

Debugging code.

Chris> +    def display_hint(self):
Chris> +        itype0  = self.val.type.template_argument(0)
Chris> +        rc = 'array'
Chris> +        if itype0.tag:
Chris> +            if -1 != itype0.tag.find('vector'):

This is not a suitable test.  Instead extract the regular expression
from the recognizer and use that.  Ideally, stuff the compiled form in a
global and use it in both places:

Chris> +    pretty_printers_dict[re.compile('^std::vector<.*>$')] = StdVectorPrinter

Tom

  parent reply	other threads:[~2010-05-27 21:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 17:46 Chris Moller
2010-05-27 21:14 ` Phil Muldoon
2010-05-27 22:25   ` Chris Moller
2010-05-27 21:20 ` Tom Tromey [this message]
2010-05-31 23:21   ` [patch] pr10659 pretty-printing: Display vectors of vectors as matrix--rev 2 Chris Moller
2010-06-02 22:58     ` Tom Tromey
2010-06-30 12:26     ` Jan Kratochvil

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=m31vcxf3oi.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=cmoller@redhat.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).