Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: tromey@redhat.com
Cc: brobecker@adacore.com (Joel Brobecker), gdb-patches@sourceware.org
Subject: Re: [RFC/RFA] add struct parse_context to all command functions
Date: Wed, 22 Oct 2008 18:03:00 -0000	[thread overview]
Message-ID: <200810221802.m9MI27P1024024@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <m37i819232.fsf@fleche.redhat.com> from "Tom Tromey" at Oct 21, 2008 01:32:01 PM

Tom Tromey wrote:

> I've been meaning to do this for a while, so I went ahead today and
> updated my patch to apply to cvs trunk.

Thanks!

> Basically I moved all print-formatting globals into a structure.  To
> ensure I didn't miss anything in the value_print/val_print hierarchy,
> I actually removed the globals everywhere and replaced remaining
> references to them with references to user_print_options (where the
> global state now resides).

This looks reasonable to me.  However, (some of) the places where you
now have to reference members of user_print_options seems to indicate
either that something is really weird (why should evaluate_subexp_standard
*evaluate* an expression differently depending on "objectprint" ??), or
that some routines maybe need to get print options passed as arguments
(print_formatted?  address printing?  the breakpoint print routines?).

> A couple spots needed to make their own print-options structure; here
> I made a couple of convenience functions to copy the global structure
> and modify it to suit.  I wrote them to initialize an argument to
> avoid any possible confusion about ownership (a previous patch had
> get_raw_print_options, e.g., return a pointer to a static struct --
> but this could be confusing, or even wrong if there is any recursion).

In fact, I'm wondering if it wouldn't be nicer to also have something
like a get_default_print_options function instead of refering to the
user_print_options global in the top-level printing routines ...

> This patch, I believe, fixes a latent bug.  print_command_1 may set
> the global inspect_it, but the value is not reset on error.  I.e.,
> this function is missing a cleanup.  I found this by inspection; I
> haven't tried testing this theory.

However, with your code it would appear "inspect" is now a no-op:

@@ -846,10 +844,10 @@ print_command_1 (char *exp, int inspect, int voidprint)
   struct value *val;
   struct format_data fmt;
   int cleanup = 0;
+  struct value_print_options opts;

-  /* Pass inspect flag to the rest of the print routines in a global
-     (sigh).  */
-  inspect_it = inspect;
+  opts = user_print_options;
+  opts.inspect_it = inspect;

   if (exp && *exp == '/')
     {
@@ -909,7 +907,6 @@ print_command_1 (char *exp, int inspect, int voidprint)

   if (cleanup)
     do_cleanups (old_chain);
-  inspect_it = 0;              /* Reset print routines to normal.  */
 }


Note how "opts" is never used throughout print_command_1 ...


> Let me know what you think.  I'd like to get something along these
> lines into gdb.  If this looks reasonable, I'll write a ChangeLog
> entry and send it through testing.  Or, if you want changes, let me
> know that.

Except for the issues discussed above, this definitely looks
reasonable to me.

There's still two globals used in various places throughout the
print routines: current_language and current_gdbarch.  Ideally,
these should be replaced by passing arguments as well ... I'm
not sure if the value_print_options structure is the correct
place to put language and gdbarch pointer, though.  Do you have
and opinions how to handle those?


Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2008-10-22 18:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09 14:05 Joel Brobecker
2008-10-09 16:13 ` Tom Tromey
2008-10-09 22:20   ` Joel Brobecker
2008-10-20 16:16 ` Joel Brobecker
2008-10-20 19:03   ` Thiago Jung Bauermann
2008-10-21  0:47     ` Daniel Jacobowitz
2008-10-21 18:06       ` Ulrich Weigand
2008-10-21 18:18         ` Daniel Jacobowitz
2008-10-22  1:40           ` Joel Brobecker
2008-10-22 20:15             ` Tom Tromey
2008-10-22 20:36               ` Joel Brobecker
2008-10-21  1:22   ` Tom Tromey
2008-10-21  7:07     ` Joel Brobecker
2008-10-21 18:12     ` Ulrich Weigand
2008-10-21 18:58       ` Tom Tromey
2008-10-21 19:33       ` Tom Tromey
2008-10-22 18:03         ` Ulrich Weigand [this message]
2008-10-22 18:54           ` Tom Tromey
2008-10-22 22:24             ` Ulrich Weigand
2008-10-23  1:02               ` Tom Tromey
2008-10-23 19:50                 ` Ulrich Weigand
2008-10-23 21:29                   ` Tom Tromey
2008-10-24 13:01                     ` Ulrich Weigand
2008-10-25 16:05                       ` Tom Tromey
2008-10-27 17:07                       ` Tom Tromey
2008-10-28 16:27                         ` Ulrich Weigand
2008-10-28 18:17                           ` Tom Tromey
2008-10-28 20:00                             ` Ulrich Weigand
2008-10-25 16:25                     ` Joel Brobecker
2008-10-25 16:46                       ` Tom Tromey
2008-10-26 15:19                         ` Joel Brobecker
2008-10-21 18:05 ` Ulrich Weigand

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=200810221802.m9MI27P1024024@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /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