Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC/RFA] add struct parse_context to all command functions
@ 2008-10-09 14:05 Joel Brobecker
  2008-10-09 16:13 ` Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Joel Brobecker @ 2008-10-09 14:05 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 4194 bytes --]

Hello,

I'd like to start working on adding a struct parse_context again.
The ultimate goal is to pass this structure as an argument to all
the "parse..." routines, rather than rely on the current_language
and input_radix globals.  In addition to being cleaner, it will also
help fix a bug where the current_language is switched under us while
trying to do parse an expression.

The first thing was to define the parse_context struct.  Since a very
large number of .c files add new commands, I decided to put the struct
in defs.h.  The alternative was to put it in expression.h, besides the
parse_* routines, or perhaps in command.h, or in language.h.  Putting
it in defs.h minimizes the size of the patch by avoiding an extra include.

The next step for this task is to add a struct parse_context parameter
to the "command" functions (the functions being called when the user
calls a function in the UI).  When the user enters a command, we know
that we can use the current language and input radix to parse the
arguments. So we create a struct parse context there, and pass it
to the command function.  The goal is to eventually have only one place
that uses the parse context globals: the UI interpreter that calls
the function commands.  Note that I decided to pass a struct rather
than a pointer to the struct to avoid any memory management issue.

I plan to propagate the parse_context argument progressively. But
the first step, which is to add the parse_context argument to the
command functions, is massive. It affects almost every .c file in
the project, so I'd like to make sure that everyone is happy with
what the change looks like.  For this, I will attach a patch that
changes the "add_cmd" et al interface to add the parse_context
argument to the command functions. The patch also contains the
associated adjustements in the implementation of these functions,
as well as one random .c file updated to include the new parameter.

My goal is to get an agreement on the principle, then spent the time
to do the entire transition, and then commit either immediately or
shortly after that. I don't mind posting the patch and let it sit
for a few days, but it's going to be massive, and I don't think that
this is going to bring much value.  But I'm ok with doing that if
people prefer.

If you look at the patch, you'll probably notice a few things that
I would like to fix before doing the transition for real:

  1. The prototypes for the various add_* functions are duplicated.
     There is a copy in command.h, and another in cli/cli-decode.h.
     Is there a specific reason why we can't keep only one copy?
     For instance, only keep the copy in cli/cli-decode.h?

  2. Most if not all add_ command define the profile of the callback
     on the fly, like this:
 
     | add_prefix_cmd (char *, enum command_class,
 !!->|                 void (*fun) (char *, int, struct parse_context),
     |                 char *, struct cmd_list_element **, char *, int,
     |                 struct cmd_list_element **);

     There is the following typedef:

     | typedef void cmd_cfunc_ftype (char *args, ...)

     We should really use this typedef instead of repeating it everywhere.
  
  3. There is one function "add_com" which seems to be a shortcut
     for add_cmd:

       add_com (char *name, enum command_class class,
                void (*fun) (char *, int, struct parse_context),
                char *doc)
       {
         return add_cmd (name, class, fun, doc, &cmdlist);
       }

     The only difference is that one doesn't have to pass the cmdlist
     to add_com.  Do we really want to keep it?  I have always been
     confused trying to find the difference between the two...

  4. I noticed a few command functions that are declared global and
     yet should be static.  I checked insight, and there are only used
     locally.  I will fix them separately.

Voila voila. I will start working on the little issues mentioned above
while waiting for feedback.  I would like to start working on this
no later than, say, a week from now.  And I will provide gdbint
documentation as well as requested by Eli when we discussed this idea
the last time.

-- 
Joel

[-- Attachment #2: parse_context.diff --]
[-- Type: text/plain, Size: 12952 bytes --]

diff -r e3c43da3934b gdb/defs.h
--- a/gdb/defs.h	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/defs.h	Thu Oct 09 08:55:57 2008 -0400
@@ -194,6 +194,23 @@ enum language
     language_minimal,		/* All other languages, minimal support only */
     nr_languages
   };
+
+/* Parsing an expression is dependent on a certain context such as
+   the language to use, or the input radix for numbers.  This structure
+   contains that context information.  */
+
+struct parse_context
+ {
+   /* The language to use when parsing an expression.  */
+   const struct language_defn *language;
+
+   /* The radix to use by default when parsing numbers.  */
+   int radix;
+ };
+
+/* A function that builds a parse_context structure containing
+   the current language and the current input radix.  */
+struct parse_context current_parse_context (void);
 
 enum precision_type
   {
diff -r e3c43da3934b gdb/parse.c
--- a/gdb/parse.c	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/parse.c	Thu Oct 09 08:55:57 2008 -0400
@@ -131,6 +131,16 @@ struct funcall
   };
 
 static struct funcall *funcall_chain;
+
+struct parse_context
+current_parse_context (void)
+{
+  struct parse_context parse_context;
+
+  parse_context.language = current_language;
+  parse_context.radix = input_radix;
+  return parse_context;
+}
 
 /* Begin counting arguments for a function call,
    saving the data about any containing call.  */
diff -r e3c43da3934b gdb/command.h
--- a/gdb/command.h	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/command.h	Thu Oct 09 08:55:57 2008 -0400
@@ -98,34 +98,30 @@ struct cmd_list_element;
 
 /* Forward-declarations of the entry-points of cli/cli-decode.c.  */
 
-extern struct cmd_list_element *add_cmd (char *, enum command_class,
-					 void (*fun) (char *, int), char *,
-					 struct cmd_list_element **);
+extern struct cmd_list_element *
+  add_cmd (char *, enum command_class,
+	   void (*fun) (char *, int, struct parse_context),
+	   char *, struct cmd_list_element **);
 
 extern struct cmd_list_element *add_alias_cmd (char *, char *,
 					       enum command_class, int,
 					       struct cmd_list_element **);
 
-extern struct cmd_list_element *add_prefix_cmd (char *, enum command_class,
-						void (*fun) (char *, int),
-						char *,
-						struct cmd_list_element **,
-						char *, int,
-						struct cmd_list_element **);
+extern struct cmd_list_element *
+  add_prefix_cmd (char *, enum command_class,
+                  void (*fun) (char *, int, struct parse_context),
+		  char *, struct cmd_list_element **, char *, int,
+		  struct cmd_list_element **);
 
-extern struct cmd_list_element *add_abbrev_prefix_cmd (char *,
-						       enum command_class,
-						       void (*fun) (char *,
-								    int),
-						       char *,
-						       struct cmd_list_element
-						       **, char *, int,
-						       struct cmd_list_element
-						       **);
+extern struct cmd_list_element *
+  add_abbrev_prefix_cmd (char *, enum command_class,
+			 void (*fun) (char *, int, struct parse_context),
+			 char *, struct cmd_list_element **, char *, int,
+		         struct cmd_list_element **);
 
 /* Set the commands corresponding callback.  */
 
-typedef void cmd_cfunc_ftype (char *args, int from_tty);
+typedef void cmd_cfunc_ftype (char *args, int from_tty, struct parse_context);
 extern void set_cmd_cfunc (struct cmd_list_element *cmd,
 			   cmd_cfunc_ftype *cfunc);
 
@@ -140,7 +136,8 @@ extern void set_cmd_completer (struct cm
 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
    around in cmd objects to test the value of the commands sfunc().  */
 extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
-			 void (*cfunc) (char *args, int from_tty));
+			 void (*cfunc) (char *args, int from_tty,
+                                        struct parse_context));
 
 /* Each command object has a local context attached to it. .  */
 extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
@@ -178,14 +175,17 @@ extern int
                         struct cmd_list_element **prefix_cmd,
                         struct cmd_list_element **cmd);
 
-extern struct cmd_list_element *add_com (char *, enum command_class,
-					 void (*fun) (char *, int), char *);
+extern struct cmd_list_element *
+  add_com (char *, enum command_class,
+	   void (*fun) (char *, int, struct parse_context),
+	   char *);
 
 extern struct cmd_list_element *add_com_alias (char *, char *,
 					       enum command_class, int);
 
-extern struct cmd_list_element *add_info (char *, void (*fun) (char *, int),
-					  char *);
+extern struct cmd_list_element *
+  add_info (char *, void (*fun) (char *, int, struct parse_context),
+	    char *);
 
 extern struct cmd_list_element *add_info_alias (char *, char *, int);
 
diff -r e3c43da3934b gdb/cli/cli-decode.h
--- a/gdb/cli/cli-decode.h	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/cli/cli-decode.h	Thu Oct 09 08:55:57 2008 -0400
@@ -201,35 +201,32 @@ struct cmd_list_element
 
 /* API to the manipulation of command lists.  */
 
-extern struct cmd_list_element *add_cmd (char *, enum command_class,
-					 void (*fun) (char *, int), char *,
-					 struct cmd_list_element **);
+extern struct cmd_list_element *
+  add_cmd (char *, enum command_class,
+	   void (*fun) (char *, int, struct parse_context),
+	   char *, struct cmd_list_element **);
 
 extern struct cmd_list_element *add_alias_cmd (char *, char *,
 					       enum command_class, int,
 					       struct cmd_list_element **);
 
-extern struct cmd_list_element *add_prefix_cmd (char *, enum command_class,
-						void (*fun) (char *, int),
-						char *,
-						struct cmd_list_element **,
-						char *, int,
-						struct cmd_list_element **);
+extern struct cmd_list_element *
+  add_prefix_cmd (char *, enum command_class,
+                  void (*fun) (char *, int, struct parse_context),
+		  char *, struct cmd_list_element **, char *, int,
+		  struct cmd_list_element **);
 
-extern struct cmd_list_element *add_abbrev_prefix_cmd (char *,
-						       enum command_class,
-						       void (*fun) (char *,
-								    int),
-						       char *,
-						       struct cmd_list_element
-						       **, char *, int,
-						       struct cmd_list_element
-						       **);
+extern struct cmd_list_element *
+  add_abbrev_prefix_cmd (char *, enum command_class,
+			 void (*fun) (char *, int, struct parse_context),
+			 char *, struct cmd_list_element **, char *, int,
+		         struct cmd_list_element **);
 
 /* Set the commands corresponding callback.  */
 
 extern void set_cmd_cfunc (struct cmd_list_element *cmd,
-			   void (*cfunc) (char *args, int from_tty));
+			   void (*cfunc) (char *args, int from_tty,
+                                          struct parse_context));
 
 extern void set_cmd_sfunc (struct cmd_list_element *cmd,
 			   void (*sfunc) (char *args, int from_tty,
@@ -241,7 +238,8 @@ extern void set_cmd_completer (struct cm
 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
    around in cmd objects to test the value of the commands sfunc().  */
 extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
-			 void (*cfunc) (char *args, int from_tty));
+			 void (*cfunc) (char *args, int from_tty,
+                                        struct parse_context));
 
 /* Access to the command's local context.  */
 extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
@@ -275,14 +273,17 @@ extern int
                         struct cmd_list_element **prefix_cmd,
                         struct cmd_list_element **cmd);
 
-extern struct cmd_list_element *add_com (char *, enum command_class,
-					 void (*fun) (char *, int), char *);
+extern struct cmd_list_element *
+  add_com (char *, enum command_class,
+	   void (*fun) (char *, int, struct parse_context),
+	   char *);
 
 extern struct cmd_list_element *add_com_alias (char *, char *,
 					       enum command_class, int);
 
-extern struct cmd_list_element *add_info (char *, void (*fun) (char *, int),
-					  char *);
+extern struct cmd_list_element *
+  add_info (char *, void (*fun) (char *, int, struct parse_context),
+	    char *);
 
 extern struct cmd_list_element *add_info_alias (char *, char *, int);
 
diff -r e3c43da3934b gdb/cli/cli-decode.c
--- a/gdb/cli/cli-decode.c	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/cli/cli-decode.c	Thu Oct 09 08:55:57 2008 -0400
@@ -57,7 +57,7 @@ static void
 static void
 do_cfunc (struct cmd_list_element *c, char *args, int from_tty)
 {
-  c->function.cfunc (args, from_tty); /* Ok.  */
+  c->function.cfunc (args, from_tty, current_parse_context ()); /* Ok.  */
 }
 
 void
@@ -88,7 +88,7 @@ set_cmd_sfunc (struct cmd_list_element *
 
 int
 cmd_cfunc_eq (struct cmd_list_element *cmd,
-	      void (*cfunc) (char *args, int from_tty))
+	      void (*cfunc) (char *args, int from_tty, struct parse_context))
 {
   return cmd->func == do_cfunc && cmd->function.cfunc == cfunc;
 }
@@ -149,7 +149,8 @@ set_cmd_completer (struct cmd_list_eleme
    of *LIST). */
 
 struct cmd_list_element *
-add_cmd (char *name, enum command_class class, void (*fun) (char *, int),
+add_cmd (char *name, enum command_class class,
+         void (*fun) (char *, int, struct parse_context),
 	 char *doc, struct cmd_list_element **list)
 {
   struct cmd_list_element *c
@@ -261,7 +262,8 @@ add_alias_cmd (char *name, char *oldname
    of the variable containing that list.  */
 
 struct cmd_list_element *
-add_prefix_cmd (char *name, enum command_class class, void (*fun) (char *, int),
+add_prefix_cmd (char *name, enum command_class class,
+                void (*fun) (char *, int, struct parse_context),
 		char *doc, struct cmd_list_element **prefixlist,
 		char *prefixname, int allow_unknown,
 		struct cmd_list_element **list)
@@ -277,7 +279,8 @@ add_prefix_cmd (char *name, enum command
 
 struct cmd_list_element *
 add_abbrev_prefix_cmd (char *name, enum command_class class,
-		       void (*fun) (char *, int), char *doc,
+		       void (*fun) (char *, int, struct parse_context),
+                       char *doc,
 		       struct cmd_list_element **prefixlist, char *prefixname,
 		       int allow_unknown, struct cmd_list_element **list)
 {
@@ -657,7 +660,8 @@ delete_cmd (char *name, struct cmd_list_
 /* Add an element to the list of info subcommands.  */
 
 struct cmd_list_element *
-add_info (char *name, void (*fun) (char *, int), char *doc)
+add_info (char *name, void (*fun) (char *, int, struct parse_context),
+          char *doc)
 {
   return add_cmd (name, no_class, fun, doc, &infolist);
 }
@@ -673,7 +677,8 @@ add_info_alias (char *name, char *oldnam
 /* Add an element to the list of commands.  */
 
 struct cmd_list_element *
-add_com (char *name, enum command_class class, void (*fun) (char *, int),
+add_com (char *name, enum command_class class,
+         void (*fun) (char *, int, struct parse_context),
 	 char *doc)
 {
   return add_cmd (name, class, fun, doc, &cmdlist);
diff -r e3c43da3934b gdb/exceptions.h
--- a/gdb/exceptions.h	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/exceptions.h	Thu Oct 09 08:55:57 2008 -0400
@@ -233,7 +233,7 @@ extern int catch_errors (catch_errors_ft
 /* Template to catch_errors() that wraps calls to command
    functions. */
 
-typedef void (catch_command_errors_ftype) (char *, int);
+typedef void (catch_command_errors_ftype) (char *, int, struct parse_context);
 extern int catch_command_errors (catch_command_errors_ftype *func, char *command, int from_tty, return_mask);
 
 #endif
diff -r e3c43da3934b gdb/exceptions.c
--- a/gdb/exceptions.c	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/exceptions.c	Thu Oct 09 08:55:57 2008 -0400
@@ -528,7 +528,7 @@ catch_command_errors (catch_command_erro
   volatile struct gdb_exception e;
   TRY_CATCH (e, mask)
     {
-      command (arg, from_tty);
+      command (arg, from_tty, current_parse_context ());
     }
   print_any_exception (gdb_stderr, NULL, e);
   if (e.reason < 0)
diff -r e3c43da3934b gdb/language.c
--- a/gdb/language.c	Tue Oct 07 11:21:29 2008 -0400
+++ b/gdb/language.c	Thu Oct 09 08:55:57 2008 -0400
@@ -59,9 +59,9 @@ static void unk_lang_error (char *);
 
 static int unk_lang_parser (void);
 
-static void show_check (char *, int);
+static void show_check (char *, int, struct parse_context parse_context);
 
-static void set_check (char *, int);
+static void set_check (char *, int, struct parse_context parse_context);
 
 static void set_type_range_case (void);
 
@@ -917,7 +917,7 @@ language_str (enum language lang)
 }
 
 static void
-set_check (char *ignore, int from_tty)
+set_check (char *ignore, int from_tty, struct parse_context parse_context)
 {
   printf_unfiltered (
      "\"set check\" must be followed by the name of a check subcommand.\n");
@@ -925,7 +925,7 @@ set_check (char *ignore, int from_tty)
 }
 
 static void
-show_check (char *ignore, int from_tty)
+show_check (char *ignore, int from_tty, struct parse_context parse_context)
 {
   cmd_show_list (showchecklist, from_tty, "");
 }

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-09 14:05 [RFC/RFA] add struct parse_context to all command functions 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-21 18:05 ` Ulrich Weigand
  2 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-09 16:13 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> I'd like to start working on adding a struct parse_context again.
Joel> The ultimate goal is to pass this structure as an argument to all
Joel> the "parse..." routines, rather than rely on the current_language
Joel> and input_radix globals.  In addition to being cleaner, it will also
Joel> help fix a bug where the current_language is switched under us while
Joel> trying to do parse an expression.

I looked for the previous thread, and found this:

http://sourceware.org/ml/gdb-patches/2007-12/msg00255.html

... but I didn't see an explanation of the problem.  Would you mind
repeating it?

Joel> The next step for this task is to add a struct parse_context parameter
Joel> to the "command" functions (the functions being called when the user
Joel> calls a function in the UI).  When the user enters a command, we know
Joel> that we can use the current language and input radix to parse the
Joel> arguments.

I'm all in favor of this kind of cleanup.

struct cmd_list_element already has some support for multiple styles
of callback.  It seems to me that you could limit your change to a
subset of all the commands by adding a new field to the 'function'
union.  (That would mean more add_* functions, though.)

Joel>   1. The prototypes for the various add_* functions are duplicated.
Joel>      There is a copy in command.h, and another in cli/cli-decode.h.
Joel>      Is there a specific reason why we can't keep only one copy?
Joel>      For instance, only keep the copy in cli/cli-decode.h?
[ and 2 and 3]

I have wondered about these myself.

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-09 16:13 ` Tom Tromey
@ 2008-10-09 22:20   ` Joel Brobecker
  0 siblings, 0 replies; 32+ messages in thread
From: Joel Brobecker @ 2008-10-09 22:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> ... but I didn't see an explanation of the problem.  Would you mind
> repeating it?

Sure, http://www.sourceware.org/ml/gdb-patches/2007-10/msg00181.html:
> There is a project that I'm itching to start is to rework a bit our
> expression evaluation interfaces to use an explicit language rather
> than relying on the current_language global. The reason for this is
> that it will make it much clearer which language is to be used and
> will prevent some oopsies that can appear during situations like:
> 
>     breakpoint_re_set_one
>        -> set language to breakpoint language
>        -> re-evaluation breakpoint location
>        -> reset language to intial value
> 
> I have seen some cases, especially during the inferior startup
> phase, where we inadvertandly switch the language to an irrelevant
> value because as a side-effect of calling "select_frame ()". As
> a result, we end up evaluating the breakpoint location using
> the wrong language!
> 
> On mips-irix, we end up getting errors like this:
> 
>     % gdb foo
>     (gdb) b foo
>     Breakpoint 1 at 0x1000278c: file foo.adb, line 4.
>     (gdb) run
>     Starting program: /kern.a/brobecke/head/ex/foo
>     Error in re-setting breakpoint 1:
>     Function "foo" not defined.
> 
>     Program exited normally.
> 
> I think it's going to be a lot cleaner to pass a specific language
> to the parser/evaluator rather having it use the current language.
> And it's going to help us fix that problem above. Right now, I'm
> not sure I can find a solution as we have done a few times in the
> past already.

> struct cmd_list_element already has some support for multiple styles
> of callback.  It seems to me that you could limit your change to a
> subset of all the commands by adding a new field to the 'function'
> union.  (That would mean more add_* functions, though.)

Do you mean adding new "add_..." commands, and transitionning the old
ones to the new ones gradually? That should work indeed - the trickiness
is related to the fact that some of the command functions are used for
more than one commands through "add_cmd" and "add_prefix_cmd". For
instance in breakpoint.c:

  add_prefix_cmd ("enable", class_breakpoint, enable_command, ...);
  if (xdb_commands)
    add_com ("ab", class_breakpoint, enable_command, ...);

If I provide replacement versions for all the add_... commands right
from the start, it should allow us to transition gradually. I could
propose the following:

  . First patch: Rename all the add_... functions into add_..._nopc
    (for "NO Parse Context"). That's a mega-patch, but should be
    automatable.

  . Second patch: Add the add_... functions back, with the new
    interface.

  . Followup patches: Transition each file one after the other.

  . Final patch: When the old functions are no longer used, we remove
    them.

I'm Ok with this either the initial approach where everything is
transitionned all at once.  I don't really prefer the gradual transition
because it doesn't avoid the mega patch issue, makes the transition
last over a longer duration, and is in fact a little more work for
me. But I don't mind using the gradual approach is people prefer that.

-- 
Joel


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-09 14:05 [RFC/RFA] add struct parse_context to all command functions Joel Brobecker
  2008-10-09 16:13 ` Tom Tromey
@ 2008-10-20 16:16 ` Joel Brobecker
  2008-10-20 19:03   ` Thiago Jung Bauermann
  2008-10-21  1:22   ` Tom Tromey
  2008-10-21 18:05 ` Ulrich Weigand
  2 siblings, 2 replies; 32+ messages in thread
From: Joel Brobecker @ 2008-10-20 16:16 UTC (permalink / raw)
  To: gdb-patches

Har har har, I should be able to be active again soon :-)

> I'd like to start working on adding a struct parse_context again.
> The ultimate goal is to pass this structure as an argument to all
> the "parse..." routines, rather than rely on the current_language
> and input_radix globals.  In addition to being cleaner, it will also
> help fix a bug where the current_language is switched under us while
> trying to do parse an expression.

Going back to this, Tom and I exchanged a couple of emails, and
the discussion lead to an interesting suggestion. The base for the
suggestion is that Tom wonders whether it might be a little excessive
to push this extra argument that might actually only be used by a
subset of the commands. I initially agreed, but then thought about
it some more, and realized that all the command functions receive
the arguments as a string, and thus can potentially parse it.
So, always passing the parsing context wouldn't seem unreasonable
to me either. In any case, the idea that emerged is that we could
provide 2 possible command profiles, dependending on what the specific
needs of the function are. The advantage is that we then only
transition the command functions that need the parse context,
and the transition can be done piecemeal.  The issue is that
we will have to duplicate all the various add_cmd functions for
the new extended profile.

So we have 3 alternatives:

  1. All command functions receive the parse_context structure.
     Do the transition all at once.

  2. All command functions should receive the parse_context structure.
     Do the transition gradually by introducing a set of "old_add_..."
     functions that allow to hook command functions that have the old
     profile.

  3. Only the command functions that needed it would be passed
     the parse_context. Add a second set of add_... routines
     to hook these command functions.

I am 50/50 on (1) and (3). I like (2) a little less. Long term,
I think I prefer (1), but it's more painful in the short term.
I don't mind taking the initial hit, but other's opinion welcome.

Perhaps it's another bikeshed discussion, in which case let me know,
and I'll just decide on my own. It's just that it's such a large change
that I want to make sure I won't screw anyone up.

-- 
Joel


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  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  1:22   ` Tom Tromey
  1 sibling, 1 reply; 32+ messages in thread
From: Thiago Jung Bauermann @ 2008-10-20 19:03 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

El lun, 20-10-2008 a las 09:16 -0700, Joel Brobecker escribió:
> Har har har, I should be able to be active again soon :-)

Hooray. :-)

> So we have 3 alternatives:
> 
>   1. All command functions receive the parse_context structure.
>      Do the transition all at once.
> 
>   2. All command functions should receive the parse_context structure.
>      Do the transition gradually by introducing a set of "old_add_..."
>      functions that allow to hook command functions that have the old
>      profile.
> 
>   3. Only the command functions that needed it would be passed
>      the parse_context. Add a second set of add_... routines
>      to hook these command functions.
> 
> I am 50/50 on (1) and (3). I like (2) a little less. Long term,
> I think I prefer (1), but it's more painful in the short term.
> I don't mind taking the initial hit, but other's opinion welcome.

Is there any difference between (2) and (3) other than having the second
set of ad__... routines have a prettier name in (3) than they'd have in
(2)?

You could do (3) first and then stop there, or use it as an intermediate
step to get to (1).

THe problem with (3) is that you make the code slightly more complex by
adding an additional add_*_cmd that the GDB hacker will have to learn
about.

The advantage is that you can avoid writing functions with argument
they'll never use. I mention this because the ProjectIdeas wiki page
mentions that it's desirable to have GDB compile with -Wunused.

IMHO I prefer to use (3) and have the option of using the -Wunused later
(not that I'm stepping up to the task! :-) ).

> Perhaps it's another bikeshed discussion, in which case let me know,
> and I'll just decide on my own.

Perhaps it is. It took me a while to decide which I thought was better,
and then again I don't feel strong about either option.

>  It's just that it's such a large change
> that I want to make sure I won't screw anyone up.

Right, I'd also want input and some assurance before doing all this
work...
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-20 19:03   ` Thiago Jung Bauermann
@ 2008-10-21  0:47     ` Daniel Jacobowitz
  2008-10-21 18:06       ` Ulrich Weigand
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel Jacobowitz @ 2008-10-21  0:47 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: Joel Brobecker, gdb-patches

On Mon, Oct 20, 2008 at 05:02:14PM -0200, Thiago Jung Bauermann wrote:
> El lun, 20-10-2008 a las 09:16 -0700, Joel Brobecker escribió:
> > Har har har, I should be able to be active again soon :-)
> 
> Hooray. :-)
> 
> > So we have 3 alternatives:
> > 
> >   1. All command functions receive the parse_context structure.
> >      Do the transition all at once.

Personally, I prefer this one, unless the person doing the work
(that's you!) doesn't agree.

> THe problem with (3) is that you make the code slightly more complex by
> adding an additional add_*_cmd that the GDB hacker will have to learn
> about.

I also worry that there will end up being a combinatorial explosion of
these things.

> The advantage is that you can avoid writing functions with argument
> they'll never use. I mention this because the ProjectIdeas wiki page
> mentions that it's desirable to have GDB compile with -Wunused.
> 
> IMHO I prefer to use (3) and have the option of using the -Wunused later
> (not that I'm stepping up to the task! :-) ).

Let's not use this as a design decision.  IMO it is not too ugly to
mark unused arguments with e.g. ATTRIBUTE_UNUSED; that's what GCC
does.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-20 16:16 ` Joel Brobecker
  2008-10-20 19:03   ` Thiago Jung Bauermann
@ 2008-10-21  1:22   ` Tom Tromey
  2008-10-21  7:07     ` Joel Brobecker
  2008-10-21 18:12     ` Ulrich Weigand
  1 sibling, 2 replies; 32+ messages in thread
From: Tom Tromey @ 2008-10-21  1:22 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> The base for the suggestion is that Tom wonders whether it might
Joel> be a little excessive to push this extra argument that might
Joel> actually only be used by a subset of the commands.

Yeah, this is one issue.

I don't understand why the parameterization is needed by command
implementations.  My understanding is that it is needed when resetting
breakpoints (reparsing conditions or what have you).  However, it
seems like this could be done by simply parameterizing the parse
functions and sticking a bit more state on the breakpoint.

I assume I'm missing something here; I'd like to understand what.


Also, why pass in this particular subset of globals?  There are lots
of globals in gdb, used all over.  My view is that commands are by
their nature singletons (unless you want to support multiple CLIs at
once of course :-) and so would reasonably access global state even in
a design from scratch.  IOW, I think it would make sense to only
bother with global-elimination for layers underneath the command
functions.

What do you think of that?

Joel> Perhaps it's another bikeshed discussion, in which case let me know,
Joel> and I'll just decide on my own. It's just that it's such a large change
Joel> that I want to make sure I won't screw anyone up.

It won't mess anything up for me :-)

I'm interested in understanding the problem and also in everybody's
thoughts on future directions for gdb's implementation.  Also I'd
rather you do less work if possible.

FWIW I also have a vaguely similar reorganization in the wings.  I
removed all accesses to global variables from the value_print and
val_print hierarchy, in favor of a "print options" argument.  So, my
interest in this sort of thing is not totally academic.

I hope this isn't too bikesheddy.  I'm sensitive to the possibility :-)

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-21  1:22   ` Tom Tromey
@ 2008-10-21  7:07     ` Joel Brobecker
  2008-10-21 18:12     ` Ulrich Weigand
  1 sibling, 0 replies; 32+ messages in thread
From: Joel Brobecker @ 2008-10-21  7:07 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> I don't understand why the parameterization is needed by command
> implementations.  My understanding is that it is needed when resetting
> breakpoints (reparsing conditions or what have you).  However, it
> seems like this could be done by simply parameterizing the parse
> functions and sticking a bit more state on the breakpoint.
> I assume I'm missing something here; I'd like to understand what.

Right - In terms of the parsing issue in isolation, adding a language
paramenter is what is going to be needed, and what I will eventually
do. In fact, this is something that I actually did. But by doing so,
I realized that all I did was moving the use of the current_language
global variable up in the call stack in other routines that really
shouldn't be using it either.

So the global purpose of the exercise has become to remove the use
of the current_language global (as well as the input_radix one, which
was actually recommended by Ulrich when I initially introduced this
subject).  The fact this should fix the problem on IRIX almost for free
has almost become incidental (almost :-).

On my first approach to this issue, I started from the parse routines,
adding a language parameter, and slowly "propagated" this new parameter
up in the call stack (that is, adding this new parameters to the
callers, and using that parameter instead of using current_language).
But I felt disatisfied, because the number of uses of current_language
was in fact rapidly increasing.

If I work from the command functions, I work with a parameter right
from the start, so I won't have to increase the unwanted use of that
global, even temporarily.

> Also, why pass in this particular subset of globals?  There are lots
> of globals in gdb, used all over.  My view is that commands are by
> their nature singletons (unless you want to support multiple CLIs at
> once of course :-) and so would reasonably access global state even in
> a design from scratch.  IOW, I think it would make sense to only
> bother with global-elimination for layers underneath the command
> functions.

For this thread, we need to restrict ourselves to the globals that
affect the interpretation of the commands entered by the user. I chose
these parameters because they have an influence on the parsing of
the command arguments. There will likely be others, as hinted by Ulrich
(I think he was thinking of adding the gdbarch, or something equivalent).
So this might only be a start...

Generally speaking, I think this fits well in the goal of avoiding
the use of global variables to pass information from one routine
to the next.

-- 
Joel


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-09 14:05 [RFC/RFA] add struct parse_context to all command functions Joel Brobecker
  2008-10-09 16:13 ` Tom Tromey
  2008-10-20 16:16 ` Joel Brobecker
@ 2008-10-21 18:05 ` Ulrich Weigand
  2 siblings, 0 replies; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-21 18:05 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Joel Brobecker wrote:

> I'd like to start working on adding a struct parse_context again.
> The ultimate goal is to pass this structure as an argument to all
> the "parse..." routines, rather than rely on the current_language
> and input_radix globals.  In addition to being cleaner, it will also
> help fix a bug where the current_language is switched under us while
> trying to do parse an expression.

Now that current_gdbarch is already pulled out of the parse routines,
it would make sense to also add a gdbarch parameter to the parse_context
structure; this would be used to set up expout->gdbarch in 
parse_exp_in_context.

Otherwise, I like the proposal :-)

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-21  0:47     ` Daniel Jacobowitz
@ 2008-10-21 18:06       ` Ulrich Weigand
  2008-10-21 18:18         ` Daniel Jacobowitz
  0 siblings, 1 reply; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-21 18:06 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Thiago Jung Bauermann, Joel Brobecker, gdb-patches

Dan Jacobowitz wrote:
> On Mon, Oct 20, 2008 at 05:02:14PM -0200, Thiago Jung Bauermann wrote:
> > El lun, 20-10-2008 a las 09:16 -0700, Joel Brobecker escribió:
> > > Har har har, I should be able to be active again soon :-)
> > 
> > Hooray. :-)
> > 
> > > So we have 3 alternatives:
> > > 
> > >   1. All command functions receive the parse_context structure.
> > >      Do the transition all at once.
> 
> Personally, I prefer this one, unless the person doing the work
> (that's you!) doesn't agree.

FWIW I'd also prefer this option.

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  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
  1 sibling, 2 replies; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-21 18:12 UTC (permalink / raw)
  To: tromey; +Cc: Joel Brobecker, gdb-patches

Tom Tromey wrote:

> Also, why pass in this particular subset of globals?  There are lots
> of globals in gdb, used all over.  My view is that commands are by
> their nature singletons (unless you want to support multiple CLIs at
> once of course :-) and so would reasonably access global state even in
> a design from scratch.  IOW, I think it would make sense to only
> bother with global-elimination for layers underneath the command
> functions.

I think it does make sense to make the context where a command is
executed more explicit, so that at some point in the future we might
actually be able to do something like "execute command X on thread Y"
transparently without having to switch global state.  Of course, more
than just Joel's patch will be needed to achieve this ...

> FWIW I also have a vaguely similar reorganization in the wings.  I
> removed all accesses to global variables from the value_print and
> val_print hierarchy, in favor of a "print options" argument.  So, my
> interest in this sort of thing is not totally academic.

Great!  I was just about to start implementing something along those
lines (to pull current_gdbarch out of the print routines) ...  Do you
already have a version of that patch you could share?

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-21 18:06       ` Ulrich Weigand
@ 2008-10-21 18:18         ` Daniel Jacobowitz
  2008-10-22  1:40           ` Joel Brobecker
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel Jacobowitz @ 2008-10-21 18:18 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Thiago Jung Bauermann, Joel Brobecker, gdb-patches

On Tue, Oct 21, 2008 at 08:05:21PM +0200, Ulrich Weigand wrote:
> FWIW I'd also prefer this option.

Listening to Tom talk about this I've started to wonder if it's
necessary... do we have a unified vision on where the global state
accesses are OK?

GDB is single threaded.  I anticipate it will remain so.  So, having
the functions which implement user interface commands read global
state doesn't seem like a big problem - unlike the expression parser.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-21 18:12     ` Ulrich Weigand
@ 2008-10-21 18:58       ` Tom Tromey
  2008-10-21 19:33       ` Tom Tromey
  1 sibling, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2008-10-21 18:58 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

Tom> FWIW I also have a vaguely similar reorganization in the wings.  I
Tom> removed all accesses to global variables from the value_print and
Tom> val_print hierarchy, in favor of a "print options" argument.  So, my
Tom> interest in this sort of thing is not totally academic.

Ulrich> Great!  I was just about to start implementing something along those
Ulrich> lines (to pull current_gdbarch out of the print routines) ...  Do you
Ulrich> already have a version of that patch you could share?

My only patch almost certainly wouldn't apply to head (I made it
against the python branch so it has some extraneous stuff in it).

Would you like it, even though it is pretty broken?

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  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
  1 sibling, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-21 19:33 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2113 bytes --]

>>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:

Ulrich> Great!  I was just about to start implementing something along those
Ulrich> lines (to pull current_gdbarch out of the print routines) ...  Do you
Ulrich> already have a version of that patch you could share?

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

I have not written a ChangeLog entry yet, sorry.  And, I haven't sent
this through the tester yet either.  IOW, this is a raw patch, use at
your own risk, etc.

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).

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).

My motivation here is that I wanted to add a new value-printing flag
to control Python-based pretty-printing.  I didn't think that adding a
new enum value to val_prettyprint would yield good results; but adding
a new argument to the whole hierarchy looked ugly.  On the python
branch, I just used a global -- also ugly, but at least easy to
implement and maintain separately from the trunk.

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.

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.

Tom


[-- Attachment #2: the patch --]
[-- Type: application/octet-stream, Size: 176667 bytes --]

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2e29770..cbd031e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -353,9 +353,9 @@ ada_get_gdb_completer_word_break_characters (void)
 
 static void
 ada_print_array_index (struct value *index_value, struct ui_file *stream,
-                       int format, enum val_prettyprint pretty)
+                       const struct value_print_options *options)
 {
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, " => ");
 }
 
@@ -10060,7 +10060,7 @@ static void
 print_one_exception (enum exception_catchpoint_kind ex,
                      struct breakpoint *b, CORE_ADDR *last_addr)
 { 
-  if (addressprint)
+  if (user_print_options.addressprint)
     {
       annotate_field (4);
       ui_out_field_core_addr (uiout, "addr", b->loc->address);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 2d13603..e65a838 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -258,11 +258,11 @@ extern void ada_print_type (struct type *, char *, struct ui_file *, int,
                             int);
 
 extern int ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-                          struct ui_file *, int, int, int,
-                          enum val_prettyprint);
+                          struct ui_file *, int,
+			  const struct value_print_options *);
 
-extern int ada_value_print (struct value *, struct ui_file *, int,
-                            enum val_prettyprint);
+extern int ada_value_print (struct value *, struct ui_file *,
+			    const struct value_print_options *);
 
                                 /* Defined in ada-lang.c */
 
@@ -275,7 +275,8 @@ extern void ada_emit_char (int, struct ui_file *, int, int);
 extern void ada_printchar (int, struct ui_file *);
 
 extern void ada_printstr (struct ui_file *, const gdb_byte *,
-			  unsigned int, int, int);
+			  unsigned int, int, int,
+			  const struct value_print_options *);
 
 struct value *ada_convert_actual (struct value *actual,
                                   struct type *formal_type0,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index e2f7740..794f799 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -43,18 +43,17 @@ struct ada_val_print_args
   int embedded_offset;
   CORE_ADDR address;
   struct ui_file *stream;
-  int format;
-  int deref_ref;
   int recurse;
-  enum val_prettyprint pretty;
+  const struct value_print_options *options;
 };
 
 static void print_record (struct type *, const gdb_byte *, struct ui_file *,
-			  int, int, enum val_prettyprint);
+			  int, const struct value_print_options *);
 
 static int print_field_values (struct type *, const gdb_byte *,
-			       struct ui_file *, int, int,
-			       enum val_prettyprint, int, struct type *,
+			       struct ui_file *, int,
+			       const struct value_print_options *,
+			       int, struct type *,
 			       const gdb_byte *);
 
 static void adjust_type_signedness (struct type *);
@@ -62,8 +61,8 @@ static void adjust_type_signedness (struct type *);
 static int ada_val_print_stub (void *args0);
 
 static int ada_val_print_1 (struct type *, const gdb_byte *, int, CORE_ADDR,
-			    struct ui_file *, int, int, int,
-			    enum val_prettyprint);
+			    struct ui_file *, int,
+			    const struct value_print_options *);
 \f
 
 /* Make TYPE unsigned if its range of values includes no negatives.  */
@@ -81,13 +80,14 @@ adjust_type_signedness (struct type *type)
    otherwise 0.  */
 
 static int
-print_optional_low_bound (struct ui_file *stream, struct type *type)
+print_optional_low_bound (struct ui_file *stream, struct type *type,
+			  const struct value_print_options *options)
 {
   struct type *index_type;
   long low_bound;
   long high_bound;
 
-  if (print_array_indexes_p ())
+  if (options->print_array_indexes)
     return 0;
 
   if (!get_array_bounds (type, &low_bound, &high_bound))
@@ -145,8 +145,8 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
 static void
 val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 				 int bitoffset, struct ui_file *stream,
-				 int format, int recurse,
-				 enum val_prettyprint pretty)
+				 int recurse,
+				 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -172,14 +172,14 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
   i = 0;
   annotate_array_section_begin (i, elttype);
 
-  while (i < len && things_printed < print_max)
+  while (i < len && things_printed < options->print_max)
     {
       struct value *v0, *v1;
       int i0;
 
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -190,7 +190,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    }
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
-      maybe_print_array_index (index_type, i + low, stream, format, pretty);
+      maybe_print_array_index (index_type, i + low, stream, options);
 
       i0 = i;
       v0 = ada_value_primitive_packed_val (NULL, valaddr,
@@ -210,10 +210,10 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    break;
 	}
 
-      if (i - i0 > repeat_count_threshold)
+      if (i - i0 > options->repeat_count_threshold)
 	{
-	  val_print (elttype, value_contents (v0), 0, 0, stream, format,
-		     0, recurse + 1, pretty, current_language);
+	  val_print (elttype, value_contents (v0), 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt_rep (i - i0);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), i - i0);
 	  annotate_elt_rep_end ();
@@ -226,7 +226,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    {
 	      if (j > i0)
 		{
-		  if (prettyprint_arrays)
+		  if (options->prettyprint_arrays)
 		    {
 		      fprintf_filtered (stream, ",\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -237,10 +237,10 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 		    }
 		  wrap_here (n_spaces (2 + 2 * recurse));
 		  maybe_print_array_index (index_type, j + low,
-					   stream, format, pretty);
+					   stream, options);
 		}
-	      val_print (elttype, value_contents (v0), 0, 0, stream, format,
-			 0, recurse + 1, pretty, current_language);
+	      val_print (elttype, value_contents (v0), 0, 0, stream,
+			 recurse + 1, options, current_language);
 	      annotate_elt ();
 	    }
 	}
@@ -452,7 +452,8 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 
 static void
 printstr (struct ui_file *stream, const gdb_byte *string,
-	  unsigned int length, int force_ellipses, int type_len)
+	  unsigned int length, int force_ellipses, int type_len,
+	  const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -465,7 +466,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; i += 1)
+  for (i = 0; i < length && things_printed < options->print_max; i += 1)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -491,11 +492,11 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  reps += 1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -507,14 +508,14 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  fputs_filtered ("'", stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -529,7 +530,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
@@ -541,9 +542,10 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 
 void
 ada_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
-  printstr (stream, string, length, force_ellipses, width);
+  printstr (stream, string, length, force_ellipses, width, options);
 }
 
 
@@ -569,8 +571,8 @@ ada_printstr (struct ui_file *stream, const gdb_byte *string,
 int
 ada_val_print (struct type *type, const gdb_byte *valaddr0,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   struct ada_val_print_args args;
   args.type = type;
@@ -578,10 +580,8 @@ ada_val_print (struct type *type, const gdb_byte *valaddr0,
   args.embedded_offset = embedded_offset;
   args.address = address;
   args.stream = stream;
-  args.format = format;
-  args.deref_ref = deref_ref;
   args.recurse = recurse;
-  args.pretty = pretty;
+  args.options = options;
 
   return catch_errors (ada_val_print_stub, &args, NULL, RETURN_MASK_ALL);
 }
@@ -594,8 +594,7 @@ ada_val_print_stub (void *args0)
   struct ada_val_print_args *argsp = (struct ada_val_print_args *) args0;
   return ada_val_print_1 (argsp->type, argsp->valaddr0,
 			  argsp->embedded_offset, argsp->address,
-			  argsp->stream, argsp->format, argsp->deref_ref,
-			  argsp->recurse, argsp->pretty);
+			  argsp->stream, argsp->recurse, argsp->options);
 }
 
 /* Assuming TYPE is a simple array, print the value of this array located
@@ -605,8 +604,8 @@ ada_val_print_stub (void *args0)
 
 static int
 ada_val_print_array (struct type *type, const gdb_byte *valaddr,
-		     CORE_ADDR address, struct ui_file *stream, int format,
-		     int deref_ref, int recurse, enum val_prettyprint pretty)
+		     CORE_ADDR address, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
 {
   struct type *elttype = TYPE_TARGET_TYPE (type);
   unsigned int eltlen;
@@ -623,40 +622,40 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
     len = TYPE_LENGTH (type) / eltlen;
 
   /* For an array of chars, print with string syntax.  */
-  if (ada_is_string_type (type) && (format == 0 || format == 's'))
+  if (ada_is_string_type (type)
+      && (options->output_format == 0 || options->output_format == 's'))
     {
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
         print_spaces_filtered (2 + 2 * recurse, stream);
 
       /* If requested, look for the first null char and only print
          elements up to it.  */
-      if (stop_print_at_null)
+      if (options->stop_print_at_null)
         {
           int temp_len;
 
           /* Look for a NULL char.  */
           for (temp_len = 0;
                (temp_len < len
-                && temp_len < print_max
+                && temp_len < options->print_max
                 && char_at (valaddr, temp_len, eltlen) != 0);
                temp_len += 1);
           len = temp_len;
         }
 
-      printstr (stream, valaddr, len, 0, eltlen);
+      printstr (stream, valaddr, len, 0, eltlen, options);
       result = len;
     }
   else
     {
       fprintf_filtered (stream, "(");
-      print_optional_low_bound (stream, type);
+      print_optional_low_bound (stream, type, options);
       if (TYPE_FIELD_BITSIZE (type, 0) > 0)
         val_print_packed_array_elements (type, valaddr, 0, stream,
-                                         format, recurse, pretty);
+                                         recurse, options);
       else
         val_print_array_elements (type, valaddr, address, stream,
-                                  format, deref_ref, recurse,
-                                  pretty, 0);
+                                  recurse, options, 0);
       fprintf_filtered (stream, ")");
     }
 
@@ -669,8 +668,8 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
 static int
 ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 		 int embedded_offset, CORE_ADDR address,
-		 struct ui_file *stream, int format,
-		 int deref_ref, int recurse, enum val_prettyprint pretty)
+		 struct ui_file *stream, int recurse,
+		 const struct value_print_options *options)
 {
   unsigned int len;
   int i;
@@ -695,8 +694,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	retn = ada_val_print_1 (value_type (val), value_contents (val), 0,
-				VALUE_ADDRESS (val), stream, format,
-				deref_ref, recurse, pretty);
+				VALUE_ADDRESS (val), stream, recurse, options);
       value_free_to_mark (mark);
       return retn;
     }
@@ -709,12 +707,12 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
     {
     default:
       return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
 
     case TYPE_CODE_PTR:
       {
 	int ret = c_val_print (type, valaddr0, embedded_offset, address, 
-			       stream, format, deref_ref, recurse, pretty);
+			       stream, recurse, options);
 	if (ada_is_tag_type (type))
 	  {
 	    struct value *val = 
@@ -778,17 +776,16 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 					    value_from_contents_and_address
 					    (type, valaddr, 0));
 	      return ada_val_print_1 (target_type, value_contents (v), 0, 0,
-				      stream, format, 0, recurse + 1, pretty);
+				      stream, recurse + 1, options);
 	    }
 	  else
 	    return ada_val_print_1 (TYPE_TARGET_TYPE (type),
 				    valaddr0, embedded_offset,
-				    address, stream, format, deref_ref,
-				    recurse, pretty);
+				    address, stream, recurse, options);
 	}
       else
 	{
-	  format = format ? format : output_format;
+	  int format = options->output_format;
 	  if (format)
 	    {
 	      print_scalar_formatted (valaddr, type, format, 0, stream);
@@ -830,9 +827,10 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -860,16 +858,17 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			    format, deref_ref, recurse, pretty);
+			    recurse, options);
       else
 	ada_print_floating (valaddr0 + embedded_offset, type, stream);
       break;
@@ -883,13 +882,13 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	{
-	  print_record (type, valaddr, stream, format, recurse, pretty);
+	  print_record (type, valaddr, stream, recurse, options);
 	  return 0;
 	}
 
     case TYPE_CODE_ARRAY:
-      return ada_val_print_array (type, valaddr, address, stream, format,
-                                  deref_ref, recurse, pretty);
+      return ada_val_print_array (type, valaddr, address, stream,
+				  recurse, options);
 
     case TYPE_CODE_REF:
       /* For references, the debugger is expected to print the value as
@@ -910,8 +909,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
                                 deref_val_int));
               val_print (value_type (deref_val),
                          value_contents (deref_val), 0,
-                         VALUE_ADDRESS (deref_val), stream, format,
-                         deref_ref, recurse + 1, pretty, current_language);
+                         VALUE_ADDRESS (deref_val), stream, recurse + 1,
+			 options, current_language);
             }
           else
             fputs_filtered ("(null)", stream);
@@ -927,8 +926,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 
 static int
 print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options, int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
@@ -941,13 +940,13 @@ print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
       (TYPE_FIELD_TYPE (var_type, which),
        valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
        + TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
-       stream, format, recurse, pretty,
+       stream, recurse, options,
        comma_needed, outer_type, outer_valaddr);
 }
 
 int
-ada_value_print (struct value *val0, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+ada_value_print (struct value *val0, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
   const gdb_byte *valaddr = value_contents (val0);
   CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
@@ -985,20 +984,20 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
     }
 
   return (val_print (type, value_contents (val), 0, address,
-		     stream, format, 1, 0, pretty, current_language));
+		     stream, 0, options, current_language));
 }
 
 static void
 print_record (struct type *type, const gdb_byte *valaddr,
-	      struct ui_file *stream, int format, int recurse,
-	      enum val_prettyprint pretty)
+	      struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   type = ada_check_typedef (type);
 
   fprintf_filtered (stream, "(");
 
-  if (print_field_values (type, valaddr, stream, format, recurse, pretty,
-			  0, type, valaddr) != 0 && pretty)
+  if (print_field_values (type, valaddr, stream, recurse, options,
+			  0, type, valaddr) != 0 && options->pretty)
     {
       fprintf_filtered (stream, "\n");
       print_spaces_filtered (2 * recurse, stream);
@@ -1023,8 +1022,9 @@ print_record (struct type *type, const gdb_byte *valaddr,
 
 static int
 print_field_values (struct type *type, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options,
+		    int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   int i, len;
@@ -1042,7 +1042,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	    print_field_values (TYPE_FIELD_TYPE (type, i),
 				valaddr
 				+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-				stream, format, recurse, pretty,
+				stream, recurse, options,
 				comma_needed, type, valaddr);
 	  continue;
 	}
@@ -1050,7 +1050,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  comma_needed =
 	    print_variant_part (type, i, valaddr,
-				stream, format, recurse, pretty, comma_needed,
+				stream, recurse, options, comma_needed,
 				outer_type, outer_valaddr);
 	  continue;
 	}
@@ -1059,7 +1059,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, ", ");
       comma_needed = 1;
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1068,7 +1068,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  wrap_here (n_spaces (2 + 2 * recurse));
 	}
-      if (inspect_it)
+      if (options->inspect_it)
 	{
 	  if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 	    fputs_filtered ("\"( ptr \"", stream);
@@ -1115,14 +1115,13 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 						  bit_size,
 						  TYPE_FIELD_TYPE (type, i));
 	      val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0, 0,
-			 stream, format, 0, recurse + 1, pretty,
-			 current_language);
+			 stream, recurse + 1, options, current_language);
 	    }
 	}
       else
 	ada_val_print (TYPE_FIELD_TYPE (type, i),
 		       valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-		       0, 0, stream, format, 0, recurse + 1, pretty);
+		       0, 0, stream, recurse + 1, options);
       annotate_field_end ();
     }
 
diff --git a/gdb/auxv.c b/gdb/auxv.c
index afc7fdd..ed0201c 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -172,7 +172,6 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 
   while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
     {
-      extern int addressprint;
       const char *name = "???";
       const char *description = "";
       enum { dec, hex, str } flavor = hex;
@@ -240,9 +239,9 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 	  fprintf_filtered (file, "0x%s\n", paddr_nz (val));
 	  break;
 	case str:
-	  if (addressprint)
+	  if (user_print_options.addressprint)
 	    fprintf_filtered (file, "0x%s", paddr_nz (val));
-	  val_print_string (val, -1, 1, file);
+	  val_print_string (val, -1, 1, file, &user_print_options);
 	  fprintf_filtered (file, "\n");
 	  break;
 	}
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 180f6c9..3ca4c08 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -56,6 +56,7 @@
 #include "ada-lang.h"
 #include "top.h"
 #include "wrapper.h"
+#include "valprint.h"
 
 #include "mi/mi-common.h"
 
@@ -283,8 +284,6 @@ breakpoints_always_inserted_mode (void)
 
 void _initialize_breakpoint (void);
 
-extern int addressprint;	/* Print machine addresses? */
-
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
@@ -2259,7 +2258,7 @@ watchpoint_value_print (struct value *val, struct ui_file *stream)
   if (val == NULL)
     fprintf_unfiltered (stream, _("<unreadable>"));
   else
-    value_print (val, stream, 0, Val_pretty_default);
+    value_print (val, stream, &user_print_options);
 }
 
 /* This is the normal print function for a bpstat.  In the future,
@@ -3640,7 +3639,7 @@ print_one_breakpoint_location (struct breakpoint *b,
   
   /* 5 and 6 */
   strcpy (wrap_indent, "                           ");
-  if (addressprint)
+  if (user_print_options.addressprint)
     {
       if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	strcat (wrap_indent, "           ");
@@ -3672,7 +3671,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (user_print_options.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	print_expression (b->exp, stb->stream);
@@ -3684,7 +3683,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (user_print_options.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->dll_pathname == NULL)
@@ -3704,7 +3703,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (user_print_options.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->exec_pathname != NULL)
@@ -3727,7 +3726,7 @@ print_one_breakpoint_location (struct breakpoint *b,
       case bp_shlib_event:
       case bp_thread_event:
       case bp_overlay_event:
-	if (addressprint)
+	if (user_print_options.addressprint)
 	  {
 	    annotate_field (4);
 	    if (header_of_multiple)
@@ -3944,7 +3943,7 @@ breakpoint_1 (int bnum, int allflag)
 	  nr_printable_breakpoints++;
       }
 
-  if (addressprint)
+  if (user_print_options.addressprint)
     bkpttbl_chain 
       = make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
                                              "BreakpointTable");
@@ -3967,7 +3966,7 @@ breakpoint_1 (int bnum, int allflag)
   if (nr_printable_breakpoints > 0)
     annotate_field (3);
   ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb");	/* 4 */
-  if (addressprint)
+  if (user_print_options.addressprint)
 	{
 	  if (nr_printable_breakpoints > 0)
 	    annotate_field (4);
@@ -4763,7 +4762,7 @@ print_one_catch_fork (struct breakpoint *b, CORE_ADDR *last_addr)
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (user_print_options.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "fork");
@@ -4841,7 +4840,7 @@ print_one_catch_vfork (struct breakpoint *b, CORE_ADDR *last_addr)
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (user_print_options.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "vfork");
@@ -5184,7 +5183,7 @@ mention (struct breakpoint *b)
 	}
       else
 	{
-	  if (addressprint || b->source_file == NULL)
+	  if (user_print_options.addressprint || b->source_file == NULL)
 	    {
 	      printf_filtered (" at ");
 	      fputs_filtered (paddress (b->loc->address), gdb_stdout);
@@ -6746,7 +6745,7 @@ print_exception_catchpoint (struct breakpoint *b)
 static void
 print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
 {
-  if (addressprint)
+  if (user_print_options.addressprint)
     {
       annotate_field (4);
       if (b->loc == NULL || b->loc->shlib_disabled)
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a978b17..067e429 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -86,7 +86,8 @@ c_printchar (int c, struct ui_file *stream)
 
 void
 c_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -108,7 +109,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -137,11 +138,11 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -150,14 +151,14 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  LA_PRINT_CHAR (current_char, stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -171,7 +172,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index fe1939a..cc9abde 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -40,11 +40,11 @@ extern void c_print_type (struct type *, char *, struct ui_file *, int,
 extern void c_print_typedef (struct type *, struct symbol *, struct ui_file *);
 
 extern int c_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 /* These are in c-lang.c: */
 
@@ -52,7 +52,8 @@ extern void c_printchar (int, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, const gdb_byte *string,
 			unsigned int length, int width,
-			int force_ellipses);
+			int force_ellipses,
+			const struct value_print_options *options);
 
 extern void scan_macro_expansion (char *expansion);
 extern int scanning_macro_expansion (void);
@@ -70,17 +71,13 @@ extern void c_type_print_base (struct type *, struct ui_file *, int, int);
 
 /* These are in cp-valprint.c */
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void cp_print_class_member (const gdb_byte *, struct type *,
 				   struct ui_file *, char *);
 
 extern void cp_print_value_fields (struct type *, struct type *,
 				   const gdb_byte *, int, CORE_ADDR,
 				   struct ui_file *, int,
-				   int, enum val_prettyprint,
+				   const struct value_print_options *,
 				   struct type **, int);
 
 extern int cp_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 1dff6cb..fb7148e 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -36,7 +36,8 @@
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -115,8 +116,8 @@ textual_element_type (struct type *type, char format)
 
 int
 c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -134,29 +135,29 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	{
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
 
 	  /* Print arrays of textual chars with a string syntax.  */
-          if (textual_element_type (elttype, format))
+          if (textual_element_type (elttype, options->output_format))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0, options);
 	      i = len;
 	    }
 	  else
@@ -174,7 +175,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -184,9 +185,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_MEMBERPTR:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
@@ -197,19 +199,20 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
 	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.) */
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	  break;
 	}
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -220,21 +223,24 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
 	    {
 	      /* Try to print what function it points to.  */
-	      print_function_pointer_address (addr, stream);
+	      print_function_pointer_address (addr, stream,
+					      options->addressprint);
 	      /* Return value is irrelevant except for string pointers.  */
 	      return (0);
 	    }
 
-	  if (addressprint)
+	  if (options->addressprint)
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to a textual type, also print the string
 	     pointed to, unless pointer is null.  */
 	  /* FIXME: need to handle wchar_t here... */
 
-	  if (textual_element_type (elttype, format) && addr != 0)
+	  if (textual_element_type (elttype, options->output_format)
+	      && addr != 0)
 	    {
-	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				    options);
 	    }
 	  else if (cp_is_vtbl_member (type))
 	    {
@@ -250,7 +256,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -271,10 +277,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format,
-				    deref_ref, recurse + 1, pretty,
+		  common_val_print (vt_val, stream, recurse + 1, options,
 				    current_language);
-		  if (pretty)
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -291,17 +296,17 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -309,8 +314,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -318,7 +323,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -326,7 +331,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
       /*FIXME: Abstract this away */
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -337,17 +342,18 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + offset, field_type);
 
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	}
       else
-	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
-			       recurse, pretty, NULL, 0);
+	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream,
+			       recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -371,17 +377,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -394,9 +402,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -420,10 +428,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -432,7 +440,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	     Since we don't know whether the value is really intended to
 	     be used as an integer or a character, print the character
 	     equivalent as well.  */
-	  if (textual_element_type (type, format))
+	  if (textual_element_type (type, options->output_format))
 	    {
 	      fputs_filtered (" ", stream);
 	      LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
@@ -442,10 +450,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -460,9 +468,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -471,8 +480,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_DECFLOAT:
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	print_decimal_floating (valaddr + embedded_offset, type, stream);
       break;
@@ -493,19 +503,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_COMPLEX:
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset,
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
 			stream);
       fprintf_filtered (stream, " + ");
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset
 				+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	print_floating (valaddr + embedded_offset
 			+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
@@ -522,8 +532,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 }
 \f
 int
-c_value_print (struct value *val, struct ui_file *stream, int format,
-	       enum val_prettyprint pretty)
+c_value_print (struct value *val, struct ui_file *stream, 
+	       const struct value_print_options *options)
 {
   struct type *type, *real_type;
   int full, top, using_enc;
@@ -551,7 +561,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	{
 	  /* Print nothing */
 	}
-      else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+      else if (options->objectprint
+	       && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
 	{
 
 	  if (TYPE_CODE(type) == TYPE_CODE_REF)
@@ -602,7 +613,7 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   if (!value_initialized (val))
     fprintf_filtered (stream, " [uninitialized] ");
 
-  if (objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
+  if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
     {
       /* Attempt to determine real type of object */
       real_type = value_rtti_type (val, &full, &top, &using_enc);
@@ -616,8 +627,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	  /* Print out object: enclosing type is same as real_type if full */
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    options, current_language);
           /* Note: When we look up RTTI entries, we don't get any information on
              const or volatile attributes */
 	}
@@ -628,8 +639,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 			    TYPE_NAME (value_enclosing_type (val)));
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    options, current_language);
 	}
       /* Otherwise, we end up at the return outside this "if" */
     }
@@ -637,5 +648,5 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   return val_print (type, value_contents_all (val),
 		    value_embedded_offset (val),
 		    VALUE_ADDRESS (val) + value_offset (val),
-		    stream, format, 1, 0, pretty, current_language);
+		    stream, 0, options, current_language);
 }
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 61559af..bbb7689 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -38,7 +38,6 @@
 #include "language.h"
 
 /* Controls printing of vtbl's */
-int vtblprint;
 static void
 show_vtblprint (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -50,7 +49,6 @@ Printing of C++ virtual function tables is %s.\n"),
 
 /* Controls looking up an object's derived type using what we find in
    its vtables.  */
-int objectprint;
 static void
 show_objectprint (struct ui_file *file, int from_tty,
 		  struct cmd_list_element *c,
@@ -61,7 +59,6 @@ Printing of object's derived type based on vtable info is %s.\n"),
 		    value);
 }
 
-int static_field_print;		/* Controls printing of static fields. */
 static void
 show_static_field_print (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -77,12 +74,12 @@ static struct obstack dont_print_statmem_obstack;
 extern void _initialize_cp_valprint (void);
 
 static void cp_print_static_field (struct type *, struct value *,
-				   struct ui_file *, int, int,
-				   enum val_prettyprint);
+				   struct ui_file *, int,
+				   const struct value_print_options *);
 
 static void cp_print_value (struct type *, struct type *, const gdb_byte *,
-			    int, CORE_ADDR, struct ui_file *, int, int,
-			    enum val_prettyprint, struct type **);
+			    int, CORE_ADDR, struct ui_file *, int,
+			    const struct value_print_options *, struct type **);
 
 
 /* GCC versions after 2.4.5 use this.  */
@@ -151,9 +148,9 @@ cp_is_vtbl_member (struct type *type)
 void
 cp_print_value_fields (struct type *type, struct type *real_type,
 		       const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		       struct ui_file *stream, int format, int recurse,
-		       enum val_prettyprint pretty,
-		       struct type **dont_print_vb,int dont_print_statmem)
+		       struct ui_file *stream, int recurse,
+		       const struct value_print_options *options,
+		       struct type **dont_print_vb, int dont_print_statmem)
 {
   int i, len, n_baseclasses;
   char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
@@ -170,7 +167,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
   if (n_baseclasses > 0)
     cp_print_value (type, real_type, valaddr, offset, address, stream,
-		    format, recurse + 1, pretty, dont_print_vb);
+		    recurse + 1, options, dont_print_vb);
 
   /* Second, print out data fields */
 
@@ -192,7 +189,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!static_field_print
+	  if (!options->static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 
@@ -200,7 +197,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -211,7 +208,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -220,7 +217,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -270,7 +267,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		    (TYPE_FIELD_TYPE (type, i), 
 		     unpack_field_as_long (type, valaddr + offset, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1, pretty,
+		  common_val_print (v, stream, recurse + 1, options,
 				    current_language);
 		}
 	    }
@@ -287,15 +284,14 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		    fputs_filtered ("<optimized out>", stream);
 		  else
 		    cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
-					   stream, format, recurse + 1,
-					   pretty);
+					   stream, recurse + 1, options);
 		}
 	      else
 		{
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, options,
 			     current_language);
 		}
 	    }
@@ -310,7 +306,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -326,8 +322,9 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 static void
 cp_print_value (struct type *type, struct type *real_type,
 		const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int recurse,
-		enum val_prettyprint pretty, struct type **dont_print_vb)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options,
+		struct type **dont_print_vb)
 {
   struct type **last_dont_print
     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
@@ -402,7 +399,7 @@ cp_print_value (struct type *type, struct type *real_type,
 	base_valaddr = valaddr;
 
       /* now do the printing */
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -419,8 +416,7 @@ cp_print_value (struct type *type, struct type *real_type,
       else
 	cp_print_value_fields (baseclass, thistype, base_valaddr,
 			       thisoffset + boffset, address + boffset,
-			       stream, format,
-			       recurse, pretty,
+			       stream, recurse, options,
 			       ((struct type **)
 				obstack_base (&dont_print_vb_obstack)),
 			       0);
@@ -454,9 +450,8 @@ static void
 cp_print_static_field (struct type *type,
 		       struct value *val,
 		       struct ui_file *stream,
-		       int format,
 		       int recurse,
-		       enum val_prettyprint pretty)
+		       const struct value_print_options *options)
 {
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
@@ -485,12 +480,12 @@ cp_print_static_field (struct type *type,
       CHECK_TYPEDEF (type);
       cp_print_value_fields (type, type, value_contents_all (val),
 			     value_embedded_offset (val), VALUE_ADDRESS (val),
-			     stream, format, recurse, pretty, NULL, 1);
+			     stream, recurse, options, NULL, 1);
       return;
     }
   val_print (type, value_contents_all (val), 
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stream, format, 0, recurse, pretty, current_language);
+	     stream, recurse, options, current_language);
 }
 
 
@@ -589,32 +584,29 @@ void
 _initialize_cp_valprint (void)
 {
   add_setshow_boolean_cmd ("static-members", class_support,
-			   &static_field_print, _("\
+			   &user_print_options.static_field_print, _("\
 Set printing of C++ static members."), _("\
 Show printing of C++ static members."), NULL,
 			   NULL,
 			   show_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  static_field_print = 1;
 
-  add_setshow_boolean_cmd ("vtbl", class_support, &vtblprint, _("\
+  add_setshow_boolean_cmd ("vtbl", class_support,
+			   &user_print_options.vtblprint, _("\
 Set printing of C++ virtual function tables."), _("\
 Show printing of C++ virtual function tables."), NULL,
 			   NULL,
 			   show_vtblprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("object", class_support, &objectprint, _("\
+  add_setshow_boolean_cmd ("object", class_support,
+			   &user_print_options.objectprint, _("\
 Set printing of object's derived type based on vtable info."), _("\
 Show printing of object's derived type based on vtable info."), NULL,
 			   NULL,
 			   show_objectprint,
 			   &setprintlist, &showprintlist);
 
-  /* Give people the defaults which they are used to.  */
-  objectprint = 0;
-  vtblprint = 0;
   obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
   obstack_specify_allocation (&dont_print_statmem_obstack,
 			      32 * sizeof (CORE_ADDR), sizeof (CORE_ADDR),
diff --git a/gdb/eval.c b/gdb/eval.c
index cf3e876..bc07658 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -39,16 +39,13 @@
 #include "exceptions.h"
 #include "regcache.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 
 /* This is defined in valops.c */
 extern int overload_resolution;
 
-/* JYG: lookup rtti type of STRUCTOP_PTR when this is set to continue
-   on with successful lookup for member/method of the rtti type. */
-extern int objectprint;
-
 /* Prototypes for local functions. */
 
 static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
@@ -1629,7 +1626,7 @@ evaluate_subexp_standard (struct type *expect_type,
         struct type *real_type;
         int full, top, using_enc;
         
-        if (objectprint && TYPE_TARGET_TYPE(type) &&
+        if (user_print_options.objectprint && TYPE_TARGET_TYPE(type) &&
             (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
           {
             real_type = value_rtti_target_type (arg1, &full, &top, &using_enc);
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 079f2a9..ce65a81 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -31,6 +31,7 @@
 #include "block.h"
 #include "objfiles.h"
 #include "gdb_assert.h"
+#include "valprint.h"
 
 #ifdef HAVE_CTYPE_H
 #include <ctype.h>
@@ -92,17 +93,25 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_LONG:
-      (*pos) += 3;
-      value_print (value_from_longest (exp->elts[pc + 1].type,
-				       exp->elts[pc + 2].longconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_longest (exp->elts[pc + 1].type,
+					 exp->elts[pc + 2].longconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_DOUBLE:
-      (*pos) += 3;
-      value_print (value_from_double (exp->elts[pc + 1].type,
-				      exp->elts[pc + 2].doubleconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_double (exp->elts[pc + 1].type,
+					exp->elts[pc + 2].doubleconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_VAR_VALUE:
@@ -174,7 +183,8 @@ print_subexp_standard (struct expression *exp, int *pos,
       /* LA_PRINT_STRING will print using the current repeat count threshold.
          If necessary, we can temporarily set it to zero, or pass it as an
          additional parameter to LA_PRINT_STRING.  -fnf */
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+		       &user_print_options);
       return;
 
     case OP_BITSTRING:
@@ -188,7 +198,8 @@ print_subexp_standard (struct expression *exp, int *pos,
       nargs = longest_to_int (exp->elts[pc + 1].longconst);
       (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
       fputs_filtered ("@\"", stream);
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+		       &user_print_options);
       fputs_filtered ("\"", stream);
       return;
 
@@ -270,7 +281,8 @@ print_subexp_standard (struct expression *exp, int *pos,
 	}
       if (tem > 0)
 	{
-	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
+	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
+			   &user_print_options);
 	  (*pos) = pc;
 	}
       else
@@ -394,6 +406,8 @@ print_subexp_standard (struct expression *exp, int *pos,
       if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
 	  exp->elts[pc + 3].opcode == OP_LONG)
 	{
+	  struct value_print_options opts;
+
 	  /* We have a minimal symbol fn, probably.  It's encoded
 	     as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
 	     Swallow the OP_LONG (including both its opcodes); ignore
@@ -401,7 +415,8 @@ print_subexp_standard (struct expression *exp, int *pos,
 	  (*pos) += 4;
 	  val = value_at_lazy (exp->elts[pc + 1].type,
 			       (CORE_ADDR) exp->elts[pc + 5].longconst);
-	  value_print (val, stream, 0, Val_no_prettyprint);
+	  get_raw_print_options (&opts);
+	  value_print (val, stream, &opts);
 	}
       else
 	{
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 736d6c6..4d4d4d7 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -142,7 +142,8 @@ f_printchar (int c, struct ui_file *stream)
 
 static void
 f_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -155,7 +156,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -179,11 +180,11 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -192,14 +193,14 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  f_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -213,7 +214,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
@@ -305,8 +306,8 @@ f_language_arch_info (struct gdbarch *gdbarch,
 
 /* This is declared in c-lang.h but it is silly to import that file for what
    is already just a hack. */
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 const struct language_defn f_language_defn =
 {
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 252d25d..3b3487e 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -29,8 +29,8 @@ extern void f_print_type (struct type *, char *, struct ui_file *, int,
 			  int);
 
 extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
 /* Language-specific data structures */
 
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 672e95c..3fae0a7 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -164,42 +164,42 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
 static void
 f77_print_array_1 (int nss, int ndimensions, struct type *type,
 		   const gdb_byte *valaddr, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty,
+		   struct ui_file *stream, int recurse,
+		   const struct value_print_options *options,
 		   int *elts)
 {
   int i;
 
   if (nss != ndimensions)
     {
-      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++)
+      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++)
 	{
 	  fprintf_filtered (stream, "( ");
 	  f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
 			     valaddr + i * F77_DIM_OFFSET (nss),
 			     address + i * F77_DIM_OFFSET (nss),
-			     stream, format, deref_ref, recurse, pretty, elts);
+			     stream, recurse, options, elts);
 	  fprintf_filtered (stream, ") ");
 	}
-      if (*elts >= print_max && i < F77_DIM_SIZE (nss)) 
+      if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) 
 	fprintf_filtered (stream, "...");
     }
   else
     {
-      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < print_max; 
+      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
 	   i++, (*elts)++)
 	{
 	  val_print (TYPE_TARGET_TYPE (type),
 		     valaddr + i * F77_DIM_OFFSET (ndimensions),
 		     0,
 		     address + i * F77_DIM_OFFSET (ndimensions),
-		     stream, format, deref_ref, recurse, pretty,
-		     current_language);
+		     stream, recurse, options, current_language);
 
 	  if (i != (F77_DIM_SIZE (nss) - 1))
 	    fprintf_filtered (stream, ", ");
 
-	  if ((*elts == print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1)))
+	  if ((*elts == options->print_max - 1)
+	      && (i != (F77_DIM_SIZE (nss) - 1)))
 	    fprintf_filtered (stream, "...");
 	}
     }
@@ -211,8 +211,7 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
 static void
 f77_print_array (struct type *type, const gdb_byte *valaddr,
 		 CORE_ADDR address, struct ui_file *stream,
-		 int format, int deref_ref, int recurse,
-		 enum val_prettyprint pretty)
+		 int recurse, const struct value_print_options *options)
 {
   int ndimensions;
   int elts = 0;
@@ -229,8 +228,8 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
 
   f77_create_arrayprint_offset_tbl (type, stream);
 
-  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream, format,
-		     deref_ref, recurse, pretty, &elts);
+  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream,
+		     recurse, options, &elts);
 }
 \f
 
@@ -249,8 +248,8 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
 
 int
 f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *elttype;
@@ -263,20 +262,20 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     {
     case TYPE_CODE_STRING:
       f77_get_dynamic_length_of_aggregate (type);
-      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0);
+      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0, options);
       break;
 
     case TYPE_CODE_ARRAY:
       fprintf_filtered (stream, "(");
-      f77_print_array (type, valaddr, address, stream, format,
-		       deref_ref, recurse, pretty);
+      f77_print_array (type, valaddr, address, stream, recurse, options);
       fprintf_filtered (stream, ")");
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
 	  break;
 	}
       else
@@ -292,16 +291,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      return 0;
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->output_format != 's')
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to char or unsigned char, also print the string
 	     pointed to, unless pointer is null.  */
 	  if (TYPE_LENGTH (elttype) == 1
 	      && TYPE_CODE (elttype) == TYPE_CODE_INT
-	      && (format == 0 || format == 's')
+	      && (options->output_format == 0 || options->output_format == 's')
 	      && addr != 0)
-	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				  options);
 
 	  /* Return number of characters printed, including the terminating
 	     '\0' if we reached the end.  val_print_string takes care including
@@ -312,17 +312,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -330,8 +330,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref, recurse,
-				pretty, current_language);
+	      common_val_print (deref_val, stream, recurse,
+				options, current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -339,9 +339,10 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -354,9 +355,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else
 	{
 	  val_print_type_code_int (type, valaddr, stream);
@@ -374,15 +375,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else
 	print_floating (valaddr, type, stream);
       break;
@@ -401,9 +404,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else
 	{
 	  val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
@@ -417,8 +420,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	    {
 	      /* Bash the type code temporarily.  */
 	      TYPE_CODE (type) = TYPE_CODE_INT;
-	      f_val_print (type, valaddr, 0, address, stream, format,
-			   deref_ref, recurse, pretty);
+	      f_val_print (type, valaddr, 0, address, stream, recurse, options);
 	      /* Restore the type code so later uses work as intended. */
 	      TYPE_CODE (type) = TYPE_CODE_BOOL;
 	    }
@@ -450,8 +452,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
         {
           int offset = TYPE_FIELD_BITPOS (type, index) / 8;
           f_val_print (TYPE_FIELD_TYPE (type, index), valaddr + offset,
-                       embedded_offset, address, stream,
-                       format, deref_ref, recurse, pretty);
+                       embedded_offset, address, stream, recurse, options);
           if (index != TYPE_NFIELDS (type) - 1)
             fputs_filtered (", ", stream);
         }
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 4f55c33..f475330 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -51,6 +51,7 @@
 #include "exceptions.h"
 #include "cli/cli-decode.h"
 #include "gdbthread.h"
+#include "valprint.h"
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -1282,6 +1283,8 @@ print_return_value (struct type *func_type, struct type *value_type)
 
   if (value)
     {
+      struct value_print_options opts;
+
       /* Print it.  */
       stb = ui_out_stream_new (uiout);
       old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -1289,7 +1292,8 @@ print_return_value (struct type *func_type, struct type *value_type)
       ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
 			record_latest_value (value));
       ui_out_text (uiout, " = ");
-      value_print (value, stb->stream, 0, Val_no_prettyprint);
+      get_raw_print_options (&opts);
+      value_print (value, stb->stream, &opts);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
       do_cleanups (old_chain);
@@ -1805,7 +1809,7 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	  int j;
 
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 0, 1, 0, Val_pretty_default, current_language);
+		     file, 0, &user_print_options, current_language);
 
 	  fprintf_filtered (file, "\t(raw 0x");
 	  for (j = 0; j < register_size (gdbarch, i); j++)
@@ -1821,16 +1825,20 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	}
       else
 	{
+	  struct value_print_options opts;
+
 	  /* Print the register in hex.  */
+	  get_formatted_print_options (&opts, 'x');
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 'x', 1, 0, Val_pretty_default, current_language);
+		     file, 0, &opts,
+		     current_language);
           /* If not a vector register, print it also according to its
              natural format.  */
 	  if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
 	    {
 	      fprintf_filtered (file, "\t");
 	      val_print (register_type (gdbarch, i), buffer, 0, 0,
-			 file, 0, 1, 0, Val_pretty_default, current_language);
+			 file, 0, &user_print_options, current_language);
 	    }
 	}
 
diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h
index 51bada2..04ba383 100644
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -41,11 +41,11 @@ extern struct type *java_double_type;
 extern struct type *java_void_type;
 
 extern int java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			   struct ui_file *, int, int, int,
-			   enum val_prettyprint);
+			   struct ui_file *, int,
+			   const struct value_print_options *);
 
-extern int java_value_print (struct value *, struct ui_file *, int,
-			     enum val_prettyprint);
+extern int java_value_print (struct value *, struct ui_file *,
+			     const struct value_print_options *);
 
 extern struct value *java_class_from_object (struct value *);
 
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 9e36aa4..975068b 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -35,8 +35,8 @@
 /* Local functions */
 
 int
-java_value_print (struct value *val, struct ui_file *stream, int format,
-		  enum val_prettyprint pretty)
+java_value_print (struct value *val, struct ui_file *stream, 
+		  const struct value_print_options *options)
 {
   struct type *type;
   CORE_ADDR address;
@@ -89,7 +89,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
 	  address += JAVA_OBJECT_SIZE + 4;	/* Skip object header and length. */
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      gdb_byte *buf;
 
@@ -145,7 +145,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	  VALUE_ADDRESS (v) = address + JAVA_OBJECT_SIZE + 4;
 	  VALUE_ADDRESS (next_v) = VALUE_ADDRESS (v);
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      fputs_filtered (", ", stream);
 	      wrap_here (n_spaces (2));
@@ -180,8 +180,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	      else
 		fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
 
-	      common_val_print (v, stream, format, 2, 1, pretty,
-				current_language);
+	      common_val_print (v, stream, 1, options, current_language);
 
 	      things_printed++;
 	      i += reps;
@@ -203,7 +202,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
       && TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
       && strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)),
 		 "java.lang.String") == 0
-      && (format == 0 || format == 's')
+      && (options->output_format == 0 || options->output_format == 's')
       && address != 0
       && value_as_address (val) != 0)
     {
@@ -228,13 +227,12 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
       value_free_to_mark (mark);	/* Release unnecessary values */
 
-      val_print_string (data + boffset, count, 2, stream);
+      val_print_string (data + boffset, count, 2, stream, options);
 
       return 0;
     }
 
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  return common_val_print (val, stream, 0, options, current_language);
 }
 
 /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
@@ -246,7 +244,8 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 static void
 java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 			 CORE_ADDR address, struct ui_file *stream,
-			 int format, int recurse, enum val_prettyprint pretty)
+			 int recurse,
+			 const struct value_print_options *options)
 {
   int i, len, n_baseclasses;
 
@@ -275,7 +274,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 
 	  boffset = 0;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 * (recurse + 1), stream);
@@ -289,7 +288,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  base_valaddr = valaddr;
 
 	  java_print_value_fields (baseclass, base_valaddr, address + boffset,
-				   stream, format, recurse + 1, pretty);
+				   stream, recurse + 1, options);
 	  fputs_filtered (", ", stream);
 	}
 
@@ -307,7 +306,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  if (field_is_static (&TYPE_FIELD (type, i)))
 	    {
 	      char *name = TYPE_FIELD_NAME (type, i);
-	      if (!static_field_print)
+	      if (!options->static_field_print)
 		continue;
 	      if (name != NULL && strcmp (name, "class") == 0)
 		continue;
@@ -316,7 +315,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -327,7 +326,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -336,7 +335,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -383,8 +382,8 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  common_val_print (v, stream, recurse + 1,
+				    options, current_language);
 		}
 	    }
 	  else
@@ -403,8 +402,8 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		      struct type *t = check_typedef (value_type (v));
 		      if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
 			v = value_addr (v);
-		      common_val_print (v, stream, format, 0, recurse + 1,
-					pretty, current_language);
+		      common_val_print (v, stream, recurse + 1,
+					options, current_language);
 		    }
 		}
 	      else if (TYPE_FIELD_TYPE (type, i) == NULL)
@@ -414,14 +413,14 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr + TYPE_FIELD_BITPOS (type, i) / 8, 0,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, options,
 			     current_language);
 		}
 	    }
 	  annotate_field_end ();
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -446,8 +445,8 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 int
 java_val_print (struct type *type, const gdb_byte *valaddr,
 		int embedded_offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int deref_ref,
-		int recurse, enum val_prettyprint pretty)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *target_type;
@@ -457,13 +456,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format, 0, stream);
 	  break;
 	}
 #if 0
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -490,7 +489,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
 	  return (0);
 	}
 
-      if (addressprint && format != 's')
+      if (options->addressprint && options->output_format != 's')
 	{
 	  fputs_filtered ("@", stream);
 	  print_longest (stream, 'x', 0, (ULONGEST) addr);
@@ -502,9 +501,9 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
     case TYPE_CODE_INT:
       /* Can't just call c_val_print because that prints bytes as C
 	 chars.  */
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else if (TYPE_CODE (type) == TYPE_CODE_CHAR
 	       || (TYPE_CODE (type) == TYPE_CODE_INT
 		   && TYPE_LENGTH (type) == 2
@@ -515,13 +514,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_STRUCT:
-      java_print_value_fields (type, valaddr, address, stream, format,
-			       recurse, pretty);
+      java_print_value_fields (type, valaddr, address, stream, recurse,
+			       options);
       break;
 
     default:
       return c_val_print (type, valaddr, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
     }
 
   return 0;
diff --git a/gdb/language.c b/gdb/language.c
index 121fc55..46e238d 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -72,7 +72,8 @@ static void unk_lang_printchar (int c, struct ui_file *stream);
 static void unk_lang_print_type (struct type *, char *, struct ui_file *,
 				 int, int);
 
-static int unk_lang_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+static int unk_lang_value_print (struct value *, struct ui_file *,
+				 const struct value_print_options *);
 
 static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
 
@@ -1035,10 +1036,10 @@ default_word_break_characters (void)
 
 void
 default_print_array_index (struct value *index_value, struct ui_file *stream,
-                           int format, enum val_prettyprint pretty)
+			   const struct value_print_options *options)
 {
   fprintf_filtered (stream, "[");
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, "] = ");
 }
 
@@ -1070,7 +1071,8 @@ unk_lang_printchar (int c, struct ui_file *stream)
 
 static void
 unk_lang_printstr (struct ui_file *stream, const gdb_byte *string,
-		   unsigned int length, int width, int force_ellipses)
+		   unsigned int length, int width, int force_ellipses,
+		   const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_printstr called."));
 }
@@ -1085,15 +1087,15 @@ unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
 static int
 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
 		    int embedded_offset, CORE_ADDR address,
-		    struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_val_print called."));
 }
 
 static int
-unk_lang_value_print (struct value *val, struct ui_file *stream, int format,
-		      enum val_prettyprint pretty)
+unk_lang_value_print (struct value *val, struct ui_file *stream,
+		      const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_value_print called."));
 }
diff --git a/gdb/language.h b/gdb/language.h
index cc10ff2..c92c57c 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -30,6 +30,7 @@ struct objfile;
 struct frame_info;
 struct expression;
 struct ui_file;
+struct value_print_options;
 
 #define MAX_FORTRAN_DIMS  7	/* Maximum number of F77 array dims */
 
@@ -189,7 +190,8 @@ struct language_defn
 
     void (*la_printstr) (struct ui_file * stream, const gdb_byte *string,
 			 unsigned int length, int width,
-			 int force_ellipses);
+			 int force_ellipses,
+			 const struct value_print_options *);
 
     void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
 
@@ -208,13 +210,13 @@ struct language_defn
     /* Print a value using syntax appropriate for this language. */
 
     int (*la_val_print) (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
     /* Print a top-level value using syntax appropriate for this language. */
 
     int (*la_value_print) (struct value *, struct ui_file *,
-			   int, enum val_prettyprint);
+			   const struct value_print_options *);
 
     /* PC is possibly an unknown languages trampoline.
        If that PC falls in a trampoline belonging to this language,
@@ -274,8 +276,7 @@ struct language_defn
     /* Print the index of an element of an array.  */
     void (*la_print_array_index) (struct value *index_value,
                                   struct ui_file *stream,
-                                  int format,
-                                  enum val_prettyprint pretty);
+                                  const struct value_print_options *options);
 
     /* Return non-zero if TYPE should be passed (and returned) by
        reference at the language level.  */
@@ -366,21 +367,22 @@ extern enum language set_language (enum language);
 #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
   (current_language->la_print_typedef(type,new_symbol,stream))
 
-#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,fmt,deref,recurse,pretty) \
-  (current_language->la_val_print(type,valaddr,offset,addr,stream,fmt,deref, \
-				  recurse,pretty))
-#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
-  (current_language->la_value_print(val,stream,fmt,pretty))
+#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,recurse,options) \
+  (current_language->la_val_print(type,valaddr,offset,addr,stream, \
+				  recurse,options))
+#define LA_VALUE_PRINT(val,stream,options) \
+  (current_language->la_value_print(val,stream,options))
 
 #define LA_PRINT_CHAR(ch, stream) \
   (current_language->la_printchar(ch, stream))
-#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
-  (current_language->la_printstr(stream, string, length, width, force_ellipses))
+#define LA_PRINT_STRING(stream, string, length, width, force_ellipses,options) \
+  (current_language->la_printstr(stream, string, length, width, \
+				 force_ellipses,options))
 #define LA_EMIT_CHAR(ch, stream, quoter) \
   (current_language->la_emitchar(ch, stream, quoter))
 
-#define LA_PRINT_ARRAY_INDEX(index_value, stream, format, pretty) \
-  (current_language->la_print_array_index(index_value, stream, format, pretty))
+#define LA_PRINT_ARRAY_INDEX(index_value, stream, optins) \
+  (current_language->la_print_array_index(index_value, stream, options))
 
 /* Test a character to decide whether it can be printed in literal form
    or needs to be printed in another representation.  For example,
@@ -472,8 +474,7 @@ extern char *default_word_break_characters (void);
 /* Print the index of an array element using the C99 syntax.  */
 extern void default_print_array_index (struct value *index_value,
                                        struct ui_file *stream,
-                                       int format,
-                                       enum val_prettyprint pretty);
+				       const struct value_print_options *options);
 
 /* Return non-zero if TYPE should be passed (and returned) by
    reference at the language level.  */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index ea59403..e09b64b 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -104,7 +104,8 @@ m2_printchar (int c, struct ui_file *stream)
 
 static void
 m2_printstr (struct ui_file *stream, const gdb_byte *string,
-	     unsigned int length, int width, int force_ellipses)
+	     unsigned int length, int width, int force_ellipses,
+	     const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -117,7 +118,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -141,11 +142,11 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -154,14 +155,14 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  m2_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -175,7 +176,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 8ce458c..f99e31a 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -33,8 +33,8 @@ extern int m2_is_long_set (struct type *type);
 extern int m2_is_unbounded_array (struct type *type);
 
 extern int m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
 extern int get_long_set_bounds (struct type *type, LONGEST *low,
 				LONGEST *high);
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 82ff30e..e276e86 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -30,22 +30,24 @@
 #include "m2-lang.h"
 #include "target.h"
 
-int print_unpacked_pointer (struct type *type,
-			    CORE_ADDR address, CORE_ADDR addr,
-			    int format, struct ui_file *stream);
+static int print_unpacked_pointer (struct type *type,
+				   CORE_ADDR address, CORE_ADDR addr,
+				   const struct value_print_options *options,
+				   struct ui_file *stream);
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len);
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len);
 
 
 /* Print function pointer with inferior address ADDRESS onto stdio
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -88,8 +90,7 @@ get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high)
 static void
 m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   enum val_prettyprint pretty)
+		   struct ui_file *stream)
 {
   int empty_set        = 1;
   int element_seen     = 0;
@@ -184,9 +185,8 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 static void
 m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
 			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int format,
-			  int deref_ref, enum val_prettyprint pretty,
-			  int recurse)
+			  struct ui_file *stream, int recurse,
+			  const struct value_print_options *options)
 {
   struct type *content_type;
   CORE_ADDR addr;
@@ -207,26 +207,27 @@ m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
   fprintf_filtered (stream, "{");  
   m2_print_array_contents (value_type (val), value_contents(val),
 			   value_embedded_offset (val), addr, stream,
-			   format, deref_ref, pretty, recurse, len);
+			   recurse, options, len);
   fprintf_filtered (stream, ", HIGH = %d}", (int) len);
 }
 
-int
+static int
 print_unpacked_pointer (struct type *type,
 			CORE_ADDR address, CORE_ADDR addr,
-			int format, struct ui_file *stream)
+			const struct value_print_options *options,
+			struct ui_file *stream)
 {
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
 
   if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
     {
       /* Try to print what function it points to.  */
-      print_function_pointer_address (addr, stream);
+      print_function_pointer_address (addr, stream, options->addressprint);
       /* Return value is irrelevant except for string pointers.  */
       return 0;
     }
 
-  if (addressprint && format != 's')
+  if (options->addressprint && options->output_format != 's')
     fputs_filtered (paddress (address), stream);
 
   /* For a pointer to char or unsigned char, also print the string
@@ -234,9 +235,9 @@ print_unpacked_pointer (struct type *type,
 
   if (TYPE_LENGTH (elttype) == 1
       && TYPE_CODE (elttype) == TYPE_CODE_INT
-      && (format == 0 || format == 's')
+      && (options->output_format == 0 || options->output_format == 's')
       && addr != 0)
-      return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+    return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options);
   
   return 0;
 }
@@ -244,9 +245,9 @@ print_unpacked_pointer (struct type *type,
 static void
 print_variable_at_address (struct type *type,
 			   const gdb_byte *valaddr,
-			   struct ui_file *stream, int format,
-			   int deref_ref, int recurse,
-			   enum val_prettyprint pretty)
+			   struct ui_file *stream,
+			   int recurse,
+			   const struct value_print_options *options)
 {
   CORE_ADDR addr = unpack_pointer (type, valaddr);
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -259,8 +260,7 @@ print_variable_at_address (struct type *type,
     {
       struct value *deref_val =
 	value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr));
-      common_val_print (deref_val, stream, format, deref_ref,
-			recurse, pretty, current_language);
+      common_val_print (deref_val, stream, recurse, options, current_language);
     }
   else
     fputs_filtered ("???", stream);
@@ -276,9 +276,9 @@ print_variable_at_address (struct type *type,
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len)
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len)
 {
   int eltlen;
   CHECK_TYPEDEF (type);
@@ -286,21 +286,20 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
   if (TYPE_LENGTH (type) > 0)
     {
       eltlen = TYPE_LENGTH (type);
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
 	print_spaces_filtered (2 + 2 * recurse, stream);
       /* For an array of chars, print with string syntax.  */
       if (eltlen == 1 &&
 	  ((TYPE_CODE (type) == TYPE_CODE_INT)
 	   || ((current_language->la_language == language_m2)
 	       && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
-	  && (format == 0 || format == 's'))
-	val_print_string (address, len+1, eltlen, stream);
+	  && (options->output_format == 0 || options->output_format == 's'))
+	val_print_string (address, len+1, eltlen, stream, options);
       else
 	{
 	  fprintf_filtered (stream, "{");
 	  val_print_array_elements (type, valaddr + embedded_offset,
-				    address, stream, format,
-				    deref_ref, recurse, pretty, 0);
+				    address, stream, recurse, options, 0);
 	  fprintf_filtered (stream, "}");
 	}
     }
@@ -322,8 +321,8 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 
 int
 m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int format,
-	      int deref_ref, int recurse, enum val_prettyprint pretty)
+	      CORE_ADDR address, struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -343,74 +342,73 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    print_spaces_filtered (2 + 2 * recurse, stream);
 	  /* For an array of chars, print with string syntax.  */
 	  if (eltlen == 1 &&
 	      ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_m2)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->output_format == 0 || options->output_format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-			 && temp_len < len && temp_len < print_max;
+			 && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
 	    {
 	      fprintf_filtered (stream, "{");
 	      val_print_array_elements (type, valaddr + embedded_offset,
-					address, stream, format, deref_ref,
-					recurse, pretty, 0);
+					address, stream, recurse, options, 0);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
 	}
       /* Array of unspecified length: treat like pointer to first elt.  */
-      print_unpacked_pointer (type, address, address, format, stream);
+      print_unpacked_pointer (type, address, address, options, stream);
       break;
 
     case TYPE_CODE_PTR:
       if (TYPE_CONST (type))
 	print_variable_at_address (type, valaddr + embedded_offset,
-				   stream, format, deref_ref, recurse,
-				   pretty);
-      else if (format && format != 's')
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+				   stream, recurse, options);
+      else if (options->output_format && options->output_format != 's')
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	{
 	  addr = unpack_pointer (type, valaddr + embedded_offset);
-	  print_unpacked_pointer (type, addr, address, format, stream);
+	  print_unpacked_pointer (type, addr, address, options, stream);
 	}
       break;
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -418,8 +416,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		value_at
 		(TYPE_TARGET_TYPE (type),
 		 unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -427,7 +425,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -436,22 +434,20 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     case TYPE_CODE_STRUCT:
       if (m2_is_long_set (type))
 	m2_print_long_set (type, valaddr, embedded_offset, address,
-			   stream, format, pretty);
+			   stream);
       else if (m2_is_unbounded_array (type))
 	m2_print_unbounded_array (type, valaddr, embedded_offset,
-				  address, stream, format, deref_ref,
-				  pretty, recurse);
+				  address, stream, recurse, options);
       else
 	cp_print_value_fields (type, type, valaddr, embedded_offset,
-			       address, stream, format,
-			       recurse, pretty, NULL, 0);
+			       address, stream, recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options->output_format, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -475,10 +471,10 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options->output_format, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -491,10 +487,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -511,7 +506,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
 	{
 	  m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset,
-			address, stream, format, deref_ref, recurse, pretty);
+			address, stream, recurse, options);
 	  break;
 	}
       /* FIXME: create_range_type does not set the unsigned bit in a
@@ -524,19 +519,17 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	val_print_type_code_int (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -550,9 +543,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, type, stream);
       break;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index baf9b6d..9c55b4b 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -30,6 +30,7 @@
 #include "dictionary.h"
 #include "gdb_string.h"
 #include "language.h"
+#include "valprint.h"
 
 static void list_args_or_locals (int locals, int values, struct frame_info *fi);
 
@@ -280,21 +281,27 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
 		      && TYPE_CODE (type) != TYPE_CODE_STRUCT
 		      && TYPE_CODE (type) != TYPE_CODE_UNION)
 		    {
+		      struct value_print_options opts;
 		      val = read_var_value (sym2, fi);
+		      get_raw_print_options (&opts);
 		      common_val_print
-			(val, stb->stream, 0, 1, 0, Val_no_prettyprint,
+			(val, stb->stream, 0, &opts,
 			 language_def (SYMBOL_LANGUAGE (sym2)));
 		      ui_out_field_stream (uiout, "value", stb);
 		    }
 		  do_cleanups (cleanup_tuple);
 		  break;
 		case PRINT_ALL_VALUES:
-		  val = read_var_value (sym2, fi);
-		  common_val_print
-		    (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
-		     language_def (SYMBOL_LANGUAGE (sym2)));
-		  ui_out_field_stream (uiout, "value", stb);
-		  do_cleanups (cleanup_tuple);
+		  {
+		    struct value_print_options opts;
+		    val = read_var_value (sym2, fi);
+		    get_raw_print_options (&opts);
+		    common_val_print
+		      (val, stb->stream, 0, &opts,
+		       language_def (SYMBOL_LANGUAGE (sym2)));
+		    ui_out_field_stream (uiout, "value", stb);
+		    do_cleanups (cleanup_tuple);
+		  }
 		  break;
 		}
 	    }
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 7780207..4fdbdb5 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -45,6 +45,7 @@
 #include "frame.h"
 #include "mi-main.h"
 #include "language.h"
+#include "valprint.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -500,8 +501,7 @@ get_register (int regnum, int format)
   else
     {
       val_print (register_type (current_gdbarch, regnum), buffer, 0, 0,
-		 stb->stream, format, 1, 0, Val_pretty_default,
-		 current_language);
+		 stb->stream, 0, &user_print_options, current_language);
       ui_out_field_stream (uiout, "value", stb);
       ui_out_stream_delete (stb);
     }
@@ -588,7 +588,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   /* Print the result of the expression evaluation.  */
   val_print (value_type (val), value_contents (val),
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stb->stream, 0, 0, 0, 0, current_language);
+	     stb->stream, 0, &user_print_options, current_language);
 
   ui_out_field_stream (uiout, "value", stb);
   ui_out_stream_delete (stb);
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index da4afe3..ae6f382 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -37,6 +37,7 @@
 #include "infcall.h"
 #include "gdb_assert.h"
 #include "language.h"
+#include "valprint.h"
 
 enum mt_arch_constants
 {
@@ -675,6 +676,7 @@ mt_registers_info (struct gdbarch *gdbarch,
 	{
 	  /* Special output handling for the 'coprocessor' register.  */
 	  gdb_byte *buf;
+	  struct value_print_options opts;
 
 	  buf = alloca (register_size (gdbarch, MT_COPRO_REGNUM));
 	  frame_register_read (frame, MT_COPRO_REGNUM, buf);
@@ -685,8 +687,9 @@ mt_registers_info (struct gdbarch *gdbarch,
 	  print_spaces_filtered (15 - strlen (gdbarch_register_name
 					        (gdbarch, regnum)),
 				 file);
+	  get_raw_print_options (&opts);
 	  val_print (register_type (gdbarch, regnum), buf,
-		     0, 0, file, 0, 1, 0, Val_no_prettyprint,
+		     0, 0, file, 0, &opts,
 		     current_language);
 	  fputs_filtered ("\n", file);
 	}
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 7d287a0..3a952f5 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -341,7 +341,8 @@ objc_printchar (int c, struct ui_file *stream)
 
 static void
 objc_printstr (struct ui_file *stream, const gdb_byte *string, 
-	       unsigned int length, int width, int force_ellipses)
+	       unsigned int length, int width, int force_ellipses,
+	       const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -360,7 +361,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining to see whether it
 	 is repeated.  */
@@ -384,11 +385,11 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -397,14 +398,14 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  objc_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -418,7 +419,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 7ecdd8d..cd4285d 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -207,7 +207,8 @@ pascal_printchar (int c, struct ui_file *stream)
 
 void
 pascal_printstr (struct ui_file *stream, const gdb_byte *string,
-		 unsigned int length, int width, int force_ellipses)
+		 unsigned int length, int width, int force_ellipses,
+		 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -226,7 +227,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -250,11 +251,11 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -263,7 +264,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  pascal_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
@@ -271,7 +272,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  int c = string[i];
 	  if ((!in_quotes) && (PRINT_LITERAL_FORM (c)))
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -285,7 +286,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index a4f878f..4ebfbc1 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -35,10 +35,11 @@ extern void pascal_print_typedef (struct type *, struct symbol *,
 				  struct ui_file *);
 
 extern int pascal_val_print (struct type *, const gdb_byte *, int,
-			     CORE_ADDR, struct ui_file *, int, int,
-			     int, enum val_prettyprint);
+			     CORE_ADDR, struct ui_file *, int,
+			     const struct value_print_options *);
 
-extern int pascal_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+extern int pascal_value_print (struct value *, struct ui_file *,
+			       const struct value_print_options *);
 
 extern void pascal_type_print_method_args (char *, char *,
 					   struct ui_file *);
@@ -51,7 +52,8 @@ extern int
 extern void pascal_printchar (int, struct ui_file *);
 
 extern void pascal_printstr (struct ui_file *, const gdb_byte *,
-			     unsigned int, int, int);
+			     unsigned int, int, int,
+			     const struct value_print_options *);
 
 extern struct type **const (pascal_builtin_types[]);
 
@@ -63,15 +65,10 @@ extern void
 extern void
   pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int);
 
-/* These are in cp-valprint.c */
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
 					      CORE_ADDR, struct ui_file *,
-					      int, int, enum val_prettyprint,
+					      int,
+					      const struct value_print_options *,
 					      struct type **, int);
 
 extern int pascal_object_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index bc4fbe1..e074413 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -59,8 +59,8 @@
 int
 pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  int embedded_offset, CORE_ADDR address,
-		  struct ui_file *stream, int format, int deref_ref,
-		  int recurse, enum val_prettyprint pretty)
+		  struct ui_file *stream, int recurse,
+		  const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -80,7 +80,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
@@ -89,23 +89,24 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      && ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_pascal)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->output_format == 0 || options->output_format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
@@ -123,7 +124,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -133,12 +134,13 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -162,7 +164,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      return (0);
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->output_format != 's')
 	    {
 	      fputs_filtered (paddress (addr), stream);
 	    }
@@ -172,11 +174,11 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  if (TYPE_LENGTH (elttype) == 1
 	      && (TYPE_CODE (elttype) == TYPE_CODE_INT
 		  || TYPE_CODE(elttype) == TYPE_CODE_CHAR)
-	      && (format == 0 || format == 's')
+	      && (options->output_format == 0 || options->output_format == 's')
 	      && addr != 0)
 	    {
 	      /* no wide string yet */
-	      i = val_print_string (addr, -1, 1, stream);
+	      i = val_print_string (addr, -1, 1, stream, options);
 	    }
 	  /* also for pointers to pascal strings */
 	  /* Note: this is Free Pascal specific:
@@ -193,7 +195,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
               read_memory (addr + length_pos, buffer, length_size);
 	      string_length = extract_unsigned_integer (buffer, length_size);
               xfree (buffer);
-              i = val_print_string (addr + string_pos, string_length, char_size, stream);
+              i = val_print_string (addr + string_pos, string_length, char_size, stream, options);
 	    }
 	  else if (pascal_object_is_vtbl_member (type))
 	    {
@@ -209,7 +211,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -230,9 +232,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format, deref_ref,
-				    recurse + 1, pretty, current_language);
-		  if (pretty)
+		  common_val_print (vt_val, stream, recurse + 1, options,
+				    current_language);
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -249,18 +251,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fprintf_filtered (stream, "@");
 	  /* Extract the address, assume that it is unsigned.  */
 	  fputs_filtered (paddress (
 	    extract_unsigned_integer (valaddr + embedded_offset,
 	       gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT)), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -268,8 +270,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse + 1, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse + 1, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -277,14 +279,14 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
 	}
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -301,18 +303,19 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
                                      &string_pos, &char_size, NULL))
 	    {
 	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0, options);
 	    }
 	  else
-	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream, format,
-					      recurse, pretty, NULL, 0);
+	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
+					      recurse, options, NULL, 0);
 	}
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -336,16 +339,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -358,9 +363,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -387,10 +392,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -399,10 +404,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -417,9 +422,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -517,8 +523,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 }
 \f
 int
-pascal_value_print (struct value *val, struct ui_file *stream, int format,
-		    enum val_prettyprint pretty)
+pascal_value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options)
 {
   struct type *type = value_type (val);
 
@@ -547,19 +553,10 @@ pascal_value_print (struct value *val, struct ui_file *stream, int format,
 	  fprintf_filtered (stream, ") ");
 	}
     }
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  return common_val_print (val, stream, 0, options, current_language);
 }
 
 
-/******************************************************************************
-                    Inserted from cp-valprint
-******************************************************************************/
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-static int pascal_static_field_print;	/* Controls printing of static fields. */
 static void
 show_pascal_static_field_print (struct ui_file *file, int from_tty,
 				struct cmd_list_element *c, const char *value)
@@ -572,12 +569,12 @@ static struct obstack dont_print_vb_obstack;
 static struct obstack dont_print_statmem_obstack;
 
 static void pascal_object_print_static_field (struct value *,
-					      struct ui_file *, int, int,
-					      enum val_prettyprint);
+					      struct ui_file *, int,
+					      const struct value_print_options *);
 
 static void pascal_object_print_value (struct type *, const gdb_byte *,
-				       CORE_ADDR, struct ui_file *,
-				       int, int, enum val_prettyprint,
+				       CORE_ADDR, struct ui_file *, int,
+				       const struct value_print_options *,
 				       struct type **);
 
 /* It was changed to this after 2.4.5.  */
@@ -633,8 +630,8 @@ pascal_object_is_vtbl_member (struct type *type)
 void
 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 				  CORE_ADDR address, struct ui_file *stream,
-				  int format, int recurse,
-				  enum val_prettyprint pretty,
+				  int recurse,
+				  const struct value_print_options *options,
 				  struct type **dont_print_vb,
 				  int dont_print_statmem)
 {
@@ -651,7 +648,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
      duplicates of virtual baseclasses.  */
   if (n_baseclasses > 0)
     pascal_object_print_value (type, valaddr, address, stream,
-			       format, recurse + 1, pretty, dont_print_vb);
+			       recurse + 1, options, dont_print_vb);
 
   if (!len && n_baseclasses == 1)
     fprintf_filtered (stream, "<No data fields>");
@@ -671,14 +668,14 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!pascal_static_field_print
+	  if (!options->pascal_static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 	  if (fields_seen)
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -689,7 +686,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -698,7 +695,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -745,8 +742,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  common_val_print (v, stream, recurse + 1, options,
+				    current_language);
 		}
 	    }
 	  else
@@ -765,8 +762,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  if (v == NULL)
 		    fputs_filtered ("<optimized out>", stream);
 		  else
-		    pascal_object_print_static_field (v, stream, format,
-						      recurse + 1, pretty);
+		    pascal_object_print_static_field (v, stream, recurse + 1,
+						      options);
 		}
 	      else
 		{
@@ -777,7 +774,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, options,
 			     current_language);
 		}
 	    }
@@ -792,7 +789,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -807,8 +804,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 static void
 pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 			   CORE_ADDR address, struct ui_file *stream,
-			   int format, int recurse,
-			   enum val_prettyprint pretty,
+			   int recurse,
+			   const struct value_print_options *options,
 			   struct type **dont_print_vb)
 {
   struct type **last_dont_print
@@ -849,7 +846,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
       boffset = baseclass_offset (type, i, valaddr, address);
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -881,7 +878,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, "<invalid address>");
       else
 	pascal_object_print_value_fields (baseclass, base_valaddr, address + boffset,
-					  stream, format, recurse, pretty,
+					  stream, recurse, options,
 		     (struct type **) obstack_base (&dont_print_vb_obstack),
 					  0);
       fputs_filtered (", ", stream);
@@ -912,8 +909,9 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
 static void
 pascal_object_print_static_field (struct value *val,
-				  struct ui_file *stream, int format,
-				  int recurse, enum val_prettyprint pretty)
+				  struct ui_file *stream,
+				  int recurse,
+				  const struct value_print_options *options)
 {
   struct type *type = value_type (val);
 
@@ -942,11 +940,10 @@ pascal_object_print_static_field (struct value *val,
 
       CHECK_TYPEDEF (type);
       pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
-				  stream, format, recurse, pretty, NULL, 1);
+					stream, recurse, options, NULL, 1);
       return;
     }
-  common_val_print (val, stream, format, 0, recurse, pretty,
-		    current_language);
+  common_val_print (val, stream, recurse, options, current_language);
 }
 
 extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototypes */
@@ -955,13 +952,10 @@ void
 _initialize_pascal_valprint (void)
 {
   add_setshow_boolean_cmd ("pascal_static-members", class_support,
-			   &pascal_static_field_print, _("\
+			   &user_print_options.pascal_static_field_print, _("\
 Set printing of pascal static members."), _("\
 Show printing of pascal static members."), NULL,
 			   NULL,
 			   show_pascal_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  pascal_static_field_print = 1;
-
 }
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 021e191..2de3ef3 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -42,6 +42,7 @@
 #include "block.h"
 #include "disasm.h"
 #include "dfp.h"
+#include "valprint.h"
 
 #ifdef TUI
 #include "tui/tui.h"		/* For tui_active et.al.   */
@@ -55,7 +56,6 @@
 #endif
 
 extern int asm_demangle;	/* Whether to demangle syms in asm printouts */
-extern int addressprint;	/* Whether to print hex addresses in HLL " */
 
 struct format_data
   {
@@ -120,13 +120,6 @@ Printing of source filename and line number with <symbol> is %s.\n"),
 
 int current_display_number;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-
-int inspect_it = 0;
-
 struct display
   {
     /* Chain link to next auto-display item.  */
@@ -278,7 +271,8 @@ print_formatted (struct value *val, int format, int size,
 	case 's':
 	  /* FIXME: Need to handle wchar_t's here... */
 	  next_address = VALUE_ADDRESS (val)
-	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
+	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream,
+				&user_print_options);
 	  return;
 
 	case 'i':
@@ -298,10 +292,14 @@ print_formatted (struct value *val, int format, int size,
       || TYPE_CODE (type) == TYPE_CODE_STRUCT
       || TYPE_CODE (type) == TYPE_CODE_UNION
       || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
-    /* If format is 0, use the 'natural' format for that type of
-       value.  If the type is non-scalar, we have to use language
-       rules to print it as a series of scalars.  */
-    value_print (val, stream, format, Val_pretty_default);
+    {
+      /* If format is 0, use the 'natural' format for that type of
+	 value.  If the type is non-scalar, we have to use language
+	 rules to print it as a series of scalars.  */
+      struct value_print_options options = user_print_options;
+      options.output_format = format;
+      value_print (val, stream, &options);
+    }
   else
     /* User specified format, so don't look to the the type to
        tell us what to do.  */
@@ -347,7 +345,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
      again.  */
   if (format == 's')
     {
-      val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default,
+      val_print (type, valaddr, 0, 0, stream, 0, &user_print_options,
 		 current_language);
       return;
     }
@@ -445,10 +443,10 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       if (TYPE_UNSIGNED (type))
 	value_print (value_from_longest (builtin_type_true_unsigned_char,
 					 val_long),
-		     stream, 0, Val_pretty_default);
+		     stream, &user_print_options);
       else
 	value_print (value_from_longest (builtin_type_true_char, val_long),
-		     stream, 0, Val_pretty_default);
+		     stream, &user_print_options);
       break;
 
     case 'f':
@@ -711,7 +709,7 @@ print_address_demangle (CORE_ADDR addr, struct ui_file *stream,
     {
       fprintf_filtered (stream, "0");
     }
-  else if (addressprint)
+  else if (user_print_options.addressprint)
     {
       fputs_filtered (paddress (addr), stream);
       print_address_symbolic (addr, stream, do_demangle, " ");
@@ -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.  */
 }
 
 static void
@@ -1678,7 +1675,7 @@ print_variable_value (struct symbol *var, struct frame_info *frame,
 {
   struct value *val = read_var_value (var, frame);
 
-  value_print (val, stream, 0, Val_pretty_default);
+  value_print (val, stream, &user_print_options);
 }
 
 static void
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 6c4be54..69179b6 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -23,6 +23,7 @@
 #include "exceptions.h"
 #include "language.h"
 #include "dfp.h"
+#include "valprint.h"
 
 /* List of all values which are currently exposed to Python. It is
    maintained so that when an objfile is discarded, preserve_values
@@ -194,8 +195,8 @@ valpy_str (PyObject *self)
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
-      common_val_print (((value_object *) self)->value, stb, 0, 0, 0,
-			Val_pretty_default, current_language);
+      common_val_print (((value_object *) self)->value, stb, 0,
+			&user_print_options, current_language);
       s = ui_file_xstrdup (stb, &dummy);
     }
   GDB_PY_HANDLE_EXCEPTION (except);
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 42d2502..0b25590 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -50,7 +50,8 @@ scm_printchar (int c, struct ui_file *stream)
 
 static void
 scm_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
   fprintf_filtered (stream, "\"%s\"", string);
 }
diff --git a/gdb/scm-lang.h b/gdb/scm-lang.h
index 654095c..369905b 100644
--- a/gdb/scm-lang.h
+++ b/gdb/scm-lang.h
@@ -46,16 +46,16 @@
 struct value;
 
 extern int scm_value_print (struct value *, struct ui_file *,
-			    int, enum val_prettyprint);
+			    const struct value_print_options *);
 
 extern int scm_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			  struct ui_file *, int, int, int,
-			  enum val_prettyprint);
+			  struct ui_file *, int,
+			  const struct value_print_options *);
 
 extern LONGEST scm_get_field (LONGEST, int);
 
-extern void scm_scmval_print (LONGEST, struct ui_file *, int, int, int,
-			      enum val_prettyprint);
+extern void scm_scmval_print (LONGEST, struct ui_file *, int,
+			      const struct value_print_options *);
 
 extern int is_scmvalue_type (struct type *);
 
diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
index feb43dd..bf2e907 100644
--- a/gdb/scm-valprint.c
+++ b/gdb/scm-valprint.c
@@ -33,18 +33,18 @@
 #include "objfiles.h"
 
 static void scm_ipruk (char *, LONGEST, struct ui_file *);
-static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
-static int scm_inferior_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
+static void scm_scmlist_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
+static int scm_inferior_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
 
 /* Prints the SCM value VALUE by invoking the inferior, if appropraite.
    Returns >= 0 on success;  return -1 if the inferior cannot/should not
    print VALUE. */
 
 static int
-scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_inferior_print (LONGEST value, struct ui_file *stream,
+		    int recurse, const struct value_print_options *options)
 {
   struct objfile *objf;
   struct gdbarch *gdbarch;
@@ -129,17 +129,16 @@ static char *scm_isymnames[] =
 };
 
 static void
-scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int recurse,
+		   const struct value_print_options *options)
 {
-  unsigned int more = print_max;
+  unsigned int more = options->print_max;
   if (recurse > 6)
     {
       fputs_filtered ("...", stream);
       return;
     }
-  scm_scmval_print (SCM_CAR (svalue), stream, format,
-		    deref_ref, recurse + 1, pretty);
+  scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
   svalue = SCM_CDR (svalue);
   for (; SCM_NIMP (svalue); svalue = SCM_CDR (svalue))
     {
@@ -151,14 +150,12 @@ scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
 	  fputs_filtered ("...", stream);
 	  return;
 	}
-      scm_scmval_print (SCM_CAR (svalue), stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
     }
   if (SCM_NNULLP (svalue))
     {
       fputs_filtered (" . ", stream);
-      scm_scmval_print (svalue, stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (svalue, stream, recurse + 1, options);
     }
 }
 
@@ -174,15 +171,17 @@ scm_ipruk (char *hdr, LONGEST ptr, struct ui_file *stream)
 }
 
 void
-scm_scmval_print (LONGEST svalue, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmval_print (LONGEST svalue, struct ui_file *stream,
+		  int recurse, const struct value_print_options *options)
 {
 taloop:
   switch (7 & (int) svalue)
     {
     case 2:
     case 6:
-      print_longest (stream, format ? format : 'd', 1, svalue >> 2);
+      print_longest (stream,
+		     options->output_format ? options->output_format : 'd',
+		     1, svalue >> 2);
       break;
     case 4:
       if (SCM_ICHRP (svalue))
@@ -243,14 +242,12 @@ taloop:
 	case scm_tcs_cons_imcar:
 	case scm_tcs_cons_nimcar:
 	  fputs_filtered ("(", stream);
-	  scm_scmlist_print (svalue, stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (svalue, stream, recurse + 1, options);
 	  fputs_filtered (")", stream);
 	  break;
 	case scm_tcs_closures:
 	  fputs_filtered ("#<CLOSURE ", stream);
-	  scm_scmlist_print (SCM_CODE (svalue), stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (SCM_CODE (svalue), stream, recurse + 1, options);
 	  fputs_filtered (">", stream);
 	  break;
 	case scm_tc7_string:
@@ -261,9 +258,9 @@ taloop:
 	    int done = 0;
 	    int buf_size;
 	    gdb_byte buffer[64];
-	    int truncate = print_max && len > (int) print_max;
+	    int truncate = options->print_max && len > (int) options->print_max;
 	    if (truncate)
-	      len = print_max;
+	      len = options->print_max;
 	    fputs_filtered ("\"", stream);
 	    for (; done < len; done += buf_size)
 	      {
@@ -305,8 +302,8 @@ taloop:
 	      {
 		if (i > 0)
 		  fputs_filtered (" ", stream);
-		scm_scmval_print (scm_get_field (elements, i), stream, format,
-				  deref_ref, recurse + 1, pretty);
+		scm_scmval_print (scm_get_field (elements, i), stream,
+				  recurse + 1, options);
 	      }
 	    fputs_filtered (")", stream);
 	  }
@@ -401,21 +398,19 @@ taloop:
 int
 scm_val_print (struct type *type, const gdb_byte *valaddr,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   if (is_scmvalue_type (type))
     {
       LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
 
-      if (scm_inferior_print (svalue, stream, format,
-			      deref_ref, recurse, pretty) >= 0)
+      if (scm_inferior_print (svalue, stream, recurse, options) >= 0)
 	{
 	}
       else
 	{
-	  scm_scmval_print (svalue, stream, format,
-			    deref_ref, recurse, pretty);
+	  scm_scmval_print (svalue, stream, recurse, options);
 	}
 
       gdb_flush (stream);
@@ -423,15 +418,13 @@ scm_val_print (struct type *type, const gdb_byte *valaddr,
     }
   else
     {
-      return c_val_print (type, valaddr, 0, address, stream, format,
-			  deref_ref, recurse, pretty);
+      return c_val_print (type, valaddr, 0, address, stream, recurse, options);
     }
 }
 
 int
-scm_value_print (struct value *val, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+scm_value_print (struct value *val, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
-  return (common_val_print (val, stream, format, 1, 0, pretty,
-			    current_language));
+  return (common_val_print (val, stream, 0, options, current_language));
 }
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 474d49a..407206d 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -40,6 +40,7 @@
 #include "arch-utils.h"
 #include "regcache.h"
 #include "osabi.h"
+#include "valprint.h"
 
 #include "elf-bfd.h"
 
@@ -2092,6 +2093,7 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
 		  struct frame_info *frame, int regnum)
 {
   unsigned char raw_buffer[MAX_REGISTER_SIZE];
+  struct value_print_options opts;
 
   fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
   print_spaces_filtered (15 - strlen (gdbarch_register_name
@@ -2100,12 +2102,14 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
   /* Get the data in raw format.  */
   if (!frame_register_read (frame, regnum, raw_buffer))
     fprintf_filtered (file, "*value not available*\n");
-      
+
+  get_formatted_print_options (&opts, 'x');
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 'x', 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\t");
+  get_formatted_print_options (&opts, 0);
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 0, 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\n");
 }
 
diff --git a/gdb/stack.c b/gdb/stack.c
index 2c3c0bb..8236ae3 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -368,6 +368,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
 	      if (val)
 	        {
                   const struct language_defn *language;
+		  struct value_print_options opts;
 
                   /* Use the appropriate language to display our symbol,
                      unless the user forced the language to a specific
@@ -377,8 +378,9 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
                   else
                     language = current_language;
 
-		  common_val_print (val, stb->stream, 0, 0, 2,
-				    Val_no_prettyprint, language);
+		  get_raw_print_options (&opts);
+		  common_val_print (val, stb->stream, 2,
+				    &opts, language);
 		  ui_out_field_stream (uiout, "value", stb);
 	        }
 	      else
@@ -555,7 +557,7 @@ print_frame_info (struct frame_info *frame, int print_level,
 		 line. Only the command line really wants this
 		 behavior. Other UIs probably would like the
 		 ability to decide for themselves if it is desired.  */
-	      if (addressprint && mid_statement)
+	      if (user_print_options.addressprint && mid_statement)
 		{
 		  ui_out_field_core_addr (uiout, "addr", get_frame_pc (frame));
 		  ui_out_text (uiout, "\t");
@@ -665,7 +667,7 @@ print_frame (struct frame_info *frame, int print_level,
       ui_out_field_fmt_int (uiout, 2, ui_left, "level",
 			    frame_relative_level (frame));
     }
-  if (addressprint)
+  if (user_print_options.addressprint)
     if (get_frame_pc (frame) != sal.pc || !sal.symtab
 	|| print_what == LOC_AND_ADDRESS)
       {
@@ -1408,7 +1410,7 @@ print_block_frame_labels (struct block *b, int *have_default,
 	  sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
 	  values_printed = 1;
 	  fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
-	  if (addressprint)
+	  if (user_print_options.addressprint)
 	    {
 	      fprintf_filtered (stream, " ");
 	      fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (sym)), stream);
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4f5c56a..c859574 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -38,6 +38,7 @@
 #include "dictionary.h"
 #include "observer.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
@@ -67,7 +68,6 @@
 extern void (*deprecated_readline_begin_hook) (char *, ...);
 extern char *(*deprecated_readline_hook) (char *);
 extern void (*deprecated_readline_end_hook) (void);
-extern int addressprint;	/* Print machine addresses? */
 
 /* GDB commands implemented in other modules:
  */  
@@ -436,7 +436,7 @@ trace_mention (struct tracepoint *tp)
 {
   printf_filtered ("Tracepoint %d", tp->number);
 
-  if (addressprint || (tp->source_file == NULL))
+  if (user_print_options.addressprint || (tp->source_file == NULL))
     {
       printf_filtered (" at ");
       printf_filtered ("%s", paddress (tp->address));
@@ -467,12 +467,10 @@ tracepoints_info (char *tpnum_exp, int from_tty)
   ALL_TRACEPOINTS (t)
     if (tpnum == -1 || tpnum == t->number)
     {
-      extern int addressprint;	/* Print machine addresses?  */
-
       if (!found_a_tracepoint++)
 	{
 	  printf_filtered ("Num Enb ");
-	  if (addressprint)
+	  if (user_print_options.addressprint)
 	    {
 	      if (gdbarch_addr_bit (current_gdbarch) <= 32)
 		printf_filtered ("Address    ");
@@ -482,7 +480,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 	  printf_filtered ("PassC StepC What\n");
 	}
       strcpy (wrap_indent, "                           ");
-      if (addressprint)
+      if (user_print_options.addressprint)
 	{
 	  if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	    strcat (wrap_indent, "           ");
@@ -492,7 +490,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 
       printf_filtered ("%-3d %-3s ", t->number,
 		       t->enabled_p ? "y" : "n");
-      if (addressprint)
+      if (user_print_options.addressprint)
 	{
 	  char *tmp;
 
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 44f1a77..af96f10 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -33,12 +33,9 @@
 #include "cp-abi.h"
 #include "typeprint.h"
 #include "gdb_string.h"
+#include "valprint.h"
 #include <errno.h>
 
-/* For real-type printing in whatis_exp() */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-
 extern void _initialize_typeprint (void);
 
 static void ptype_command (char *, int);
@@ -107,7 +104,7 @@ whatis_exp (char *exp, int show)
 
   type = value_type (val);
 
-  if (objectprint)
+  if (user_print_options.objectprint)
     {
       if (((TYPE_CODE (type) == TYPE_CODE_PTR)
 	   || (TYPE_CODE (type) == TYPE_CODE_REF))
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 99c376f..7348176 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -60,13 +60,49 @@ static void set_output_radix_1 (int, unsigned);
 
 void _initialize_valprint (void);
 
-/* Maximum number of chars to print for a string pointer value or vector
-   contents, or UINT_MAX for no limit.  Note that "set print elements 0"
-   stores UINT_MAX in print_max, which displays in a show command as
-   "unlimited". */
-
-unsigned int print_max;
 #define PRINT_MAX_DEFAULT 200	/* Start print_max off at this value. */
+
+struct value_print_options user_print_options =
+{
+  Val_pretty_default,		/* pretty */
+  0,				/* prettyprint_arrays */
+  0,				/* prettyprint_structs */
+  0,				/* vtblprint */
+  1,				/* unionprint */
+  1,				/* addressprint */
+  0,				/* objectprint */
+  PRINT_MAX_DEFAULT,		/* print_max */
+  10,				/* repeat_count_threshold */
+  0,				/* output_format */
+  0,				/* stop_print_at_null */
+  0,				/* raw */
+  0,				/* inspect_it */
+  0,				/* print_array_indexes */
+  0,				/* deref_ref */
+  1,				/* static_field_print */
+  1				/* pascal_static_field_print */
+};
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+void
+get_raw_print_options (struct value_print_options *opts)
+{  
+  *opts = user_print_options;
+  opts->pretty = Val_no_prettyprint;
+  opts->raw = 1;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+void
+get_formatted_print_options (struct value_print_options *opts,
+			     char format)
+{
+  *opts = user_print_options;
+  opts->output_format = format;
+}
+
 static void
 show_print_max (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -103,7 +139,6 @@ int output_format = 0;
 /* By default we print arrays without printing the index of each element in
    the array.  This behavior can be changed by setting PRINT_ARRAY_INDEXES.  */
 
-static int print_array_indexes = 0;
 static void
 show_print_array_indexes (struct ui_file *file, int from_tty,
 		          struct cmd_list_element *c, const char *value)
@@ -115,7 +150,6 @@ show_print_array_indexes (struct ui_file *file, int from_tty,
    element in an array.  Referenced by the low level language dependent
    print routines. */
 
-unsigned int repeat_count_threshold = 10;
 static void
 show_repeat_count_threshold (struct ui_file *file, int from_tty,
 			     struct cmd_list_element *c, const char *value)
@@ -126,7 +160,6 @@ show_repeat_count_threshold (struct ui_file *file, int from_tty,
 
 /* If nonzero, stops printing of char arrays at first null. */
 
-int stop_print_at_null;
 static void
 show_stop_print_at_null (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -138,7 +171,6 @@ Printing of char arrays to stop at first null char is %s.\n"),
 
 /* Controls pretty printing of structures. */
 
-int prettyprint_structs;
 static void
 show_prettyprint_structs (struct ui_file *file, int from_tty,
 			  struct cmd_list_element *c, const char *value)
@@ -148,7 +180,6 @@ show_prettyprint_structs (struct ui_file *file, int from_tty,
 
 /* Controls pretty printing of arrays.  */
 
-int prettyprint_arrays;
 static void
 show_prettyprint_arrays (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -159,7 +190,6 @@ show_prettyprint_arrays (struct ui_file *file, int from_tty,
 /* If nonzero, causes unions inside structures or other unions to be
    printed. */
 
-int unionprint;			/* Controls printing of nested unions.  */
 static void
 show_unionprint (struct ui_file *file, int from_tty,
 		 struct cmd_list_element *c, const char *value)
@@ -171,7 +201,6 @@ Printing of unions interior to structures is %s.\n"),
 
 /* If nonzero, causes machine addresses to be printed in certain contexts. */
 
-int addressprint;		/* Controls printing of machine addresses */
 static void
 show_addressprint (struct ui_file *file, int from_tty,
 		   struct cmd_list_element *c, const char *value)
@@ -203,17 +232,18 @@ show_addressprint (struct ui_file *file, int from_tty,
 
 int
 val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	   CORE_ADDR address, struct ui_file *stream, int format,
-	   int deref_ref, int recurse, enum val_prettyprint pretty,
+	   CORE_ADDR address, struct ui_file *stream, int recurse,
+	   const struct value_print_options *options,
 	   const struct language_defn *language)
 {
   volatile struct gdb_exception except;
-  volatile enum val_prettyprint real_pretty = pretty;
   int ret = 0;
-
+  struct value_print_options local_opts = *options;
   struct type *real_type = check_typedef (type);
-  if (pretty == Val_pretty_default)
-    real_pretty = prettyprint_structs ? Val_prettyprint : Val_no_prettyprint;
+
+  if (local_opts.pretty == Val_pretty_default)
+    local_opts.pretty = (local_opts.prettyprint_structs
+			 ? Val_prettyprint : Val_no_prettyprint);
 
   QUIT;
 
@@ -231,8 +261,7 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
   TRY_CATCH (except, RETURN_MASK_ERROR)
     {
       ret = language->la_val_print (type, valaddr, embedded_offset, address,
-				    stream, format, deref_ref, recurse,
-				    real_pretty);
+				    stream, recurse, &local_opts);
     }
   if (except.reason < 0)
     fprintf_filtered (stream, _("<error reading variable>"));
@@ -277,8 +306,8 @@ value_check_printable (struct value *val, struct ui_file *stream)
    GDB's value mechanism.  */
 
 int
-common_val_print (struct value *val, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty,
+common_val_print (struct value *val, struct ui_file *stream, int recurse,
+		  const struct value_print_options *options,
 		  const struct language_defn *language)
 {
   if (!value_check_printable (val, stream))
@@ -286,8 +315,7 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
 
   return val_print (value_type (val), value_contents_all (val),
 		    value_embedded_offset (val), VALUE_ADDRESS (val),
-		    stream, format, deref_ref, recurse, pretty,
-		    language);
+		    stream, recurse, options, language);
 }
 
 /* Print the value VAL in C-ish syntax on stream STREAM.
@@ -296,13 +324,13 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
    the number of string bytes printed.  */
 
 int
-value_print (struct value *val, struct ui_file *stream, int format,
-	     enum val_prettyprint pretty)
+value_print (struct value *val, struct ui_file *stream,
+	     const struct value_print_options *options)
 {
   if (!value_check_printable (val, stream))
     return 0;
 
-  return LA_VALUE_PRINT (val, stream, format, pretty);
+  return LA_VALUE_PRINT (val, stream, options);
 }
 
 /* Called by various <lang>_val_print routines to print
@@ -928,15 +956,6 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
     }
 }
 
-/* Return non-zero if the debugger should print the index of each element
-   when printing array values.  */
-
-int
-print_array_indexes_p (void)
-{              
-  return print_array_indexes;
-} 
-
 /* Assuming TYPE is a simple, non-empty array type, compute its upper
    and lower bound.  Save the low bound into LOW_BOUND if not NULL.
    Save the high bound into HIGH_BOUND if not NULL.
@@ -997,18 +1016,18 @@ get_array_bounds (struct type *type, long *low_bound, long *high_bound)
     
 void  
 maybe_print_array_index (struct type *index_type, LONGEST index,
-                         struct ui_file *stream, int format,
-                         enum val_prettyprint pretty)
+                         struct ui_file *stream,
+			 const struct value_print_options *options)
 {
   struct value *index_value;
 
-  if (!print_array_indexes)
+  if (!options->print_array_indexes)
     return; 
     
   index_value = value_from_longest (index_type, index);
 
-  LA_PRINT_ARRAY_INDEX (index_value, stream, format, pretty);
-}   
+  LA_PRINT_ARRAY_INDEX (index_value, stream, options);
+}
 
 /*  Called by various <lang>_val_print routines to print elements of an
    array in the form "<elem1>, <elem2>, <elem3>, ...".
@@ -1022,8 +1041,8 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
 void
 val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 			  CORE_ADDR address, struct ui_file *stream,
-			  int format, int deref_ref,
-			  int recurse, enum val_prettyprint pretty,
+			  int recurse,
+			  const struct value_print_options *options,
 			  unsigned int i)
 {
   unsigned int things_printed = 0;
@@ -1070,11 +1089,11 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 
   annotate_array_section_begin (i, elttype);
 
-  for (; i < len && things_printed < print_max; i++)
+  for (; i < len && things_printed < options->print_max; i++)
     {
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1086,7 +1105,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
       maybe_print_array_index (index_type, i + low_bound_index,
-                               stream, format, pretty);
+                               stream, options);
 
       rep1 = i + 1;
       reps = 1;
@@ -1097,21 +1116,21 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	  ++rep1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt_rep (reps);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  annotate_elt_rep_end ();
 
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	}
       else
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt ();
 	  things_printed++;
 	}
@@ -1173,7 +1192,8 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int *errnoptr
 /* FIXME: Use target_read_string.  */
 
 int
-val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
+val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
+		  const struct value_print_options *options)
 {
   int force_ellipsis = 0;	/* Force ellipsis to be printed if nonzero. */
   int errcode;			/* Errno returned from bad reads. */
@@ -1194,7 +1214,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      because finding the null byte (or available memory) is what actually
      limits the fetch. */
 
-  fetchlimit = (len == -1 ? print_max : min (len, print_max));
+  fetchlimit = (len == -1 ? options->print_max : min (len, options->print_max));
 
   /* Now decide how large of chunks to try to read in one operation.  This
      is also pretty simple.  If LEN >= zero, then we want fetchlimit chars,
@@ -1317,11 +1337,11 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      and then the error message.  */
   if (errcode == 0 || bufptr > buffer)
     {
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fputs_filtered (" ", stream);
 	}
-      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis);
+      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis, options);
     }
 
   if (errcode != 0)
@@ -1494,7 +1514,8 @@ _initialize_valprint (void)
   add_alias_cmd ("p", "print", no_class, 1, &showlist);
   add_alias_cmd ("pr", "print", no_class, 1, &showlist);
 
-  add_setshow_uinteger_cmd ("elements", no_class, &print_max, _("\
+  add_setshow_uinteger_cmd ("elements", no_class,
+			    &user_print_options.print_max, _("\
 Set limit on string chars or array elements to print."), _("\
 Show limit on string chars or array elements to print."), _("\
 \"set print elements 0\" causes there to be no limit."),
@@ -1502,7 +1523,8 @@ Show limit on string chars or array elements to print."), _("\
 			    show_print_max,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("null-stop", no_class, &stop_print_at_null, _("\
+  add_setshow_boolean_cmd ("null-stop", no_class,
+			   &user_print_options.stop_print_at_null, _("\
 Set printing of char arrays to stop at first null char."), _("\
 Show printing of char arrays to stop at first null char."), NULL,
 			   NULL,
@@ -1510,7 +1532,7 @@ Show printing of char arrays to stop at first null char."), NULL,
 			   &setprintlist, &showprintlist);
 
   add_setshow_uinteger_cmd ("repeats", no_class,
-			    &repeat_count_threshold, _("\
+			    &user_print_options.repeat_count_threshold, _("\
 Set threshold for repeated print elements."), _("\
 Show threshold for repeated print elements."), _("\
 \"set print repeats 0\" causes all elements to be individually printed."),
@@ -1518,28 +1540,32 @@ Show threshold for repeated print elements."), _("\
 			    show_repeat_count_threshold,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("pretty", class_support, &prettyprint_structs, _("\
+  add_setshow_boolean_cmd ("pretty", class_support,
+			   &user_print_options.prettyprint_structs, _("\
 Set prettyprinting of structures."), _("\
 Show prettyprinting of structures."), NULL,
 			   NULL,
 			   show_prettyprint_structs,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("union", class_support, &unionprint, _("\
+  add_setshow_boolean_cmd ("union", class_support,
+			   &user_print_options.unionprint, _("\
 Set printing of unions interior to structures."), _("\
 Show printing of unions interior to structures."), NULL,
 			   NULL,
 			   show_unionprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("array", class_support, &prettyprint_arrays, _("\
+  add_setshow_boolean_cmd ("array", class_support,
+			   &user_print_options.prettyprint_arrays, _("\
 Set prettyprinting of arrays."), _("\
 Show prettyprinting of arrays."), NULL,
 			   NULL,
 			   show_prettyprint_arrays,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("address", class_support, &addressprint, _("\
+  add_setshow_boolean_cmd ("address", class_support,
+			   &user_print_options.addressprint, _("\
 Set printing of addresses."), _("\
 Show printing of addresses."), NULL,
 			   NULL,
@@ -1578,15 +1604,8 @@ Use 'show input-radix' or 'show output-radix' to independently show each."),
 	   &showlist);
 
   add_setshow_boolean_cmd ("array-indexes", class_support,
-                           &print_array_indexes, _("\
+                           &user_print_options.print_array_indexes, _("\
 Set printing of array indexes."), _("\
 Show printing of array indexes"), NULL, NULL, show_print_array_indexes,
                            &setprintlist, &showprintlist);
-
-  /* Give people the defaults which they are used to.  */
-  prettyprint_structs = 0;
-  prettyprint_arrays = 0;
-  unionprint = 1;
-  addressprint = 1;
-  print_max = PRINT_MAX_DEFAULT;
 }
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 3b20516..f9d7501 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -21,45 +21,91 @@
 #ifndef VALPRINT_H
 #define VALPRINT_H
 
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
-extern int prettyprint_structs;	/* Controls pretty printing of structures */
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
+/* This is used to pass formatting options to various value-printing
+   functions.  */
+struct value_print_options
+{
+  /* Pretty-printing control.  */
+  enum val_prettyprint pretty;
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int unionprint;		/* Controls printing of nested unions.  */
-extern int addressprint;	/* Controls pretty printing of addresses.  */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
+  /* Controls pretty printing of arrays.  */
+  int prettyprint_arrays;
 
-extern unsigned int print_max;	/* Max # of chars for strings/vectors */
+  /* Controls pretty printing of structures.  */
+  int prettyprint_structs;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-extern int inspect_it;
+  /* Controls printing of virtual tables.  */
+  int vtblprint;
 
-/* Print repeat counts if there are more than this many repetitions of an
-   element in an array.  Referenced by the low level language dependent
-   print routines. */
-extern unsigned int repeat_count_threshold;
+  /* Controls printing of nested unions.  */
+  int unionprint;
 
-extern int output_format;
+  /* Controls printing of addresses.  */
+  int addressprint;
 
-extern int stop_print_at_null;	/* Stop printing at null char? */
+  /* Controls looking up an object's derived type using what we find
+     in its vtables.  */
+  int objectprint;
+
+  /* Maximum number of chars to print for a string pointer value or vector
+     contents, or UINT_MAX for no limit.  Note that "set print elements 0"
+     stores UINT_MAX in print_max, which displays in a show command as
+     "unlimited". */
+  unsigned int print_max;
+
+  /* Print repeat counts if there are more than this many repetitions
+     of an element in an array.  */
+  unsigned int repeat_count_threshold;
+
+  int output_format;
+
+  /* Stop printing at null character?  */
+  int stop_print_at_null;
+
+  /* If true, print "raw" -- bypass any Python pretty-printers.  */
+  int raw;
+
+  /* True if this value is being printed in an epoch window.  */
+  int inspect_it;
+
+  /* True if we should print the index of each element when printing
+     an array.  */
+  int print_array_indexes;
+
+  /* If nonzero, then dereference references, otherwise just print
+     them like pointers.  */
+  int deref_ref;
+
+  /* If nonzero, print static fields.  */
+  int static_field_print;
+
+  /* If nonzero, print static fields for Pascal.  FIXME: C++ and Java
+     share one flag, why not Pascal too?  */
+  int pascal_static_field_print;
+};
+
+/* The global print options set by the user.  */
+extern struct value_print_options user_print_options;
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+extern void get_raw_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+extern void get_formatted_print_options (struct value_print_options *opts,
+					 char format);
 
-extern int print_array_indexes_p (void);
- 
 extern int get_array_bounds (struct type *type, long *low_bound,
 			     long *high_bound);
 
 extern void maybe_print_array_index (struct type *index_type, LONGEST index,
-                                     struct ui_file *stream, int format,
-                                     enum val_prettyprint pretty);
+                                     struct ui_file *stream,
+				     const struct value_print_options *options);
 
 extern void val_print_array_elements (struct type *, const gdb_byte *,
 				      CORE_ADDR, struct ui_file *, int,
-				      int, int, enum val_prettyprint,
+				      const struct value_print_options *,
 				      unsigned int);
 
 extern void val_print_type_code_int (struct type *, const gdb_byte *,
diff --git a/gdb/value.c b/gdb/value.c
index 0b530f0..514b3fc 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -36,6 +36,7 @@
 #include "block.h"
 #include "dfp.h"
 #include "objfiles.h"
+#include "valprint.h"
 
 #include "python/python.h"
 
@@ -710,7 +711,7 @@ show_values (char *num_exp, int from_tty)
     {
       val = access_value_history (i);
       printf_filtered (("$%d = "), i);
-      value_print (val, gdb_stdout, 0, Val_pretty_default);
+      value_print (val, gdb_stdout, &user_print_options);
       printf_filtered (("\n"));
     }
 
@@ -978,7 +979,7 @@ show_convenience (char *ignore, int from_tty)
 	}
       printf_filtered (("$%s = "), var->name);
       value_print (value_of_internalvar (var), gdb_stdout,
-		   0, Val_pretty_default);
+		   &user_print_options);
       printf_filtered (("\n"));
     }
   if (!varseen)
diff --git a/gdb/value.h b/gdb/value.h
index f53d333..65fea99 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -32,6 +32,7 @@ struct symbol;
 struct type;
 struct ui_file;
 struct language_defn;
+struct value_print_options;
 
 /* The structure which defines the type of a value.  It should never
    be possible for a program lval value to survive over a call to the
@@ -526,8 +527,8 @@ extern void print_floating (const gdb_byte *valaddr, struct type *type,
 extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
 				    struct ui_file *stream);
 
-extern int value_print (struct value *val, struct ui_file *stream, int format,
-			enum val_prettyprint pretty);
+extern int value_print (struct value *val, struct ui_file *stream,
+			const struct value_print_options *options);
 
 extern void value_print_array_elements (struct value *val,
 					struct ui_file *stream, int format,
@@ -537,19 +538,18 @@ extern struct value *value_release_to_mark (struct value *mark);
 
 extern int val_print (struct type *type, const gdb_byte *valaddr,
 		      int embedded_offset, CORE_ADDR address,
-		      struct ui_file *stream, int format,
-		      int deref_ref, int recurse,
-		      enum val_prettyprint pretty,
+		      struct ui_file *stream, int recurse,
+		      const struct value_print_options *options,
 		      const struct language_defn *language);
 
 extern int common_val_print (struct value *val,
-			     struct ui_file *stream, int format,
-			     int deref_ref, int recurse,
-			     enum val_prettyprint pretty,
+			     struct ui_file *stream, int recurse,
+			     const struct value_print_options *options,
 			     const struct language_defn *language);
 
 extern int val_print_string (CORE_ADDR addr, int len, int width,
-			     struct ui_file *stream);
+			     struct ui_file *stream,
+			     const struct value_print_options *options);
 
 extern void print_variable_value (struct symbol *var,
 				  struct frame_info *frame,
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 15cbd45..a9b6579 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -25,6 +25,7 @@
 #include "wrapper.h"
 #include "gdbcmd.h"
 #include "block.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 #include "gdb_string.h"
@@ -1791,6 +1792,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   struct ui_file *stb;
   struct cleanup *old_chain;
   char *thevalue;
+  struct value_print_options opts;
 
   if (value == NULL)
     return NULL;
@@ -1798,7 +1800,8 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
-  common_val_print (value, stb, format_code[(int) format], 1, 0, 0,
+  get_formatted_print_options (&opts, format_code[(int) format]);
+  common_val_print (value, stb, 0, &opts,
 		    current_language);
   thevalue = ui_file_xstrdup (stb, &dummy);
 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-21 18:18         ` Daniel Jacobowitz
@ 2008-10-22  1:40           ` Joel Brobecker
  2008-10-22 20:15             ` Tom Tromey
  0 siblings, 1 reply; 32+ messages in thread
From: Joel Brobecker @ 2008-10-22  1:40 UTC (permalink / raw)
  To: Ulrich Weigand, Thiago Jung Bauermann, gdb-patches

> Listening to Tom talk about this I've started to wonder if it's
> necessary... do we have a unified vision on where the global state
> accesses are OK?

I think it will depend on each global. For the current_language and
the input_radix, my goal is to have it used only from the command line
loop that calls the command functions.

> GDB is single threaded.  I anticipate it will remain so.  So, having
> the functions which implement user interface commands read global
> state doesn't seem like a big problem - unlike the expression parser.

I initially thought that it would be OK to have the command functions
that need it access current_language.  But I quickly realized that
this was actually pretty confusing. In order to audit the use of
a current_language, you'd have to check what the function using it
is used for - in particular, make sure that it's used as a command
function. When you have zillions of them spread everywhere in
the code, it's nearly impossible to avoid re-introducing incorrect
uses of the global.

With the approach that I suggest where I add the parameter, I should
be able to never increase the number of references to current_language
(and input_radix). And eventually, I should be able to eliminate them
all, save a couple of places where we know it's OK.

I will wait another couple of days to see how people react, but it
seems at this point that everyone was OK with approach (1), where
I do the transition all in one go. And since Tom was the lead
"questioner" of this change, I'd like to mention that my understanding
is that Tom understands the benefits of adding the extra parameter,
given the above explaination. Tom, please yell if I misunderstood you!
If all is well, I hope to be able to start looking into this sometime
late this week or maybe early next week.

-- 
Joel


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-21 19:33       ` Tom Tromey
@ 2008-10-22 18:03         ` Ulrich Weigand
  2008-10-22 18:54           ` Tom Tromey
  0 siblings, 1 reply; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-22 18:03 UTC (permalink / raw)
  To: tromey; +Cc: Joel Brobecker, gdb-patches

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-22 18:03         ` Ulrich Weigand
@ 2008-10-22 18:54           ` Tom Tromey
  2008-10-22 22:24             ` Ulrich Weigand
  0 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-22 18:54 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

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

Yeah, there's some weird stuff.  In most cases I did not want to
change behavior, so I just added a reference to the global.

For evaluate_subexp_standard, there was a patch recently in this
area:

    http://sourceware.org/ml/gdb-patches/2008-08/msg00525.html

AFAIK this has not been reviewed.

For breakpoint print routines, I don't know.  I consider this part of
the patch a kind of technicality -- only needed because I chose to
remove the globals entirely, which I only did to ensure that I caught
all uses in the call hierarchy I really cared about.

This sort of thing can easily be addressed later, if necessary.  The
reason I'm not sure it is necessary is that it seems to me that the
user would really want breakpoint-printing to use the current globals.
So, capturing the state somewhere would not be correct.  At that
point... well, I'd rather have Joel solve this problem ;)

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

No problem.  Do you want it to make a copy?  Or just return a pointer
to the global?

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

Whoops.

Well, I did say it was untested :-)

I'll fix this by fixing print_formatted as you suggested.

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

I don't really mind putting these into that structure.  In the context
of this call hierarchy, these are immutable arguments to a particular
call, modifying that call's behavior.  For me that is enough to
qualify them.

But, we could take other approaches.  We could pass in a structure
that contains a struct value_print_options and a struct something_else.

FWIW I'd like to keep just a single "options" argument -- many of
these functions already have too many arguments.

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-22  1:40           ` Joel Brobecker
@ 2008-10-22 20:15             ` Tom Tromey
  2008-10-22 20:36               ` Joel Brobecker
  0 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-22 20:15 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Ulrich Weigand, Thiago Jung Bauermann, gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> I think it will depend on each global. For the current_language and
Joel> the input_radix, my goal is to have it used only from the command line
Joel> loop that calls the command functions.

Though there is a little wart, namely that the set and show commands
must refer to the globals directly.

Joel> I will wait another couple of days to see how people react, but it
Joel> seems at this point that everyone was OK with approach (1), where
Joel> I do the transition all in one go. And since Tom was the lead
Joel> "questioner" of this change, I'd like to mention that my understanding
Joel> is that Tom understands the benefits of adding the extra parameter,
Joel> given the above explaination. Tom, please yell if I misunderstood you!

I still think the benefits are mild, at best, but I don't want to stop
your gusto.  I don't think this change will make gdb worse.

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-22 20:15             ` Tom Tromey
@ 2008-10-22 20:36               ` Joel Brobecker
  0 siblings, 0 replies; 32+ messages in thread
From: Joel Brobecker @ 2008-10-22 20:36 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Ulrich Weigand, Thiago Jung Bauermann, gdb-patches

> I still think the benefits are mild, at best, but I don't want to stop
> your gusto.  I don't think this change will make gdb worse.

Well, if I read other's temperature well, it seems to me that I might
be the only one convinced that this is a good change. This is usually
an indicator that the idea might not be as obviously good as I think.
Since this is a pretty labour-intensive change, I'm now thinking that,
short of more support, I should just enhance the parse routines to take
a parse_context structure as a parameter rather than using the globals,
and leave the rest of GDB alone.

-- 
Joel


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-22 18:54           ` Tom Tromey
@ 2008-10-22 22:24             ` Ulrich Weigand
  2008-10-23  1:02               ` Tom Tromey
  0 siblings, 1 reply; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-22 22:24 UTC (permalink / raw)
  To: tromey; +Cc: Joel Brobecker, gdb-patches

Tom Tromey wrote:

> For evaluate_subexp_standard, there was a patch recently in this
> area:
> 
>     http://sourceware.org/ml/gdb-patches/2008-08/msg00525.html
> 
> AFAIK this has not been reviewed.

Ah, I'd forgotten about that thread.  I'll have a look at the
above patch.

> For breakpoint print routines, I don't know.  I consider this part of
> the patch a kind of technicality -- only needed because I chose to
> remove the globals entirely, which I only did to ensure that I caught
> all uses in the call hierarchy I really cared about.
> 
> This sort of thing can easily be addressed later, if necessary.  The
> reason I'm not sure it is necessary is that it seems to me that the
> user would really want breakpoint-printing to use the current globals.
> So, capturing the state somewhere would not be correct.  At that
> point... well, I'd rather have Joel solve this problem ;)

Sure, that's fine with me :-)

> Ulrich> In fact, I'm wondering if it wouldn't be nicer to also have something
> Ulrich> like a get_default_print_options function instead of refering to the
> Ulrich> user_print_options global in the top-level printing routines ...
> 
> No problem.  Do you want it to make a copy?  Or just return a pointer
> to the global?

I'd prefer a copy, just like the other routines.

> I'll fix this by fixing print_formatted as you suggested.

OK.

> Ulrich> There's still two globals used in various places throughout the
> Ulrich> print routines: current_language and current_gdbarch.  Ideally,
> Ulrich> these should be replaced by passing arguments as well ... I'm
> Ulrich> not sure if the value_print_options structure is the correct
> Ulrich> place to put language and gdbarch pointer, though.  Do you have
> Ulrich> and opinions how to handle those?
> 
> I don't really mind putting these into that structure.  In the context
> of this call hierarchy, these are immutable arguments to a particular
> call, modifying that call's behavior.  For me that is enough to
> qualify them.
> 
> But, we could take other approaches.  We could pass in a structure
> that contains a struct value_print_options and a struct something_else.
> 
> FWIW I'd like to keep just a single "options" argument -- many of
> these functions already have too many arguments.

OK, I'm fine with this.  However, this means that we'll really have
to construct the option struct on the fly, we cannot have a global
struct hold pre-initialized pointers to current_language etc.

(But if you use a get_default_print_options () routine that constructs
an option struct, the routine can just fill in the current values.)

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-22 22:24             ` Ulrich Weigand
@ 2008-10-23  1:02               ` Tom Tromey
  2008-10-23 19:50                 ` Ulrich Weigand
  0 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-23  1:02 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2304 bytes --]

Tom> http://sourceware.org/ml/gdb-patches/2008-08/msg00525.html

Ulrich> Ah, I'd forgotten about that thread.  I'll have a look at the
Ulrich> above patch.

Thanks!

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

I implemented this, and I fixed the other problems you mentioned.
The result is appended.  I still haven't tested this or written a
ChangeLog entry.

This version reduces the use of user_print_options to the absolute
minimum.  I don't think this is notably cleaner, but the difference
isn't extreme.  If we cared, we could make it mildly less ugly by
having get_user_print_options return its argument.

I still have a version of the patch without get_user_print_options in
case you change your mind on this.

Doing this did point out a couple things:

* As you mentioned, breakpoint-printing could probably use a small
  refactoring to give value_print_options arguments to various
  methods.  I can do this and roll it into this patch if you want;
  though my first reaction is to leave it as a follow-up patch (or
  just not do it).  Let me know what you want.

* print_scalar_formatted probably needs an options argument as well.
  What do you think?  This worries me a little since it is another 47
  call sites; so it could make the patch even bigger.  Maybe this
  ought to be a follow-up.

Ulrich> OK, I'm fine with this.  However, this means that we'll really have
Ulrich> to construct the option struct on the fly, we cannot have a global
Ulrich> struct hold pre-initialized pointers to current_language etc.

There's always "GCC style":

    #define current_language user_print_options.language

Semi-awful.

Or just s/current_language/user_print_options.current_language/
everywhere.  This, IMO, is not terrible, aside from its verbosity.

This is related to Joel's patch and to Daniel's question about a
policy for access to globals.  Before going too far down this road it
may be worth coming up with an agreement there.


To sum up, once I know how much more I should do, I will implement it
and then submit the patch for real.  I am not looking forward to
writing this ChangeLog entry...

Tom


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: the patch --]
[-- Type: text/x-patch, Size: 186099 bytes --]

projecttype:gdb
email:tromey@gcc.gnu.org
revision:093731ed652a7eca552b23985ccaff06f516f12c
configure:
make:
check:

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2e29770..426c5ce 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -353,9 +353,9 @@ ada_get_gdb_completer_word_break_characters (void)
 
 static void
 ada_print_array_index (struct value *index_value, struct ui_file *stream,
-                       int format, enum val_prettyprint pretty)
+                       const struct value_print_options *options)
 {
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, " => ");
 }
 
@@ -10060,7 +10060,10 @@ static void
 print_one_exception (enum exception_catchpoint_kind ex,
                      struct breakpoint *b, CORE_ADDR *last_addr)
 { 
-  if (addressprint)
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     {
       annotate_field (4);
       ui_out_field_core_addr (uiout, "addr", b->loc->address);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 2d13603..e65a838 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -258,11 +258,11 @@ extern void ada_print_type (struct type *, char *, struct ui_file *, int,
                             int);
 
 extern int ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-                          struct ui_file *, int, int, int,
-                          enum val_prettyprint);
+                          struct ui_file *, int,
+			  const struct value_print_options *);
 
-extern int ada_value_print (struct value *, struct ui_file *, int,
-                            enum val_prettyprint);
+extern int ada_value_print (struct value *, struct ui_file *,
+			    const struct value_print_options *);
 
                                 /* Defined in ada-lang.c */
 
@@ -275,7 +275,8 @@ extern void ada_emit_char (int, struct ui_file *, int, int);
 extern void ada_printchar (int, struct ui_file *);
 
 extern void ada_printstr (struct ui_file *, const gdb_byte *,
-			  unsigned int, int, int);
+			  unsigned int, int, int,
+			  const struct value_print_options *);
 
 struct value *ada_convert_actual (struct value *actual,
                                   struct type *formal_type0,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index e2f7740..794f799 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -43,18 +43,17 @@ struct ada_val_print_args
   int embedded_offset;
   CORE_ADDR address;
   struct ui_file *stream;
-  int format;
-  int deref_ref;
   int recurse;
-  enum val_prettyprint pretty;
+  const struct value_print_options *options;
 };
 
 static void print_record (struct type *, const gdb_byte *, struct ui_file *,
-			  int, int, enum val_prettyprint);
+			  int, const struct value_print_options *);
 
 static int print_field_values (struct type *, const gdb_byte *,
-			       struct ui_file *, int, int,
-			       enum val_prettyprint, int, struct type *,
+			       struct ui_file *, int,
+			       const struct value_print_options *,
+			       int, struct type *,
 			       const gdb_byte *);
 
 static void adjust_type_signedness (struct type *);
@@ -62,8 +61,8 @@ static void adjust_type_signedness (struct type *);
 static int ada_val_print_stub (void *args0);
 
 static int ada_val_print_1 (struct type *, const gdb_byte *, int, CORE_ADDR,
-			    struct ui_file *, int, int, int,
-			    enum val_prettyprint);
+			    struct ui_file *, int,
+			    const struct value_print_options *);
 \f
 
 /* Make TYPE unsigned if its range of values includes no negatives.  */
@@ -81,13 +80,14 @@ adjust_type_signedness (struct type *type)
    otherwise 0.  */
 
 static int
-print_optional_low_bound (struct ui_file *stream, struct type *type)
+print_optional_low_bound (struct ui_file *stream, struct type *type,
+			  const struct value_print_options *options)
 {
   struct type *index_type;
   long low_bound;
   long high_bound;
 
-  if (print_array_indexes_p ())
+  if (options->print_array_indexes)
     return 0;
 
   if (!get_array_bounds (type, &low_bound, &high_bound))
@@ -145,8 +145,8 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
 static void
 val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 				 int bitoffset, struct ui_file *stream,
-				 int format, int recurse,
-				 enum val_prettyprint pretty)
+				 int recurse,
+				 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -172,14 +172,14 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
   i = 0;
   annotate_array_section_begin (i, elttype);
 
-  while (i < len && things_printed < print_max)
+  while (i < len && things_printed < options->print_max)
     {
       struct value *v0, *v1;
       int i0;
 
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -190,7 +190,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    }
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
-      maybe_print_array_index (index_type, i + low, stream, format, pretty);
+      maybe_print_array_index (index_type, i + low, stream, options);
 
       i0 = i;
       v0 = ada_value_primitive_packed_val (NULL, valaddr,
@@ -210,10 +210,10 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    break;
 	}
 
-      if (i - i0 > repeat_count_threshold)
+      if (i - i0 > options->repeat_count_threshold)
 	{
-	  val_print (elttype, value_contents (v0), 0, 0, stream, format,
-		     0, recurse + 1, pretty, current_language);
+	  val_print (elttype, value_contents (v0), 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt_rep (i - i0);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), i - i0);
 	  annotate_elt_rep_end ();
@@ -226,7 +226,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    {
 	      if (j > i0)
 		{
-		  if (prettyprint_arrays)
+		  if (options->prettyprint_arrays)
 		    {
 		      fprintf_filtered (stream, ",\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -237,10 +237,10 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 		    }
 		  wrap_here (n_spaces (2 + 2 * recurse));
 		  maybe_print_array_index (index_type, j + low,
-					   stream, format, pretty);
+					   stream, options);
 		}
-	      val_print (elttype, value_contents (v0), 0, 0, stream, format,
-			 0, recurse + 1, pretty, current_language);
+	      val_print (elttype, value_contents (v0), 0, 0, stream,
+			 recurse + 1, options, current_language);
 	      annotate_elt ();
 	    }
 	}
@@ -452,7 +452,8 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 
 static void
 printstr (struct ui_file *stream, const gdb_byte *string,
-	  unsigned int length, int force_ellipses, int type_len)
+	  unsigned int length, int force_ellipses, int type_len,
+	  const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -465,7 +466,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; i += 1)
+  for (i = 0; i < length && things_printed < options->print_max; i += 1)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -491,11 +492,11 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  reps += 1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -507,14 +508,14 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  fputs_filtered ("'", stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -529,7 +530,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
@@ -541,9 +542,10 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 
 void
 ada_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
-  printstr (stream, string, length, force_ellipses, width);
+  printstr (stream, string, length, force_ellipses, width, options);
 }
 
 
@@ -569,8 +571,8 @@ ada_printstr (struct ui_file *stream, const gdb_byte *string,
 int
 ada_val_print (struct type *type, const gdb_byte *valaddr0,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   struct ada_val_print_args args;
   args.type = type;
@@ -578,10 +580,8 @@ ada_val_print (struct type *type, const gdb_byte *valaddr0,
   args.embedded_offset = embedded_offset;
   args.address = address;
   args.stream = stream;
-  args.format = format;
-  args.deref_ref = deref_ref;
   args.recurse = recurse;
-  args.pretty = pretty;
+  args.options = options;
 
   return catch_errors (ada_val_print_stub, &args, NULL, RETURN_MASK_ALL);
 }
@@ -594,8 +594,7 @@ ada_val_print_stub (void *args0)
   struct ada_val_print_args *argsp = (struct ada_val_print_args *) args0;
   return ada_val_print_1 (argsp->type, argsp->valaddr0,
 			  argsp->embedded_offset, argsp->address,
-			  argsp->stream, argsp->format, argsp->deref_ref,
-			  argsp->recurse, argsp->pretty);
+			  argsp->stream, argsp->recurse, argsp->options);
 }
 
 /* Assuming TYPE is a simple array, print the value of this array located
@@ -605,8 +604,8 @@ ada_val_print_stub (void *args0)
 
 static int
 ada_val_print_array (struct type *type, const gdb_byte *valaddr,
-		     CORE_ADDR address, struct ui_file *stream, int format,
-		     int deref_ref, int recurse, enum val_prettyprint pretty)
+		     CORE_ADDR address, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
 {
   struct type *elttype = TYPE_TARGET_TYPE (type);
   unsigned int eltlen;
@@ -623,40 +622,40 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
     len = TYPE_LENGTH (type) / eltlen;
 
   /* For an array of chars, print with string syntax.  */
-  if (ada_is_string_type (type) && (format == 0 || format == 's'))
+  if (ada_is_string_type (type)
+      && (options->output_format == 0 || options->output_format == 's'))
     {
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
         print_spaces_filtered (2 + 2 * recurse, stream);
 
       /* If requested, look for the first null char and only print
          elements up to it.  */
-      if (stop_print_at_null)
+      if (options->stop_print_at_null)
         {
           int temp_len;
 
           /* Look for a NULL char.  */
           for (temp_len = 0;
                (temp_len < len
-                && temp_len < print_max
+                && temp_len < options->print_max
                 && char_at (valaddr, temp_len, eltlen) != 0);
                temp_len += 1);
           len = temp_len;
         }
 
-      printstr (stream, valaddr, len, 0, eltlen);
+      printstr (stream, valaddr, len, 0, eltlen, options);
       result = len;
     }
   else
     {
       fprintf_filtered (stream, "(");
-      print_optional_low_bound (stream, type);
+      print_optional_low_bound (stream, type, options);
       if (TYPE_FIELD_BITSIZE (type, 0) > 0)
         val_print_packed_array_elements (type, valaddr, 0, stream,
-                                         format, recurse, pretty);
+                                         recurse, options);
       else
         val_print_array_elements (type, valaddr, address, stream,
-                                  format, deref_ref, recurse,
-                                  pretty, 0);
+                                  recurse, options, 0);
       fprintf_filtered (stream, ")");
     }
 
@@ -669,8 +668,8 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
 static int
 ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 		 int embedded_offset, CORE_ADDR address,
-		 struct ui_file *stream, int format,
-		 int deref_ref, int recurse, enum val_prettyprint pretty)
+		 struct ui_file *stream, int recurse,
+		 const struct value_print_options *options)
 {
   unsigned int len;
   int i;
@@ -695,8 +694,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	retn = ada_val_print_1 (value_type (val), value_contents (val), 0,
-				VALUE_ADDRESS (val), stream, format,
-				deref_ref, recurse, pretty);
+				VALUE_ADDRESS (val), stream, recurse, options);
       value_free_to_mark (mark);
       return retn;
     }
@@ -709,12 +707,12 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
     {
     default:
       return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
 
     case TYPE_CODE_PTR:
       {
 	int ret = c_val_print (type, valaddr0, embedded_offset, address, 
-			       stream, format, deref_ref, recurse, pretty);
+			       stream, recurse, options);
 	if (ada_is_tag_type (type))
 	  {
 	    struct value *val = 
@@ -778,17 +776,16 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 					    value_from_contents_and_address
 					    (type, valaddr, 0));
 	      return ada_val_print_1 (target_type, value_contents (v), 0, 0,
-				      stream, format, 0, recurse + 1, pretty);
+				      stream, recurse + 1, options);
 	    }
 	  else
 	    return ada_val_print_1 (TYPE_TARGET_TYPE (type),
 				    valaddr0, embedded_offset,
-				    address, stream, format, deref_ref,
-				    recurse, pretty);
+				    address, stream, recurse, options);
 	}
       else
 	{
-	  format = format ? format : output_format;
+	  int format = options->output_format;
 	  if (format)
 	    {
 	      print_scalar_formatted (valaddr, type, format, 0, stream);
@@ -830,9 +827,10 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -860,16 +858,17 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			    format, deref_ref, recurse, pretty);
+			    recurse, options);
       else
 	ada_print_floating (valaddr0 + embedded_offset, type, stream);
       break;
@@ -883,13 +882,13 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	{
-	  print_record (type, valaddr, stream, format, recurse, pretty);
+	  print_record (type, valaddr, stream, recurse, options);
 	  return 0;
 	}
 
     case TYPE_CODE_ARRAY:
-      return ada_val_print_array (type, valaddr, address, stream, format,
-                                  deref_ref, recurse, pretty);
+      return ada_val_print_array (type, valaddr, address, stream,
+				  recurse, options);
 
     case TYPE_CODE_REF:
       /* For references, the debugger is expected to print the value as
@@ -910,8 +909,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
                                 deref_val_int));
               val_print (value_type (deref_val),
                          value_contents (deref_val), 0,
-                         VALUE_ADDRESS (deref_val), stream, format,
-                         deref_ref, recurse + 1, pretty, current_language);
+                         VALUE_ADDRESS (deref_val), stream, recurse + 1,
+			 options, current_language);
             }
           else
             fputs_filtered ("(null)", stream);
@@ -927,8 +926,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 
 static int
 print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options, int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
@@ -941,13 +940,13 @@ print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
       (TYPE_FIELD_TYPE (var_type, which),
        valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
        + TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
-       stream, format, recurse, pretty,
+       stream, recurse, options,
        comma_needed, outer_type, outer_valaddr);
 }
 
 int
-ada_value_print (struct value *val0, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+ada_value_print (struct value *val0, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
   const gdb_byte *valaddr = value_contents (val0);
   CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
@@ -985,20 +984,20 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
     }
 
   return (val_print (type, value_contents (val), 0, address,
-		     stream, format, 1, 0, pretty, current_language));
+		     stream, 0, options, current_language));
 }
 
 static void
 print_record (struct type *type, const gdb_byte *valaddr,
-	      struct ui_file *stream, int format, int recurse,
-	      enum val_prettyprint pretty)
+	      struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   type = ada_check_typedef (type);
 
   fprintf_filtered (stream, "(");
 
-  if (print_field_values (type, valaddr, stream, format, recurse, pretty,
-			  0, type, valaddr) != 0 && pretty)
+  if (print_field_values (type, valaddr, stream, recurse, options,
+			  0, type, valaddr) != 0 && options->pretty)
     {
       fprintf_filtered (stream, "\n");
       print_spaces_filtered (2 * recurse, stream);
@@ -1023,8 +1022,9 @@ print_record (struct type *type, const gdb_byte *valaddr,
 
 static int
 print_field_values (struct type *type, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options,
+		    int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   int i, len;
@@ -1042,7 +1042,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	    print_field_values (TYPE_FIELD_TYPE (type, i),
 				valaddr
 				+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-				stream, format, recurse, pretty,
+				stream, recurse, options,
 				comma_needed, type, valaddr);
 	  continue;
 	}
@@ -1050,7 +1050,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  comma_needed =
 	    print_variant_part (type, i, valaddr,
-				stream, format, recurse, pretty, comma_needed,
+				stream, recurse, options, comma_needed,
 				outer_type, outer_valaddr);
 	  continue;
 	}
@@ -1059,7 +1059,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, ", ");
       comma_needed = 1;
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1068,7 +1068,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  wrap_here (n_spaces (2 + 2 * recurse));
 	}
-      if (inspect_it)
+      if (options->inspect_it)
 	{
 	  if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 	    fputs_filtered ("\"( ptr \"", stream);
@@ -1115,14 +1115,13 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 						  bit_size,
 						  TYPE_FIELD_TYPE (type, i));
 	      val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0, 0,
-			 stream, format, 0, recurse + 1, pretty,
-			 current_language);
+			 stream, recurse + 1, options, current_language);
 	    }
 	}
       else
 	ada_val_print (TYPE_FIELD_TYPE (type, i),
 		       valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-		       0, 0, stream, format, 0, recurse + 1, pretty);
+		       0, 0, stream, recurse + 1, options);
       annotate_field_end ();
     }
 
diff --git a/gdb/auxv.c b/gdb/auxv.c
index afc7fdd..121a749 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -172,7 +172,6 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 
   while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
     {
-      extern int addressprint;
       const char *name = "???";
       const char *description = "";
       enum { dec, hex, str } flavor = hex;
@@ -240,10 +239,14 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 	  fprintf_filtered (file, "0x%s\n", paddr_nz (val));
 	  break;
 	case str:
-	  if (addressprint)
-	    fprintf_filtered (file, "0x%s", paddr_nz (val));
-	  val_print_string (val, -1, 1, file);
-	  fprintf_filtered (file, "\n");
+	  {
+	    struct value_print_options opts;
+	    get_user_print_options (&opts);
+	    if (opts.addressprint)
+	      fprintf_filtered (file, "0x%s", paddr_nz (val));
+	    val_print_string (val, -1, 1, file, &opts);
+	    fprintf_filtered (file, "\n");
+	  }
 	  break;
 	}
       ++ents;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 180f6c9..01b2990 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -56,6 +56,7 @@
 #include "ada-lang.h"
 #include "top.h"
 #include "wrapper.h"
+#include "valprint.h"
 
 #include "mi/mi-common.h"
 
@@ -283,8 +284,6 @@ breakpoints_always_inserted_mode (void)
 
 void _initialize_breakpoint (void);
 
-extern int addressprint;	/* Print machine addresses? */
-
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
@@ -2259,7 +2258,11 @@ watchpoint_value_print (struct value *val, struct ui_file *stream)
   if (val == NULL)
     fprintf_unfiltered (stream, _("<unreadable>"));
   else
-    value_print (val, stream, 0, Val_pretty_default);
+    {
+      struct value_print_options opts;
+      get_user_print_options (&opts);
+      value_print (val, stream, &opts);
+    }
 }
 
 /* This is the normal print function for a bpstat.  In the future,
@@ -3577,6 +3580,9 @@ print_one_breakpoint_location (struct breakpoint *b,
 
   int header_of_multiple = 0;
   int part_of_multiple = (loc != NULL);
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
 
   gdb_assert (!loc || loc_number != 0);
   /* See comment in print_one_breakpoint concerning
@@ -3640,7 +3646,7 @@ print_one_breakpoint_location (struct breakpoint *b,
   
   /* 5 and 6 */
   strcpy (wrap_indent, "                           ");
-  if (addressprint)
+  if (opts.addressprint)
     {
       if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	strcat (wrap_indent, "           ");
@@ -3672,7 +3678,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	print_expression (b->exp, stb->stream);
@@ -3684,7 +3690,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->dll_pathname == NULL)
@@ -3704,7 +3710,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->exec_pathname != NULL)
@@ -3727,7 +3733,7 @@ print_one_breakpoint_location (struct breakpoint *b,
       case bp_shlib_event:
       case bp_thread_event:
       case bp_overlay_event:
-	if (addressprint)
+	if (opts.addressprint)
 	  {
 	    annotate_field (4);
 	    if (header_of_multiple)
@@ -3933,7 +3939,10 @@ breakpoint_1 (int bnum, int allflag)
   CORE_ADDR last_addr = (CORE_ADDR) -1;
   int nr_printable_breakpoints;
   struct cleanup *bkpttbl_chain;
+  struct value_print_options opts;
   
+  get_user_print_options (&opts);
+
   /* Compute the number of rows in the table. */
   nr_printable_breakpoints = 0;
   ALL_BREAKPOINTS (b)
@@ -3944,7 +3953,7 @@ breakpoint_1 (int bnum, int allflag)
 	  nr_printable_breakpoints++;
       }
 
-  if (addressprint)
+  if (opts.addressprint)
     bkpttbl_chain 
       = make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
                                              "BreakpointTable");
@@ -3967,7 +3976,7 @@ breakpoint_1 (int bnum, int allflag)
   if (nr_printable_breakpoints > 0)
     annotate_field (3);
   ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb");	/* 4 */
-  if (addressprint)
+  if (opts.addressprint)
 	{
 	  if (nr_printable_breakpoints > 0)
 	    annotate_field (4);
@@ -4760,10 +4769,14 @@ print_it_catch_fork (struct breakpoint *b)
 static void
 print_one_catch_fork (struct breakpoint *b, CORE_ADDR *last_addr)
 {
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
+
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (opts.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "fork");
@@ -4838,10 +4851,13 @@ print_it_catch_vfork (struct breakpoint *b)
 static void
 print_one_catch_vfork (struct breakpoint *b, CORE_ADDR *last_addr)
 {
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (opts.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "vfork");
@@ -5072,6 +5088,9 @@ mention (struct breakpoint *b)
   int say_where = 0;
   struct cleanup *old_chain, *ui_out_chain;
   struct ui_stream *stb;
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
 
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -5184,7 +5203,7 @@ mention (struct breakpoint *b)
 	}
       else
 	{
-	  if (addressprint || b->source_file == NULL)
+	  if (opts.addressprint || b->source_file == NULL)
 	    {
 	      printf_filtered (" at ");
 	      fputs_filtered (paddress (b->loc->address), gdb_stdout);
@@ -6746,7 +6765,9 @@ print_exception_catchpoint (struct breakpoint *b)
 static void
 print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
 {
-  if (addressprint)
+  struct value_print_options opts;
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     {
       annotate_field (4);
       if (b->loc == NULL || b->loc->shlib_disabled)
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a978b17..067e429 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -86,7 +86,8 @@ c_printchar (int c, struct ui_file *stream)
 
 void
 c_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -108,7 +109,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -137,11 +138,11 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -150,14 +151,14 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  LA_PRINT_CHAR (current_char, stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -171,7 +172,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index fe1939a..cc9abde 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -40,11 +40,11 @@ extern void c_print_type (struct type *, char *, struct ui_file *, int,
 extern void c_print_typedef (struct type *, struct symbol *, struct ui_file *);
 
 extern int c_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 /* These are in c-lang.c: */
 
@@ -52,7 +52,8 @@ extern void c_printchar (int, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, const gdb_byte *string,
 			unsigned int length, int width,
-			int force_ellipses);
+			int force_ellipses,
+			const struct value_print_options *options);
 
 extern void scan_macro_expansion (char *expansion);
 extern int scanning_macro_expansion (void);
@@ -70,17 +71,13 @@ extern void c_type_print_base (struct type *, struct ui_file *, int, int);
 
 /* These are in cp-valprint.c */
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void cp_print_class_member (const gdb_byte *, struct type *,
 				   struct ui_file *, char *);
 
 extern void cp_print_value_fields (struct type *, struct type *,
 				   const gdb_byte *, int, CORE_ADDR,
 				   struct ui_file *, int,
-				   int, enum val_prettyprint,
+				   const struct value_print_options *,
 				   struct type **, int);
 
 extern int cp_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 1dff6cb..fb7148e 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -36,7 +36,8 @@
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -115,8 +116,8 @@ textual_element_type (struct type *type, char format)
 
 int
 c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -134,29 +135,29 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	{
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
 
 	  /* Print arrays of textual chars with a string syntax.  */
-          if (textual_element_type (elttype, format))
+          if (textual_element_type (elttype, options->output_format))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0, options);
 	      i = len;
 	    }
 	  else
@@ -174,7 +175,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -184,9 +185,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_MEMBERPTR:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
@@ -197,19 +199,20 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
 	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.) */
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	  break;
 	}
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -220,21 +223,24 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
 	    {
 	      /* Try to print what function it points to.  */
-	      print_function_pointer_address (addr, stream);
+	      print_function_pointer_address (addr, stream,
+					      options->addressprint);
 	      /* Return value is irrelevant except for string pointers.  */
 	      return (0);
 	    }
 
-	  if (addressprint)
+	  if (options->addressprint)
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to a textual type, also print the string
 	     pointed to, unless pointer is null.  */
 	  /* FIXME: need to handle wchar_t here... */
 
-	  if (textual_element_type (elttype, format) && addr != 0)
+	  if (textual_element_type (elttype, options->output_format)
+	      && addr != 0)
 	    {
-	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				    options);
 	    }
 	  else if (cp_is_vtbl_member (type))
 	    {
@@ -250,7 +256,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -271,10 +277,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format,
-				    deref_ref, recurse + 1, pretty,
+		  common_val_print (vt_val, stream, recurse + 1, options,
 				    current_language);
-		  if (pretty)
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -291,17 +296,17 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -309,8 +314,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -318,7 +323,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -326,7 +331,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
       /*FIXME: Abstract this away */
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -337,17 +342,18 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + offset, field_type);
 
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	}
       else
-	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
-			       recurse, pretty, NULL, 0);
+	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream,
+			       recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -371,17 +377,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -394,9 +402,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -420,10 +428,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -432,7 +440,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	     Since we don't know whether the value is really intended to
 	     be used as an integer or a character, print the character
 	     equivalent as well.  */
-	  if (textual_element_type (type, format))
+	  if (textual_element_type (type, options->output_format))
 	    {
 	      fputs_filtered (" ", stream);
 	      LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
@@ -442,10 +450,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -460,9 +468,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -471,8 +480,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_DECFLOAT:
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	print_decimal_floating (valaddr + embedded_offset, type, stream);
       break;
@@ -493,19 +503,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_COMPLEX:
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset,
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
 			stream);
       fprintf_filtered (stream, " + ");
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset
 				+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	print_floating (valaddr + embedded_offset
 			+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
@@ -522,8 +532,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 }
 \f
 int
-c_value_print (struct value *val, struct ui_file *stream, int format,
-	       enum val_prettyprint pretty)
+c_value_print (struct value *val, struct ui_file *stream, 
+	       const struct value_print_options *options)
 {
   struct type *type, *real_type;
   int full, top, using_enc;
@@ -551,7 +561,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	{
 	  /* Print nothing */
 	}
-      else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+      else if (options->objectprint
+	       && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
 	{
 
 	  if (TYPE_CODE(type) == TYPE_CODE_REF)
@@ -602,7 +613,7 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   if (!value_initialized (val))
     fprintf_filtered (stream, " [uninitialized] ");
 
-  if (objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
+  if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
     {
       /* Attempt to determine real type of object */
       real_type = value_rtti_type (val, &full, &top, &using_enc);
@@ -616,8 +627,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	  /* Print out object: enclosing type is same as real_type if full */
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    options, current_language);
           /* Note: When we look up RTTI entries, we don't get any information on
              const or volatile attributes */
 	}
@@ -628,8 +639,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 			    TYPE_NAME (value_enclosing_type (val)));
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    options, current_language);
 	}
       /* Otherwise, we end up at the return outside this "if" */
     }
@@ -637,5 +648,5 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   return val_print (type, value_contents_all (val),
 		    value_embedded_offset (val),
 		    VALUE_ADDRESS (val) + value_offset (val),
-		    stream, format, 1, 0, pretty, current_language);
+		    stream, 0, options, current_language);
 }
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 61559af..bbb7689 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -38,7 +38,6 @@
 #include "language.h"
 
 /* Controls printing of vtbl's */
-int vtblprint;
 static void
 show_vtblprint (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -50,7 +49,6 @@ Printing of C++ virtual function tables is %s.\n"),
 
 /* Controls looking up an object's derived type using what we find in
    its vtables.  */
-int objectprint;
 static void
 show_objectprint (struct ui_file *file, int from_tty,
 		  struct cmd_list_element *c,
@@ -61,7 +59,6 @@ Printing of object's derived type based on vtable info is %s.\n"),
 		    value);
 }
 
-int static_field_print;		/* Controls printing of static fields. */
 static void
 show_static_field_print (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -77,12 +74,12 @@ static struct obstack dont_print_statmem_obstack;
 extern void _initialize_cp_valprint (void);
 
 static void cp_print_static_field (struct type *, struct value *,
-				   struct ui_file *, int, int,
-				   enum val_prettyprint);
+				   struct ui_file *, int,
+				   const struct value_print_options *);
 
 static void cp_print_value (struct type *, struct type *, const gdb_byte *,
-			    int, CORE_ADDR, struct ui_file *, int, int,
-			    enum val_prettyprint, struct type **);
+			    int, CORE_ADDR, struct ui_file *, int,
+			    const struct value_print_options *, struct type **);
 
 
 /* GCC versions after 2.4.5 use this.  */
@@ -151,9 +148,9 @@ cp_is_vtbl_member (struct type *type)
 void
 cp_print_value_fields (struct type *type, struct type *real_type,
 		       const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		       struct ui_file *stream, int format, int recurse,
-		       enum val_prettyprint pretty,
-		       struct type **dont_print_vb,int dont_print_statmem)
+		       struct ui_file *stream, int recurse,
+		       const struct value_print_options *options,
+		       struct type **dont_print_vb, int dont_print_statmem)
 {
   int i, len, n_baseclasses;
   char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
@@ -170,7 +167,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
   if (n_baseclasses > 0)
     cp_print_value (type, real_type, valaddr, offset, address, stream,
-		    format, recurse + 1, pretty, dont_print_vb);
+		    recurse + 1, options, dont_print_vb);
 
   /* Second, print out data fields */
 
@@ -192,7 +189,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!static_field_print
+	  if (!options->static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 
@@ -200,7 +197,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -211,7 +208,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -220,7 +217,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -270,7 +267,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		    (TYPE_FIELD_TYPE (type, i), 
 		     unpack_field_as_long (type, valaddr + offset, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1, pretty,
+		  common_val_print (v, stream, recurse + 1, options,
 				    current_language);
 		}
 	    }
@@ -287,15 +284,14 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		    fputs_filtered ("<optimized out>", stream);
 		  else
 		    cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
-					   stream, format, recurse + 1,
-					   pretty);
+					   stream, recurse + 1, options);
 		}
 	      else
 		{
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, options,
 			     current_language);
 		}
 	    }
@@ -310,7 +306,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -326,8 +322,9 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 static void
 cp_print_value (struct type *type, struct type *real_type,
 		const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int recurse,
-		enum val_prettyprint pretty, struct type **dont_print_vb)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options,
+		struct type **dont_print_vb)
 {
   struct type **last_dont_print
     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
@@ -402,7 +399,7 @@ cp_print_value (struct type *type, struct type *real_type,
 	base_valaddr = valaddr;
 
       /* now do the printing */
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -419,8 +416,7 @@ cp_print_value (struct type *type, struct type *real_type,
       else
 	cp_print_value_fields (baseclass, thistype, base_valaddr,
 			       thisoffset + boffset, address + boffset,
-			       stream, format,
-			       recurse, pretty,
+			       stream, recurse, options,
 			       ((struct type **)
 				obstack_base (&dont_print_vb_obstack)),
 			       0);
@@ -454,9 +450,8 @@ static void
 cp_print_static_field (struct type *type,
 		       struct value *val,
 		       struct ui_file *stream,
-		       int format,
 		       int recurse,
-		       enum val_prettyprint pretty)
+		       const struct value_print_options *options)
 {
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
@@ -485,12 +480,12 @@ cp_print_static_field (struct type *type,
       CHECK_TYPEDEF (type);
       cp_print_value_fields (type, type, value_contents_all (val),
 			     value_embedded_offset (val), VALUE_ADDRESS (val),
-			     stream, format, recurse, pretty, NULL, 1);
+			     stream, recurse, options, NULL, 1);
       return;
     }
   val_print (type, value_contents_all (val), 
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stream, format, 0, recurse, pretty, current_language);
+	     stream, recurse, options, current_language);
 }
 
 
@@ -589,32 +584,29 @@ void
 _initialize_cp_valprint (void)
 {
   add_setshow_boolean_cmd ("static-members", class_support,
-			   &static_field_print, _("\
+			   &user_print_options.static_field_print, _("\
 Set printing of C++ static members."), _("\
 Show printing of C++ static members."), NULL,
 			   NULL,
 			   show_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  static_field_print = 1;
 
-  add_setshow_boolean_cmd ("vtbl", class_support, &vtblprint, _("\
+  add_setshow_boolean_cmd ("vtbl", class_support,
+			   &user_print_options.vtblprint, _("\
 Set printing of C++ virtual function tables."), _("\
 Show printing of C++ virtual function tables."), NULL,
 			   NULL,
 			   show_vtblprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("object", class_support, &objectprint, _("\
+  add_setshow_boolean_cmd ("object", class_support,
+			   &user_print_options.objectprint, _("\
 Set printing of object's derived type based on vtable info."), _("\
 Show printing of object's derived type based on vtable info."), NULL,
 			   NULL,
 			   show_objectprint,
 			   &setprintlist, &showprintlist);
 
-  /* Give people the defaults which they are used to.  */
-  objectprint = 0;
-  vtblprint = 0;
   obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
   obstack_specify_allocation (&dont_print_statmem_obstack,
 			      32 * sizeof (CORE_ADDR), sizeof (CORE_ADDR),
diff --git a/gdb/eval.c b/gdb/eval.c
index cf3e876..4394aa1 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -39,16 +39,13 @@
 #include "exceptions.h"
 #include "regcache.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 
 /* This is defined in valops.c */
 extern int overload_resolution;
 
-/* JYG: lookup rtti type of STRUCTOP_PTR when this is set to continue
-   on with successful lookup for member/method of the rtti type. */
-extern int objectprint;
-
 /* Prototypes for local functions. */
 
 static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
@@ -1628,8 +1625,10 @@ evaluate_subexp_standard (struct type *expect_type,
         struct type *type = value_type (arg1);
         struct type *real_type;
         int full, top, using_enc;
-        
-        if (objectprint && TYPE_TARGET_TYPE(type) &&
+	struct value_print_options opts;
+
+	get_user_print_options (&opts);
+        if (opts.objectprint && TYPE_TARGET_TYPE(type) &&
             (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
           {
             real_type = value_rtti_target_type (arg1, &full, &top, &using_enc);
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 079f2a9..756a02e 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -31,6 +31,7 @@
 #include "block.h"
 #include "objfiles.h"
 #include "gdb_assert.h"
+#include "valprint.h"
 
 #ifdef HAVE_CTYPE_H
 #include <ctype.h>
@@ -92,17 +93,25 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_LONG:
-      (*pos) += 3;
-      value_print (value_from_longest (exp->elts[pc + 1].type,
-				       exp->elts[pc + 2].longconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_longest (exp->elts[pc + 1].type,
+					 exp->elts[pc + 2].longconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_DOUBLE:
-      (*pos) += 3;
-      value_print (value_from_double (exp->elts[pc + 1].type,
-				      exp->elts[pc + 2].doubleconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_double (exp->elts[pc + 1].type,
+					exp->elts[pc + 2].doubleconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_VAR_VALUE:
@@ -169,12 +178,17 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_STRING:
-      nargs = longest_to_int (exp->elts[pc + 1].longconst);
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
-      /* LA_PRINT_STRING will print using the current repeat count threshold.
-         If necessary, we can temporarily set it to zero, or pass it as an
-         additional parameter to LA_PRINT_STRING.  -fnf */
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+      {
+	struct value_print_options opts;
+	nargs = longest_to_int (exp->elts[pc + 1].longconst);
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+	/* LA_PRINT_STRING will print using the current repeat count threshold.
+	   If necessary, we can temporarily set it to zero, or pass it as an
+	   additional parameter to LA_PRINT_STRING.  -fnf */
+	get_user_print_options (&opts);
+	LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+			 &opts);
+      }
       return;
 
     case OP_BITSTRING:
@@ -185,11 +199,16 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_OBJC_NSSTRING:	/* Objective-C Foundation Class NSString constant.  */
-      nargs = longest_to_int (exp->elts[pc + 1].longconst);
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
-      fputs_filtered ("@\"", stream);
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
-      fputs_filtered ("\"", stream);
+      {
+	struct value_print_options opts;
+	nargs = longest_to_int (exp->elts[pc + 1].longconst);
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+	fputs_filtered ("@\"", stream);
+	get_user_print_options (&opts);
+	LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+			 &opts);
+	fputs_filtered ("\"", stream);
+      }
       return;
 
     case OP_OBJC_MSGCALL:
@@ -270,7 +289,10 @@ print_subexp_standard (struct expression *exp, int *pos,
 	}
       if (tem > 0)
 	{
-	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
+	  struct value_print_options opts;
+	  get_user_print_options (&opts);
+	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
+			   &opts);
 	  (*pos) = pc;
 	}
       else
@@ -394,6 +416,8 @@ print_subexp_standard (struct expression *exp, int *pos,
       if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
 	  exp->elts[pc + 3].opcode == OP_LONG)
 	{
+	  struct value_print_options opts;
+
 	  /* We have a minimal symbol fn, probably.  It's encoded
 	     as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
 	     Swallow the OP_LONG (including both its opcodes); ignore
@@ -401,7 +425,8 @@ print_subexp_standard (struct expression *exp, int *pos,
 	  (*pos) += 4;
 	  val = value_at_lazy (exp->elts[pc + 1].type,
 			       (CORE_ADDR) exp->elts[pc + 5].longconst);
-	  value_print (val, stream, 0, Val_no_prettyprint);
+	  get_raw_print_options (&opts);
+	  value_print (val, stream, &opts);
 	}
       else
 	{
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 736d6c6..4d4d4d7 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -142,7 +142,8 @@ f_printchar (int c, struct ui_file *stream)
 
 static void
 f_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -155,7 +156,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -179,11 +180,11 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -192,14 +193,14 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  f_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -213,7 +214,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
@@ -305,8 +306,8 @@ f_language_arch_info (struct gdbarch *gdbarch,
 
 /* This is declared in c-lang.h but it is silly to import that file for what
    is already just a hack. */
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 const struct language_defn f_language_defn =
 {
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 252d25d..3b3487e 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -29,8 +29,8 @@ extern void f_print_type (struct type *, char *, struct ui_file *, int,
 			  int);
 
 extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
 /* Language-specific data structures */
 
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 672e95c..3fae0a7 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -164,42 +164,42 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
 static void
 f77_print_array_1 (int nss, int ndimensions, struct type *type,
 		   const gdb_byte *valaddr, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty,
+		   struct ui_file *stream, int recurse,
+		   const struct value_print_options *options,
 		   int *elts)
 {
   int i;
 
   if (nss != ndimensions)
     {
-      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++)
+      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++)
 	{
 	  fprintf_filtered (stream, "( ");
 	  f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
 			     valaddr + i * F77_DIM_OFFSET (nss),
 			     address + i * F77_DIM_OFFSET (nss),
-			     stream, format, deref_ref, recurse, pretty, elts);
+			     stream, recurse, options, elts);
 	  fprintf_filtered (stream, ") ");
 	}
-      if (*elts >= print_max && i < F77_DIM_SIZE (nss)) 
+      if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) 
 	fprintf_filtered (stream, "...");
     }
   else
     {
-      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < print_max; 
+      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
 	   i++, (*elts)++)
 	{
 	  val_print (TYPE_TARGET_TYPE (type),
 		     valaddr + i * F77_DIM_OFFSET (ndimensions),
 		     0,
 		     address + i * F77_DIM_OFFSET (ndimensions),
-		     stream, format, deref_ref, recurse, pretty,
-		     current_language);
+		     stream, recurse, options, current_language);
 
 	  if (i != (F77_DIM_SIZE (nss) - 1))
 	    fprintf_filtered (stream, ", ");
 
-	  if ((*elts == print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1)))
+	  if ((*elts == options->print_max - 1)
+	      && (i != (F77_DIM_SIZE (nss) - 1)))
 	    fprintf_filtered (stream, "...");
 	}
     }
@@ -211,8 +211,7 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
 static void
 f77_print_array (struct type *type, const gdb_byte *valaddr,
 		 CORE_ADDR address, struct ui_file *stream,
-		 int format, int deref_ref, int recurse,
-		 enum val_prettyprint pretty)
+		 int recurse, const struct value_print_options *options)
 {
   int ndimensions;
   int elts = 0;
@@ -229,8 +228,8 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
 
   f77_create_arrayprint_offset_tbl (type, stream);
 
-  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream, format,
-		     deref_ref, recurse, pretty, &elts);
+  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream,
+		     recurse, options, &elts);
 }
 \f
 
@@ -249,8 +248,8 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
 
 int
 f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *elttype;
@@ -263,20 +262,20 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     {
     case TYPE_CODE_STRING:
       f77_get_dynamic_length_of_aggregate (type);
-      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0);
+      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0, options);
       break;
 
     case TYPE_CODE_ARRAY:
       fprintf_filtered (stream, "(");
-      f77_print_array (type, valaddr, address, stream, format,
-		       deref_ref, recurse, pretty);
+      f77_print_array (type, valaddr, address, stream, recurse, options);
       fprintf_filtered (stream, ")");
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
 	  break;
 	}
       else
@@ -292,16 +291,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      return 0;
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->output_format != 's')
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to char or unsigned char, also print the string
 	     pointed to, unless pointer is null.  */
 	  if (TYPE_LENGTH (elttype) == 1
 	      && TYPE_CODE (elttype) == TYPE_CODE_INT
-	      && (format == 0 || format == 's')
+	      && (options->output_format == 0 || options->output_format == 's')
 	      && addr != 0)
-	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				  options);
 
 	  /* Return number of characters printed, including the terminating
 	     '\0' if we reached the end.  val_print_string takes care including
@@ -312,17 +312,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -330,8 +330,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref, recurse,
-				pretty, current_language);
+	      common_val_print (deref_val, stream, recurse,
+				options, current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -339,9 +339,10 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -354,9 +355,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else
 	{
 	  val_print_type_code_int (type, valaddr, stream);
@@ -374,15 +375,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr, type, options->output_format,
+				  0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else
 	print_floating (valaddr, type, stream);
       break;
@@ -401,9 +404,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else
 	{
 	  val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
@@ -417,8 +420,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	    {
 	      /* Bash the type code temporarily.  */
 	      TYPE_CODE (type) = TYPE_CODE_INT;
-	      f_val_print (type, valaddr, 0, address, stream, format,
-			   deref_ref, recurse, pretty);
+	      f_val_print (type, valaddr, 0, address, stream, recurse, options);
 	      /* Restore the type code so later uses work as intended. */
 	      TYPE_CODE (type) = TYPE_CODE_BOOL;
 	    }
@@ -450,8 +452,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
         {
           int offset = TYPE_FIELD_BITPOS (type, index) / 8;
           f_val_print (TYPE_FIELD_TYPE (type, index), valaddr + offset,
-                       embedded_offset, address, stream,
-                       format, deref_ref, recurse, pretty);
+                       embedded_offset, address, stream, recurse, options);
           if (index != TYPE_NFIELDS (type) - 1)
             fputs_filtered (", ", stream);
         }
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 4f55c33..5256203 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -51,6 +51,7 @@
 #include "exceptions.h"
 #include "cli/cli-decode.h"
 #include "gdbthread.h"
+#include "valprint.h"
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -1282,6 +1283,8 @@ print_return_value (struct type *func_type, struct type *value_type)
 
   if (value)
     {
+      struct value_print_options opts;
+
       /* Print it.  */
       stb = ui_out_stream_new (uiout);
       old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -1289,7 +1292,8 @@ print_return_value (struct type *func_type, struct type *value_type)
       ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
 			record_latest_value (value));
       ui_out_text (uiout, " = ");
-      value_print (value, stb->stream, 0, Val_no_prettyprint);
+      get_raw_print_options (&opts);
+      value_print (value, stb->stream, &opts);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
       do_cleanups (old_chain);
@@ -1803,9 +1807,11 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	  || TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_DECFLOAT)
 	{
 	  int j;
+	  struct value_print_options opts;
 
+	  get_user_print_options (&opts);
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 0, 1, 0, Val_pretty_default, current_language);
+		     file, 0, &opts, current_language);
 
 	  fprintf_filtered (file, "\t(raw 0x");
 	  for (j = 0; j < register_size (gdbarch, i); j++)
@@ -1821,16 +1827,22 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	}
       else
 	{
+	  struct value_print_options opts;
+
 	  /* Print the register in hex.  */
+	  get_formatted_print_options (&opts, 'x');
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 'x', 1, 0, Val_pretty_default, current_language);
+		     file, 0, &opts,
+		     current_language);
           /* If not a vector register, print it also according to its
              natural format.  */
 	  if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
 	    {
+	      struct value_print_options opts;
+	      get_user_print_options (&opts);
 	      fprintf_filtered (file, "\t");
 	      val_print (register_type (gdbarch, i), buffer, 0, 0,
-			 file, 0, 1, 0, Val_pretty_default, current_language);
+			 file, 0, &opts, current_language);
 	    }
 	}
 
diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h
index 51bada2..04ba383 100644
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -41,11 +41,11 @@ extern struct type *java_double_type;
 extern struct type *java_void_type;
 
 extern int java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			   struct ui_file *, int, int, int,
-			   enum val_prettyprint);
+			   struct ui_file *, int,
+			   const struct value_print_options *);
 
-extern int java_value_print (struct value *, struct ui_file *, int,
-			     enum val_prettyprint);
+extern int java_value_print (struct value *, struct ui_file *,
+			     const struct value_print_options *);
 
 extern struct value *java_class_from_object (struct value *);
 
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 9e36aa4..975068b 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -35,8 +35,8 @@
 /* Local functions */
 
 int
-java_value_print (struct value *val, struct ui_file *stream, int format,
-		  enum val_prettyprint pretty)
+java_value_print (struct value *val, struct ui_file *stream, 
+		  const struct value_print_options *options)
 {
   struct type *type;
   CORE_ADDR address;
@@ -89,7 +89,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
 	  address += JAVA_OBJECT_SIZE + 4;	/* Skip object header and length. */
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      gdb_byte *buf;
 
@@ -145,7 +145,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	  VALUE_ADDRESS (v) = address + JAVA_OBJECT_SIZE + 4;
 	  VALUE_ADDRESS (next_v) = VALUE_ADDRESS (v);
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      fputs_filtered (", ", stream);
 	      wrap_here (n_spaces (2));
@@ -180,8 +180,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	      else
 		fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
 
-	      common_val_print (v, stream, format, 2, 1, pretty,
-				current_language);
+	      common_val_print (v, stream, 1, options, current_language);
 
 	      things_printed++;
 	      i += reps;
@@ -203,7 +202,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
       && TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
       && strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)),
 		 "java.lang.String") == 0
-      && (format == 0 || format == 's')
+      && (options->output_format == 0 || options->output_format == 's')
       && address != 0
       && value_as_address (val) != 0)
     {
@@ -228,13 +227,12 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
       value_free_to_mark (mark);	/* Release unnecessary values */
 
-      val_print_string (data + boffset, count, 2, stream);
+      val_print_string (data + boffset, count, 2, stream, options);
 
       return 0;
     }
 
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  return common_val_print (val, stream, 0, options, current_language);
 }
 
 /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
@@ -246,7 +244,8 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 static void
 java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 			 CORE_ADDR address, struct ui_file *stream,
-			 int format, int recurse, enum val_prettyprint pretty)
+			 int recurse,
+			 const struct value_print_options *options)
 {
   int i, len, n_baseclasses;
 
@@ -275,7 +274,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 
 	  boffset = 0;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 * (recurse + 1), stream);
@@ -289,7 +288,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  base_valaddr = valaddr;
 
 	  java_print_value_fields (baseclass, base_valaddr, address + boffset,
-				   stream, format, recurse + 1, pretty);
+				   stream, recurse + 1, options);
 	  fputs_filtered (", ", stream);
 	}
 
@@ -307,7 +306,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  if (field_is_static (&TYPE_FIELD (type, i)))
 	    {
 	      char *name = TYPE_FIELD_NAME (type, i);
-	      if (!static_field_print)
+	      if (!options->static_field_print)
 		continue;
 	      if (name != NULL && strcmp (name, "class") == 0)
 		continue;
@@ -316,7 +315,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -327,7 +326,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -336,7 +335,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -383,8 +382,8 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  common_val_print (v, stream, recurse + 1,
+				    options, current_language);
 		}
 	    }
 	  else
@@ -403,8 +402,8 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		      struct type *t = check_typedef (value_type (v));
 		      if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
 			v = value_addr (v);
-		      common_val_print (v, stream, format, 0, recurse + 1,
-					pretty, current_language);
+		      common_val_print (v, stream, recurse + 1,
+					options, current_language);
 		    }
 		}
 	      else if (TYPE_FIELD_TYPE (type, i) == NULL)
@@ -414,14 +413,14 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr + TYPE_FIELD_BITPOS (type, i) / 8, 0,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, options,
 			     current_language);
 		}
 	    }
 	  annotate_field_end ();
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -446,8 +445,8 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 int
 java_val_print (struct type *type, const gdb_byte *valaddr,
 		int embedded_offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int deref_ref,
-		int recurse, enum val_prettyprint pretty)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *target_type;
@@ -457,13 +456,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options->output_format, 0, stream);
 	  break;
 	}
 #if 0
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -490,7 +489,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
 	  return (0);
 	}
 
-      if (addressprint && format != 's')
+      if (options->addressprint && options->output_format != 's')
 	{
 	  fputs_filtered ("@", stream);
 	  print_longest (stream, 'x', 0, (ULONGEST) addr);
@@ -502,9 +501,9 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
     case TYPE_CODE_INT:
       /* Can't just call c_val_print because that prints bytes as C
 	 chars.  */
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options->output_format,
+				0, stream);
       else if (TYPE_CODE (type) == TYPE_CODE_CHAR
 	       || (TYPE_CODE (type) == TYPE_CODE_INT
 		   && TYPE_LENGTH (type) == 2
@@ -515,13 +514,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_STRUCT:
-      java_print_value_fields (type, valaddr, address, stream, format,
-			       recurse, pretty);
+      java_print_value_fields (type, valaddr, address, stream, recurse,
+			       options);
       break;
 
     default:
       return c_val_print (type, valaddr, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
     }
 
   return 0;
diff --git a/gdb/language.c b/gdb/language.c
index 121fc55..46e238d 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -72,7 +72,8 @@ static void unk_lang_printchar (int c, struct ui_file *stream);
 static void unk_lang_print_type (struct type *, char *, struct ui_file *,
 				 int, int);
 
-static int unk_lang_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+static int unk_lang_value_print (struct value *, struct ui_file *,
+				 const struct value_print_options *);
 
 static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
 
@@ -1035,10 +1036,10 @@ default_word_break_characters (void)
 
 void
 default_print_array_index (struct value *index_value, struct ui_file *stream,
-                           int format, enum val_prettyprint pretty)
+			   const struct value_print_options *options)
 {
   fprintf_filtered (stream, "[");
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, "] = ");
 }
 
@@ -1070,7 +1071,8 @@ unk_lang_printchar (int c, struct ui_file *stream)
 
 static void
 unk_lang_printstr (struct ui_file *stream, const gdb_byte *string,
-		   unsigned int length, int width, int force_ellipses)
+		   unsigned int length, int width, int force_ellipses,
+		   const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_printstr called."));
 }
@@ -1085,15 +1087,15 @@ unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
 static int
 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
 		    int embedded_offset, CORE_ADDR address,
-		    struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_val_print called."));
 }
 
 static int
-unk_lang_value_print (struct value *val, struct ui_file *stream, int format,
-		      enum val_prettyprint pretty)
+unk_lang_value_print (struct value *val, struct ui_file *stream,
+		      const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_value_print called."));
 }
diff --git a/gdb/language.h b/gdb/language.h
index cc10ff2..c92c57c 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -30,6 +30,7 @@ struct objfile;
 struct frame_info;
 struct expression;
 struct ui_file;
+struct value_print_options;
 
 #define MAX_FORTRAN_DIMS  7	/* Maximum number of F77 array dims */
 
@@ -189,7 +190,8 @@ struct language_defn
 
     void (*la_printstr) (struct ui_file * stream, const gdb_byte *string,
 			 unsigned int length, int width,
-			 int force_ellipses);
+			 int force_ellipses,
+			 const struct value_print_options *);
 
     void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
 
@@ -208,13 +210,13 @@ struct language_defn
     /* Print a value using syntax appropriate for this language. */
 
     int (*la_val_print) (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
     /* Print a top-level value using syntax appropriate for this language. */
 
     int (*la_value_print) (struct value *, struct ui_file *,
-			   int, enum val_prettyprint);
+			   const struct value_print_options *);
 
     /* PC is possibly an unknown languages trampoline.
        If that PC falls in a trampoline belonging to this language,
@@ -274,8 +276,7 @@ struct language_defn
     /* Print the index of an element of an array.  */
     void (*la_print_array_index) (struct value *index_value,
                                   struct ui_file *stream,
-                                  int format,
-                                  enum val_prettyprint pretty);
+                                  const struct value_print_options *options);
 
     /* Return non-zero if TYPE should be passed (and returned) by
        reference at the language level.  */
@@ -366,21 +367,22 @@ extern enum language set_language (enum language);
 #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
   (current_language->la_print_typedef(type,new_symbol,stream))
 
-#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,fmt,deref,recurse,pretty) \
-  (current_language->la_val_print(type,valaddr,offset,addr,stream,fmt,deref, \
-				  recurse,pretty))
-#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
-  (current_language->la_value_print(val,stream,fmt,pretty))
+#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,recurse,options) \
+  (current_language->la_val_print(type,valaddr,offset,addr,stream, \
+				  recurse,options))
+#define LA_VALUE_PRINT(val,stream,options) \
+  (current_language->la_value_print(val,stream,options))
 
 #define LA_PRINT_CHAR(ch, stream) \
   (current_language->la_printchar(ch, stream))
-#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
-  (current_language->la_printstr(stream, string, length, width, force_ellipses))
+#define LA_PRINT_STRING(stream, string, length, width, force_ellipses,options) \
+  (current_language->la_printstr(stream, string, length, width, \
+				 force_ellipses,options))
 #define LA_EMIT_CHAR(ch, stream, quoter) \
   (current_language->la_emitchar(ch, stream, quoter))
 
-#define LA_PRINT_ARRAY_INDEX(index_value, stream, format, pretty) \
-  (current_language->la_print_array_index(index_value, stream, format, pretty))
+#define LA_PRINT_ARRAY_INDEX(index_value, stream, optins) \
+  (current_language->la_print_array_index(index_value, stream, options))
 
 /* Test a character to decide whether it can be printed in literal form
    or needs to be printed in another representation.  For example,
@@ -472,8 +474,7 @@ extern char *default_word_break_characters (void);
 /* Print the index of an array element using the C99 syntax.  */
 extern void default_print_array_index (struct value *index_value,
                                        struct ui_file *stream,
-                                       int format,
-                                       enum val_prettyprint pretty);
+				       const struct value_print_options *options);
 
 /* Return non-zero if TYPE should be passed (and returned) by
    reference at the language level.  */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index ea59403..e09b64b 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -104,7 +104,8 @@ m2_printchar (int c, struct ui_file *stream)
 
 static void
 m2_printstr (struct ui_file *stream, const gdb_byte *string,
-	     unsigned int length, int width, int force_ellipses)
+	     unsigned int length, int width, int force_ellipses,
+	     const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -117,7 +118,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -141,11 +142,11 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -154,14 +155,14 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  m2_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -175,7 +176,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 8ce458c..f99e31a 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -33,8 +33,8 @@ extern int m2_is_long_set (struct type *type);
 extern int m2_is_unbounded_array (struct type *type);
 
 extern int m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
 extern int get_long_set_bounds (struct type *type, LONGEST *low,
 				LONGEST *high);
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 82ff30e..e276e86 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -30,22 +30,24 @@
 #include "m2-lang.h"
 #include "target.h"
 
-int print_unpacked_pointer (struct type *type,
-			    CORE_ADDR address, CORE_ADDR addr,
-			    int format, struct ui_file *stream);
+static int print_unpacked_pointer (struct type *type,
+				   CORE_ADDR address, CORE_ADDR addr,
+				   const struct value_print_options *options,
+				   struct ui_file *stream);
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len);
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len);
 
 
 /* Print function pointer with inferior address ADDRESS onto stdio
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -88,8 +90,7 @@ get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high)
 static void
 m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   enum val_prettyprint pretty)
+		   struct ui_file *stream)
 {
   int empty_set        = 1;
   int element_seen     = 0;
@@ -184,9 +185,8 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 static void
 m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
 			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int format,
-			  int deref_ref, enum val_prettyprint pretty,
-			  int recurse)
+			  struct ui_file *stream, int recurse,
+			  const struct value_print_options *options)
 {
   struct type *content_type;
   CORE_ADDR addr;
@@ -207,26 +207,27 @@ m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
   fprintf_filtered (stream, "{");  
   m2_print_array_contents (value_type (val), value_contents(val),
 			   value_embedded_offset (val), addr, stream,
-			   format, deref_ref, pretty, recurse, len);
+			   recurse, options, len);
   fprintf_filtered (stream, ", HIGH = %d}", (int) len);
 }
 
-int
+static int
 print_unpacked_pointer (struct type *type,
 			CORE_ADDR address, CORE_ADDR addr,
-			int format, struct ui_file *stream)
+			const struct value_print_options *options,
+			struct ui_file *stream)
 {
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
 
   if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
     {
       /* Try to print what function it points to.  */
-      print_function_pointer_address (addr, stream);
+      print_function_pointer_address (addr, stream, options->addressprint);
       /* Return value is irrelevant except for string pointers.  */
       return 0;
     }
 
-  if (addressprint && format != 's')
+  if (options->addressprint && options->output_format != 's')
     fputs_filtered (paddress (address), stream);
 
   /* For a pointer to char or unsigned char, also print the string
@@ -234,9 +235,9 @@ print_unpacked_pointer (struct type *type,
 
   if (TYPE_LENGTH (elttype) == 1
       && TYPE_CODE (elttype) == TYPE_CODE_INT
-      && (format == 0 || format == 's')
+      && (options->output_format == 0 || options->output_format == 's')
       && addr != 0)
-      return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+    return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options);
   
   return 0;
 }
@@ -244,9 +245,9 @@ print_unpacked_pointer (struct type *type,
 static void
 print_variable_at_address (struct type *type,
 			   const gdb_byte *valaddr,
-			   struct ui_file *stream, int format,
-			   int deref_ref, int recurse,
-			   enum val_prettyprint pretty)
+			   struct ui_file *stream,
+			   int recurse,
+			   const struct value_print_options *options)
 {
   CORE_ADDR addr = unpack_pointer (type, valaddr);
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -259,8 +260,7 @@ print_variable_at_address (struct type *type,
     {
       struct value *deref_val =
 	value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr));
-      common_val_print (deref_val, stream, format, deref_ref,
-			recurse, pretty, current_language);
+      common_val_print (deref_val, stream, recurse, options, current_language);
     }
   else
     fputs_filtered ("???", stream);
@@ -276,9 +276,9 @@ print_variable_at_address (struct type *type,
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len)
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len)
 {
   int eltlen;
   CHECK_TYPEDEF (type);
@@ -286,21 +286,20 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
   if (TYPE_LENGTH (type) > 0)
     {
       eltlen = TYPE_LENGTH (type);
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
 	print_spaces_filtered (2 + 2 * recurse, stream);
       /* For an array of chars, print with string syntax.  */
       if (eltlen == 1 &&
 	  ((TYPE_CODE (type) == TYPE_CODE_INT)
 	   || ((current_language->la_language == language_m2)
 	       && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
-	  && (format == 0 || format == 's'))
-	val_print_string (address, len+1, eltlen, stream);
+	  && (options->output_format == 0 || options->output_format == 's'))
+	val_print_string (address, len+1, eltlen, stream, options);
       else
 	{
 	  fprintf_filtered (stream, "{");
 	  val_print_array_elements (type, valaddr + embedded_offset,
-				    address, stream, format,
-				    deref_ref, recurse, pretty, 0);
+				    address, stream, recurse, options, 0);
 	  fprintf_filtered (stream, "}");
 	}
     }
@@ -322,8 +321,8 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 
 int
 m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int format,
-	      int deref_ref, int recurse, enum val_prettyprint pretty)
+	      CORE_ADDR address, struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -343,74 +342,73 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    print_spaces_filtered (2 + 2 * recurse, stream);
 	  /* For an array of chars, print with string syntax.  */
 	  if (eltlen == 1 &&
 	      ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_m2)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->output_format == 0 || options->output_format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-			 && temp_len < len && temp_len < print_max;
+			 && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
 	    {
 	      fprintf_filtered (stream, "{");
 	      val_print_array_elements (type, valaddr + embedded_offset,
-					address, stream, format, deref_ref,
-					recurse, pretty, 0);
+					address, stream, recurse, options, 0);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
 	}
       /* Array of unspecified length: treat like pointer to first elt.  */
-      print_unpacked_pointer (type, address, address, format, stream);
+      print_unpacked_pointer (type, address, address, options, stream);
       break;
 
     case TYPE_CODE_PTR:
       if (TYPE_CONST (type))
 	print_variable_at_address (type, valaddr + embedded_offset,
-				   stream, format, deref_ref, recurse,
-				   pretty);
-      else if (format && format != 's')
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+				   stream, recurse, options);
+      else if (options->output_format && options->output_format != 's')
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	{
 	  addr = unpack_pointer (type, valaddr + embedded_offset);
-	  print_unpacked_pointer (type, addr, address, format, stream);
+	  print_unpacked_pointer (type, addr, address, options, stream);
 	}
       break;
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -418,8 +416,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		value_at
 		(TYPE_TARGET_TYPE (type),
 		 unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -427,7 +425,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -436,22 +434,20 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     case TYPE_CODE_STRUCT:
       if (m2_is_long_set (type))
 	m2_print_long_set (type, valaddr, embedded_offset, address,
-			   stream, format, pretty);
+			   stream);
       else if (m2_is_unbounded_array (type))
 	m2_print_unbounded_array (type, valaddr, embedded_offset,
-				  address, stream, format, deref_ref,
-				  pretty, recurse);
+				  address, stream, recurse, options);
       else
 	cp_print_value_fields (type, type, valaddr, embedded_offset,
-			       address, stream, format,
-			       recurse, pretty, NULL, 0);
+			       address, stream, recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options->output_format, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -475,10 +471,10 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options->output_format, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -491,10 +487,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -511,7 +506,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
 	{
 	  m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset,
-			address, stream, format, deref_ref, recurse, pretty);
+			address, stream, recurse, options);
 	  break;
 	}
       /* FIXME: create_range_type does not set the unsigned bit in a
@@ -524,19 +519,17 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	val_print_type_code_int (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -550,9 +543,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options->output_format, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, type, stream);
       break;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index baf9b6d..9c55b4b 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -30,6 +30,7 @@
 #include "dictionary.h"
 #include "gdb_string.h"
 #include "language.h"
+#include "valprint.h"
 
 static void list_args_or_locals (int locals, int values, struct frame_info *fi);
 
@@ -280,21 +281,27 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
 		      && TYPE_CODE (type) != TYPE_CODE_STRUCT
 		      && TYPE_CODE (type) != TYPE_CODE_UNION)
 		    {
+		      struct value_print_options opts;
 		      val = read_var_value (sym2, fi);
+		      get_raw_print_options (&opts);
 		      common_val_print
-			(val, stb->stream, 0, 1, 0, Val_no_prettyprint,
+			(val, stb->stream, 0, &opts,
 			 language_def (SYMBOL_LANGUAGE (sym2)));
 		      ui_out_field_stream (uiout, "value", stb);
 		    }
 		  do_cleanups (cleanup_tuple);
 		  break;
 		case PRINT_ALL_VALUES:
-		  val = read_var_value (sym2, fi);
-		  common_val_print
-		    (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
-		     language_def (SYMBOL_LANGUAGE (sym2)));
-		  ui_out_field_stream (uiout, "value", stb);
-		  do_cleanups (cleanup_tuple);
+		  {
+		    struct value_print_options opts;
+		    val = read_var_value (sym2, fi);
+		    get_raw_print_options (&opts);
+		    common_val_print
+		      (val, stb->stream, 0, &opts,
+		       language_def (SYMBOL_LANGUAGE (sym2)));
+		    ui_out_field_stream (uiout, "value", stb);
+		    do_cleanups (cleanup_tuple);
+		  }
 		  break;
 		}
 	    }
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 7780207..5a483f1 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -45,6 +45,7 @@
 #include "frame.h"
 #include "mi-main.h"
 #include "language.h"
+#include "valprint.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -499,9 +500,10 @@ get_register (int regnum, int format)
     }
   else
     {
+      struct value_print_options opts;
+      get_user_print_options (&opts);
       val_print (register_type (current_gdbarch, regnum), buffer, 0, 0,
-		 stb->stream, format, 1, 0, Val_pretty_default,
-		 current_language);
+		 stb->stream, 0, &opts, current_language);
       ui_out_field_stream (uiout, "value", stb);
       ui_out_stream_delete (stb);
     }
@@ -570,6 +572,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   struct cleanup *old_chain = NULL;
   struct value *val;
   struct ui_stream *stb = NULL;
+  struct value_print_options opts;
 
   stb = ui_out_stream_new (uiout);
 
@@ -586,9 +589,10 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   val = evaluate_expression (expr);
 
   /* Print the result of the expression evaluation.  */
+  get_user_print_options (&opts);
   val_print (value_type (val), value_contents (val),
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stb->stream, 0, 0, 0, 0, current_language);
+	     stb->stream, 0, &opts, current_language);
 
   ui_out_field_stream (uiout, "value", stb);
   ui_out_stream_delete (stb);
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index da4afe3..ae6f382 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -37,6 +37,7 @@
 #include "infcall.h"
 #include "gdb_assert.h"
 #include "language.h"
+#include "valprint.h"
 
 enum mt_arch_constants
 {
@@ -675,6 +676,7 @@ mt_registers_info (struct gdbarch *gdbarch,
 	{
 	  /* Special output handling for the 'coprocessor' register.  */
 	  gdb_byte *buf;
+	  struct value_print_options opts;
 
 	  buf = alloca (register_size (gdbarch, MT_COPRO_REGNUM));
 	  frame_register_read (frame, MT_COPRO_REGNUM, buf);
@@ -685,8 +687,9 @@ mt_registers_info (struct gdbarch *gdbarch,
 	  print_spaces_filtered (15 - strlen (gdbarch_register_name
 					        (gdbarch, regnum)),
 				 file);
+	  get_raw_print_options (&opts);
 	  val_print (register_type (gdbarch, regnum), buf,
-		     0, 0, file, 0, 1, 0, Val_no_prettyprint,
+		     0, 0, file, 0, &opts,
 		     current_language);
 	  fputs_filtered ("\n", file);
 	}
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 7d287a0..3a952f5 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -341,7 +341,8 @@ objc_printchar (int c, struct ui_file *stream)
 
 static void
 objc_printstr (struct ui_file *stream, const gdb_byte *string, 
-	       unsigned int length, int width, int force_ellipses)
+	       unsigned int length, int width, int force_ellipses,
+	       const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -360,7 +361,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining to see whether it
 	 is repeated.  */
@@ -384,11 +385,11 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -397,14 +398,14 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  objc_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -418,7 +419,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 7ecdd8d..cd4285d 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -207,7 +207,8 @@ pascal_printchar (int c, struct ui_file *stream)
 
 void
 pascal_printstr (struct ui_file *stream, const gdb_byte *string,
-		 unsigned int length, int width, int force_ellipses)
+		 unsigned int length, int width, int force_ellipses,
+		 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -226,7 +227,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -250,11 +251,11 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -263,7 +264,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  pascal_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
@@ -271,7 +272,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  int c = string[i];
 	  if ((!in_quotes) && (PRINT_LITERAL_FORM (c)))
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -285,7 +286,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index a4f878f..4ebfbc1 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -35,10 +35,11 @@ extern void pascal_print_typedef (struct type *, struct symbol *,
 				  struct ui_file *);
 
 extern int pascal_val_print (struct type *, const gdb_byte *, int,
-			     CORE_ADDR, struct ui_file *, int, int,
-			     int, enum val_prettyprint);
+			     CORE_ADDR, struct ui_file *, int,
+			     const struct value_print_options *);
 
-extern int pascal_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+extern int pascal_value_print (struct value *, struct ui_file *,
+			       const struct value_print_options *);
 
 extern void pascal_type_print_method_args (char *, char *,
 					   struct ui_file *);
@@ -51,7 +52,8 @@ extern int
 extern void pascal_printchar (int, struct ui_file *);
 
 extern void pascal_printstr (struct ui_file *, const gdb_byte *,
-			     unsigned int, int, int);
+			     unsigned int, int, int,
+			     const struct value_print_options *);
 
 extern struct type **const (pascal_builtin_types[]);
 
@@ -63,15 +65,10 @@ extern void
 extern void
   pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int);
 
-/* These are in cp-valprint.c */
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
 					      CORE_ADDR, struct ui_file *,
-					      int, int, enum val_prettyprint,
+					      int,
+					      const struct value_print_options *,
 					      struct type **, int);
 
 extern int pascal_object_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index bc4fbe1..e074413 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -59,8 +59,8 @@
 int
 pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  int embedded_offset, CORE_ADDR address,
-		  struct ui_file *stream, int format, int deref_ref,
-		  int recurse, enum val_prettyprint pretty)
+		  struct ui_file *stream, int recurse,
+		  const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -80,7 +80,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
@@ -89,23 +89,24 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      && ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_pascal)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->output_format == 0 || options->output_format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
@@ -123,7 +124,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -133,12 +134,13 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -162,7 +164,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      return (0);
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->output_format != 's')
 	    {
 	      fputs_filtered (paddress (addr), stream);
 	    }
@@ -172,11 +174,11 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  if (TYPE_LENGTH (elttype) == 1
 	      && (TYPE_CODE (elttype) == TYPE_CODE_INT
 		  || TYPE_CODE(elttype) == TYPE_CODE_CHAR)
-	      && (format == 0 || format == 's')
+	      && (options->output_format == 0 || options->output_format == 's')
 	      && addr != 0)
 	    {
 	      /* no wide string yet */
-	      i = val_print_string (addr, -1, 1, stream);
+	      i = val_print_string (addr, -1, 1, stream, options);
 	    }
 	  /* also for pointers to pascal strings */
 	  /* Note: this is Free Pascal specific:
@@ -193,7 +195,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
               read_memory (addr + length_pos, buffer, length_size);
 	      string_length = extract_unsigned_integer (buffer, length_size);
               xfree (buffer);
-              i = val_print_string (addr + string_pos, string_length, char_size, stream);
+              i = val_print_string (addr + string_pos, string_length, char_size, stream, options);
 	    }
 	  else if (pascal_object_is_vtbl_member (type))
 	    {
@@ -209,7 +211,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -230,9 +232,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format, deref_ref,
-				    recurse + 1, pretty, current_language);
-		  if (pretty)
+		  common_val_print (vt_val, stream, recurse + 1, options,
+				    current_language);
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -249,18 +251,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fprintf_filtered (stream, "@");
 	  /* Extract the address, assume that it is unsigned.  */
 	  fputs_filtered (paddress (
 	    extract_unsigned_integer (valaddr + embedded_offset,
 	       gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT)), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -268,8 +270,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse + 1, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse + 1, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -277,14 +279,14 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
 	}
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -301,18 +303,19 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
                                      &string_pos, &char_size, NULL))
 	    {
 	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0, options);
 	    }
 	  else
-	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream, format,
-					      recurse, pretty, NULL, 0);
+	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
+					      recurse, options, NULL, 0);
 	}
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -336,16 +339,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -358,9 +363,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options->output_format, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -387,10 +392,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -399,10 +404,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -417,9 +422,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options->output_format, 0, stream);
 	}
       else
 	{
@@ -517,8 +523,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 }
 \f
 int
-pascal_value_print (struct value *val, struct ui_file *stream, int format,
-		    enum val_prettyprint pretty)
+pascal_value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options)
 {
   struct type *type = value_type (val);
 
@@ -547,19 +553,10 @@ pascal_value_print (struct value *val, struct ui_file *stream, int format,
 	  fprintf_filtered (stream, ") ");
 	}
     }
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  return common_val_print (val, stream, 0, options, current_language);
 }
 
 
-/******************************************************************************
-                    Inserted from cp-valprint
-******************************************************************************/
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-static int pascal_static_field_print;	/* Controls printing of static fields. */
 static void
 show_pascal_static_field_print (struct ui_file *file, int from_tty,
 				struct cmd_list_element *c, const char *value)
@@ -572,12 +569,12 @@ static struct obstack dont_print_vb_obstack;
 static struct obstack dont_print_statmem_obstack;
 
 static void pascal_object_print_static_field (struct value *,
-					      struct ui_file *, int, int,
-					      enum val_prettyprint);
+					      struct ui_file *, int,
+					      const struct value_print_options *);
 
 static void pascal_object_print_value (struct type *, const gdb_byte *,
-				       CORE_ADDR, struct ui_file *,
-				       int, int, enum val_prettyprint,
+				       CORE_ADDR, struct ui_file *, int,
+				       const struct value_print_options *,
 				       struct type **);
 
 /* It was changed to this after 2.4.5.  */
@@ -633,8 +630,8 @@ pascal_object_is_vtbl_member (struct type *type)
 void
 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 				  CORE_ADDR address, struct ui_file *stream,
-				  int format, int recurse,
-				  enum val_prettyprint pretty,
+				  int recurse,
+				  const struct value_print_options *options,
 				  struct type **dont_print_vb,
 				  int dont_print_statmem)
 {
@@ -651,7 +648,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
      duplicates of virtual baseclasses.  */
   if (n_baseclasses > 0)
     pascal_object_print_value (type, valaddr, address, stream,
-			       format, recurse + 1, pretty, dont_print_vb);
+			       recurse + 1, options, dont_print_vb);
 
   if (!len && n_baseclasses == 1)
     fprintf_filtered (stream, "<No data fields>");
@@ -671,14 +668,14 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!pascal_static_field_print
+	  if (!options->pascal_static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 	  if (fields_seen)
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -689,7 +686,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -698,7 +695,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -745,8 +742,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  common_val_print (v, stream, recurse + 1, options,
+				    current_language);
 		}
 	    }
 	  else
@@ -765,8 +762,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  if (v == NULL)
 		    fputs_filtered ("<optimized out>", stream);
 		  else
-		    pascal_object_print_static_field (v, stream, format,
-						      recurse + 1, pretty);
+		    pascal_object_print_static_field (v, stream, recurse + 1,
+						      options);
 		}
 	      else
 		{
@@ -777,7 +774,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, options,
 			     current_language);
 		}
 	    }
@@ -792,7 +789,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -807,8 +804,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 static void
 pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 			   CORE_ADDR address, struct ui_file *stream,
-			   int format, int recurse,
-			   enum val_prettyprint pretty,
+			   int recurse,
+			   const struct value_print_options *options,
 			   struct type **dont_print_vb)
 {
   struct type **last_dont_print
@@ -849,7 +846,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
       boffset = baseclass_offset (type, i, valaddr, address);
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -881,7 +878,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, "<invalid address>");
       else
 	pascal_object_print_value_fields (baseclass, base_valaddr, address + boffset,
-					  stream, format, recurse, pretty,
+					  stream, recurse, options,
 		     (struct type **) obstack_base (&dont_print_vb_obstack),
 					  0);
       fputs_filtered (", ", stream);
@@ -912,8 +909,9 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
 static void
 pascal_object_print_static_field (struct value *val,
-				  struct ui_file *stream, int format,
-				  int recurse, enum val_prettyprint pretty)
+				  struct ui_file *stream,
+				  int recurse,
+				  const struct value_print_options *options)
 {
   struct type *type = value_type (val);
 
@@ -942,11 +940,10 @@ pascal_object_print_static_field (struct value *val,
 
       CHECK_TYPEDEF (type);
       pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
-				  stream, format, recurse, pretty, NULL, 1);
+					stream, recurse, options, NULL, 1);
       return;
     }
-  common_val_print (val, stream, format, 0, recurse, pretty,
-		    current_language);
+  common_val_print (val, stream, recurse, options, current_language);
 }
 
 extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototypes */
@@ -955,13 +952,10 @@ void
 _initialize_pascal_valprint (void)
 {
   add_setshow_boolean_cmd ("pascal_static-members", class_support,
-			   &pascal_static_field_print, _("\
+			   &user_print_options.pascal_static_field_print, _("\
 Set printing of pascal static members."), _("\
 Show printing of pascal static members."), NULL,
 			   NULL,
 			   show_pascal_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  pascal_static_field_print = 1;
-
 }
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 021e191..939a923 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -42,6 +42,7 @@
 #include "block.h"
 #include "disasm.h"
 #include "dfp.h"
+#include "valprint.h"
 
 #ifdef TUI
 #include "tui/tui.h"		/* For tui_active et.al.   */
@@ -55,7 +56,6 @@
 #endif
 
 extern int asm_demangle;	/* Whether to demangle syms in asm printouts */
-extern int addressprint;	/* Whether to print hex addresses in HLL " */
 
 struct format_data
   {
@@ -120,13 +120,6 @@ Printing of source filename and line number with <symbol> is %s.\n"),
 
 int current_display_number;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-
-int inspect_it = 0;
-
 struct display
   {
     /* Chain link to next auto-display item.  */
@@ -254,15 +247,15 @@ decode_format (char **string_ptr, int oformat, int osize)
   return val;
 }
 \f
-/* Print value VAL on stream according to FORMAT, a letter or 0.
+/* Print value VAL on stream according to OPTIONS.
    Do not end with a newline.
-   0 means print VAL according to its own type.
    SIZE is the letter for the size of datum being printed.
    This is used to pad hex numbers so they line up.  SIZE is 0
    for print / output and set for examine.  */
 
 static void
-print_formatted (struct value *val, int format, int size,
+print_formatted (struct value *val, int size,
+		 const struct value_print_options *options,
 		 struct ui_file *stream)
 {
   struct type *type = check_typedef (value_type (val));
@@ -273,12 +266,13 @@ print_formatted (struct value *val, int format, int size,
 
   if (size)
     {
-      switch (format)
+      switch (options->output_format)
 	{
 	case 's':
 	  /* FIXME: Need to handle wchar_t's here... */
 	  next_address = VALUE_ADDRESS (val)
-	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
+	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream,
+				options);
 	  return;
 
 	case 'i':
@@ -291,22 +285,19 @@ print_formatted (struct value *val, int format, int size,
 	}
     }
 
-  if (format == 0 || format == 's'
+  if (options->output_format == 0 || options->output_format == 's'
       || TYPE_CODE (type) == TYPE_CODE_REF
       || TYPE_CODE (type) == TYPE_CODE_ARRAY
       || TYPE_CODE (type) == TYPE_CODE_STRING
       || TYPE_CODE (type) == TYPE_CODE_STRUCT
       || TYPE_CODE (type) == TYPE_CODE_UNION
       || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
-    /* If format is 0, use the 'natural' format for that type of
-       value.  If the type is non-scalar, we have to use language
-       rules to print it as a series of scalars.  */
-    value_print (val, stream, format, Val_pretty_default);
+    value_print (val, stream, options);
   else
     /* User specified format, so don't look to the the type to
        tell us what to do.  */
     print_scalar_formatted (value_contents (val), type,
-			    format, size, stream);
+			    options->output_format, size, stream);
 }
 
 /* Return builtin floating point type of same length as TYPE.
@@ -341,13 +332,16 @@ print_scalar_formatted (const void *valaddr, struct type *type,
   LONGEST val_long = 0;
   unsigned int len = TYPE_LENGTH (type);
   enum bfd_endian byte_order = gdbarch_byte_order (current_gdbarch);
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
 
   /* If we get here with a string format, try again without it.  Go
      all the way back to the language printers, which may call us
      again.  */
   if (format == 's')
     {
-      val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default,
+      val_print (type, valaddr, 0, 0, stream, 0, &opts,
 		 current_language);
       return;
     }
@@ -445,10 +439,10 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       if (TYPE_UNSIGNED (type))
 	value_print (value_from_longest (builtin_type_true_unsigned_char,
 					 val_long),
-		     stream, 0, Val_pretty_default);
+		     stream, &opts);
       else
 	value_print (value_from_longest (builtin_type_true_char, val_long),
-		     stream, 0, Val_pretty_default);
+		     stream, &opts);
       break;
 
     case 'f':
@@ -707,11 +701,13 @@ void
 print_address_demangle (CORE_ADDR addr, struct ui_file *stream,
 			int do_demangle)
 {
+  struct value_print_options opts;
+  get_user_print_options (&opts);
   if (addr == 0)
     {
       fprintf_filtered (stream, "0");
     }
-  else if (addressprint)
+  else if (opts.addressprint)
     {
       fputs_filtered (paddress (addr), stream);
       print_address_symbolic (addr, stream, do_demangle, " ");
@@ -745,6 +741,7 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
   struct type *val_type = NULL;
   int i;
   int maxelts;
+  struct value_print_options opts;
 
   format = fmt.format;
   size = fmt.size;
@@ -775,6 +772,8 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
   if (format == 's' || format == 'i')
     maxelts = 1;
 
+  get_formatted_print_options (&opts, format);
+
   /* Print as many objects as specified in COUNT, at most maxelts per line,
      with the address of the next one at the start of each line.  */
 
@@ -809,7 +808,7 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
 	  if (last_examine_value)
 	    release_value (last_examine_value);
 
-	  print_formatted (last_examine_value, format, size, gdb_stdout);
+	  print_formatted (last_examine_value, size, &opts, gdb_stdout);
 
 	  /* Display any branch delay slots following the final insn.  */
 	  if (format == 'i' && count == 1)
@@ -847,10 +846,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
   struct format_data fmt;
   int cleanup = 0;
 
-  /* Pass inspect flag to the rest of the print routines in a global
-     (sigh).  */
-  inspect_it = inspect;
-
   if (exp && *exp == '/')
     {
       exp++;
@@ -879,6 +874,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
   if (voidprint || (val && value_type (val) &&
 		    TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
     {
+      struct value_print_options opts;
       int histindex = record_latest_value (val);
 
       if (histindex >= 0)
@@ -895,7 +891,10 @@ print_command_1 (char *exp, int inspect, int voidprint)
       if (histindex >= 0)
 	annotate_value_history_value ();
 
-      print_formatted (val, format, fmt.size, gdb_stdout);
+      get_formatted_print_options (&opts, format);
+      opts.inspect_it = inspect;
+
+      print_formatted (val, fmt.size, &opts, gdb_stdout);
       printf_filtered ("\n");
 
       if (histindex >= 0)
@@ -909,7 +908,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
 
   if (cleanup)
     do_cleanups (old_chain);
-  inspect_it = 0;		/* Reset print routines to normal.  */
 }
 
 static void
@@ -942,6 +940,7 @@ output_command (char *exp, int from_tty)
   char format = 0;
   struct value *val;
   struct format_data fmt;
+  struct value_print_options opts;
 
   fmt.size = 0;
 
@@ -960,7 +959,8 @@ output_command (char *exp, int from_tty)
 
   annotate_value_begin (value_type (val));
 
-  print_formatted (val, format, fmt.size, gdb_stdout);
+  get_formatted_print_options (&opts, format);
+  print_formatted (val, fmt.size, &opts, gdb_stdout);
 
   annotate_value_end ();
 
@@ -1507,6 +1507,8 @@ do_one_display (struct display *d)
     }
   else
     {
+      struct value_print_options opts;
+
       annotate_display_format ();
 
       if (d->format.format)
@@ -1521,8 +1523,9 @@ do_one_display (struct display *d)
 
       annotate_display_expression ();
 
+      get_formatted_print_options (&opts, d->format.format);
       print_formatted (evaluate_expression (d->exp),
-		       d->format.format, d->format.size, gdb_stdout);
+		       d->format.size, &opts, gdb_stdout);
       printf_filtered ("\n");
     }
 
@@ -1677,8 +1680,10 @@ print_variable_value (struct symbol *var, struct frame_info *frame,
 		      struct ui_file *stream)
 {
   struct value *val = read_var_value (var, frame);
+  struct value_print_options opts;
 
-  value_print (val, stream, 0, Val_pretty_default);
+  get_user_print_options (&opts);
+  value_print (val, stream, &opts);
 }
 
 static void
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 6c4be54..aff323a 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -23,6 +23,7 @@
 #include "exceptions.h"
 #include "language.h"
 #include "dfp.h"
+#include "valprint.h"
 
 /* List of all values which are currently exposed to Python. It is
    maintained so that when an objfile is discarded, preserve_values
@@ -187,15 +188,17 @@ valpy_str (PyObject *self)
   struct ui_file *stb;
   struct cleanup *old_chain;
   PyObject *result;
+  struct value_print_options opts;
   volatile struct gdb_exception except;
 
+  get_user_print_options (&opts);
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
-      common_val_print (((value_object *) self)->value, stb, 0, 0, 0,
-			Val_pretty_default, current_language);
+      common_val_print (((value_object *) self)->value, stb, 0,
+			&opts, current_language);
       s = ui_file_xstrdup (stb, &dummy);
     }
   GDB_PY_HANDLE_EXCEPTION (except);
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 42d2502..0b25590 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -50,7 +50,8 @@ scm_printchar (int c, struct ui_file *stream)
 
 static void
 scm_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
   fprintf_filtered (stream, "\"%s\"", string);
 }
diff --git a/gdb/scm-lang.h b/gdb/scm-lang.h
index 654095c..369905b 100644
--- a/gdb/scm-lang.h
+++ b/gdb/scm-lang.h
@@ -46,16 +46,16 @@
 struct value;
 
 extern int scm_value_print (struct value *, struct ui_file *,
-			    int, enum val_prettyprint);
+			    const struct value_print_options *);
 
 extern int scm_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			  struct ui_file *, int, int, int,
-			  enum val_prettyprint);
+			  struct ui_file *, int,
+			  const struct value_print_options *);
 
 extern LONGEST scm_get_field (LONGEST, int);
 
-extern void scm_scmval_print (LONGEST, struct ui_file *, int, int, int,
-			      enum val_prettyprint);
+extern void scm_scmval_print (LONGEST, struct ui_file *, int,
+			      const struct value_print_options *);
 
 extern int is_scmvalue_type (struct type *);
 
diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
index feb43dd..bf2e907 100644
--- a/gdb/scm-valprint.c
+++ b/gdb/scm-valprint.c
@@ -33,18 +33,18 @@
 #include "objfiles.h"
 
 static void scm_ipruk (char *, LONGEST, struct ui_file *);
-static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
-static int scm_inferior_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
+static void scm_scmlist_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
+static int scm_inferior_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
 
 /* Prints the SCM value VALUE by invoking the inferior, if appropraite.
    Returns >= 0 on success;  return -1 if the inferior cannot/should not
    print VALUE. */
 
 static int
-scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_inferior_print (LONGEST value, struct ui_file *stream,
+		    int recurse, const struct value_print_options *options)
 {
   struct objfile *objf;
   struct gdbarch *gdbarch;
@@ -129,17 +129,16 @@ static char *scm_isymnames[] =
 };
 
 static void
-scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int recurse,
+		   const struct value_print_options *options)
 {
-  unsigned int more = print_max;
+  unsigned int more = options->print_max;
   if (recurse > 6)
     {
       fputs_filtered ("...", stream);
       return;
     }
-  scm_scmval_print (SCM_CAR (svalue), stream, format,
-		    deref_ref, recurse + 1, pretty);
+  scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
   svalue = SCM_CDR (svalue);
   for (; SCM_NIMP (svalue); svalue = SCM_CDR (svalue))
     {
@@ -151,14 +150,12 @@ scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
 	  fputs_filtered ("...", stream);
 	  return;
 	}
-      scm_scmval_print (SCM_CAR (svalue), stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
     }
   if (SCM_NNULLP (svalue))
     {
       fputs_filtered (" . ", stream);
-      scm_scmval_print (svalue, stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (svalue, stream, recurse + 1, options);
     }
 }
 
@@ -174,15 +171,17 @@ scm_ipruk (char *hdr, LONGEST ptr, struct ui_file *stream)
 }
 
 void
-scm_scmval_print (LONGEST svalue, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmval_print (LONGEST svalue, struct ui_file *stream,
+		  int recurse, const struct value_print_options *options)
 {
 taloop:
   switch (7 & (int) svalue)
     {
     case 2:
     case 6:
-      print_longest (stream, format ? format : 'd', 1, svalue >> 2);
+      print_longest (stream,
+		     options->output_format ? options->output_format : 'd',
+		     1, svalue >> 2);
       break;
     case 4:
       if (SCM_ICHRP (svalue))
@@ -243,14 +242,12 @@ taloop:
 	case scm_tcs_cons_imcar:
 	case scm_tcs_cons_nimcar:
 	  fputs_filtered ("(", stream);
-	  scm_scmlist_print (svalue, stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (svalue, stream, recurse + 1, options);
 	  fputs_filtered (")", stream);
 	  break;
 	case scm_tcs_closures:
 	  fputs_filtered ("#<CLOSURE ", stream);
-	  scm_scmlist_print (SCM_CODE (svalue), stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (SCM_CODE (svalue), stream, recurse + 1, options);
 	  fputs_filtered (">", stream);
 	  break;
 	case scm_tc7_string:
@@ -261,9 +258,9 @@ taloop:
 	    int done = 0;
 	    int buf_size;
 	    gdb_byte buffer[64];
-	    int truncate = print_max && len > (int) print_max;
+	    int truncate = options->print_max && len > (int) options->print_max;
 	    if (truncate)
-	      len = print_max;
+	      len = options->print_max;
 	    fputs_filtered ("\"", stream);
 	    for (; done < len; done += buf_size)
 	      {
@@ -305,8 +302,8 @@ taloop:
 	      {
 		if (i > 0)
 		  fputs_filtered (" ", stream);
-		scm_scmval_print (scm_get_field (elements, i), stream, format,
-				  deref_ref, recurse + 1, pretty);
+		scm_scmval_print (scm_get_field (elements, i), stream,
+				  recurse + 1, options);
 	      }
 	    fputs_filtered (")", stream);
 	  }
@@ -401,21 +398,19 @@ taloop:
 int
 scm_val_print (struct type *type, const gdb_byte *valaddr,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   if (is_scmvalue_type (type))
     {
       LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
 
-      if (scm_inferior_print (svalue, stream, format,
-			      deref_ref, recurse, pretty) >= 0)
+      if (scm_inferior_print (svalue, stream, recurse, options) >= 0)
 	{
 	}
       else
 	{
-	  scm_scmval_print (svalue, stream, format,
-			    deref_ref, recurse, pretty);
+	  scm_scmval_print (svalue, stream, recurse, options);
 	}
 
       gdb_flush (stream);
@@ -423,15 +418,13 @@ scm_val_print (struct type *type, const gdb_byte *valaddr,
     }
   else
     {
-      return c_val_print (type, valaddr, 0, address, stream, format,
-			  deref_ref, recurse, pretty);
+      return c_val_print (type, valaddr, 0, address, stream, recurse, options);
     }
 }
 
 int
-scm_value_print (struct value *val, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+scm_value_print (struct value *val, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
-  return (common_val_print (val, stream, format, 1, 0, pretty,
-			    current_language));
+  return (common_val_print (val, stream, 0, options, current_language));
 }
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 474d49a..407206d 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -40,6 +40,7 @@
 #include "arch-utils.h"
 #include "regcache.h"
 #include "osabi.h"
+#include "valprint.h"
 
 #include "elf-bfd.h"
 
@@ -2092,6 +2093,7 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
 		  struct frame_info *frame, int regnum)
 {
   unsigned char raw_buffer[MAX_REGISTER_SIZE];
+  struct value_print_options opts;
 
   fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
   print_spaces_filtered (15 - strlen (gdbarch_register_name
@@ -2100,12 +2102,14 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
   /* Get the data in raw format.  */
   if (!frame_register_read (frame, regnum, raw_buffer))
     fprintf_filtered (file, "*value not available*\n");
-      
+
+  get_formatted_print_options (&opts, 'x');
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 'x', 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\t");
+  get_formatted_print_options (&opts, 0);
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 0, 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\n");
 }
 
diff --git a/gdb/stack.c b/gdb/stack.c
index 2c3c0bb..dcff140 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -368,6 +368,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
 	      if (val)
 	        {
                   const struct language_defn *language;
+		  struct value_print_options opts;
 
                   /* Use the appropriate language to display our symbol,
                      unless the user forced the language to a specific
@@ -377,8 +378,9 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
                   else
                     language = current_language;
 
-		  common_val_print (val, stb->stream, 0, 0, 2,
-				    Val_no_prettyprint, language);
+		  get_raw_print_options (&opts);
+		  common_val_print (val, stb->stream, 2,
+				    &opts, language);
 		  ui_out_field_stream (uiout, "value", stb);
 	        }
 	      else
@@ -547,6 +549,8 @@ print_frame_info (struct frame_info *frame, int print_level,
 						      sal.line + 1, 0);
 	  else
 	    {
+	      struct value_print_options opts;
+	      get_user_print_options (&opts);
 	      /* We used to do this earlier, but that is clearly
 		 wrong. This function is used by many different
 		 parts of gdb, including normal_stop in infrun.c,
@@ -555,7 +559,7 @@ print_frame_info (struct frame_info *frame, int print_level,
 		 line. Only the command line really wants this
 		 behavior. Other UIs probably would like the
 		 ability to decide for themselves if it is desired.  */
-	      if (addressprint && mid_statement)
+	      if (opts.addressprint && mid_statement)
 		{
 		  ui_out_field_core_addr (uiout, "addr", get_frame_pc (frame));
 		  ui_out_text (uiout, "\t");
@@ -584,6 +588,7 @@ print_frame (struct frame_info *frame, int print_level,
   enum language funlang = language_unknown;
   struct ui_stream *stb;
   struct cleanup *old_chain, *list_chain;
+  struct value_print_options opts;
 
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -665,7 +670,8 @@ print_frame (struct frame_info *frame, int print_level,
       ui_out_field_fmt_int (uiout, 2, ui_left, "level",
 			    frame_relative_level (frame));
     }
-  if (addressprint)
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     if (get_frame_pc (frame) != sal.pc || !sal.symtab
 	|| print_what == LOC_AND_ADDRESS)
       {
@@ -1405,10 +1411,12 @@ print_block_frame_labels (struct block *b, int *have_default,
       if (SYMBOL_CLASS (sym) == LOC_LABEL)
 	{
 	  struct symtab_and_line sal;
+	  struct value_print_options opts;
 	  sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
 	  values_printed = 1;
 	  fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
-	  if (addressprint)
+	  get_user_print_options (&opts);
+	  if (opts.addressprint)
 	    {
 	      fprintf_filtered (stream, " ");
 	      fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (sym)), stream);
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4f5c56a..4646ab1 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -38,6 +38,7 @@
 #include "dictionary.h"
 #include "observer.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
@@ -67,7 +68,6 @@
 extern void (*deprecated_readline_begin_hook) (char *, ...);
 extern char *(*deprecated_readline_hook) (char *);
 extern void (*deprecated_readline_end_hook) (void);
-extern int addressprint;	/* Print machine addresses? */
 
 /* GDB commands implemented in other modules:
  */  
@@ -434,9 +434,11 @@ trace_command (char *arg, int from_tty)
 static void
 trace_mention (struct tracepoint *tp)
 {
+  struct value_print_options opts;
   printf_filtered ("Tracepoint %d", tp->number);
 
-  if (addressprint || (tp->source_file == NULL))
+  get_user_print_options (&opts);
+  if (opts.addressprint || (tp->source_file == NULL))
     {
       printf_filtered (" at ");
       printf_filtered ("%s", paddress (tp->address));
@@ -467,12 +469,12 @@ tracepoints_info (char *tpnum_exp, int from_tty)
   ALL_TRACEPOINTS (t)
     if (tpnum == -1 || tpnum == t->number)
     {
-      extern int addressprint;	/* Print machine addresses?  */
-
+      struct value_print_options opts;
+      get_user_print_options (&opts);
       if (!found_a_tracepoint++)
 	{
 	  printf_filtered ("Num Enb ");
-	  if (addressprint)
+	  if (opts.addressprint)
 	    {
 	      if (gdbarch_addr_bit (current_gdbarch) <= 32)
 		printf_filtered ("Address    ");
@@ -482,7 +484,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 	  printf_filtered ("PassC StepC What\n");
 	}
       strcpy (wrap_indent, "                           ");
-      if (addressprint)
+      if (opts.addressprint)
 	{
 	  if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	    strcat (wrap_indent, "           ");
@@ -492,7 +494,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 
       printf_filtered ("%-3d %-3s ", t->number,
 		       t->enabled_p ? "y" : "n");
-      if (addressprint)
+      if (opts.addressprint)
 	{
 	  char *tmp;
 
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 44f1a77..edf87cd 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -33,12 +33,9 @@
 #include "cp-abi.h"
 #include "typeprint.h"
 #include "gdb_string.h"
+#include "valprint.h"
 #include <errno.h>
 
-/* For real-type printing in whatis_exp() */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-
 extern void _initialize_typeprint (void);
 
 static void ptype_command (char *, int);
@@ -95,6 +92,7 @@ whatis_exp (char *exp, int show)
   int full = 0;
   int top = -1;
   int using_enc = 0;
+  struct value_print_options opts;
 
   if (exp)
     {
@@ -107,7 +105,8 @@ whatis_exp (char *exp, int show)
 
   type = value_type (val);
 
-  if (objectprint)
+  get_user_print_options (&opts);
+  if (opts.objectprint)
     {
       if (((TYPE_CODE (type) == TYPE_CODE_PTR)
 	   || (TYPE_CODE (type) == TYPE_CODE_REF))
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 99c376f..0cc7e7f 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -60,13 +60,54 @@ static void set_output_radix_1 (int, unsigned);
 
 void _initialize_valprint (void);
 
-/* Maximum number of chars to print for a string pointer value or vector
-   contents, or UINT_MAX for no limit.  Note that "set print elements 0"
-   stores UINT_MAX in print_max, which displays in a show command as
-   "unlimited". */
-
-unsigned int print_max;
 #define PRINT_MAX_DEFAULT 200	/* Start print_max off at this value. */
+
+struct value_print_options user_print_options =
+{
+  Val_pretty_default,		/* pretty */
+  0,				/* prettyprint_arrays */
+  0,				/* prettyprint_structs */
+  0,				/* vtblprint */
+  1,				/* unionprint */
+  1,				/* addressprint */
+  0,				/* objectprint */
+  PRINT_MAX_DEFAULT,		/* print_max */
+  10,				/* repeat_count_threshold */
+  0,				/* output_format */
+  0,				/* stop_print_at_null */
+  0,				/* inspect_it */
+  0,				/* print_array_indexes */
+  0,				/* deref_ref */
+  1,				/* static_field_print */
+  1				/* pascal_static_field_print */
+};
+
+/* Initialize *OPTS to be a copy of the user print options.  */
+void
+get_user_print_options (struct value_print_options *opts)
+{
+  *opts = user_print_options;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+void
+get_raw_print_options (struct value_print_options *opts)
+{  
+  *opts = user_print_options;
+  opts->pretty = Val_no_prettyprint;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+void
+get_formatted_print_options (struct value_print_options *opts,
+			     char format)
+{
+  *opts = user_print_options;
+  opts->output_format = format;
+}
+
 static void
 show_print_max (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -103,7 +144,6 @@ int output_format = 0;
 /* By default we print arrays without printing the index of each element in
    the array.  This behavior can be changed by setting PRINT_ARRAY_INDEXES.  */
 
-static int print_array_indexes = 0;
 static void
 show_print_array_indexes (struct ui_file *file, int from_tty,
 		          struct cmd_list_element *c, const char *value)
@@ -115,7 +155,6 @@ show_print_array_indexes (struct ui_file *file, int from_tty,
    element in an array.  Referenced by the low level language dependent
    print routines. */
 
-unsigned int repeat_count_threshold = 10;
 static void
 show_repeat_count_threshold (struct ui_file *file, int from_tty,
 			     struct cmd_list_element *c, const char *value)
@@ -126,7 +165,6 @@ show_repeat_count_threshold (struct ui_file *file, int from_tty,
 
 /* If nonzero, stops printing of char arrays at first null. */
 
-int stop_print_at_null;
 static void
 show_stop_print_at_null (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -138,7 +176,6 @@ Printing of char arrays to stop at first null char is %s.\n"),
 
 /* Controls pretty printing of structures. */
 
-int prettyprint_structs;
 static void
 show_prettyprint_structs (struct ui_file *file, int from_tty,
 			  struct cmd_list_element *c, const char *value)
@@ -148,7 +185,6 @@ show_prettyprint_structs (struct ui_file *file, int from_tty,
 
 /* Controls pretty printing of arrays.  */
 
-int prettyprint_arrays;
 static void
 show_prettyprint_arrays (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -159,7 +195,6 @@ show_prettyprint_arrays (struct ui_file *file, int from_tty,
 /* If nonzero, causes unions inside structures or other unions to be
    printed. */
 
-int unionprint;			/* Controls printing of nested unions.  */
 static void
 show_unionprint (struct ui_file *file, int from_tty,
 		 struct cmd_list_element *c, const char *value)
@@ -171,7 +206,6 @@ Printing of unions interior to structures is %s.\n"),
 
 /* If nonzero, causes machine addresses to be printed in certain contexts. */
 
-int addressprint;		/* Controls printing of machine addresses */
 static void
 show_addressprint (struct ui_file *file, int from_tty,
 		   struct cmd_list_element *c, const char *value)
@@ -203,17 +237,18 @@ show_addressprint (struct ui_file *file, int from_tty,
 
 int
 val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	   CORE_ADDR address, struct ui_file *stream, int format,
-	   int deref_ref, int recurse, enum val_prettyprint pretty,
+	   CORE_ADDR address, struct ui_file *stream, int recurse,
+	   const struct value_print_options *options,
 	   const struct language_defn *language)
 {
   volatile struct gdb_exception except;
-  volatile enum val_prettyprint real_pretty = pretty;
   int ret = 0;
-
+  struct value_print_options local_opts = *options;
   struct type *real_type = check_typedef (type);
-  if (pretty == Val_pretty_default)
-    real_pretty = prettyprint_structs ? Val_prettyprint : Val_no_prettyprint;
+
+  if (local_opts.pretty == Val_pretty_default)
+    local_opts.pretty = (local_opts.prettyprint_structs
+			 ? Val_prettyprint : Val_no_prettyprint);
 
   QUIT;
 
@@ -231,8 +266,7 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
   TRY_CATCH (except, RETURN_MASK_ERROR)
     {
       ret = language->la_val_print (type, valaddr, embedded_offset, address,
-				    stream, format, deref_ref, recurse,
-				    real_pretty);
+				    stream, recurse, &local_opts);
     }
   if (except.reason < 0)
     fprintf_filtered (stream, _("<error reading variable>"));
@@ -277,8 +311,8 @@ value_check_printable (struct value *val, struct ui_file *stream)
    GDB's value mechanism.  */
 
 int
-common_val_print (struct value *val, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty,
+common_val_print (struct value *val, struct ui_file *stream, int recurse,
+		  const struct value_print_options *options,
 		  const struct language_defn *language)
 {
   if (!value_check_printable (val, stream))
@@ -286,8 +320,7 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
 
   return val_print (value_type (val), value_contents_all (val),
 		    value_embedded_offset (val), VALUE_ADDRESS (val),
-		    stream, format, deref_ref, recurse, pretty,
-		    language);
+		    stream, recurse, options, language);
 }
 
 /* Print the value VAL in C-ish syntax on stream STREAM.
@@ -296,13 +329,13 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
    the number of string bytes printed.  */
 
 int
-value_print (struct value *val, struct ui_file *stream, int format,
-	     enum val_prettyprint pretty)
+value_print (struct value *val, struct ui_file *stream,
+	     const struct value_print_options *options)
 {
   if (!value_check_printable (val, stream))
     return 0;
 
-  return LA_VALUE_PRINT (val, stream, format, pretty);
+  return LA_VALUE_PRINT (val, stream, options);
 }
 
 /* Called by various <lang>_val_print routines to print
@@ -928,15 +961,6 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
     }
 }
 
-/* Return non-zero if the debugger should print the index of each element
-   when printing array values.  */
-
-int
-print_array_indexes_p (void)
-{              
-  return print_array_indexes;
-} 
-
 /* Assuming TYPE is a simple, non-empty array type, compute its upper
    and lower bound.  Save the low bound into LOW_BOUND if not NULL.
    Save the high bound into HIGH_BOUND if not NULL.
@@ -997,18 +1021,18 @@ get_array_bounds (struct type *type, long *low_bound, long *high_bound)
     
 void  
 maybe_print_array_index (struct type *index_type, LONGEST index,
-                         struct ui_file *stream, int format,
-                         enum val_prettyprint pretty)
+                         struct ui_file *stream,
+			 const struct value_print_options *options)
 {
   struct value *index_value;
 
-  if (!print_array_indexes)
+  if (!options->print_array_indexes)
     return; 
     
   index_value = value_from_longest (index_type, index);
 
-  LA_PRINT_ARRAY_INDEX (index_value, stream, format, pretty);
-}   
+  LA_PRINT_ARRAY_INDEX (index_value, stream, options);
+}
 
 /*  Called by various <lang>_val_print routines to print elements of an
    array in the form "<elem1>, <elem2>, <elem3>, ...".
@@ -1022,8 +1046,8 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
 void
 val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 			  CORE_ADDR address, struct ui_file *stream,
-			  int format, int deref_ref,
-			  int recurse, enum val_prettyprint pretty,
+			  int recurse,
+			  const struct value_print_options *options,
 			  unsigned int i)
 {
   unsigned int things_printed = 0;
@@ -1070,11 +1094,11 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 
   annotate_array_section_begin (i, elttype);
 
-  for (; i < len && things_printed < print_max; i++)
+  for (; i < len && things_printed < options->print_max; i++)
     {
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1086,7 +1110,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
       maybe_print_array_index (index_type, i + low_bound_index,
-                               stream, format, pretty);
+                               stream, options);
 
       rep1 = i + 1;
       reps = 1;
@@ -1097,21 +1121,21 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	  ++rep1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt_rep (reps);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  annotate_elt_rep_end ();
 
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	}
       else
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt ();
 	  things_printed++;
 	}
@@ -1173,7 +1197,8 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int *errnoptr
 /* FIXME: Use target_read_string.  */
 
 int
-val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
+val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
+		  const struct value_print_options *options)
 {
   int force_ellipsis = 0;	/* Force ellipsis to be printed if nonzero. */
   int errcode;			/* Errno returned from bad reads. */
@@ -1194,7 +1219,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      because finding the null byte (or available memory) is what actually
      limits the fetch. */
 
-  fetchlimit = (len == -1 ? print_max : min (len, print_max));
+  fetchlimit = (len == -1 ? options->print_max : min (len, options->print_max));
 
   /* Now decide how large of chunks to try to read in one operation.  This
      is also pretty simple.  If LEN >= zero, then we want fetchlimit chars,
@@ -1317,11 +1342,11 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      and then the error message.  */
   if (errcode == 0 || bufptr > buffer)
     {
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fputs_filtered (" ", stream);
 	}
-      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis);
+      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis, options);
     }
 
   if (errcode != 0)
@@ -1494,7 +1519,8 @@ _initialize_valprint (void)
   add_alias_cmd ("p", "print", no_class, 1, &showlist);
   add_alias_cmd ("pr", "print", no_class, 1, &showlist);
 
-  add_setshow_uinteger_cmd ("elements", no_class, &print_max, _("\
+  add_setshow_uinteger_cmd ("elements", no_class,
+			    &user_print_options.print_max, _("\
 Set limit on string chars or array elements to print."), _("\
 Show limit on string chars or array elements to print."), _("\
 \"set print elements 0\" causes there to be no limit."),
@@ -1502,7 +1528,8 @@ Show limit on string chars or array elements to print."), _("\
 			    show_print_max,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("null-stop", no_class, &stop_print_at_null, _("\
+  add_setshow_boolean_cmd ("null-stop", no_class,
+			   &user_print_options.stop_print_at_null, _("\
 Set printing of char arrays to stop at first null char."), _("\
 Show printing of char arrays to stop at first null char."), NULL,
 			   NULL,
@@ -1510,7 +1537,7 @@ Show printing of char arrays to stop at first null char."), NULL,
 			   &setprintlist, &showprintlist);
 
   add_setshow_uinteger_cmd ("repeats", no_class,
-			    &repeat_count_threshold, _("\
+			    &user_print_options.repeat_count_threshold, _("\
 Set threshold for repeated print elements."), _("\
 Show threshold for repeated print elements."), _("\
 \"set print repeats 0\" causes all elements to be individually printed."),
@@ -1518,28 +1545,32 @@ Show threshold for repeated print elements."), _("\
 			    show_repeat_count_threshold,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("pretty", class_support, &prettyprint_structs, _("\
+  add_setshow_boolean_cmd ("pretty", class_support,
+			   &user_print_options.prettyprint_structs, _("\
 Set prettyprinting of structures."), _("\
 Show prettyprinting of structures."), NULL,
 			   NULL,
 			   show_prettyprint_structs,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("union", class_support, &unionprint, _("\
+  add_setshow_boolean_cmd ("union", class_support,
+			   &user_print_options.unionprint, _("\
 Set printing of unions interior to structures."), _("\
 Show printing of unions interior to structures."), NULL,
 			   NULL,
 			   show_unionprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("array", class_support, &prettyprint_arrays, _("\
+  add_setshow_boolean_cmd ("array", class_support,
+			   &user_print_options.prettyprint_arrays, _("\
 Set prettyprinting of arrays."), _("\
 Show prettyprinting of arrays."), NULL,
 			   NULL,
 			   show_prettyprint_arrays,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("address", class_support, &addressprint, _("\
+  add_setshow_boolean_cmd ("address", class_support,
+			   &user_print_options.addressprint, _("\
 Set printing of addresses."), _("\
 Show printing of addresses."), NULL,
 			   NULL,
@@ -1578,15 +1609,8 @@ Use 'show input-radix' or 'show output-radix' to independently show each."),
 	   &showlist);
 
   add_setshow_boolean_cmd ("array-indexes", class_support,
-                           &print_array_indexes, _("\
+                           &user_print_options.print_array_indexes, _("\
 Set printing of array indexes."), _("\
 Show printing of array indexes"), NULL, NULL, show_print_array_indexes,
                            &setprintlist, &showprintlist);
-
-  /* Give people the defaults which they are used to.  */
-  prettyprint_structs = 0;
-  prettyprint_arrays = 0;
-  unionprint = 1;
-  addressprint = 1;
-  print_max = PRINT_MAX_DEFAULT;
 }
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 3b20516..22ec5c8 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -21,45 +21,93 @@
 #ifndef VALPRINT_H
 #define VALPRINT_H
 
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
-extern int prettyprint_structs;	/* Controls pretty printing of structures */
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
+/* This is used to pass formatting options to various value-printing
+   functions.  */
+struct value_print_options
+{
+  /* Pretty-printing control.  */
+  enum val_prettyprint pretty;
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int unionprint;		/* Controls printing of nested unions.  */
-extern int addressprint;	/* Controls pretty printing of addresses.  */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
+  /* Controls pretty printing of arrays.  */
+  int prettyprint_arrays;
 
-extern unsigned int print_max;	/* Max # of chars for strings/vectors */
+  /* Controls pretty printing of structures.  */
+  int prettyprint_structs;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-extern int inspect_it;
+  /* Controls printing of virtual tables.  */
+  int vtblprint;
 
-/* Print repeat counts if there are more than this many repetitions of an
-   element in an array.  Referenced by the low level language dependent
-   print routines. */
-extern unsigned int repeat_count_threshold;
+  /* Controls printing of nested unions.  */
+  int unionprint;
 
-extern int output_format;
+  /* Controls printing of addresses.  */
+  int addressprint;
 
-extern int stop_print_at_null;	/* Stop printing at null char? */
+  /* Controls looking up an object's derived type using what we find
+     in its vtables.  */
+  int objectprint;
+
+  /* Maximum number of chars to print for a string pointer value or vector
+     contents, or UINT_MAX for no limit.  Note that "set print elements 0"
+     stores UINT_MAX in print_max, which displays in a show command as
+     "unlimited". */
+  unsigned int print_max;
+
+  /* Print repeat counts if there are more than this many repetitions
+     of an element in an array.  */
+  unsigned int repeat_count_threshold;
+
+  int output_format;
+
+  /* Stop printing at null character?  */
+  int stop_print_at_null;
+
+  /* True if this value is being printed in an epoch window.  */
+  int inspect_it;
+
+  /* True if we should print the index of each element when printing
+     an array.  */
+  int print_array_indexes;
+
+  /* If nonzero, then dereference references, otherwise just print
+     them like pointers.  */
+  int deref_ref;
+
+  /* If nonzero, print static fields.  */
+  int static_field_print;
+
+  /* If nonzero, print static fields for Pascal.  FIXME: C++ and Java
+     share one flag, why not Pascal too?  */
+  int pascal_static_field_print;
+};
+
+/* The global print options set by the user.  In general this should
+   not be directly accessed, except by set/show commands.  Ordinary
+   code should call get_user_print_options instead.  */
+extern struct value_print_options user_print_options;
+
+/* Initialize *OPTS to be a copy of the user print options.  */
+extern void get_user_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+extern void get_raw_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+extern void get_formatted_print_options (struct value_print_options *opts,
+					 char format);
 
-extern int print_array_indexes_p (void);
- 
 extern int get_array_bounds (struct type *type, long *low_bound,
 			     long *high_bound);
 
 extern void maybe_print_array_index (struct type *index_type, LONGEST index,
-                                     struct ui_file *stream, int format,
-                                     enum val_prettyprint pretty);
+                                     struct ui_file *stream,
+				     const struct value_print_options *options);
 
 extern void val_print_array_elements (struct type *, const gdb_byte *,
 				      CORE_ADDR, struct ui_file *, int,
-				      int, int, enum val_prettyprint,
+				      const struct value_print_options *,
 				      unsigned int);
 
 extern void val_print_type_code_int (struct type *, const gdb_byte *,
diff --git a/gdb/value.c b/gdb/value.c
index 0b530f0..1fa376d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -36,6 +36,7 @@
 #include "block.h"
 #include "dfp.h"
 #include "objfiles.h"
+#include "valprint.h"
 
 #include "python/python.h"
 
@@ -708,9 +709,11 @@ show_values (char *num_exp, int from_tty)
 
   for (i = num; i < num + 10 && i <= value_history_count; i++)
     {
+      struct value_print_options opts;
       val = access_value_history (i);
       printf_filtered (("$%d = "), i);
-      value_print (val, gdb_stdout, 0, Val_pretty_default);
+      get_user_print_options (&opts);
+      value_print (val, gdb_stdout, &opts);
       printf_filtered (("\n"));
     }
 
@@ -969,7 +972,9 @@ show_convenience (char *ignore, int from_tty)
 {
   struct internalvar *var;
   int varseen = 0;
+  struct value_print_options opts;
 
+  get_user_print_options (&opts);
   for (var = internalvars; var; var = var->next)
     {
       if (!varseen)
@@ -978,7 +983,7 @@ show_convenience (char *ignore, int from_tty)
 	}
       printf_filtered (("$%s = "), var->name);
       value_print (value_of_internalvar (var), gdb_stdout,
-		   0, Val_pretty_default);
+		   &opts);
       printf_filtered (("\n"));
     }
   if (!varseen)
diff --git a/gdb/value.h b/gdb/value.h
index f53d333..65fea99 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -32,6 +32,7 @@ struct symbol;
 struct type;
 struct ui_file;
 struct language_defn;
+struct value_print_options;
 
 /* The structure which defines the type of a value.  It should never
    be possible for a program lval value to survive over a call to the
@@ -526,8 +527,8 @@ extern void print_floating (const gdb_byte *valaddr, struct type *type,
 extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
 				    struct ui_file *stream);
 
-extern int value_print (struct value *val, struct ui_file *stream, int format,
-			enum val_prettyprint pretty);
+extern int value_print (struct value *val, struct ui_file *stream,
+			const struct value_print_options *options);
 
 extern void value_print_array_elements (struct value *val,
 					struct ui_file *stream, int format,
@@ -537,19 +538,18 @@ extern struct value *value_release_to_mark (struct value *mark);
 
 extern int val_print (struct type *type, const gdb_byte *valaddr,
 		      int embedded_offset, CORE_ADDR address,
-		      struct ui_file *stream, int format,
-		      int deref_ref, int recurse,
-		      enum val_prettyprint pretty,
+		      struct ui_file *stream, int recurse,
+		      const struct value_print_options *options,
 		      const struct language_defn *language);
 
 extern int common_val_print (struct value *val,
-			     struct ui_file *stream, int format,
-			     int deref_ref, int recurse,
-			     enum val_prettyprint pretty,
+			     struct ui_file *stream, int recurse,
+			     const struct value_print_options *options,
 			     const struct language_defn *language);
 
 extern int val_print_string (CORE_ADDR addr, int len, int width,
-			     struct ui_file *stream);
+			     struct ui_file *stream,
+			     const struct value_print_options *options);
 
 extern void print_variable_value (struct symbol *var,
 				  struct frame_info *frame,
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 15cbd45..a9b6579 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -25,6 +25,7 @@
 #include "wrapper.h"
 #include "gdbcmd.h"
 #include "block.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 #include "gdb_string.h"
@@ -1791,6 +1792,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   struct ui_file *stb;
   struct cleanup *old_chain;
   char *thevalue;
+  struct value_print_options opts;
 
   if (value == NULL)
     return NULL;
@@ -1798,7 +1800,8 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
-  common_val_print (value, stb, format_code[(int) format], 1, 0, 0,
+  get_formatted_print_options (&opts, format_code[(int) format]);
+  common_val_print (value, stb, 0, &opts,
 		    current_language);
   thevalue = ui_file_xstrdup (stb, &dummy);
 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-23  1:02               ` Tom Tromey
@ 2008-10-23 19:50                 ` Ulrich Weigand
  2008-10-23 21:29                   ` Tom Tromey
  0 siblings, 1 reply; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-23 19:50 UTC (permalink / raw)
  To: tromey; +Cc: Joel Brobecker, gdb-patches

Tom Tromey wrote:

> I implemented this, and I fixed the other problems you mentioned.
> The result is appended.  I still haven't tested this or written a
> ChangeLog entry.

Thanks!

> This version reduces the use of user_print_options to the absolute
> minimum.  I don't think this is notably cleaner, but the difference
> isn't extreme.  If we cared, we could make it mildly less ugly by
> having get_user_print_options return its argument.
> 
> I still have a version of the patch without get_user_print_options in
> case you change your mind on this.

I do feel this version is nicer; in particular because it allows for
more flexible implementation of get_user_print_options later on.

I can see that it looks a bit ugly to do get_user_print_options just
to look at, say, the addrprint flag.  But many of those uses might
instead be cleaned up by refactoring like you descibe below ...

My choice would be to just go with what you have now.

> Doing this did point out a couple things:
> 
> * As you mentioned, breakpoint-printing could probably use a small
>   refactoring to give value_print_options arguments to various
>   methods.  I can do this and roll it into this patch if you want;
>   though my first reaction is to leave it as a follow-up patch (or
>   just not do it).  Let me know what you want.

I think that would be nice, but not really important -- this can
certainly be done in a follow-up patch.

> * print_scalar_formatted probably needs an options argument as well.
>   What do you think?  This worries me a little since it is another 47
>   call sites; so it could make the patch even bigger.  Maybe this
>   ought to be a follow-up.

This looks more critical, and could in fact even be a bug: for example,
in the cases where print_scalar_formatted recurses back to val_print,
you now lose the inspect_it setting ...

> Ulrich> OK, I'm fine with this.  However, this means that we'll really have
> Ulrich> to construct the option struct on the fly, we cannot have a global
> Ulrich> struct hold pre-initialized pointers to current_language etc.
> 
> There's always "GCC style":
> 
>     #define current_language user_print_options.language
> 
> Semi-awful.
> 
> Or just s/current_language/user_print_options.current_language/
> everywhere.  This, IMO, is not terrible, aside from its verbosity.

As current_language (and even more so, current_gdbarch) is used in
many places that have nothing whatsoever to do with printing, I don't
think it is a good idea to do that.

If we add language and gdbarch fields to value_print_options,  I
would expect those to be dynamically instantiated by the get_...
functions; either from whatever global holds the "primary" value,
or  -more likely, as those globals really need to go away at
some point-  from arguments to the get_... routines.

(Allowing for dynamic instantiation like this is one reason why
I prefer always using get_... routines instead of just accessing
the global struct.)

> This is related to Joel's patch and to Daniel's question about a
> policy for access to globals.  Before going too far down this road it
> may be worth coming up with an agreement there.

With current_gdbarch and current_language, I think the only clean
long-term solution is for these globals to go away completely.  In
the general case of a multi-arch multi-language inferior they just
don't make sense.   (The same holds IMO for some other pervasively
used globals like current_target and inferior_ptid.)

So the question is really how to handle the transition period
until they are gone -- and my feeling would be that accesses
should be pushed up the stack as far as possible, in general.

> To sum up, once I know how much more I should do, I will implement it
> and then submit the patch for real.  I am not looking forward to
> writing this ChangeLog entry...

One other issue I noticed: the deref_ref flag seems to be handled
incorrectly with your current patch.  It is always 0 in the structs
returned by the get_... routines, and never set to any nonzero value
manually either, as far as I can see.

Apart from that, the patch looked good to me.

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  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:25                     ` Joel Brobecker
  0 siblings, 2 replies; 32+ messages in thread
From: Tom Tromey @ 2008-10-23 21:29 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]

>>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:

Ulrich> My choice would be to just go with what you have now.

Ok.

Tom> * print_scalar_formatted probably needs an options argument as well.
Tom> What do you think?  This worries me a little since it is another 47
Tom> call sites; so it could make the patch even bigger.  Maybe this
Tom> ought to be a follow-up.

Ulrich> This looks more critical, and could in fact even be a bug: for example,
Ulrich> in the cases where print_scalar_formatted recurses back to val_print,
Ulrich> you now lose the inspect_it setting ...

Good point.  I implemented this.  It turned out to be pretty easy;
most of the call sites already had an option structure available.

Ulrich> One other issue I noticed: the deref_ref flag seems to be handled
Ulrich> incorrectly with your current patch.  It is always 0 in the structs
Ulrich> returned by the get_... routines, and never set to any nonzero value
Ulrich> manually either, as far as I can see.

Thanks.  The appended tries to fix this.  I took a behavior-preserving
approach.  I looked at all the val_print-like calls.  If the code
before the patch passed 'deref_ref' to such a call, I ignored it.
Otherwise I made a copy of the options and set deref_ref
appropriately.

In some cases I suspect the previous code is really a "don't care" and
we could just pass through the options.  But, I think that would be
better done by someone more familiar with each call site than I am.

I'll start testing this and writing the ChangeLog entry.

Tom


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: updated patch --]
[-- Type: text/x-patch, Size: 195936 bytes --]

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index cce7da9..9fdd944 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -353,9 +353,9 @@ ada_get_gdb_completer_word_break_characters (void)
 
 static void
 ada_print_array_index (struct value *index_value, struct ui_file *stream,
-                       int format, enum val_prettyprint pretty)
+                       const struct value_print_options *options)
 {
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, " => ");
 }
 
@@ -10100,7 +10100,10 @@ static void
 print_one_exception (enum exception_catchpoint_kind ex,
                      struct breakpoint *b, CORE_ADDR *last_addr)
 { 
-  if (addressprint)
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     {
       annotate_field (4);
       ui_out_field_core_addr (uiout, "addr", b->loc->address);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index ce6be4b..562a867 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -249,11 +249,11 @@ extern void ada_print_type (struct type *, char *, struct ui_file *, int,
                             int);
 
 extern int ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-                          struct ui_file *, int, int, int,
-                          enum val_prettyprint);
+                          struct ui_file *, int,
+			  const struct value_print_options *);
 
-extern int ada_value_print (struct value *, struct ui_file *, int,
-                            enum val_prettyprint);
+extern int ada_value_print (struct value *, struct ui_file *,
+			    const struct value_print_options *);
 
                                 /* Defined in ada-lang.c */
 
@@ -266,7 +266,8 @@ extern void ada_emit_char (int, struct ui_file *, int, int);
 extern void ada_printchar (int, struct ui_file *);
 
 extern void ada_printstr (struct ui_file *, const gdb_byte *,
-			  unsigned int, int, int);
+			  unsigned int, int, int,
+			  const struct value_print_options *);
 
 struct value *ada_convert_actual (struct value *actual,
                                   struct type *formal_type0,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index e2f7740..fefd3da 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -43,18 +43,17 @@ struct ada_val_print_args
   int embedded_offset;
   CORE_ADDR address;
   struct ui_file *stream;
-  int format;
-  int deref_ref;
   int recurse;
-  enum val_prettyprint pretty;
+  const struct value_print_options *options;
 };
 
 static void print_record (struct type *, const gdb_byte *, struct ui_file *,
-			  int, int, enum val_prettyprint);
+			  int, const struct value_print_options *);
 
 static int print_field_values (struct type *, const gdb_byte *,
-			       struct ui_file *, int, int,
-			       enum val_prettyprint, int, struct type *,
+			       struct ui_file *, int,
+			       const struct value_print_options *,
+			       int, struct type *,
 			       const gdb_byte *);
 
 static void adjust_type_signedness (struct type *);
@@ -62,8 +61,8 @@ static void adjust_type_signedness (struct type *);
 static int ada_val_print_stub (void *args0);
 
 static int ada_val_print_1 (struct type *, const gdb_byte *, int, CORE_ADDR,
-			    struct ui_file *, int, int, int,
-			    enum val_prettyprint);
+			    struct ui_file *, int,
+			    const struct value_print_options *);
 \f
 
 /* Make TYPE unsigned if its range of values includes no negatives.  */
@@ -81,13 +80,14 @@ adjust_type_signedness (struct type *type)
    otherwise 0.  */
 
 static int
-print_optional_low_bound (struct ui_file *stream, struct type *type)
+print_optional_low_bound (struct ui_file *stream, struct type *type,
+			  const struct value_print_options *options)
 {
   struct type *index_type;
   long low_bound;
   long high_bound;
 
-  if (print_array_indexes_p ())
+  if (options->print_array_indexes)
     return 0;
 
   if (!get_array_bounds (type, &low_bound, &high_bound))
@@ -145,8 +145,8 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
 static void
 val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 				 int bitoffset, struct ui_file *stream,
-				 int format, int recurse,
-				 enum val_prettyprint pretty)
+				 int recurse,
+				 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -172,14 +172,14 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
   i = 0;
   annotate_array_section_begin (i, elttype);
 
-  while (i < len && things_printed < print_max)
+  while (i < len && things_printed < options->print_max)
     {
       struct value *v0, *v1;
       int i0;
 
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -190,7 +190,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    }
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
-      maybe_print_array_index (index_type, i + low, stream, format, pretty);
+      maybe_print_array_index (index_type, i + low, stream, options);
 
       i0 = i;
       v0 = ada_value_primitive_packed_val (NULL, valaddr,
@@ -210,10 +210,12 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    break;
 	}
 
-      if (i - i0 > repeat_count_threshold)
+      if (i - i0 > options->repeat_count_threshold)
 	{
-	  val_print (elttype, value_contents (v0), 0, 0, stream, format,
-		     0, recurse + 1, pretty, current_language);
+	  struct value_print_options opts = *options;
+	  opts.deref_ref = 0;
+	  val_print (elttype, value_contents (v0), 0, 0, stream,
+		     recurse + 1, &opts, current_language);
 	  annotate_elt_rep (i - i0);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), i - i0);
 	  annotate_elt_rep_end ();
@@ -222,11 +224,13 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
       else
 	{
 	  int j;
+	  struct value_print_options opts = *options;
+	  opts.deref_ref = 0;
 	  for (j = i0; j < i; j += 1)
 	    {
 	      if (j > i0)
 		{
-		  if (prettyprint_arrays)
+		  if (options->prettyprint_arrays)
 		    {
 		      fprintf_filtered (stream, ",\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -237,10 +241,10 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 		    }
 		  wrap_here (n_spaces (2 + 2 * recurse));
 		  maybe_print_array_index (index_type, j + low,
-					   stream, format, pretty);
+					   stream, options);
 		}
-	      val_print (elttype, value_contents (v0), 0, 0, stream, format,
-			 0, recurse + 1, pretty, current_language);
+	      val_print (elttype, value_contents (v0), 0, 0, stream,
+			 recurse + 1, &opts, current_language);
 	      annotate_elt ();
 	    }
 	}
@@ -452,7 +456,8 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 
 static void
 printstr (struct ui_file *stream, const gdb_byte *string,
-	  unsigned int length, int force_ellipses, int type_len)
+	  unsigned int length, int force_ellipses, int type_len,
+	  const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -465,7 +470,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; i += 1)
+  for (i = 0; i < length && things_printed < options->print_max; i += 1)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -491,11 +496,11 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  reps += 1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -507,14 +512,14 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  fputs_filtered ("'", stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -529,7 +534,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
@@ -541,9 +546,10 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 
 void
 ada_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
-  printstr (stream, string, length, force_ellipses, width);
+  printstr (stream, string, length, force_ellipses, width, options);
 }
 
 
@@ -569,8 +575,8 @@ ada_printstr (struct ui_file *stream, const gdb_byte *string,
 int
 ada_val_print (struct type *type, const gdb_byte *valaddr0,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   struct ada_val_print_args args;
   args.type = type;
@@ -578,10 +584,8 @@ ada_val_print (struct type *type, const gdb_byte *valaddr0,
   args.embedded_offset = embedded_offset;
   args.address = address;
   args.stream = stream;
-  args.format = format;
-  args.deref_ref = deref_ref;
   args.recurse = recurse;
-  args.pretty = pretty;
+  args.options = options;
 
   return catch_errors (ada_val_print_stub, &args, NULL, RETURN_MASK_ALL);
 }
@@ -594,8 +598,7 @@ ada_val_print_stub (void *args0)
   struct ada_val_print_args *argsp = (struct ada_val_print_args *) args0;
   return ada_val_print_1 (argsp->type, argsp->valaddr0,
 			  argsp->embedded_offset, argsp->address,
-			  argsp->stream, argsp->format, argsp->deref_ref,
-			  argsp->recurse, argsp->pretty);
+			  argsp->stream, argsp->recurse, argsp->options);
 }
 
 /* Assuming TYPE is a simple array, print the value of this array located
@@ -605,8 +608,8 @@ ada_val_print_stub (void *args0)
 
 static int
 ada_val_print_array (struct type *type, const gdb_byte *valaddr,
-		     CORE_ADDR address, struct ui_file *stream, int format,
-		     int deref_ref, int recurse, enum val_prettyprint pretty)
+		     CORE_ADDR address, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
 {
   struct type *elttype = TYPE_TARGET_TYPE (type);
   unsigned int eltlen;
@@ -623,40 +626,40 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
     len = TYPE_LENGTH (type) / eltlen;
 
   /* For an array of chars, print with string syntax.  */
-  if (ada_is_string_type (type) && (format == 0 || format == 's'))
+  if (ada_is_string_type (type)
+      && (options->output_format == 0 || options->output_format == 's'))
     {
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
         print_spaces_filtered (2 + 2 * recurse, stream);
 
       /* If requested, look for the first null char and only print
          elements up to it.  */
-      if (stop_print_at_null)
+      if (options->stop_print_at_null)
         {
           int temp_len;
 
           /* Look for a NULL char.  */
           for (temp_len = 0;
                (temp_len < len
-                && temp_len < print_max
+                && temp_len < options->print_max
                 && char_at (valaddr, temp_len, eltlen) != 0);
                temp_len += 1);
           len = temp_len;
         }
 
-      printstr (stream, valaddr, len, 0, eltlen);
+      printstr (stream, valaddr, len, 0, eltlen, options);
       result = len;
     }
   else
     {
       fprintf_filtered (stream, "(");
-      print_optional_low_bound (stream, type);
+      print_optional_low_bound (stream, type, options);
       if (TYPE_FIELD_BITSIZE (type, 0) > 0)
         val_print_packed_array_elements (type, valaddr, 0, stream,
-                                         format, recurse, pretty);
+                                         recurse, options);
       else
         val_print_array_elements (type, valaddr, address, stream,
-                                  format, deref_ref, recurse,
-                                  pretty, 0);
+                                  recurse, options, 0);
       fprintf_filtered (stream, ")");
     }
 
@@ -669,8 +672,8 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
 static int
 ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 		 int embedded_offset, CORE_ADDR address,
-		 struct ui_file *stream, int format,
-		 int deref_ref, int recurse, enum val_prettyprint pretty)
+		 struct ui_file *stream, int recurse,
+		 const struct value_print_options *options)
 {
   unsigned int len;
   int i;
@@ -695,8 +698,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	retn = ada_val_print_1 (value_type (val), value_contents (val), 0,
-				VALUE_ADDRESS (val), stream, format,
-				deref_ref, recurse, pretty);
+				VALUE_ADDRESS (val), stream, recurse, options);
       value_free_to_mark (mark);
       return retn;
     }
@@ -709,12 +711,12 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
     {
     default:
       return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
 
     case TYPE_CODE_PTR:
       {
 	int ret = c_val_print (type, valaddr0, embedded_offset, address, 
-			       stream, format, deref_ref, recurse, pretty);
+			       stream, recurse, options);
 	if (ada_is_tag_type (type))
 	  {
 	    struct value *val = 
@@ -778,20 +780,18 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 					    value_from_contents_and_address
 					    (type, valaddr, 0));
 	      return ada_val_print_1 (target_type, value_contents (v), 0, 0,
-				      stream, format, 0, recurse + 1, pretty);
+				      stream, recurse + 1, options);
 	    }
 	  else
 	    return ada_val_print_1 (TYPE_TARGET_TYPE (type),
 				    valaddr0, embedded_offset,
-				    address, stream, format, deref_ref,
-				    recurse, pretty);
+				    address, stream, recurse, options);
 	}
       else
 	{
-	  format = format ? format : output_format;
-	  if (format)
+	  if (options->output_format)
 	    {
-	      print_scalar_formatted (valaddr, type, format, 0, stream);
+	      print_scalar_formatted (valaddr, type, options, 0, stream);
 	    }
           else if (ada_is_system_address_type (type)
 		   && TYPE_OBJFILE (type) != NULL)
@@ -830,9 +830,9 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -860,16 +860,16 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			    format, deref_ref, recurse, pretty);
+			    recurse, options);
       else
 	ada_print_floating (valaddr0 + embedded_offset, type, stream);
       break;
@@ -883,13 +883,13 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	{
-	  print_record (type, valaddr, stream, format, recurse, pretty);
+	  print_record (type, valaddr, stream, recurse, options);
 	  return 0;
 	}
 
     case TYPE_CODE_ARRAY:
-      return ada_val_print_array (type, valaddr, address, stream, format,
-                                  deref_ref, recurse, pretty);
+      return ada_val_print_array (type, valaddr, address, stream,
+				  recurse, options);
 
     case TYPE_CODE_REF:
       /* For references, the debugger is expected to print the value as
@@ -910,8 +910,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
                                 deref_val_int));
               val_print (value_type (deref_val),
                          value_contents (deref_val), 0,
-                         VALUE_ADDRESS (deref_val), stream, format,
-                         deref_ref, recurse + 1, pretty, current_language);
+                         VALUE_ADDRESS (deref_val), stream, recurse + 1,
+			 options, current_language);
             }
           else
             fputs_filtered ("(null)", stream);
@@ -927,8 +927,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 
 static int
 print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options, int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
@@ -941,13 +941,13 @@ print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
       (TYPE_FIELD_TYPE (var_type, which),
        valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
        + TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
-       stream, format, recurse, pretty,
+       stream, recurse, options,
        comma_needed, outer_type, outer_valaddr);
 }
 
 int
-ada_value_print (struct value *val0, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+ada_value_print (struct value *val0, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
   const gdb_byte *valaddr = value_contents (val0);
   CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
@@ -955,6 +955,7 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
     ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);
   struct value *val =
     value_from_contents_and_address (type, valaddr, address);
+  struct value_print_options opts;
 
   /* If it is a pointer, indicate what it points to.  */
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
@@ -984,21 +985,23 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
       return 0;
     }
 
+  opts = *options;
+  opts.deref_ref = 1;
   return (val_print (type, value_contents (val), 0, address,
-		     stream, format, 1, 0, pretty, current_language));
+		     stream, 0, &opts, current_language));
 }
 
 static void
 print_record (struct type *type, const gdb_byte *valaddr,
-	      struct ui_file *stream, int format, int recurse,
-	      enum val_prettyprint pretty)
+	      struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   type = ada_check_typedef (type);
 
   fprintf_filtered (stream, "(");
 
-  if (print_field_values (type, valaddr, stream, format, recurse, pretty,
-			  0, type, valaddr) != 0 && pretty)
+  if (print_field_values (type, valaddr, stream, recurse, options,
+			  0, type, valaddr) != 0 && options->pretty)
     {
       fprintf_filtered (stream, "\n");
       print_spaces_filtered (2 * recurse, stream);
@@ -1023,8 +1026,9 @@ print_record (struct type *type, const gdb_byte *valaddr,
 
 static int
 print_field_values (struct type *type, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options,
+		    int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   int i, len;
@@ -1042,7 +1046,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	    print_field_values (TYPE_FIELD_TYPE (type, i),
 				valaddr
 				+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-				stream, format, recurse, pretty,
+				stream, recurse, options,
 				comma_needed, type, valaddr);
 	  continue;
 	}
@@ -1050,7 +1054,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  comma_needed =
 	    print_variant_part (type, i, valaddr,
-				stream, format, recurse, pretty, comma_needed,
+				stream, recurse, options, comma_needed,
 				outer_type, outer_valaddr);
 	  continue;
 	}
@@ -1059,7 +1063,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, ", ");
       comma_needed = 1;
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1068,7 +1072,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  wrap_here (n_spaces (2 + 2 * recurse));
 	}
-      if (inspect_it)
+      if (options->inspect_it)
 	{
 	  if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 	    fputs_filtered ("\"( ptr \"", stream);
@@ -1107,6 +1111,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	    {
 	      int bit_pos = TYPE_FIELD_BITPOS (type, i);
 	      int bit_size = TYPE_FIELD_BITSIZE (type, i);
+	      struct value_print_options opts;
 
 	      adjust_type_signedness (TYPE_FIELD_TYPE (type, i));
 	      v = ada_value_primitive_packed_val (NULL, valaddr,
@@ -1114,15 +1119,20 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 						  bit_pos % HOST_CHAR_BIT,
 						  bit_size,
 						  TYPE_FIELD_TYPE (type, i));
+	      opts = *options;
+	      opts.deref_ref = 0;
 	      val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0, 0,
-			 stream, format, 0, recurse + 1, pretty,
-			 current_language);
+			 stream, recurse + 1, &opts, current_language);
 	    }
 	}
       else
-	ada_val_print (TYPE_FIELD_TYPE (type, i),
-		       valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-		       0, 0, stream, format, 0, recurse + 1, pretty);
+	{
+	  struct value_print_options opts = *options;
+	  opts.deref_ref = 0;
+	  ada_val_print (TYPE_FIELD_TYPE (type, i),
+			 valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
+			 0, 0, stream, recurse + 1, &opts);
+	}
       annotate_field_end ();
     }
 
diff --git a/gdb/auxv.c b/gdb/auxv.c
index afc7fdd..121a749 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -172,7 +172,6 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 
   while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
     {
-      extern int addressprint;
       const char *name = "???";
       const char *description = "";
       enum { dec, hex, str } flavor = hex;
@@ -240,10 +239,14 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 	  fprintf_filtered (file, "0x%s\n", paddr_nz (val));
 	  break;
 	case str:
-	  if (addressprint)
-	    fprintf_filtered (file, "0x%s", paddr_nz (val));
-	  val_print_string (val, -1, 1, file);
-	  fprintf_filtered (file, "\n");
+	  {
+	    struct value_print_options opts;
+	    get_user_print_options (&opts);
+	    if (opts.addressprint)
+	      fprintf_filtered (file, "0x%s", paddr_nz (val));
+	    val_print_string (val, -1, 1, file, &opts);
+	    fprintf_filtered (file, "\n");
+	  }
 	  break;
 	}
       ++ents;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 180f6c9..01b2990 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -56,6 +56,7 @@
 #include "ada-lang.h"
 #include "top.h"
 #include "wrapper.h"
+#include "valprint.h"
 
 #include "mi/mi-common.h"
 
@@ -283,8 +284,6 @@ breakpoints_always_inserted_mode (void)
 
 void _initialize_breakpoint (void);
 
-extern int addressprint;	/* Print machine addresses? */
-
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
@@ -2259,7 +2258,11 @@ watchpoint_value_print (struct value *val, struct ui_file *stream)
   if (val == NULL)
     fprintf_unfiltered (stream, _("<unreadable>"));
   else
-    value_print (val, stream, 0, Val_pretty_default);
+    {
+      struct value_print_options opts;
+      get_user_print_options (&opts);
+      value_print (val, stream, &opts);
+    }
 }
 
 /* This is the normal print function for a bpstat.  In the future,
@@ -3577,6 +3580,9 @@ print_one_breakpoint_location (struct breakpoint *b,
 
   int header_of_multiple = 0;
   int part_of_multiple = (loc != NULL);
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
 
   gdb_assert (!loc || loc_number != 0);
   /* See comment in print_one_breakpoint concerning
@@ -3640,7 +3646,7 @@ print_one_breakpoint_location (struct breakpoint *b,
   
   /* 5 and 6 */
   strcpy (wrap_indent, "                           ");
-  if (addressprint)
+  if (opts.addressprint)
     {
       if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	strcat (wrap_indent, "           ");
@@ -3672,7 +3678,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	print_expression (b->exp, stb->stream);
@@ -3684,7 +3690,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->dll_pathname == NULL)
@@ -3704,7 +3710,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->exec_pathname != NULL)
@@ -3727,7 +3733,7 @@ print_one_breakpoint_location (struct breakpoint *b,
       case bp_shlib_event:
       case bp_thread_event:
       case bp_overlay_event:
-	if (addressprint)
+	if (opts.addressprint)
 	  {
 	    annotate_field (4);
 	    if (header_of_multiple)
@@ -3933,7 +3939,10 @@ breakpoint_1 (int bnum, int allflag)
   CORE_ADDR last_addr = (CORE_ADDR) -1;
   int nr_printable_breakpoints;
   struct cleanup *bkpttbl_chain;
+  struct value_print_options opts;
   
+  get_user_print_options (&opts);
+
   /* Compute the number of rows in the table. */
   nr_printable_breakpoints = 0;
   ALL_BREAKPOINTS (b)
@@ -3944,7 +3953,7 @@ breakpoint_1 (int bnum, int allflag)
 	  nr_printable_breakpoints++;
       }
 
-  if (addressprint)
+  if (opts.addressprint)
     bkpttbl_chain 
       = make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
                                              "BreakpointTable");
@@ -3967,7 +3976,7 @@ breakpoint_1 (int bnum, int allflag)
   if (nr_printable_breakpoints > 0)
     annotate_field (3);
   ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb");	/* 4 */
-  if (addressprint)
+  if (opts.addressprint)
 	{
 	  if (nr_printable_breakpoints > 0)
 	    annotate_field (4);
@@ -4760,10 +4769,14 @@ print_it_catch_fork (struct breakpoint *b)
 static void
 print_one_catch_fork (struct breakpoint *b, CORE_ADDR *last_addr)
 {
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
+
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (opts.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "fork");
@@ -4838,10 +4851,13 @@ print_it_catch_vfork (struct breakpoint *b)
 static void
 print_one_catch_vfork (struct breakpoint *b, CORE_ADDR *last_addr)
 {
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (opts.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "vfork");
@@ -5072,6 +5088,9 @@ mention (struct breakpoint *b)
   int say_where = 0;
   struct cleanup *old_chain, *ui_out_chain;
   struct ui_stream *stb;
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
 
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -5184,7 +5203,7 @@ mention (struct breakpoint *b)
 	}
       else
 	{
-	  if (addressprint || b->source_file == NULL)
+	  if (opts.addressprint || b->source_file == NULL)
 	    {
 	      printf_filtered (" at ");
 	      fputs_filtered (paddress (b->loc->address), gdb_stdout);
@@ -6746,7 +6765,9 @@ print_exception_catchpoint (struct breakpoint *b)
 static void
 print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
 {
-  if (addressprint)
+  struct value_print_options opts;
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     {
       annotate_field (4);
       if (b->loc == NULL || b->loc->shlib_disabled)
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a978b17..067e429 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -86,7 +86,8 @@ c_printchar (int c, struct ui_file *stream)
 
 void
 c_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -108,7 +109,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -137,11 +138,11 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -150,14 +151,14 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  LA_PRINT_CHAR (current_char, stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -171,7 +172,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index fe1939a..cc9abde 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -40,11 +40,11 @@ extern void c_print_type (struct type *, char *, struct ui_file *, int,
 extern void c_print_typedef (struct type *, struct symbol *, struct ui_file *);
 
 extern int c_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 /* These are in c-lang.c: */
 
@@ -52,7 +52,8 @@ extern void c_printchar (int, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, const gdb_byte *string,
 			unsigned int length, int width,
-			int force_ellipses);
+			int force_ellipses,
+			const struct value_print_options *options);
 
 extern void scan_macro_expansion (char *expansion);
 extern int scanning_macro_expansion (void);
@@ -70,17 +71,13 @@ extern void c_type_print_base (struct type *, struct ui_file *, int, int);
 
 /* These are in cp-valprint.c */
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void cp_print_class_member (const gdb_byte *, struct type *,
 				   struct ui_file *, char *);
 
 extern void cp_print_value_fields (struct type *, struct type *,
 				   const gdb_byte *, int, CORE_ADDR,
 				   struct ui_file *, int,
-				   int, enum val_prettyprint,
+				   const struct value_print_options *,
 				   struct type **, int);
 
 extern int cp_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 1dff6cb..c6babb1 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -36,7 +36,8 @@
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -115,8 +116,8 @@ textual_element_type (struct type *type, char format)
 
 int
 c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -134,29 +135,29 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	{
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
 
 	  /* Print arrays of textual chars with a string syntax.  */
-          if (textual_element_type (elttype, format))
+          if (textual_element_type (elttype, options->output_format))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0, options);
 	      i = len;
 	    }
 	  else
@@ -174,7 +175,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -184,9 +185,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_MEMBERPTR:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
@@ -197,19 +199,20 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
 	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.) */
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	  break;
 	}
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -220,21 +223,24 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
 	    {
 	      /* Try to print what function it points to.  */
-	      print_function_pointer_address (addr, stream);
+	      print_function_pointer_address (addr, stream,
+					      options->addressprint);
 	      /* Return value is irrelevant except for string pointers.  */
 	      return (0);
 	    }
 
-	  if (addressprint)
+	  if (options->addressprint)
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to a textual type, also print the string
 	     pointed to, unless pointer is null.  */
 	  /* FIXME: need to handle wchar_t here... */
 
-	  if (textual_element_type (elttype, format) && addr != 0)
+	  if (textual_element_type (elttype, options->output_format)
+	      && addr != 0)
 	    {
-	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				    options);
 	    }
 	  else if (cp_is_vtbl_member (type))
 	    {
@@ -250,7 +256,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -271,10 +277,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format,
-				    deref_ref, recurse + 1, pretty,
+		  common_val_print (vt_val, stream, recurse + 1, options,
 				    current_language);
-		  if (pretty)
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -291,17 +296,17 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -309,8 +314,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -318,7 +323,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -326,7 +331,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
       /*FIXME: Abstract this away */
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -337,17 +342,18 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + offset, field_type);
 
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	}
       else
-	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
-			       recurse, pretty, NULL, 0);
+	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream,
+			       recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -371,17 +377,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -394,9 +402,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -420,10 +428,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -432,7 +440,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	     Since we don't know whether the value is really intended to
 	     be used as an integer or a character, print the character
 	     equivalent as well.  */
-	  if (textual_element_type (type, format))
+	  if (textual_element_type (type, options->output_format))
 	    {
 	      fputs_filtered (" ", stream);
 	      LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
@@ -442,10 +450,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -460,9 +468,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -471,8 +480,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_DECFLOAT:
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options, 0, stream);
       else
 	print_decimal_floating (valaddr + embedded_offset, type, stream);
       break;
@@ -493,19 +503,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_COMPLEX:
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset,
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
 			stream);
       fprintf_filtered (stream, " + ");
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset
 				+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options, 0, stream);
       else
 	print_floating (valaddr + embedded_offset
 			+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
@@ -522,11 +532,14 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 }
 \f
 int
-c_value_print (struct value *val, struct ui_file *stream, int format,
-	       enum val_prettyprint pretty)
+c_value_print (struct value *val, struct ui_file *stream, 
+	       const struct value_print_options *options)
 {
   struct type *type, *real_type;
   int full, top, using_enc;
+  struct value_print_options opts = *options;
+
+  opts.deref_ref = 1;
 
   /* If it is a pointer, indicate what it points to.
 
@@ -551,7 +564,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	{
 	  /* Print nothing */
 	}
-      else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+      else if (options->objectprint
+	       && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
 	{
 
 	  if (TYPE_CODE(type) == TYPE_CODE_REF)
@@ -602,7 +616,7 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   if (!value_initialized (val))
     fprintf_filtered (stream, " [uninitialized] ");
 
-  if (objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
+  if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
     {
       /* Attempt to determine real type of object */
       real_type = value_rtti_type (val, &full, &top, &using_enc);
@@ -616,8 +630,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	  /* Print out object: enclosing type is same as real_type if full */
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    &opts, current_language);
           /* Note: When we look up RTTI entries, we don't get any information on
              const or volatile attributes */
 	}
@@ -628,8 +642,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 			    TYPE_NAME (value_enclosing_type (val)));
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    &opts, current_language);
 	}
       /* Otherwise, we end up at the return outside this "if" */
     }
@@ -637,5 +651,5 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   return val_print (type, value_contents_all (val),
 		    value_embedded_offset (val),
 		    VALUE_ADDRESS (val) + value_offset (val),
-		    stream, format, 1, 0, pretty, current_language);
+		    stream, 0, &opts, current_language);
 }
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 61559af..febcfbb 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -38,7 +38,6 @@
 #include "language.h"
 
 /* Controls printing of vtbl's */
-int vtblprint;
 static void
 show_vtblprint (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -50,7 +49,6 @@ Printing of C++ virtual function tables is %s.\n"),
 
 /* Controls looking up an object's derived type using what we find in
    its vtables.  */
-int objectprint;
 static void
 show_objectprint (struct ui_file *file, int from_tty,
 		  struct cmd_list_element *c,
@@ -61,7 +59,6 @@ Printing of object's derived type based on vtable info is %s.\n"),
 		    value);
 }
 
-int static_field_print;		/* Controls printing of static fields. */
 static void
 show_static_field_print (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -77,12 +74,12 @@ static struct obstack dont_print_statmem_obstack;
 extern void _initialize_cp_valprint (void);
 
 static void cp_print_static_field (struct type *, struct value *,
-				   struct ui_file *, int, int,
-				   enum val_prettyprint);
+				   struct ui_file *, int,
+				   const struct value_print_options *);
 
 static void cp_print_value (struct type *, struct type *, const gdb_byte *,
-			    int, CORE_ADDR, struct ui_file *, int, int,
-			    enum val_prettyprint, struct type **);
+			    int, CORE_ADDR, struct ui_file *, int,
+			    const struct value_print_options *, struct type **);
 
 
 /* GCC versions after 2.4.5 use this.  */
@@ -151,9 +148,9 @@ cp_is_vtbl_member (struct type *type)
 void
 cp_print_value_fields (struct type *type, struct type *real_type,
 		       const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		       struct ui_file *stream, int format, int recurse,
-		       enum val_prettyprint pretty,
-		       struct type **dont_print_vb,int dont_print_statmem)
+		       struct ui_file *stream, int recurse,
+		       const struct value_print_options *options,
+		       struct type **dont_print_vb, int dont_print_statmem)
 {
   int i, len, n_baseclasses;
   char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
@@ -170,7 +167,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
   if (n_baseclasses > 0)
     cp_print_value (type, real_type, valaddr, offset, address, stream,
-		    format, recurse + 1, pretty, dont_print_vb);
+		    recurse + 1, options, dont_print_vb);
 
   /* Second, print out data fields */
 
@@ -192,7 +189,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!static_field_print
+	  if (!options->static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 
@@ -200,7 +197,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -211,7 +208,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -220,7 +217,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -266,11 +263,13 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  v = value_from_longest
 		    (TYPE_FIELD_TYPE (type, i), 
 		     unpack_field_as_long (type, valaddr + offset, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1, pretty,
+		  common_val_print (v, stream, recurse + 1, &opts,
 				    current_language);
 		}
 	    }
@@ -287,15 +286,16 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		    fputs_filtered ("<optimized out>", stream);
 		  else
 		    cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
-					   stream, format, recurse + 1,
-					   pretty);
+					   stream, recurse + 1, options);
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, &opts,
 			     current_language);
 		}
 	    }
@@ -310,7 +310,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -326,8 +326,9 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 static void
 cp_print_value (struct type *type, struct type *real_type,
 		const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int recurse,
-		enum val_prettyprint pretty, struct type **dont_print_vb)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options,
+		struct type **dont_print_vb)
 {
   struct type **last_dont_print
     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
@@ -402,7 +403,7 @@ cp_print_value (struct type *type, struct type *real_type,
 	base_valaddr = valaddr;
 
       /* now do the printing */
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -419,8 +420,7 @@ cp_print_value (struct type *type, struct type *real_type,
       else
 	cp_print_value_fields (baseclass, thistype, base_valaddr,
 			       thisoffset + boffset, address + boffset,
-			       stream, format,
-			       recurse, pretty,
+			       stream, recurse, options,
 			       ((struct type **)
 				obstack_base (&dont_print_vb_obstack)),
 			       0);
@@ -454,10 +454,10 @@ static void
 cp_print_static_field (struct type *type,
 		       struct value *val,
 		       struct ui_file *stream,
-		       int format,
 		       int recurse,
-		       enum val_prettyprint pretty)
+		       const struct value_print_options *options)
 {
+  struct value_print_options opts;
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
       CORE_ADDR *first_dont_print;
@@ -485,12 +485,15 @@ cp_print_static_field (struct type *type,
       CHECK_TYPEDEF (type);
       cp_print_value_fields (type, type, value_contents_all (val),
 			     value_embedded_offset (val), VALUE_ADDRESS (val),
-			     stream, format, recurse, pretty, NULL, 1);
+			     stream, recurse, options, NULL, 1);
       return;
     }
+
+  opts = *options;
+  opts.deref_ref = 0;
   val_print (type, value_contents_all (val), 
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stream, format, 0, recurse, pretty, current_language);
+	     stream, recurse, &opts, current_language);
 }
 
 
@@ -589,32 +592,29 @@ void
 _initialize_cp_valprint (void)
 {
   add_setshow_boolean_cmd ("static-members", class_support,
-			   &static_field_print, _("\
+			   &user_print_options.static_field_print, _("\
 Set printing of C++ static members."), _("\
 Show printing of C++ static members."), NULL,
 			   NULL,
 			   show_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  static_field_print = 1;
 
-  add_setshow_boolean_cmd ("vtbl", class_support, &vtblprint, _("\
+  add_setshow_boolean_cmd ("vtbl", class_support,
+			   &user_print_options.vtblprint, _("\
 Set printing of C++ virtual function tables."), _("\
 Show printing of C++ virtual function tables."), NULL,
 			   NULL,
 			   show_vtblprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("object", class_support, &objectprint, _("\
+  add_setshow_boolean_cmd ("object", class_support,
+			   &user_print_options.objectprint, _("\
 Set printing of object's derived type based on vtable info."), _("\
 Show printing of object's derived type based on vtable info."), NULL,
 			   NULL,
 			   show_objectprint,
 			   &setprintlist, &showprintlist);
 
-  /* Give people the defaults which they are used to.  */
-  objectprint = 0;
-  vtblprint = 0;
   obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
   obstack_specify_allocation (&dont_print_statmem_obstack,
 			      32 * sizeof (CORE_ADDR), sizeof (CORE_ADDR),
diff --git a/gdb/eval.c b/gdb/eval.c
index cf3e876..4394aa1 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -39,16 +39,13 @@
 #include "exceptions.h"
 #include "regcache.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 
 /* This is defined in valops.c */
 extern int overload_resolution;
 
-/* JYG: lookup rtti type of STRUCTOP_PTR when this is set to continue
-   on with successful lookup for member/method of the rtti type. */
-extern int objectprint;
-
 /* Prototypes for local functions. */
 
 static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
@@ -1628,8 +1625,10 @@ evaluate_subexp_standard (struct type *expect_type,
         struct type *type = value_type (arg1);
         struct type *real_type;
         int full, top, using_enc;
-        
-        if (objectprint && TYPE_TARGET_TYPE(type) &&
+	struct value_print_options opts;
+
+	get_user_print_options (&opts);
+        if (opts.objectprint && TYPE_TARGET_TYPE(type) &&
             (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
           {
             real_type = value_rtti_target_type (arg1, &full, &top, &using_enc);
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 079f2a9..756a02e 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -31,6 +31,7 @@
 #include "block.h"
 #include "objfiles.h"
 #include "gdb_assert.h"
+#include "valprint.h"
 
 #ifdef HAVE_CTYPE_H
 #include <ctype.h>
@@ -92,17 +93,25 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_LONG:
-      (*pos) += 3;
-      value_print (value_from_longest (exp->elts[pc + 1].type,
-				       exp->elts[pc + 2].longconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_longest (exp->elts[pc + 1].type,
+					 exp->elts[pc + 2].longconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_DOUBLE:
-      (*pos) += 3;
-      value_print (value_from_double (exp->elts[pc + 1].type,
-				      exp->elts[pc + 2].doubleconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_double (exp->elts[pc + 1].type,
+					exp->elts[pc + 2].doubleconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_VAR_VALUE:
@@ -169,12 +178,17 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_STRING:
-      nargs = longest_to_int (exp->elts[pc + 1].longconst);
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
-      /* LA_PRINT_STRING will print using the current repeat count threshold.
-         If necessary, we can temporarily set it to zero, or pass it as an
-         additional parameter to LA_PRINT_STRING.  -fnf */
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+      {
+	struct value_print_options opts;
+	nargs = longest_to_int (exp->elts[pc + 1].longconst);
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+	/* LA_PRINT_STRING will print using the current repeat count threshold.
+	   If necessary, we can temporarily set it to zero, or pass it as an
+	   additional parameter to LA_PRINT_STRING.  -fnf */
+	get_user_print_options (&opts);
+	LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+			 &opts);
+      }
       return;
 
     case OP_BITSTRING:
@@ -185,11 +199,16 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_OBJC_NSSTRING:	/* Objective-C Foundation Class NSString constant.  */
-      nargs = longest_to_int (exp->elts[pc + 1].longconst);
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
-      fputs_filtered ("@\"", stream);
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
-      fputs_filtered ("\"", stream);
+      {
+	struct value_print_options opts;
+	nargs = longest_to_int (exp->elts[pc + 1].longconst);
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+	fputs_filtered ("@\"", stream);
+	get_user_print_options (&opts);
+	LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+			 &opts);
+	fputs_filtered ("\"", stream);
+      }
       return;
 
     case OP_OBJC_MSGCALL:
@@ -270,7 +289,10 @@ print_subexp_standard (struct expression *exp, int *pos,
 	}
       if (tem > 0)
 	{
-	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
+	  struct value_print_options opts;
+	  get_user_print_options (&opts);
+	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
+			   &opts);
 	  (*pos) = pc;
 	}
       else
@@ -394,6 +416,8 @@ print_subexp_standard (struct expression *exp, int *pos,
       if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
 	  exp->elts[pc + 3].opcode == OP_LONG)
 	{
+	  struct value_print_options opts;
+
 	  /* We have a minimal symbol fn, probably.  It's encoded
 	     as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
 	     Swallow the OP_LONG (including both its opcodes); ignore
@@ -401,7 +425,8 @@ print_subexp_standard (struct expression *exp, int *pos,
 	  (*pos) += 4;
 	  val = value_at_lazy (exp->elts[pc + 1].type,
 			       (CORE_ADDR) exp->elts[pc + 5].longconst);
-	  value_print (val, stream, 0, Val_no_prettyprint);
+	  get_raw_print_options (&opts);
+	  value_print (val, stream, &opts);
 	}
       else
 	{
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 736d6c6..4d4d4d7 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -142,7 +142,8 @@ f_printchar (int c, struct ui_file *stream)
 
 static void
 f_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -155,7 +156,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -179,11 +180,11 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -192,14 +193,14 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  f_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -213,7 +214,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
@@ -305,8 +306,8 @@ f_language_arch_info (struct gdbarch *gdbarch,
 
 /* This is declared in c-lang.h but it is silly to import that file for what
    is already just a hack. */
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 const struct language_defn f_language_defn =
 {
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 252d25d..3b3487e 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -29,8 +29,8 @@ extern void f_print_type (struct type *, char *, struct ui_file *, int,
 			  int);
 
 extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
 /* Language-specific data structures */
 
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 672e95c..81623f4 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -164,42 +164,42 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
 static void
 f77_print_array_1 (int nss, int ndimensions, struct type *type,
 		   const gdb_byte *valaddr, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty,
+		   struct ui_file *stream, int recurse,
+		   const struct value_print_options *options,
 		   int *elts)
 {
   int i;
 
   if (nss != ndimensions)
     {
-      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++)
+      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++)
 	{
 	  fprintf_filtered (stream, "( ");
 	  f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
 			     valaddr + i * F77_DIM_OFFSET (nss),
 			     address + i * F77_DIM_OFFSET (nss),
-			     stream, format, deref_ref, recurse, pretty, elts);
+			     stream, recurse, options, elts);
 	  fprintf_filtered (stream, ") ");
 	}
-      if (*elts >= print_max && i < F77_DIM_SIZE (nss)) 
+      if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) 
 	fprintf_filtered (stream, "...");
     }
   else
     {
-      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < print_max; 
+      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
 	   i++, (*elts)++)
 	{
 	  val_print (TYPE_TARGET_TYPE (type),
 		     valaddr + i * F77_DIM_OFFSET (ndimensions),
 		     0,
 		     address + i * F77_DIM_OFFSET (ndimensions),
-		     stream, format, deref_ref, recurse, pretty,
-		     current_language);
+		     stream, recurse, options, current_language);
 
 	  if (i != (F77_DIM_SIZE (nss) - 1))
 	    fprintf_filtered (stream, ", ");
 
-	  if ((*elts == print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1)))
+	  if ((*elts == options->print_max - 1)
+	      && (i != (F77_DIM_SIZE (nss) - 1)))
 	    fprintf_filtered (stream, "...");
 	}
     }
@@ -211,8 +211,7 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
 static void
 f77_print_array (struct type *type, const gdb_byte *valaddr,
 		 CORE_ADDR address, struct ui_file *stream,
-		 int format, int deref_ref, int recurse,
-		 enum val_prettyprint pretty)
+		 int recurse, const struct value_print_options *options)
 {
   int ndimensions;
   int elts = 0;
@@ -229,8 +228,8 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
 
   f77_create_arrayprint_offset_tbl (type, stream);
 
-  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream, format,
-		     deref_ref, recurse, pretty, &elts);
+  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream,
+		     recurse, options, &elts);
 }
 \f
 
@@ -249,8 +248,8 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
 
 int
 f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *elttype;
@@ -263,20 +262,19 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     {
     case TYPE_CODE_STRING:
       f77_get_dynamic_length_of_aggregate (type);
-      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0);
+      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0, options);
       break;
 
     case TYPE_CODE_ARRAY:
       fprintf_filtered (stream, "(");
-      f77_print_array (type, valaddr, address, stream, format,
-		       deref_ref, recurse, pretty);
+      f77_print_array (type, valaddr, address, stream, recurse, options);
       fprintf_filtered (stream, ")");
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
       else
@@ -292,16 +290,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      return 0;
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->output_format != 's')
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to char or unsigned char, also print the string
 	     pointed to, unless pointer is null.  */
 	  if (TYPE_LENGTH (elttype) == 1
 	      && TYPE_CODE (elttype) == TYPE_CODE_INT
-	      && (format == 0 || format == 's')
+	      && (options->output_format == 0 || options->output_format == 's')
 	      && addr != 0)
-	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				  options);
 
 	  /* Return number of characters printed, including the terminating
 	     '\0' if we reached the end.  val_print_string takes care including
@@ -312,17 +311,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -330,8 +329,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref, recurse,
-				pretty, current_language);
+	      common_val_print (deref_val, stream, recurse,
+				options, current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -339,9 +338,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -354,9 +353,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	{
 	  val_print_type_code_int (type, valaddr, stream);
@@ -374,15 +372,15 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	print_floating (valaddr, type, stream);
       break;
@@ -401,9 +399,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	{
 	  val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
@@ -417,8 +414,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	    {
 	      /* Bash the type code temporarily.  */
 	      TYPE_CODE (type) = TYPE_CODE_INT;
-	      f_val_print (type, valaddr, 0, address, stream, format,
-			   deref_ref, recurse, pretty);
+	      f_val_print (type, valaddr, 0, address, stream, recurse, options);
 	      /* Restore the type code so later uses work as intended. */
 	      TYPE_CODE (type) = TYPE_CODE_BOOL;
 	    }
@@ -450,8 +446,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
         {
           int offset = TYPE_FIELD_BITPOS (type, index) / 8;
           f_val_print (TYPE_FIELD_TYPE (type, index), valaddr + offset,
-                       embedded_offset, address, stream,
-                       format, deref_ref, recurse, pretty);
+                       embedded_offset, address, stream, recurse, options);
           if (index != TYPE_NFIELDS (type) - 1)
             fputs_filtered (", ", stream);
         }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2a41c5b..333eb31 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -28,6 +28,7 @@
 /* Forward declarations for prototypes.  */
 struct field;
 struct block;
+struct value_print_options;
 
 /* Some macros for char-based bitfields.  */
 
@@ -1246,8 +1247,9 @@ extern int field_is_static (struct field *);
 
 /* printcmd.c */
 
-extern void print_scalar_formatted (const void *, struct type *, int, int,
-				    struct ui_file *);
+extern void print_scalar_formatted (const void *, struct type *,
+				    const struct value_print_options *,
+				    int, struct ui_file *);
 
 extern int can_dereference (struct type *);
 
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 4f55c33..5f8e76e 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -51,6 +51,7 @@
 #include "exceptions.h"
 #include "cli/cli-decode.h"
 #include "gdbthread.h"
+#include "valprint.h"
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -1282,6 +1283,8 @@ print_return_value (struct type *func_type, struct type *value_type)
 
   if (value)
     {
+      struct value_print_options opts;
+
       /* Print it.  */
       stb = ui_out_stream_new (uiout);
       old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -1289,7 +1292,8 @@ print_return_value (struct type *func_type, struct type *value_type)
       ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
 			record_latest_value (value));
       ui_out_text (uiout, " = ");
-      value_print (value, stb->stream, 0, Val_no_prettyprint);
+      get_raw_print_options (&opts);
+      value_print (value, stb->stream, &opts);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
       do_cleanups (old_chain);
@@ -1803,9 +1807,12 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	  || TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_DECFLOAT)
 	{
 	  int j;
+	  struct value_print_options opts;
 
+	  get_user_print_options (&opts);
+	  opts.deref_ref = 1;
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 0, 1, 0, Val_pretty_default, current_language);
+		     file, 0, &opts, current_language);
 
 	  fprintf_filtered (file, "\t(raw 0x");
 	  for (j = 0; j < register_size (gdbarch, i); j++)
@@ -1821,16 +1828,23 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	}
       else
 	{
+	  struct value_print_options opts;
+
 	  /* Print the register in hex.  */
+	  get_formatted_print_options (&opts, 'x');
+	  opts.deref_ref = 1;
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 'x', 1, 0, Val_pretty_default, current_language);
+		     file, 0, &opts,
+		     current_language);
           /* If not a vector register, print it also according to its
              natural format.  */
 	  if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
 	    {
+	      get_user_print_options (&opts);
+	      opts.deref_ref = 1;
 	      fprintf_filtered (file, "\t");
 	      val_print (register_type (gdbarch, i), buffer, 0, 0,
-			 file, 0, 1, 0, Val_pretty_default, current_language);
+			 file, 0, &opts, current_language);
 	    }
 	}
 
@@ -1896,12 +1910,14 @@ registers_info (char *addr_exp, int fpregs)
 	    if (regnum >= gdbarch_num_regs (gdbarch)
 			  + gdbarch_num_pseudo_regs (gdbarch))
 	      {
+		struct value_print_options opts;
 		struct value *val = value_of_user_reg (regnum, frame);
 
 		printf_filtered ("%s: ", start);
+		get_formatted_print_options (&opts, 'x');
 		print_scalar_formatted (value_contents (val),
 					check_typedef (value_type (val)),
-					'x', 0, gdb_stdout);
+					&opts, 0, gdb_stdout);
 		printf_filtered ("\n");
 	      }
 	    else
diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h
index 51bada2..04ba383 100644
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -41,11 +41,11 @@ extern struct type *java_double_type;
 extern struct type *java_void_type;
 
 extern int java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			   struct ui_file *, int, int, int,
-			   enum val_prettyprint);
+			   struct ui_file *, int,
+			   const struct value_print_options *);
 
-extern int java_value_print (struct value *, struct ui_file *, int,
-			     enum val_prettyprint);
+extern int java_value_print (struct value *, struct ui_file *,
+			     const struct value_print_options *);
 
 extern struct value *java_class_from_object (struct value *);
 
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 9e36aa4..c364439 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -35,13 +35,14 @@
 /* Local functions */
 
 int
-java_value_print (struct value *val, struct ui_file *stream, int format,
-		  enum val_prettyprint pretty)
+java_value_print (struct value *val, struct ui_file *stream, 
+		  const struct value_print_options *options)
 {
   struct type *type;
   CORE_ADDR address;
   int i;
   char *name;
+  struct value_print_options opts;
 
   type = value_type (val);
   address = VALUE_ADDRESS (val) + value_offset (val);
@@ -89,7 +90,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
 	  address += JAVA_OBJECT_SIZE + 4;	/* Skip object header and length. */
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      gdb_byte *buf;
 
@@ -145,7 +146,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	  VALUE_ADDRESS (v) = address + JAVA_OBJECT_SIZE + 4;
 	  VALUE_ADDRESS (next_v) = VALUE_ADDRESS (v);
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      fputs_filtered (", ", stream);
 	      wrap_here (n_spaces (2));
@@ -180,8 +181,9 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	      else
 		fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
 
-	      common_val_print (v, stream, format, 2, 1, pretty,
-				current_language);
+	      opts = *options;
+	      opts.deref_ref = 1;
+	      common_val_print (v, stream, 1, &opts, current_language);
 
 	      things_printed++;
 	      i += reps;
@@ -203,7 +205,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
       && TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
       && strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)),
 		 "java.lang.String") == 0
-      && (format == 0 || format == 's')
+      && (options->output_format == 0 || options->output_format == 's')
       && address != 0
       && value_as_address (val) != 0)
     {
@@ -228,13 +230,14 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
       value_free_to_mark (mark);	/* Release unnecessary values */
 
-      val_print_string (data + boffset, count, 2, stream);
+      val_print_string (data + boffset, count, 2, stream, options);
 
       return 0;
     }
 
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  opts = *options;
+  opts.deref_ref = 1;
+  return common_val_print (val, stream, 0, &opts, current_language);
 }
 
 /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
@@ -246,7 +249,8 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 static void
 java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 			 CORE_ADDR address, struct ui_file *stream,
-			 int format, int recurse, enum val_prettyprint pretty)
+			 int recurse,
+			 const struct value_print_options *options)
 {
   int i, len, n_baseclasses;
 
@@ -275,7 +279,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 
 	  boffset = 0;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 * (recurse + 1), stream);
@@ -289,7 +293,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  base_valaddr = valaddr;
 
 	  java_print_value_fields (baseclass, base_valaddr, address + boffset,
-				   stream, format, recurse + 1, pretty);
+				   stream, recurse + 1, options);
 	  fputs_filtered (", ", stream);
 	}
 
@@ -307,7 +311,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  if (field_is_static (&TYPE_FIELD (type, i)))
 	    {
 	      char *name = TYPE_FIELD_NAME (type, i);
-	      if (!static_field_print)
+	      if (!options->static_field_print)
 		continue;
 	      if (name != NULL && strcmp (name, "class") == 0)
 		continue;
@@ -316,7 +320,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -327,7 +331,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -336,7 +340,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -380,11 +384,15 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		}
 	      else
 		{
+		  struct value_print_options opts;
+
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  opts = *options;
+		  opts.deref_ref = 0;
+		  common_val_print (v, stream, recurse + 1,
+				    &opts, current_language);
 		}
 	    }
 	  else
@@ -400,28 +408,33 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		    fputs_filtered ("<optimized out>", stream);
 		  else
 		    {
+		      struct value_print_options opts;
 		      struct type *t = check_typedef (value_type (v));
 		      if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
 			v = value_addr (v);
-		      common_val_print (v, stream, format, 0, recurse + 1,
-					pretty, current_language);
+		      opts = *options;
+		      opts.deref_ref = 0;
+		      common_val_print (v, stream, recurse + 1,
+					&opts, current_language);
 		    }
 		}
 	      else if (TYPE_FIELD_TYPE (type, i) == NULL)
 		fputs_filtered ("<unknown type>", stream);
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr + TYPE_FIELD_BITPOS (type, i) / 8, 0,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, &opts,
 			     current_language);
 		}
 	    }
 	  annotate_field_end ();
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -446,8 +459,8 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 int
 java_val_print (struct type *type, const gdb_byte *valaddr,
 		int embedded_offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int deref_ref,
-		int recurse, enum val_prettyprint pretty)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *target_type;
@@ -457,13 +470,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
 #if 0
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -490,7 +503,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
 	  return (0);
 	}
 
-      if (addressprint && format != 's')
+      if (options->addressprint && options->output_format != 's')
 	{
 	  fputs_filtered ("@", stream);
 	  print_longest (stream, 'x', 0, (ULONGEST) addr);
@@ -502,9 +515,8 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
     case TYPE_CODE_INT:
       /* Can't just call c_val_print because that prints bytes as C
 	 chars.  */
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr, type, options, 0, stream);
       else if (TYPE_CODE (type) == TYPE_CODE_CHAR
 	       || (TYPE_CODE (type) == TYPE_CODE_INT
 		   && TYPE_LENGTH (type) == 2
@@ -515,13 +527,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_STRUCT:
-      java_print_value_fields (type, valaddr, address, stream, format,
-			       recurse, pretty);
+      java_print_value_fields (type, valaddr, address, stream, recurse,
+			       options);
       break;
 
     default:
       return c_val_print (type, valaddr, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
     }
 
   return 0;
diff --git a/gdb/language.c b/gdb/language.c
index 121fc55..46e238d 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -72,7 +72,8 @@ static void unk_lang_printchar (int c, struct ui_file *stream);
 static void unk_lang_print_type (struct type *, char *, struct ui_file *,
 				 int, int);
 
-static int unk_lang_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+static int unk_lang_value_print (struct value *, struct ui_file *,
+				 const struct value_print_options *);
 
 static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
 
@@ -1035,10 +1036,10 @@ default_word_break_characters (void)
 
 void
 default_print_array_index (struct value *index_value, struct ui_file *stream,
-                           int format, enum val_prettyprint pretty)
+			   const struct value_print_options *options)
 {
   fprintf_filtered (stream, "[");
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, "] = ");
 }
 
@@ -1070,7 +1071,8 @@ unk_lang_printchar (int c, struct ui_file *stream)
 
 static void
 unk_lang_printstr (struct ui_file *stream, const gdb_byte *string,
-		   unsigned int length, int width, int force_ellipses)
+		   unsigned int length, int width, int force_ellipses,
+		   const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_printstr called."));
 }
@@ -1085,15 +1087,15 @@ unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
 static int
 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
 		    int embedded_offset, CORE_ADDR address,
-		    struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_val_print called."));
 }
 
 static int
-unk_lang_value_print (struct value *val, struct ui_file *stream, int format,
-		      enum val_prettyprint pretty)
+unk_lang_value_print (struct value *val, struct ui_file *stream,
+		      const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_value_print called."));
 }
diff --git a/gdb/language.h b/gdb/language.h
index cc10ff2..c92c57c 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -30,6 +30,7 @@ struct objfile;
 struct frame_info;
 struct expression;
 struct ui_file;
+struct value_print_options;
 
 #define MAX_FORTRAN_DIMS  7	/* Maximum number of F77 array dims */
 
@@ -189,7 +190,8 @@ struct language_defn
 
     void (*la_printstr) (struct ui_file * stream, const gdb_byte *string,
 			 unsigned int length, int width,
-			 int force_ellipses);
+			 int force_ellipses,
+			 const struct value_print_options *);
 
     void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
 
@@ -208,13 +210,13 @@ struct language_defn
     /* Print a value using syntax appropriate for this language. */
 
     int (*la_val_print) (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
     /* Print a top-level value using syntax appropriate for this language. */
 
     int (*la_value_print) (struct value *, struct ui_file *,
-			   int, enum val_prettyprint);
+			   const struct value_print_options *);
 
     /* PC is possibly an unknown languages trampoline.
        If that PC falls in a trampoline belonging to this language,
@@ -274,8 +276,7 @@ struct language_defn
     /* Print the index of an element of an array.  */
     void (*la_print_array_index) (struct value *index_value,
                                   struct ui_file *stream,
-                                  int format,
-                                  enum val_prettyprint pretty);
+                                  const struct value_print_options *options);
 
     /* Return non-zero if TYPE should be passed (and returned) by
        reference at the language level.  */
@@ -366,21 +367,22 @@ extern enum language set_language (enum language);
 #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
   (current_language->la_print_typedef(type,new_symbol,stream))
 
-#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,fmt,deref,recurse,pretty) \
-  (current_language->la_val_print(type,valaddr,offset,addr,stream,fmt,deref, \
-				  recurse,pretty))
-#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
-  (current_language->la_value_print(val,stream,fmt,pretty))
+#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,recurse,options) \
+  (current_language->la_val_print(type,valaddr,offset,addr,stream, \
+				  recurse,options))
+#define LA_VALUE_PRINT(val,stream,options) \
+  (current_language->la_value_print(val,stream,options))
 
 #define LA_PRINT_CHAR(ch, stream) \
   (current_language->la_printchar(ch, stream))
-#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
-  (current_language->la_printstr(stream, string, length, width, force_ellipses))
+#define LA_PRINT_STRING(stream, string, length, width, force_ellipses,options) \
+  (current_language->la_printstr(stream, string, length, width, \
+				 force_ellipses,options))
 #define LA_EMIT_CHAR(ch, stream, quoter) \
   (current_language->la_emitchar(ch, stream, quoter))
 
-#define LA_PRINT_ARRAY_INDEX(index_value, stream, format, pretty) \
-  (current_language->la_print_array_index(index_value, stream, format, pretty))
+#define LA_PRINT_ARRAY_INDEX(index_value, stream, optins) \
+  (current_language->la_print_array_index(index_value, stream, options))
 
 /* Test a character to decide whether it can be printed in literal form
    or needs to be printed in another representation.  For example,
@@ -472,8 +474,7 @@ extern char *default_word_break_characters (void);
 /* Print the index of an array element using the C99 syntax.  */
 extern void default_print_array_index (struct value *index_value,
                                        struct ui_file *stream,
-                                       int format,
-                                       enum val_prettyprint pretty);
+				       const struct value_print_options *options);
 
 /* Return non-zero if TYPE should be passed (and returned) by
    reference at the language level.  */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index ea59403..e09b64b 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -104,7 +104,8 @@ m2_printchar (int c, struct ui_file *stream)
 
 static void
 m2_printstr (struct ui_file *stream, const gdb_byte *string,
-	     unsigned int length, int width, int force_ellipses)
+	     unsigned int length, int width, int force_ellipses,
+	     const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -117,7 +118,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -141,11 +142,11 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -154,14 +155,14 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  m2_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -175,7 +176,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 8ce458c..f99e31a 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -33,8 +33,8 @@ extern int m2_is_long_set (struct type *type);
 extern int m2_is_unbounded_array (struct type *type);
 
 extern int m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
 extern int get_long_set_bounds (struct type *type, LONGEST *low,
 				LONGEST *high);
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 82ff30e..49c34f7 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -30,22 +30,24 @@
 #include "m2-lang.h"
 #include "target.h"
 
-int print_unpacked_pointer (struct type *type,
-			    CORE_ADDR address, CORE_ADDR addr,
-			    int format, struct ui_file *stream);
+static int print_unpacked_pointer (struct type *type,
+				   CORE_ADDR address, CORE_ADDR addr,
+				   const struct value_print_options *options,
+				   struct ui_file *stream);
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len);
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len);
 
 
 /* Print function pointer with inferior address ADDRESS onto stdio
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -88,8 +90,7 @@ get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high)
 static void
 m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   enum val_prettyprint pretty)
+		   struct ui_file *stream)
 {
   int empty_set        = 1;
   int element_seen     = 0;
@@ -184,9 +185,8 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 static void
 m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
 			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int format,
-			  int deref_ref, enum val_prettyprint pretty,
-			  int recurse)
+			  struct ui_file *stream, int recurse,
+			  const struct value_print_options *options)
 {
   struct type *content_type;
   CORE_ADDR addr;
@@ -207,26 +207,27 @@ m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
   fprintf_filtered (stream, "{");  
   m2_print_array_contents (value_type (val), value_contents(val),
 			   value_embedded_offset (val), addr, stream,
-			   format, deref_ref, pretty, recurse, len);
+			   recurse, options, len);
   fprintf_filtered (stream, ", HIGH = %d}", (int) len);
 }
 
-int
+static int
 print_unpacked_pointer (struct type *type,
 			CORE_ADDR address, CORE_ADDR addr,
-			int format, struct ui_file *stream)
+			const struct value_print_options *options,
+			struct ui_file *stream)
 {
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
 
   if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
     {
       /* Try to print what function it points to.  */
-      print_function_pointer_address (addr, stream);
+      print_function_pointer_address (addr, stream, options->addressprint);
       /* Return value is irrelevant except for string pointers.  */
       return 0;
     }
 
-  if (addressprint && format != 's')
+  if (options->addressprint && options->output_format != 's')
     fputs_filtered (paddress (address), stream);
 
   /* For a pointer to char or unsigned char, also print the string
@@ -234,9 +235,9 @@ print_unpacked_pointer (struct type *type,
 
   if (TYPE_LENGTH (elttype) == 1
       && TYPE_CODE (elttype) == TYPE_CODE_INT
-      && (format == 0 || format == 's')
+      && (options->output_format == 0 || options->output_format == 's')
       && addr != 0)
-      return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+    return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options);
   
   return 0;
 }
@@ -244,9 +245,9 @@ print_unpacked_pointer (struct type *type,
 static void
 print_variable_at_address (struct type *type,
 			   const gdb_byte *valaddr,
-			   struct ui_file *stream, int format,
-			   int deref_ref, int recurse,
-			   enum val_prettyprint pretty)
+			   struct ui_file *stream,
+			   int recurse,
+			   const struct value_print_options *options)
 {
   CORE_ADDR addr = unpack_pointer (type, valaddr);
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -259,8 +260,7 @@ print_variable_at_address (struct type *type,
     {
       struct value *deref_val =
 	value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr));
-      common_val_print (deref_val, stream, format, deref_ref,
-			recurse, pretty, current_language);
+      common_val_print (deref_val, stream, recurse, options, current_language);
     }
   else
     fputs_filtered ("???", stream);
@@ -276,9 +276,9 @@ print_variable_at_address (struct type *type,
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len)
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len)
 {
   int eltlen;
   CHECK_TYPEDEF (type);
@@ -286,21 +286,20 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
   if (TYPE_LENGTH (type) > 0)
     {
       eltlen = TYPE_LENGTH (type);
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
 	print_spaces_filtered (2 + 2 * recurse, stream);
       /* For an array of chars, print with string syntax.  */
       if (eltlen == 1 &&
 	  ((TYPE_CODE (type) == TYPE_CODE_INT)
 	   || ((current_language->la_language == language_m2)
 	       && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
-	  && (format == 0 || format == 's'))
-	val_print_string (address, len+1, eltlen, stream);
+	  && (options->output_format == 0 || options->output_format == 's'))
+	val_print_string (address, len+1, eltlen, stream, options);
       else
 	{
 	  fprintf_filtered (stream, "{");
 	  val_print_array_elements (type, valaddr + embedded_offset,
-				    address, stream, format,
-				    deref_ref, recurse, pretty, 0);
+				    address, stream, recurse, options, 0);
 	  fprintf_filtered (stream, "}");
 	}
     }
@@ -322,8 +321,8 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 
 int
 m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int format,
-	      int deref_ref, int recurse, enum val_prettyprint pretty)
+	      CORE_ADDR address, struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -343,74 +342,73 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    print_spaces_filtered (2 + 2 * recurse, stream);
 	  /* For an array of chars, print with string syntax.  */
 	  if (eltlen == 1 &&
 	      ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_m2)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->output_format == 0 || options->output_format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-			 && temp_len < len && temp_len < print_max;
+			 && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
 	    {
 	      fprintf_filtered (stream, "{");
 	      val_print_array_elements (type, valaddr + embedded_offset,
-					address, stream, format, deref_ref,
-					recurse, pretty, 0);
+					address, stream, recurse, options, 0);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
 	}
       /* Array of unspecified length: treat like pointer to first elt.  */
-      print_unpacked_pointer (type, address, address, format, stream);
+      print_unpacked_pointer (type, address, address, options, stream);
       break;
 
     case TYPE_CODE_PTR:
       if (TYPE_CONST (type))
 	print_variable_at_address (type, valaddr + embedded_offset,
-				   stream, format, deref_ref, recurse,
-				   pretty);
-      else if (format && format != 's')
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+				   stream, recurse, options);
+      else if (options->output_format && options->output_format != 's')
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options, 0, stream);
       else
 	{
 	  addr = unpack_pointer (type, valaddr + embedded_offset);
-	  print_unpacked_pointer (type, addr, address, format, stream);
+	  print_unpacked_pointer (type, addr, address, options, stream);
 	}
       break;
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -418,8 +416,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		value_at
 		(TYPE_TARGET_TYPE (type),
 		 unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -427,7 +425,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -436,22 +434,20 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     case TYPE_CODE_STRUCT:
       if (m2_is_long_set (type))
 	m2_print_long_set (type, valaddr, embedded_offset, address,
-			   stream, format, pretty);
+			   stream);
       else if (m2_is_unbounded_array (type))
 	m2_print_unbounded_array (type, valaddr, embedded_offset,
-				  address, stream, format, deref_ref,
-				  pretty, recurse);
+				  address, stream, recurse, options);
       else
 	cp_print_value_fields (type, type, valaddr, embedded_offset,
-			       address, stream, format,
-			       recurse, pretty, NULL, 0);
+			       address, stream, recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -475,10 +471,10 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -491,10 +487,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -511,7 +506,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
 	{
 	  m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset,
-			address, stream, format, deref_ref, recurse, pretty);
+			address, stream, recurse, options);
 	  break;
 	}
       /* FIXME: create_range_type does not set the unsigned bit in a
@@ -524,19 +519,17 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options, 0, stream);
       else
 	val_print_type_code_int (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -550,9 +543,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, type, stream);
       break;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index baf9b6d..33cc890 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -30,6 +30,7 @@
 #include "dictionary.h"
 #include "gdb_string.h"
 #include "language.h"
+#include "valprint.h"
 
 static void list_args_or_locals (int locals, int values, struct frame_info *fi);
 
@@ -280,21 +281,29 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
 		      && TYPE_CODE (type) != TYPE_CODE_STRUCT
 		      && TYPE_CODE (type) != TYPE_CODE_UNION)
 		    {
+		      struct value_print_options opts;
 		      val = read_var_value (sym2, fi);
+		      get_raw_print_options (&opts);
+		      opts.deref_ref = 1;
 		      common_val_print
-			(val, stb->stream, 0, 1, 0, Val_no_prettyprint,
+			(val, stb->stream, 0, &opts,
 			 language_def (SYMBOL_LANGUAGE (sym2)));
 		      ui_out_field_stream (uiout, "value", stb);
 		    }
 		  do_cleanups (cleanup_tuple);
 		  break;
 		case PRINT_ALL_VALUES:
-		  val = read_var_value (sym2, fi);
-		  common_val_print
-		    (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
-		     language_def (SYMBOL_LANGUAGE (sym2)));
-		  ui_out_field_stream (uiout, "value", stb);
-		  do_cleanups (cleanup_tuple);
+		  {
+		    struct value_print_options opts;
+		    val = read_var_value (sym2, fi);
+		    get_raw_print_options (&opts);
+		    opts.deref_ref = 1;
+		    common_val_print
+		      (val, stb->stream, 0, &opts,
+		       language_def (SYMBOL_LANGUAGE (sym2)));
+		    ui_out_field_stream (uiout, "value", stb);
+		    do_cleanups (cleanup_tuple);
+		  }
 		  break;
 		}
 	    }
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 7780207..a9fbcad 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -45,6 +45,7 @@
 #include "frame.h"
 #include "mi-main.h"
 #include "language.h"
+#include "valprint.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -499,9 +500,11 @@ get_register (int regnum, int format)
     }
   else
     {
+      struct value_print_options opts;
+      get_user_print_options (&opts);
+      opts.deref_ref = 1;
       val_print (register_type (current_gdbarch, regnum), buffer, 0, 0,
-		 stb->stream, format, 1, 0, Val_pretty_default,
-		 current_language);
+		 stb->stream, 0, &opts, current_language);
       ui_out_field_stream (uiout, "value", stb);
       ui_out_stream_delete (stb);
     }
@@ -570,6 +573,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   struct cleanup *old_chain = NULL;
   struct value *val;
   struct ui_stream *stb = NULL;
+  struct value_print_options opts;
 
   stb = ui_out_stream_new (uiout);
 
@@ -586,9 +590,11 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   val = evaluate_expression (expr);
 
   /* Print the result of the expression evaluation.  */
+  get_user_print_options (&opts);
+  opts.deref_ref = 0;
   val_print (value_type (val), value_contents (val),
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stb->stream, 0, 0, 0, 0, current_language);
+	     stb->stream, 0, &opts, current_language);
 
   ui_out_field_stream (uiout, "value", stb);
   ui_out_stream_delete (stb);
@@ -743,10 +749,13 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
 	int col_byte;
 	struct cleanup *cleanup_tuple;
 	struct cleanup *cleanup_list_data;
+	struct value_print_options opts;
+
 	cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
 	ui_out_field_core_addr (uiout, "addr", addr + row_byte);
 	/* ui_out_field_core_addr_symbolic (uiout, "saddr", addr + row_byte); */
 	cleanup_list_data = make_cleanup_ui_out_list_begin_end (uiout, "data");
+	get_formatted_print_options (&opts, word_format);
 	for (col = 0, col_byte = row_byte;
 	     col < nr_cols;
 	     col++, col_byte += word_size)
@@ -758,7 +767,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
 	    else
 	      {
 		ui_file_rewind (stream->stream);
-		print_scalar_formatted (mbuf + col_byte, word_type, word_format,
+		print_scalar_formatted (mbuf + col_byte, word_type, &opts,
 					word_asize, stream->stream);
 		ui_out_field_stream (uiout, NULL, stream);
 	      }
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 1babcce..0774266 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -57,6 +57,7 @@
 #include "target-descriptions.h"
 #include "dwarf2-frame.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 static const struct objfile_data *mips_pdr_data;
 
@@ -4378,12 +4379,15 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame,
 
   if (register_size (gdbarch, regnum) == 4 || mips2_fp_compat (frame))
     {
+      struct value_print_options opts;
+
       /* 4-byte registers: Print hex and floating.  Also print even
          numbered registers as doubles.  */
       mips_read_fp_register_single (frame, regnum, raw_buffer);
       flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
 
-      print_scalar_formatted (raw_buffer, builtin_type_uint32, 'x', 'w',
+      get_formatted_print_options (&opts, 'x');
+      print_scalar_formatted (raw_buffer, builtin_type_uint32, &opts, 'w',
 			      file);
 
       fprintf_filtered (file, " flt: ");
@@ -4407,6 +4411,8 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame,
     }
   else
     {
+      struct value_print_options opts;
+
       /* Eight byte registers: print each one as hex, float and double.  */
       mips_read_fp_register_single (frame, regnum, raw_buffer);
       flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
@@ -4414,8 +4420,8 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame,
       mips_read_fp_register_double (frame, regnum, raw_buffer);
       doub = unpack_double (mips_double_register_type (), raw_buffer, &inv2);
 
-
-      print_scalar_formatted (raw_buffer, builtin_type_uint64, 'x', 'g',
+      get_formatted_print_options (&opts, 'x');
+      print_scalar_formatted (raw_buffer, builtin_type_uint64, &opts, 'g',
 			      file);
 
       fprintf_filtered (file, " flt: ");
@@ -4439,6 +4445,7 @@ mips_print_register (struct ui_file *file, struct frame_info *frame,
   struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte raw_buffer[MAX_REGISTER_SIZE];
   int offset;
+  struct value_print_options opts;
 
   if (TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT)
     {
@@ -4471,8 +4478,9 @@ mips_print_register (struct ui_file *file, struct frame_info *frame,
   else
     offset = 0;
 
+  get_formatted_print_options (&opts, 'x');
   print_scalar_formatted (raw_buffer + offset,
-			  register_type (gdbarch, regnum), 'x', 0,
+			  register_type (gdbarch, regnum), &opts, 0,
 			  file);
 }
 
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index da4afe3..db42e90 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -37,6 +37,7 @@
 #include "infcall.h"
 #include "gdb_assert.h"
 #include "language.h"
+#include "valprint.h"
 
 enum mt_arch_constants
 {
@@ -675,6 +676,7 @@ mt_registers_info (struct gdbarch *gdbarch,
 	{
 	  /* Special output handling for the 'coprocessor' register.  */
 	  gdb_byte *buf;
+	  struct value_print_options opts;
 
 	  buf = alloca (register_size (gdbarch, MT_COPRO_REGNUM));
 	  frame_register_read (frame, MT_COPRO_REGNUM, buf);
@@ -685,8 +687,10 @@ mt_registers_info (struct gdbarch *gdbarch,
 	  print_spaces_filtered (15 - strlen (gdbarch_register_name
 					        (gdbarch, regnum)),
 				 file);
+	  get_raw_print_options (&opts);
+	  opts.deref_ref = 1;
 	  val_print (register_type (gdbarch, regnum), buf,
-		     0, 0, file, 0, 1, 0, Val_no_prettyprint,
+		     0, 0, file, 0, &opts,
 		     current_language);
 	  fputs_filtered ("\n", file);
 	}
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 7d287a0..3a952f5 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -341,7 +341,8 @@ objc_printchar (int c, struct ui_file *stream)
 
 static void
 objc_printstr (struct ui_file *stream, const gdb_byte *string, 
-	       unsigned int length, int width, int force_ellipses)
+	       unsigned int length, int width, int force_ellipses,
+	       const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -360,7 +361,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining to see whether it
 	 is repeated.  */
@@ -384,11 +385,11 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -397,14 +398,14 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  objc_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -418,7 +419,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 7ecdd8d..cd4285d 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -207,7 +207,8 @@ pascal_printchar (int c, struct ui_file *stream)
 
 void
 pascal_printstr (struct ui_file *stream, const gdb_byte *string,
-		 unsigned int length, int width, int force_ellipses)
+		 unsigned int length, int width, int force_ellipses,
+		 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -226,7 +227,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -250,11 +251,11 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -263,7 +264,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  pascal_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
@@ -271,7 +272,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  int c = string[i];
 	  if ((!in_quotes) && (PRINT_LITERAL_FORM (c)))
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -285,7 +286,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index a4f878f..4ebfbc1 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -35,10 +35,11 @@ extern void pascal_print_typedef (struct type *, struct symbol *,
 				  struct ui_file *);
 
 extern int pascal_val_print (struct type *, const gdb_byte *, int,
-			     CORE_ADDR, struct ui_file *, int, int,
-			     int, enum val_prettyprint);
+			     CORE_ADDR, struct ui_file *, int,
+			     const struct value_print_options *);
 
-extern int pascal_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+extern int pascal_value_print (struct value *, struct ui_file *,
+			       const struct value_print_options *);
 
 extern void pascal_type_print_method_args (char *, char *,
 					   struct ui_file *);
@@ -51,7 +52,8 @@ extern int
 extern void pascal_printchar (int, struct ui_file *);
 
 extern void pascal_printstr (struct ui_file *, const gdb_byte *,
-			     unsigned int, int, int);
+			     unsigned int, int, int,
+			     const struct value_print_options *);
 
 extern struct type **const (pascal_builtin_types[]);
 
@@ -63,15 +65,10 @@ extern void
 extern void
   pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int);
 
-/* These are in cp-valprint.c */
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
 					      CORE_ADDR, struct ui_file *,
-					      int, int, enum val_prettyprint,
+					      int,
+					      const struct value_print_options *,
 					      struct type **, int);
 
 extern int pascal_object_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index bc4fbe1..2add30a 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -59,8 +59,8 @@
 int
 pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  int embedded_offset, CORE_ADDR address,
-		  struct ui_file *stream, int format, int deref_ref,
-		  int recurse, enum val_prettyprint pretty)
+		  struct ui_file *stream, int recurse,
+		  const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -80,7 +80,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
@@ -89,23 +89,24 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      && ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_pascal)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->output_format == 0 || options->output_format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
@@ -123,7 +124,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -133,12 +134,13 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->output_format && options->output_format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -162,7 +164,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      return (0);
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->output_format != 's')
 	    {
 	      fputs_filtered (paddress (addr), stream);
 	    }
@@ -172,11 +174,11 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  if (TYPE_LENGTH (elttype) == 1
 	      && (TYPE_CODE (elttype) == TYPE_CODE_INT
 		  || TYPE_CODE(elttype) == TYPE_CODE_CHAR)
-	      && (format == 0 || format == 's')
+	      && (options->output_format == 0 || options->output_format == 's')
 	      && addr != 0)
 	    {
 	      /* no wide string yet */
-	      i = val_print_string (addr, -1, 1, stream);
+	      i = val_print_string (addr, -1, 1, stream, options);
 	    }
 	  /* also for pointers to pascal strings */
 	  /* Note: this is Free Pascal specific:
@@ -193,7 +195,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
               read_memory (addr + length_pos, buffer, length_size);
 	      string_length = extract_unsigned_integer (buffer, length_size);
               xfree (buffer);
-              i = val_print_string (addr + string_pos, string_length, char_size, stream);
+              i = val_print_string (addr + string_pos, string_length, char_size, stream, options);
 	    }
 	  else if (pascal_object_is_vtbl_member (type))
 	    {
@@ -209,7 +211,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -230,9 +232,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format, deref_ref,
-				    recurse + 1, pretty, current_language);
-		  if (pretty)
+		  common_val_print (vt_val, stream, recurse + 1, options,
+				    current_language);
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -249,18 +251,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fprintf_filtered (stream, "@");
 	  /* Extract the address, assume that it is unsigned.  */
 	  fputs_filtered (paddress (
 	    extract_unsigned_integer (valaddr + embedded_offset,
 	       gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT)), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -268,8 +270,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse + 1, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse + 1, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -277,14 +279,14 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
 	}
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -301,18 +303,19 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
                                      &string_pos, &char_size, NULL))
 	    {
 	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0, options);
 	    }
 	  else
-	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream, format,
-					      recurse, pretty, NULL, 0);
+	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
+					      recurse, options, NULL, 0);
 	}
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -336,16 +339,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -358,9 +363,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->output_format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options, 0, stream);
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -387,10 +392,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -399,10 +404,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -417,9 +422,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -517,8 +523,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 }
 \f
 int
-pascal_value_print (struct value *val, struct ui_file *stream, int format,
-		    enum val_prettyprint pretty)
+pascal_value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options)
 {
   struct type *type = value_type (val);
 
@@ -547,19 +553,10 @@ pascal_value_print (struct value *val, struct ui_file *stream, int format,
 	  fprintf_filtered (stream, ") ");
 	}
     }
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  return common_val_print (val, stream, 0, options, current_language);
 }
 
 
-/******************************************************************************
-                    Inserted from cp-valprint
-******************************************************************************/
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-static int pascal_static_field_print;	/* Controls printing of static fields. */
 static void
 show_pascal_static_field_print (struct ui_file *file, int from_tty,
 				struct cmd_list_element *c, const char *value)
@@ -572,12 +569,12 @@ static struct obstack dont_print_vb_obstack;
 static struct obstack dont_print_statmem_obstack;
 
 static void pascal_object_print_static_field (struct value *,
-					      struct ui_file *, int, int,
-					      enum val_prettyprint);
+					      struct ui_file *, int,
+					      const struct value_print_options *);
 
 static void pascal_object_print_value (struct type *, const gdb_byte *,
-				       CORE_ADDR, struct ui_file *,
-				       int, int, enum val_prettyprint,
+				       CORE_ADDR, struct ui_file *, int,
+				       const struct value_print_options *,
 				       struct type **);
 
 /* It was changed to this after 2.4.5.  */
@@ -633,8 +630,8 @@ pascal_object_is_vtbl_member (struct type *type)
 void
 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 				  CORE_ADDR address, struct ui_file *stream,
-				  int format, int recurse,
-				  enum val_prettyprint pretty,
+				  int recurse,
+				  const struct value_print_options *options,
 				  struct type **dont_print_vb,
 				  int dont_print_statmem)
 {
@@ -651,7 +648,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
      duplicates of virtual baseclasses.  */
   if (n_baseclasses > 0)
     pascal_object_print_value (type, valaddr, address, stream,
-			       format, recurse + 1, pretty, dont_print_vb);
+			       recurse + 1, options, dont_print_vb);
 
   if (!len && n_baseclasses == 1)
     fprintf_filtered (stream, "<No data fields>");
@@ -671,14 +668,14 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!pascal_static_field_print
+	  if (!options->pascal_static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 	  if (fields_seen)
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -689,7 +686,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -698,7 +695,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -742,11 +739,13 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  opts.deref_ref = 0;
+		  common_val_print (v, stream, recurse + 1, &opts,
+				    current_language);
 		}
 	    }
 	  else
@@ -765,11 +764,13 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  if (v == NULL)
 		    fputs_filtered ("<optimized out>", stream);
 		  else
-		    pascal_object_print_static_field (v, stream, format,
-						      recurse + 1, pretty);
+		    pascal_object_print_static_field (v, stream, recurse + 1,
+						      options);
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  /* val_print (TYPE_FIELD_TYPE (type, i),
 		     valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
 		     address + TYPE_FIELD_BITPOS (type, i) / 8, 0,
@@ -777,7 +778,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, &opts,
 			     current_language);
 		}
 	    }
@@ -792,7 +793,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -807,8 +808,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 static void
 pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 			   CORE_ADDR address, struct ui_file *stream,
-			   int format, int recurse,
-			   enum val_prettyprint pretty,
+			   int recurse,
+			   const struct value_print_options *options,
 			   struct type **dont_print_vb)
 {
   struct type **last_dont_print
@@ -849,7 +850,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
       boffset = baseclass_offset (type, i, valaddr, address);
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -881,7 +882,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, "<invalid address>");
       else
 	pascal_object_print_value_fields (baseclass, base_valaddr, address + boffset,
-					  stream, format, recurse, pretty,
+					  stream, recurse, options,
 		     (struct type **) obstack_base (&dont_print_vb_obstack),
 					  0);
       fputs_filtered (", ", stream);
@@ -912,10 +913,12 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
 static void
 pascal_object_print_static_field (struct value *val,
-				  struct ui_file *stream, int format,
-				  int recurse, enum val_prettyprint pretty)
+				  struct ui_file *stream,
+				  int recurse,
+				  const struct value_print_options *options)
 {
   struct type *type = value_type (val);
+  struct value_print_options opts;
 
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
@@ -942,11 +945,13 @@ pascal_object_print_static_field (struct value *val,
 
       CHECK_TYPEDEF (type);
       pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
-				  stream, format, recurse, pretty, NULL, 1);
+					stream, recurse, options, NULL, 1);
       return;
     }
-  common_val_print (val, stream, format, 0, recurse, pretty,
-		    current_language);
+
+  opts = *options;
+  opts.deref_ref = 0;
+  common_val_print (val, stream, recurse, &opts, current_language);
 }
 
 extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototypes */
@@ -955,13 +960,10 @@ void
 _initialize_pascal_valprint (void)
 {
   add_setshow_boolean_cmd ("pascal_static-members", class_support,
-			   &pascal_static_field_print, _("\
+			   &user_print_options.pascal_static_field_print, _("\
 Set printing of pascal static members."), _("\
 Show printing of pascal static members."), NULL,
 			   NULL,
 			   show_pascal_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  pascal_static_field_print = 1;
-
 }
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 021e191..5a8d50c 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -42,6 +42,7 @@
 #include "block.h"
 #include "disasm.h"
 #include "dfp.h"
+#include "valprint.h"
 
 #ifdef TUI
 #include "tui/tui.h"		/* For tui_active et.al.   */
@@ -55,7 +56,6 @@
 #endif
 
 extern int asm_demangle;	/* Whether to demangle syms in asm printouts */
-extern int addressprint;	/* Whether to print hex addresses in HLL " */
 
 struct format_data
   {
@@ -120,13 +120,6 @@ Printing of source filename and line number with <symbol> is %s.\n"),
 
 int current_display_number;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-
-int inspect_it = 0;
-
 struct display
   {
     /* Chain link to next auto-display item.  */
@@ -254,15 +247,15 @@ decode_format (char **string_ptr, int oformat, int osize)
   return val;
 }
 \f
-/* Print value VAL on stream according to FORMAT, a letter or 0.
+/* Print value VAL on stream according to OPTIONS.
    Do not end with a newline.
-   0 means print VAL according to its own type.
    SIZE is the letter for the size of datum being printed.
    This is used to pad hex numbers so they line up.  SIZE is 0
    for print / output and set for examine.  */
 
 static void
-print_formatted (struct value *val, int format, int size,
+print_formatted (struct value *val, int size,
+		 const struct value_print_options *options,
 		 struct ui_file *stream)
 {
   struct type *type = check_typedef (value_type (val));
@@ -273,12 +266,13 @@ print_formatted (struct value *val, int format, int size,
 
   if (size)
     {
-      switch (format)
+      switch (options->output_format)
 	{
 	case 's':
 	  /* FIXME: Need to handle wchar_t's here... */
 	  next_address = VALUE_ADDRESS (val)
-	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
+	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream,
+				options);
 	  return;
 
 	case 'i':
@@ -291,22 +285,19 @@ print_formatted (struct value *val, int format, int size,
 	}
     }
 
-  if (format == 0 || format == 's'
+  if (options->output_format == 0 || options->output_format == 's'
       || TYPE_CODE (type) == TYPE_CODE_REF
       || TYPE_CODE (type) == TYPE_CODE_ARRAY
       || TYPE_CODE (type) == TYPE_CODE_STRING
       || TYPE_CODE (type) == TYPE_CODE_STRUCT
       || TYPE_CODE (type) == TYPE_CODE_UNION
       || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
-    /* If format is 0, use the 'natural' format for that type of
-       value.  If the type is non-scalar, we have to use language
-       rules to print it as a series of scalars.  */
-    value_print (val, stream, format, Val_pretty_default);
+    value_print (val, stream, options);
   else
     /* User specified format, so don't look to the the type to
        tell us what to do.  */
     print_scalar_formatted (value_contents (val), type,
-			    format, size, stream);
+			    options, size, stream);
 }
 
 /* Return builtin floating point type of same length as TYPE.
@@ -336,7 +327,8 @@ float_type_from_length (struct gdbarch *gdbarch, struct type *type)
 
 void
 print_scalar_formatted (const void *valaddr, struct type *type,
-			int format, int size, struct ui_file *stream)
+			const struct value_print_options *options,
+			int size, struct ui_file *stream)
 {
   LONGEST val_long = 0;
   unsigned int len = TYPE_LENGTH (type);
@@ -345,9 +337,12 @@ print_scalar_formatted (const void *valaddr, struct type *type,
   /* If we get here with a string format, try again without it.  Go
      all the way back to the language printers, which may call us
      again.  */
-  if (format == 's')
+  if (options->output_format == 's')
     {
-      val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default,
+      struct value_print_options opts = *options;
+      opts.output_format = 0;
+      opts.deref_ref = 0;
+      val_print (type, valaddr, 0, 0, stream, 0, &opts,
 		 current_language);
       return;
     }
@@ -356,7 +351,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       (TYPE_CODE (type) == TYPE_CODE_INT
        || TYPE_CODE (type) == TYPE_CODE_ENUM))
     {
-      switch (format)
+      switch (options->output_format)
 	{
 	case 'o':
 	  print_octal_chars (stream, valaddr, len, byte_order);
@@ -379,7 +374,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
 	};
     }
 
-  if (format != 'f')
+  if (options->output_format != 'f')
     val_long = unpack_long (type, valaddr);
 
   /* If the value is a pointer, and pointers and addresses are not the
@@ -391,13 +386,13 @@ print_scalar_formatted (const void *valaddr, struct type *type,
   /* If we are printing it as unsigned, truncate it in case it is actually
      a negative signed value (e.g. "print/u (short)-1" should print 65535
      (if shorts are 16 bits) instead of 4294967295).  */
-  if (format != 'd')
+  if (options->output_format != 'd')
     {
       if (len < sizeof (LONGEST))
 	val_long &= ((LONGEST) 1 << HOST_CHAR_BIT * len) - 1;
     }
 
-  switch (format)
+  switch (options->output_format)
     {
     case 'x':
       if (!size)
@@ -445,10 +440,10 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       if (TYPE_UNSIGNED (type))
 	value_print (value_from_longest (builtin_type_true_unsigned_char,
 					 val_long),
-		     stream, 0, Val_pretty_default);
+		     stream, options);
       else
 	value_print (value_from_longest (builtin_type_true_char, val_long),
-		     stream, 0, Val_pretty_default);
+		     stream, options);
       break;
 
     case 'f':
@@ -508,7 +503,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       break;
 
     default:
-      error (_("Undefined output format \"%c\"."), format);
+      error (_("Undefined output format \"%c\"."), options->output_format);
     }
 }
 
@@ -707,11 +702,13 @@ void
 print_address_demangle (CORE_ADDR addr, struct ui_file *stream,
 			int do_demangle)
 {
+  struct value_print_options opts;
+  get_user_print_options (&opts);
   if (addr == 0)
     {
       fprintf_filtered (stream, "0");
     }
-  else if (addressprint)
+  else if (opts.addressprint)
     {
       fputs_filtered (paddress (addr), stream);
       print_address_symbolic (addr, stream, do_demangle, " ");
@@ -745,6 +742,7 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
   struct type *val_type = NULL;
   int i;
   int maxelts;
+  struct value_print_options opts;
 
   format = fmt.format;
   size = fmt.size;
@@ -775,6 +773,8 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
   if (format == 's' || format == 'i')
     maxelts = 1;
 
+  get_formatted_print_options (&opts, format);
+
   /* Print as many objects as specified in COUNT, at most maxelts per line,
      with the address of the next one at the start of each line.  */
 
@@ -809,7 +809,7 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
 	  if (last_examine_value)
 	    release_value (last_examine_value);
 
-	  print_formatted (last_examine_value, format, size, gdb_stdout);
+	  print_formatted (last_examine_value, size, &opts, gdb_stdout);
 
 	  /* Display any branch delay slots following the final insn.  */
 	  if (format == 'i' && count == 1)
@@ -847,10 +847,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
   struct format_data fmt;
   int cleanup = 0;
 
-  /* Pass inspect flag to the rest of the print routines in a global
-     (sigh).  */
-  inspect_it = inspect;
-
   if (exp && *exp == '/')
     {
       exp++;
@@ -879,6 +875,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
   if (voidprint || (val && value_type (val) &&
 		    TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
     {
+      struct value_print_options opts;
       int histindex = record_latest_value (val);
 
       if (histindex >= 0)
@@ -895,7 +892,10 @@ print_command_1 (char *exp, int inspect, int voidprint)
       if (histindex >= 0)
 	annotate_value_history_value ();
 
-      print_formatted (val, format, fmt.size, gdb_stdout);
+      get_formatted_print_options (&opts, format);
+      opts.inspect_it = inspect;
+
+      print_formatted (val, fmt.size, &opts, gdb_stdout);
       printf_filtered ("\n");
 
       if (histindex >= 0)
@@ -909,7 +909,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
 
   if (cleanup)
     do_cleanups (old_chain);
-  inspect_it = 0;		/* Reset print routines to normal.  */
 }
 
 static void
@@ -942,6 +941,7 @@ output_command (char *exp, int from_tty)
   char format = 0;
   struct value *val;
   struct format_data fmt;
+  struct value_print_options opts;
 
   fmt.size = 0;
 
@@ -960,7 +960,8 @@ output_command (char *exp, int from_tty)
 
   annotate_value_begin (value_type (val));
 
-  print_formatted (val, format, fmt.size, gdb_stdout);
+  get_formatted_print_options (&opts, format);
+  print_formatted (val, fmt.size, &opts, gdb_stdout);
 
   annotate_value_end ();
 
@@ -1507,6 +1508,8 @@ do_one_display (struct display *d)
     }
   else
     {
+      struct value_print_options opts;
+
       annotate_display_format ();
 
       if (d->format.format)
@@ -1521,8 +1524,9 @@ do_one_display (struct display *d)
 
       annotate_display_expression ();
 
+      get_formatted_print_options (&opts, d->format.format);
       print_formatted (evaluate_expression (d->exp),
-		       d->format.format, d->format.size, gdb_stdout);
+		       d->format.size, &opts, gdb_stdout);
       printf_filtered ("\n");
     }
 
@@ -1677,8 +1681,10 @@ print_variable_value (struct symbol *var, struct frame_info *frame,
 		      struct ui_file *stream)
 {
   struct value *val = read_var_value (var, frame);
+  struct value_print_options opts;
 
-  value_print (val, stream, 0, Val_pretty_default);
+  get_user_print_options (&opts);
+  value_print (val, stream, &opts);
 }
 
 static void
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 6c4be54..b8a3c0b 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -23,6 +23,7 @@
 #include "exceptions.h"
 #include "language.h"
 #include "dfp.h"
+#include "valprint.h"
 
 /* List of all values which are currently exposed to Python. It is
    maintained so that when an objfile is discarded, preserve_values
@@ -187,15 +188,19 @@ valpy_str (PyObject *self)
   struct ui_file *stb;
   struct cleanup *old_chain;
   PyObject *result;
+  struct value_print_options opts;
   volatile struct gdb_exception except;
 
+  get_user_print_options (&opts);
+  opts.deref_ref = 0;
+
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
-      common_val_print (((value_object *) self)->value, stb, 0, 0, 0,
-			Val_pretty_default, current_language);
+      common_val_print (((value_object *) self)->value, stb, 0,
+			&opts, current_language);
       s = ui_file_xstrdup (stb, &dummy);
     }
   GDB_PY_HANDLE_EXCEPTION (except);
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 42d2502..0b25590 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -50,7 +50,8 @@ scm_printchar (int c, struct ui_file *stream)
 
 static void
 scm_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
   fprintf_filtered (stream, "\"%s\"", string);
 }
diff --git a/gdb/scm-lang.h b/gdb/scm-lang.h
index 654095c..369905b 100644
--- a/gdb/scm-lang.h
+++ b/gdb/scm-lang.h
@@ -46,16 +46,16 @@
 struct value;
 
 extern int scm_value_print (struct value *, struct ui_file *,
-			    int, enum val_prettyprint);
+			    const struct value_print_options *);
 
 extern int scm_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			  struct ui_file *, int, int, int,
-			  enum val_prettyprint);
+			  struct ui_file *, int,
+			  const struct value_print_options *);
 
 extern LONGEST scm_get_field (LONGEST, int);
 
-extern void scm_scmval_print (LONGEST, struct ui_file *, int, int, int,
-			      enum val_prettyprint);
+extern void scm_scmval_print (LONGEST, struct ui_file *, int,
+			      const struct value_print_options *);
 
 extern int is_scmvalue_type (struct type *);
 
diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
index feb43dd..f7c0e51 100644
--- a/gdb/scm-valprint.c
+++ b/gdb/scm-valprint.c
@@ -33,18 +33,18 @@
 #include "objfiles.h"
 
 static void scm_ipruk (char *, LONGEST, struct ui_file *);
-static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
-static int scm_inferior_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
+static void scm_scmlist_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
+static int scm_inferior_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
 
 /* Prints the SCM value VALUE by invoking the inferior, if appropraite.
    Returns >= 0 on success;  return -1 if the inferior cannot/should not
    print VALUE. */
 
 static int
-scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_inferior_print (LONGEST value, struct ui_file *stream,
+		    int recurse, const struct value_print_options *options)
 {
   struct objfile *objf;
   struct gdbarch *gdbarch;
@@ -129,17 +129,16 @@ static char *scm_isymnames[] =
 };
 
 static void
-scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int recurse,
+		   const struct value_print_options *options)
 {
-  unsigned int more = print_max;
+  unsigned int more = options->print_max;
   if (recurse > 6)
     {
       fputs_filtered ("...", stream);
       return;
     }
-  scm_scmval_print (SCM_CAR (svalue), stream, format,
-		    deref_ref, recurse + 1, pretty);
+  scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
   svalue = SCM_CDR (svalue);
   for (; SCM_NIMP (svalue); svalue = SCM_CDR (svalue))
     {
@@ -151,14 +150,12 @@ scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
 	  fputs_filtered ("...", stream);
 	  return;
 	}
-      scm_scmval_print (SCM_CAR (svalue), stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
     }
   if (SCM_NNULLP (svalue))
     {
       fputs_filtered (" . ", stream);
-      scm_scmval_print (svalue, stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (svalue, stream, recurse + 1, options);
     }
 }
 
@@ -174,15 +171,17 @@ scm_ipruk (char *hdr, LONGEST ptr, struct ui_file *stream)
 }
 
 void
-scm_scmval_print (LONGEST svalue, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmval_print (LONGEST svalue, struct ui_file *stream,
+		  int recurse, const struct value_print_options *options)
 {
 taloop:
   switch (7 & (int) svalue)
     {
     case 2:
     case 6:
-      print_longest (stream, format ? format : 'd', 1, svalue >> 2);
+      print_longest (stream,
+		     options->output_format ? options->output_format : 'd',
+		     1, svalue >> 2);
       break;
     case 4:
       if (SCM_ICHRP (svalue))
@@ -243,14 +242,12 @@ taloop:
 	case scm_tcs_cons_imcar:
 	case scm_tcs_cons_nimcar:
 	  fputs_filtered ("(", stream);
-	  scm_scmlist_print (svalue, stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (svalue, stream, recurse + 1, options);
 	  fputs_filtered (")", stream);
 	  break;
 	case scm_tcs_closures:
 	  fputs_filtered ("#<CLOSURE ", stream);
-	  scm_scmlist_print (SCM_CODE (svalue), stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (SCM_CODE (svalue), stream, recurse + 1, options);
 	  fputs_filtered (">", stream);
 	  break;
 	case scm_tc7_string:
@@ -261,9 +258,9 @@ taloop:
 	    int done = 0;
 	    int buf_size;
 	    gdb_byte buffer[64];
-	    int truncate = print_max && len > (int) print_max;
+	    int truncate = options->print_max && len > (int) options->print_max;
 	    if (truncate)
-	      len = print_max;
+	      len = options->print_max;
 	    fputs_filtered ("\"", stream);
 	    for (; done < len; done += buf_size)
 	      {
@@ -305,8 +302,8 @@ taloop:
 	      {
 		if (i > 0)
 		  fputs_filtered (" ", stream);
-		scm_scmval_print (scm_get_field (elements, i), stream, format,
-				  deref_ref, recurse + 1, pretty);
+		scm_scmval_print (scm_get_field (elements, i), stream,
+				  recurse + 1, options);
 	      }
 	    fputs_filtered (")", stream);
 	  }
@@ -401,21 +398,19 @@ taloop:
 int
 scm_val_print (struct type *type, const gdb_byte *valaddr,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   if (is_scmvalue_type (type))
     {
       LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
 
-      if (scm_inferior_print (svalue, stream, format,
-			      deref_ref, recurse, pretty) >= 0)
+      if (scm_inferior_print (svalue, stream, recurse, options) >= 0)
 	{
 	}
       else
 	{
-	  scm_scmval_print (svalue, stream, format,
-			    deref_ref, recurse, pretty);
+	  scm_scmval_print (svalue, stream, recurse, options);
 	}
 
       gdb_flush (stream);
@@ -423,15 +418,15 @@ scm_val_print (struct type *type, const gdb_byte *valaddr,
     }
   else
     {
-      return c_val_print (type, valaddr, 0, address, stream, format,
-			  deref_ref, recurse, pretty);
+      return c_val_print (type, valaddr, 0, address, stream, recurse, options);
     }
 }
 
 int
-scm_value_print (struct value *val, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+scm_value_print (struct value *val, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
-  return (common_val_print (val, stream, format, 1, 0, pretty,
-			    current_language));
+  struct value_print_options opts = *options;
+  opts.deref_ref = 1;
+  return (common_val_print (val, stream, 0, &opts, current_language));
 }
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 474d49a..988e8cb 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -40,6 +40,7 @@
 #include "arch-utils.h"
 #include "regcache.h"
 #include "osabi.h"
+#include "valprint.h"
 
 #include "elf-bfd.h"
 
@@ -2092,6 +2093,7 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
 		  struct frame_info *frame, int regnum)
 {
   unsigned char raw_buffer[MAX_REGISTER_SIZE];
+  struct value_print_options opts;
 
   fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
   print_spaces_filtered (15 - strlen (gdbarch_register_name
@@ -2100,12 +2102,16 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
   /* Get the data in raw format.  */
   if (!frame_register_read (frame, regnum, raw_buffer))
     fprintf_filtered (file, "*value not available*\n");
-      
+
+  get_formatted_print_options (&opts, 'x');
+  opts.deref_ref = 1;
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 'x', 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\t");
+  get_formatted_print_options (&opts, 0);
+  opts.deref_ref = 1;
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 0, 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\n");
 }
 
diff --git a/gdb/stack.c b/gdb/stack.c
index 2c3c0bb..3c1019b 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -368,6 +368,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
 	      if (val)
 	        {
                   const struct language_defn *language;
+		  struct value_print_options opts;
 
                   /* Use the appropriate language to display our symbol,
                      unless the user forced the language to a specific
@@ -377,8 +378,10 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
                   else
                     language = current_language;
 
-		  common_val_print (val, stb->stream, 0, 0, 2,
-				    Val_no_prettyprint, language);
+		  get_raw_print_options (&opts);
+		  opts.deref_ref = 0;
+		  common_val_print (val, stb->stream, 2,
+				    &opts, language);
 		  ui_out_field_stream (uiout, "value", stb);
 	        }
 	      else
@@ -547,6 +550,8 @@ print_frame_info (struct frame_info *frame, int print_level,
 						      sal.line + 1, 0);
 	  else
 	    {
+	      struct value_print_options opts;
+	      get_user_print_options (&opts);
 	      /* We used to do this earlier, but that is clearly
 		 wrong. This function is used by many different
 		 parts of gdb, including normal_stop in infrun.c,
@@ -555,7 +560,7 @@ print_frame_info (struct frame_info *frame, int print_level,
 		 line. Only the command line really wants this
 		 behavior. Other UIs probably would like the
 		 ability to decide for themselves if it is desired.  */
-	      if (addressprint && mid_statement)
+	      if (opts.addressprint && mid_statement)
 		{
 		  ui_out_field_core_addr (uiout, "addr", get_frame_pc (frame));
 		  ui_out_text (uiout, "\t");
@@ -584,6 +589,7 @@ print_frame (struct frame_info *frame, int print_level,
   enum language funlang = language_unknown;
   struct ui_stream *stb;
   struct cleanup *old_chain, *list_chain;
+  struct value_print_options opts;
 
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -665,7 +671,8 @@ print_frame (struct frame_info *frame, int print_level,
       ui_out_field_fmt_int (uiout, 2, ui_left, "level",
 			    frame_relative_level (frame));
     }
-  if (addressprint)
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     if (get_frame_pc (frame) != sal.pc || !sal.symtab
 	|| print_what == LOC_AND_ADDRESS)
       {
@@ -1405,10 +1412,12 @@ print_block_frame_labels (struct block *b, int *have_default,
       if (SYMBOL_CLASS (sym) == LOC_LABEL)
 	{
 	  struct symtab_and_line sal;
+	  struct value_print_options opts;
 	  sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
 	  values_printed = 1;
 	  fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
-	  if (addressprint)
+	  get_user_print_options (&opts);
+	  if (opts.addressprint)
 	    {
 	      fprintf_filtered (stream, " ");
 	      fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (sym)), stream);
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4f5c56a..4646ab1 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -38,6 +38,7 @@
 #include "dictionary.h"
 #include "observer.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
@@ -67,7 +68,6 @@
 extern void (*deprecated_readline_begin_hook) (char *, ...);
 extern char *(*deprecated_readline_hook) (char *);
 extern void (*deprecated_readline_end_hook) (void);
-extern int addressprint;	/* Print machine addresses? */
 
 /* GDB commands implemented in other modules:
  */  
@@ -434,9 +434,11 @@ trace_command (char *arg, int from_tty)
 static void
 trace_mention (struct tracepoint *tp)
 {
+  struct value_print_options opts;
   printf_filtered ("Tracepoint %d", tp->number);
 
-  if (addressprint || (tp->source_file == NULL))
+  get_user_print_options (&opts);
+  if (opts.addressprint || (tp->source_file == NULL))
     {
       printf_filtered (" at ");
       printf_filtered ("%s", paddress (tp->address));
@@ -467,12 +469,12 @@ tracepoints_info (char *tpnum_exp, int from_tty)
   ALL_TRACEPOINTS (t)
     if (tpnum == -1 || tpnum == t->number)
     {
-      extern int addressprint;	/* Print machine addresses?  */
-
+      struct value_print_options opts;
+      get_user_print_options (&opts);
       if (!found_a_tracepoint++)
 	{
 	  printf_filtered ("Num Enb ");
-	  if (addressprint)
+	  if (opts.addressprint)
 	    {
 	      if (gdbarch_addr_bit (current_gdbarch) <= 32)
 		printf_filtered ("Address    ");
@@ -482,7 +484,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 	  printf_filtered ("PassC StepC What\n");
 	}
       strcpy (wrap_indent, "                           ");
-      if (addressprint)
+      if (opts.addressprint)
 	{
 	  if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	    strcat (wrap_indent, "           ");
@@ -492,7 +494,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 
       printf_filtered ("%-3d %-3s ", t->number,
 		       t->enabled_p ? "y" : "n");
-      if (addressprint)
+      if (opts.addressprint)
 	{
 	  char *tmp;
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 39580e6..b2428ef 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -37,6 +37,7 @@
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-file.h"
 #include "reggroups.h"
+#include "valprint.h"
 
 #include "gdb_curses.h"
 
@@ -689,11 +690,13 @@ tui_register_format (struct gdbarch *gdbarch,
     {
       gdb_byte buf[MAX_REGISTER_SIZE];
       int len;
+      struct value_print_options opts;
 
       len = register_size (current_gdbarch, regnum);
       fprintf_filtered (stream, "%-14s ", name);
       get_frame_register (frame, regnum, buf);
-      print_scalar_formatted (buf, type, 'f', len, stream);
+      get_formatted_print_options (&opts, 'f');
+      print_scalar_formatted (buf, type, &opts, len, stream);
     }
   else
     {
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 44f1a77..edf87cd 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -33,12 +33,9 @@
 #include "cp-abi.h"
 #include "typeprint.h"
 #include "gdb_string.h"
+#include "valprint.h"
 #include <errno.h>
 
-/* For real-type printing in whatis_exp() */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-
 extern void _initialize_typeprint (void);
 
 static void ptype_command (char *, int);
@@ -95,6 +92,7 @@ whatis_exp (char *exp, int show)
   int full = 0;
   int top = -1;
   int using_enc = 0;
+  struct value_print_options opts;
 
   if (exp)
     {
@@ -107,7 +105,8 @@ whatis_exp (char *exp, int show)
 
   type = value_type (val);
 
-  if (objectprint)
+  get_user_print_options (&opts);
+  if (opts.objectprint)
     {
       if (((TYPE_CODE (type) == TYPE_CODE_PTR)
 	   || (TYPE_CODE (type) == TYPE_CODE_REF))
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 99c376f..0cc7e7f 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -60,13 +60,54 @@ static void set_output_radix_1 (int, unsigned);
 
 void _initialize_valprint (void);
 
-/* Maximum number of chars to print for a string pointer value or vector
-   contents, or UINT_MAX for no limit.  Note that "set print elements 0"
-   stores UINT_MAX in print_max, which displays in a show command as
-   "unlimited". */
-
-unsigned int print_max;
 #define PRINT_MAX_DEFAULT 200	/* Start print_max off at this value. */
+
+struct value_print_options user_print_options =
+{
+  Val_pretty_default,		/* pretty */
+  0,				/* prettyprint_arrays */
+  0,				/* prettyprint_structs */
+  0,				/* vtblprint */
+  1,				/* unionprint */
+  1,				/* addressprint */
+  0,				/* objectprint */
+  PRINT_MAX_DEFAULT,		/* print_max */
+  10,				/* repeat_count_threshold */
+  0,				/* output_format */
+  0,				/* stop_print_at_null */
+  0,				/* inspect_it */
+  0,				/* print_array_indexes */
+  0,				/* deref_ref */
+  1,				/* static_field_print */
+  1				/* pascal_static_field_print */
+};
+
+/* Initialize *OPTS to be a copy of the user print options.  */
+void
+get_user_print_options (struct value_print_options *opts)
+{
+  *opts = user_print_options;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+void
+get_raw_print_options (struct value_print_options *opts)
+{  
+  *opts = user_print_options;
+  opts->pretty = Val_no_prettyprint;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+void
+get_formatted_print_options (struct value_print_options *opts,
+			     char format)
+{
+  *opts = user_print_options;
+  opts->output_format = format;
+}
+
 static void
 show_print_max (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -103,7 +144,6 @@ int output_format = 0;
 /* By default we print arrays without printing the index of each element in
    the array.  This behavior can be changed by setting PRINT_ARRAY_INDEXES.  */
 
-static int print_array_indexes = 0;
 static void
 show_print_array_indexes (struct ui_file *file, int from_tty,
 		          struct cmd_list_element *c, const char *value)
@@ -115,7 +155,6 @@ show_print_array_indexes (struct ui_file *file, int from_tty,
    element in an array.  Referenced by the low level language dependent
    print routines. */
 
-unsigned int repeat_count_threshold = 10;
 static void
 show_repeat_count_threshold (struct ui_file *file, int from_tty,
 			     struct cmd_list_element *c, const char *value)
@@ -126,7 +165,6 @@ show_repeat_count_threshold (struct ui_file *file, int from_tty,
 
 /* If nonzero, stops printing of char arrays at first null. */
 
-int stop_print_at_null;
 static void
 show_stop_print_at_null (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -138,7 +176,6 @@ Printing of char arrays to stop at first null char is %s.\n"),
 
 /* Controls pretty printing of structures. */
 
-int prettyprint_structs;
 static void
 show_prettyprint_structs (struct ui_file *file, int from_tty,
 			  struct cmd_list_element *c, const char *value)
@@ -148,7 +185,6 @@ show_prettyprint_structs (struct ui_file *file, int from_tty,
 
 /* Controls pretty printing of arrays.  */
 
-int prettyprint_arrays;
 static void
 show_prettyprint_arrays (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -159,7 +195,6 @@ show_prettyprint_arrays (struct ui_file *file, int from_tty,
 /* If nonzero, causes unions inside structures or other unions to be
    printed. */
 
-int unionprint;			/* Controls printing of nested unions.  */
 static void
 show_unionprint (struct ui_file *file, int from_tty,
 		 struct cmd_list_element *c, const char *value)
@@ -171,7 +206,6 @@ Printing of unions interior to structures is %s.\n"),
 
 /* If nonzero, causes machine addresses to be printed in certain contexts. */
 
-int addressprint;		/* Controls printing of machine addresses */
 static void
 show_addressprint (struct ui_file *file, int from_tty,
 		   struct cmd_list_element *c, const char *value)
@@ -203,17 +237,18 @@ show_addressprint (struct ui_file *file, int from_tty,
 
 int
 val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	   CORE_ADDR address, struct ui_file *stream, int format,
-	   int deref_ref, int recurse, enum val_prettyprint pretty,
+	   CORE_ADDR address, struct ui_file *stream, int recurse,
+	   const struct value_print_options *options,
 	   const struct language_defn *language)
 {
   volatile struct gdb_exception except;
-  volatile enum val_prettyprint real_pretty = pretty;
   int ret = 0;
-
+  struct value_print_options local_opts = *options;
   struct type *real_type = check_typedef (type);
-  if (pretty == Val_pretty_default)
-    real_pretty = prettyprint_structs ? Val_prettyprint : Val_no_prettyprint;
+
+  if (local_opts.pretty == Val_pretty_default)
+    local_opts.pretty = (local_opts.prettyprint_structs
+			 ? Val_prettyprint : Val_no_prettyprint);
 
   QUIT;
 
@@ -231,8 +266,7 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
   TRY_CATCH (except, RETURN_MASK_ERROR)
     {
       ret = language->la_val_print (type, valaddr, embedded_offset, address,
-				    stream, format, deref_ref, recurse,
-				    real_pretty);
+				    stream, recurse, &local_opts);
     }
   if (except.reason < 0)
     fprintf_filtered (stream, _("<error reading variable>"));
@@ -277,8 +311,8 @@ value_check_printable (struct value *val, struct ui_file *stream)
    GDB's value mechanism.  */
 
 int
-common_val_print (struct value *val, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty,
+common_val_print (struct value *val, struct ui_file *stream, int recurse,
+		  const struct value_print_options *options,
 		  const struct language_defn *language)
 {
   if (!value_check_printable (val, stream))
@@ -286,8 +320,7 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
 
   return val_print (value_type (val), value_contents_all (val),
 		    value_embedded_offset (val), VALUE_ADDRESS (val),
-		    stream, format, deref_ref, recurse, pretty,
-		    language);
+		    stream, recurse, options, language);
 }
 
 /* Print the value VAL in C-ish syntax on stream STREAM.
@@ -296,13 +329,13 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
    the number of string bytes printed.  */
 
 int
-value_print (struct value *val, struct ui_file *stream, int format,
-	     enum val_prettyprint pretty)
+value_print (struct value *val, struct ui_file *stream,
+	     const struct value_print_options *options)
 {
   if (!value_check_printable (val, stream))
     return 0;
 
-  return LA_VALUE_PRINT (val, stream, format, pretty);
+  return LA_VALUE_PRINT (val, stream, options);
 }
 
 /* Called by various <lang>_val_print routines to print
@@ -928,15 +961,6 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
     }
 }
 
-/* Return non-zero if the debugger should print the index of each element
-   when printing array values.  */
-
-int
-print_array_indexes_p (void)
-{              
-  return print_array_indexes;
-} 
-
 /* Assuming TYPE is a simple, non-empty array type, compute its upper
    and lower bound.  Save the low bound into LOW_BOUND if not NULL.
    Save the high bound into HIGH_BOUND if not NULL.
@@ -997,18 +1021,18 @@ get_array_bounds (struct type *type, long *low_bound, long *high_bound)
     
 void  
 maybe_print_array_index (struct type *index_type, LONGEST index,
-                         struct ui_file *stream, int format,
-                         enum val_prettyprint pretty)
+                         struct ui_file *stream,
+			 const struct value_print_options *options)
 {
   struct value *index_value;
 
-  if (!print_array_indexes)
+  if (!options->print_array_indexes)
     return; 
     
   index_value = value_from_longest (index_type, index);
 
-  LA_PRINT_ARRAY_INDEX (index_value, stream, format, pretty);
-}   
+  LA_PRINT_ARRAY_INDEX (index_value, stream, options);
+}
 
 /*  Called by various <lang>_val_print routines to print elements of an
    array in the form "<elem1>, <elem2>, <elem3>, ...".
@@ -1022,8 +1046,8 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
 void
 val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 			  CORE_ADDR address, struct ui_file *stream,
-			  int format, int deref_ref,
-			  int recurse, enum val_prettyprint pretty,
+			  int recurse,
+			  const struct value_print_options *options,
 			  unsigned int i)
 {
   unsigned int things_printed = 0;
@@ -1070,11 +1094,11 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 
   annotate_array_section_begin (i, elttype);
 
-  for (; i < len && things_printed < print_max; i++)
+  for (; i < len && things_printed < options->print_max; i++)
     {
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1086,7 +1110,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
       maybe_print_array_index (index_type, i + low_bound_index,
-                               stream, format, pretty);
+                               stream, options);
 
       rep1 = i + 1;
       reps = 1;
@@ -1097,21 +1121,21 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	  ++rep1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt_rep (reps);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  annotate_elt_rep_end ();
 
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	}
       else
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt ();
 	  things_printed++;
 	}
@@ -1173,7 +1197,8 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int *errnoptr
 /* FIXME: Use target_read_string.  */
 
 int
-val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
+val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
+		  const struct value_print_options *options)
 {
   int force_ellipsis = 0;	/* Force ellipsis to be printed if nonzero. */
   int errcode;			/* Errno returned from bad reads. */
@@ -1194,7 +1219,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      because finding the null byte (or available memory) is what actually
      limits the fetch. */
 
-  fetchlimit = (len == -1 ? print_max : min (len, print_max));
+  fetchlimit = (len == -1 ? options->print_max : min (len, options->print_max));
 
   /* Now decide how large of chunks to try to read in one operation.  This
      is also pretty simple.  If LEN >= zero, then we want fetchlimit chars,
@@ -1317,11 +1342,11 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      and then the error message.  */
   if (errcode == 0 || bufptr > buffer)
     {
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fputs_filtered (" ", stream);
 	}
-      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis);
+      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis, options);
     }
 
   if (errcode != 0)
@@ -1494,7 +1519,8 @@ _initialize_valprint (void)
   add_alias_cmd ("p", "print", no_class, 1, &showlist);
   add_alias_cmd ("pr", "print", no_class, 1, &showlist);
 
-  add_setshow_uinteger_cmd ("elements", no_class, &print_max, _("\
+  add_setshow_uinteger_cmd ("elements", no_class,
+			    &user_print_options.print_max, _("\
 Set limit on string chars or array elements to print."), _("\
 Show limit on string chars or array elements to print."), _("\
 \"set print elements 0\" causes there to be no limit."),
@@ -1502,7 +1528,8 @@ Show limit on string chars or array elements to print."), _("\
 			    show_print_max,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("null-stop", no_class, &stop_print_at_null, _("\
+  add_setshow_boolean_cmd ("null-stop", no_class,
+			   &user_print_options.stop_print_at_null, _("\
 Set printing of char arrays to stop at first null char."), _("\
 Show printing of char arrays to stop at first null char."), NULL,
 			   NULL,
@@ -1510,7 +1537,7 @@ Show printing of char arrays to stop at first null char."), NULL,
 			   &setprintlist, &showprintlist);
 
   add_setshow_uinteger_cmd ("repeats", no_class,
-			    &repeat_count_threshold, _("\
+			    &user_print_options.repeat_count_threshold, _("\
 Set threshold for repeated print elements."), _("\
 Show threshold for repeated print elements."), _("\
 \"set print repeats 0\" causes all elements to be individually printed."),
@@ -1518,28 +1545,32 @@ Show threshold for repeated print elements."), _("\
 			    show_repeat_count_threshold,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("pretty", class_support, &prettyprint_structs, _("\
+  add_setshow_boolean_cmd ("pretty", class_support,
+			   &user_print_options.prettyprint_structs, _("\
 Set prettyprinting of structures."), _("\
 Show prettyprinting of structures."), NULL,
 			   NULL,
 			   show_prettyprint_structs,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("union", class_support, &unionprint, _("\
+  add_setshow_boolean_cmd ("union", class_support,
+			   &user_print_options.unionprint, _("\
 Set printing of unions interior to structures."), _("\
 Show printing of unions interior to structures."), NULL,
 			   NULL,
 			   show_unionprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("array", class_support, &prettyprint_arrays, _("\
+  add_setshow_boolean_cmd ("array", class_support,
+			   &user_print_options.prettyprint_arrays, _("\
 Set prettyprinting of arrays."), _("\
 Show prettyprinting of arrays."), NULL,
 			   NULL,
 			   show_prettyprint_arrays,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("address", class_support, &addressprint, _("\
+  add_setshow_boolean_cmd ("address", class_support,
+			   &user_print_options.addressprint, _("\
 Set printing of addresses."), _("\
 Show printing of addresses."), NULL,
 			   NULL,
@@ -1578,15 +1609,8 @@ Use 'show input-radix' or 'show output-radix' to independently show each."),
 	   &showlist);
 
   add_setshow_boolean_cmd ("array-indexes", class_support,
-                           &print_array_indexes, _("\
+                           &user_print_options.print_array_indexes, _("\
 Set printing of array indexes."), _("\
 Show printing of array indexes"), NULL, NULL, show_print_array_indexes,
                            &setprintlist, &showprintlist);
-
-  /* Give people the defaults which they are used to.  */
-  prettyprint_structs = 0;
-  prettyprint_arrays = 0;
-  unionprint = 1;
-  addressprint = 1;
-  print_max = PRINT_MAX_DEFAULT;
 }
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 3b20516..22ec5c8 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -21,45 +21,93 @@
 #ifndef VALPRINT_H
 #define VALPRINT_H
 
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
-extern int prettyprint_structs;	/* Controls pretty printing of structures */
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
+/* This is used to pass formatting options to various value-printing
+   functions.  */
+struct value_print_options
+{
+  /* Pretty-printing control.  */
+  enum val_prettyprint pretty;
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int unionprint;		/* Controls printing of nested unions.  */
-extern int addressprint;	/* Controls pretty printing of addresses.  */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
+  /* Controls pretty printing of arrays.  */
+  int prettyprint_arrays;
 
-extern unsigned int print_max;	/* Max # of chars for strings/vectors */
+  /* Controls pretty printing of structures.  */
+  int prettyprint_structs;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-extern int inspect_it;
+  /* Controls printing of virtual tables.  */
+  int vtblprint;
 
-/* Print repeat counts if there are more than this many repetitions of an
-   element in an array.  Referenced by the low level language dependent
-   print routines. */
-extern unsigned int repeat_count_threshold;
+  /* Controls printing of nested unions.  */
+  int unionprint;
 
-extern int output_format;
+  /* Controls printing of addresses.  */
+  int addressprint;
 
-extern int stop_print_at_null;	/* Stop printing at null char? */
+  /* Controls looking up an object's derived type using what we find
+     in its vtables.  */
+  int objectprint;
+
+  /* Maximum number of chars to print for a string pointer value or vector
+     contents, or UINT_MAX for no limit.  Note that "set print elements 0"
+     stores UINT_MAX in print_max, which displays in a show command as
+     "unlimited". */
+  unsigned int print_max;
+
+  /* Print repeat counts if there are more than this many repetitions
+     of an element in an array.  */
+  unsigned int repeat_count_threshold;
+
+  int output_format;
+
+  /* Stop printing at null character?  */
+  int stop_print_at_null;
+
+  /* True if this value is being printed in an epoch window.  */
+  int inspect_it;
+
+  /* True if we should print the index of each element when printing
+     an array.  */
+  int print_array_indexes;
+
+  /* If nonzero, then dereference references, otherwise just print
+     them like pointers.  */
+  int deref_ref;
+
+  /* If nonzero, print static fields.  */
+  int static_field_print;
+
+  /* If nonzero, print static fields for Pascal.  FIXME: C++ and Java
+     share one flag, why not Pascal too?  */
+  int pascal_static_field_print;
+};
+
+/* The global print options set by the user.  In general this should
+   not be directly accessed, except by set/show commands.  Ordinary
+   code should call get_user_print_options instead.  */
+extern struct value_print_options user_print_options;
+
+/* Initialize *OPTS to be a copy of the user print options.  */
+extern void get_user_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+extern void get_raw_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+extern void get_formatted_print_options (struct value_print_options *opts,
+					 char format);
 
-extern int print_array_indexes_p (void);
- 
 extern int get_array_bounds (struct type *type, long *low_bound,
 			     long *high_bound);
 
 extern void maybe_print_array_index (struct type *index_type, LONGEST index,
-                                     struct ui_file *stream, int format,
-                                     enum val_prettyprint pretty);
+                                     struct ui_file *stream,
+				     const struct value_print_options *options);
 
 extern void val_print_array_elements (struct type *, const gdb_byte *,
 				      CORE_ADDR, struct ui_file *, int,
-				      int, int, enum val_prettyprint,
+				      const struct value_print_options *,
 				      unsigned int);
 
 extern void val_print_type_code_int (struct type *, const gdb_byte *,
diff --git a/gdb/value.c b/gdb/value.c
index 0b530f0..1fa376d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -36,6 +36,7 @@
 #include "block.h"
 #include "dfp.h"
 #include "objfiles.h"
+#include "valprint.h"
 
 #include "python/python.h"
 
@@ -708,9 +709,11 @@ show_values (char *num_exp, int from_tty)
 
   for (i = num; i < num + 10 && i <= value_history_count; i++)
     {
+      struct value_print_options opts;
       val = access_value_history (i);
       printf_filtered (("$%d = "), i);
-      value_print (val, gdb_stdout, 0, Val_pretty_default);
+      get_user_print_options (&opts);
+      value_print (val, gdb_stdout, &opts);
       printf_filtered (("\n"));
     }
 
@@ -969,7 +972,9 @@ show_convenience (char *ignore, int from_tty)
 {
   struct internalvar *var;
   int varseen = 0;
+  struct value_print_options opts;
 
+  get_user_print_options (&opts);
   for (var = internalvars; var; var = var->next)
     {
       if (!varseen)
@@ -978,7 +983,7 @@ show_convenience (char *ignore, int from_tty)
 	}
       printf_filtered (("$%s = "), var->name);
       value_print (value_of_internalvar (var), gdb_stdout,
-		   0, Val_pretty_default);
+		   &opts);
       printf_filtered (("\n"));
     }
   if (!varseen)
diff --git a/gdb/value.h b/gdb/value.h
index f53d333..65fea99 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -32,6 +32,7 @@ struct symbol;
 struct type;
 struct ui_file;
 struct language_defn;
+struct value_print_options;
 
 /* The structure which defines the type of a value.  It should never
    be possible for a program lval value to survive over a call to the
@@ -526,8 +527,8 @@ extern void print_floating (const gdb_byte *valaddr, struct type *type,
 extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
 				    struct ui_file *stream);
 
-extern int value_print (struct value *val, struct ui_file *stream, int format,
-			enum val_prettyprint pretty);
+extern int value_print (struct value *val, struct ui_file *stream,
+			const struct value_print_options *options);
 
 extern void value_print_array_elements (struct value *val,
 					struct ui_file *stream, int format,
@@ -537,19 +538,18 @@ extern struct value *value_release_to_mark (struct value *mark);
 
 extern int val_print (struct type *type, const gdb_byte *valaddr,
 		      int embedded_offset, CORE_ADDR address,
-		      struct ui_file *stream, int format,
-		      int deref_ref, int recurse,
-		      enum val_prettyprint pretty,
+		      struct ui_file *stream, int recurse,
+		      const struct value_print_options *options,
 		      const struct language_defn *language);
 
 extern int common_val_print (struct value *val,
-			     struct ui_file *stream, int format,
-			     int deref_ref, int recurse,
-			     enum val_prettyprint pretty,
+			     struct ui_file *stream, int recurse,
+			     const struct value_print_options *options,
 			     const struct language_defn *language);
 
 extern int val_print_string (CORE_ADDR addr, int len, int width,
-			     struct ui_file *stream);
+			     struct ui_file *stream,
+			     const struct value_print_options *options);
 
 extern void print_variable_value (struct symbol *var,
 				  struct frame_info *frame,
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 15cbd45..ab369a2 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -25,6 +25,7 @@
 #include "wrapper.h"
 #include "gdbcmd.h"
 #include "block.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 #include "gdb_string.h"
@@ -1791,6 +1792,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   struct ui_file *stb;
   struct cleanup *old_chain;
   char *thevalue;
+  struct value_print_options opts;
 
   if (value == NULL)
     return NULL;
@@ -1798,8 +1800,9 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
-  common_val_print (value, stb, format_code[(int) format], 1, 0, 0,
-		    current_language);
+  get_formatted_print_options (&opts, format_code[(int) format]);
+  opts.deref_ref = 0;
+  common_val_print (value, stb, 0, &opts, current_language);
   thevalue = ui_file_xstrdup (stb, &dummy);
 
   do_cleanups (old_chain);

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  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-25 16:25                     ` Joel Brobecker
  1 sibling, 2 replies; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-24 13:01 UTC (permalink / raw)
  To: tromey; +Cc: Joel Brobecker, gdb-patches

Tom Tromey wrote:

> Thanks.  The appended tries to fix this.  I took a behavior-preserving
> approach.  I looked at all the val_print-like calls.  If the code
> before the patch passed 'deref_ref' to such a call, I ignored it.
> Otherwise I made a copy of the options and set deref_ref
> appropriately.
> 
> In some cases I suspect the previous code is really a "don't care" and
> we could just pass through the options.  But, I think that would be
> better done by someone more familiar with each call site than I am.

Agreed.

> I'll start testing this and writing the ChangeLog entry.

Thanks!  The patch looks good to me now, so if testing goes well,
this is OK.

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-24 13:01                     ` Ulrich Weigand
@ 2008-10-25 16:05                       ` Tom Tromey
  2008-10-27 17:07                       ` Tom Tromey
  1 sibling, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2008-10-25 16:05 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

Ulrich> Thanks!  The patch looks good to me now, so if testing goes well,
Ulrich> this is OK.

Just FYI -- it will be a while longer.

I realized today that the treatment of output_format is different with
the patch.  In particular, the old code distinguishes between the
format that is passed in and the global output_format in some places,
but the new code does not.

One way to see this is by setting output-radix.  Before the patch:

  (gdb) set output-radix 8
  (gdb) print enum_constant
  $1 = enum_constant

But after:

  (gdb) set output-radix 8
  (gdb) print enum_constant
  $1 = 01

I'll go back and introduce a second 'format' field in
value_print_options, unless someone has a better idea.

This behavior is not tested for.  So, I'll also add some test cases.

I can send the current patch if you want it for something more
immediate.  Relative to the previous one it has some bug fixes plus a
ChangeLog entry.

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-23 21:29                   ` Tom Tromey
  2008-10-24 13:01                     ` Ulrich Weigand
@ 2008-10-25 16:25                     ` Joel Brobecker
  2008-10-25 16:46                       ` Tom Tromey
  1 sibling, 1 reply; 32+ messages in thread
From: Joel Brobecker @ 2008-10-25 16:25 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Ulrich Weigand, gdb-patches

(just slowly catching up...)

I like the idea as well. Just one question: Why did you elect to pass
the structure as a pointer, rather than the structure itself? I wonder
if some of the complexity in terms of who owns the data, making a copy,
etc, could be removed if we passed the structure itself. In terms of
performance, it shouldn't be a problem, as I expect large structs to
be passed by reference anyway. The down-side is that the structure
cannot be opaque, but I don't think there is much value in that, since
conceptually our new structure is just a collection of settings.

This is actually a question I asked myself for struct parse_context
as well, and I think that the situation is the same, so I expect that
the same choice will be best for both.

-- 
Joel


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-25 16:25                     ` Joel Brobecker
@ 2008-10-25 16:46                       ` Tom Tromey
  2008-10-26 15:19                         ` Joel Brobecker
  0 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-25 16:46 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Ulrich Weigand, gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> I like the idea as well. Just one question: Why did you elect to
Joel> pass the structure as a pointer, rather than the structure
Joel> itself?

To avoid copying.  Most users just reference fields from the
structure, or pass it through unmodified.  So, this is more efficient
in the common cases.

I would have looked at passing by value if the structure were smaller.
As it is, on my machine it is 68 bytes -- that seems kind of big.

Joel> I wonder if some of the complexity in terms of who owns the
Joel> data, making a copy, etc, could be removed if we passed the
Joel> structure itself. In terms of performance, it shouldn't be a
Joel> problem, as I expect large structs to be passed by reference
Joel> anyway.

I think they have to be copied regardless, though, to preserve
pass-by-value semantics.


In this particular case, ownership is not an issue.  These structures
are only ever stack-allocated.  Passing pointers to const makes it
clear that these are not mutable.

Stack allocation does make the code a bit uglier, since when we do
want to make a copy we have to give the new object a name.  That is
one advantage of pass-by-value.


struct parse_context might be a bit different depending on what you
put in it.  For example, I was thinking that lexptr should probably
not be a global.  However, if we put it in parse_context, then the
context can't be const.  (Maybe we want two different structs though
-- one immutable and one to hold state for a given parse.)

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-25 16:46                       ` Tom Tromey
@ 2008-10-26 15:19                         ` Joel Brobecker
  0 siblings, 0 replies; 32+ messages in thread
From: Joel Brobecker @ 2008-10-26 15:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Ulrich Weigand, gdb-patches

> Joel> I like the idea as well. Just one question: Why did you elect to
> Joel> pass the structure as a pointer, rather than the structure
> Joel> itself?
> 
> To avoid copying.  Most users just reference fields from the
> structure, or pass it through unmodified.  So, this is more efficient
> in the common cases.

Ah, yes, of course. I was just confused with the pass-by-reference at
the ABI level. I think the same reasons apply to struct parse_context,
so I'll adjust my approach accordingly - even if the structure is small
right now (3 words for now), it's still bigger than 1 address...

-- 
Joel


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  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
  1 sibling, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-27 17:07 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 9650 bytes --]

>>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:

Tom> I'll start testing this and writing the ChangeLog entry.

Ulrich> Thanks!  The patch looks good to me now, so if testing goes well,
Ulrich> this is OK.

Here's the final version.

Now value_print_options has both 'format' and 'output_format' fields.
Most code should only check 'format'; 'output_format' is the analog of
the old global.

You can see where this matters by searching for this in the patch:

    format = format ? format : output_format;

I added a small regression test for this.

Built and regtested on x86-64 (compile farm).
Ok?  (I figured I probably changed enough to invalidate your earlier
approval...)

Tom

2008-10-27  Tom Tromey  <tromey@redhat.com>

	* varobj.c (value_get_print_value): Include valprint.h.
	(value_get_print_value): Use get_formatted_print_options.
	* value.h (struct value_print_options): Declare.
	(value_print, val_print, common_val_print, val_print_string):
	Update.
	* value.c: Include valprint.h.
	(show_values): Use get_user_print_options.
	(show_convenience): Likewise.
	* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
	declare.
	(struct value_print_options): New type.
	(vtblprint, unionprint, addressprint, objectprint, print_max,
	inspect_it, repeat_count_threshold, output_format,
	stop_print_at_null): Don't declare.
	(user_print_options, get_user_print_options,
	get_raw_print_options, get_formatted_print_options): Declare.
	(print_array_indexes_p): Don't declare.
	(maybe_print_array_index, val_print_array_elements): Update.
	* valprint.c (print_max): Remove.
	(user_print_options): New global.
	(get_user_print_options, get_raw_print_options,
	get_formatted_print_options): New functions.
	(print_array_indexes, repeat_count_threshold, stop_print_at_null,
	prettyprint_structs, prettyprint_arrays, unionprint,
	addressprint): Remove.
	(val_print): Remove format, deref_ref, pretty arguments; add
	options.  Update.
	(common_val_print): Likewise.
	(print_array_indexes_p): Remove.
	(maybe_print_array_index): Remove format, pretty arguments; add
	options.  Update.
	(val_print_array_elements): Remove format, deref_ref, pretty
	arguments; add options.  Update.
	(val_print_string): Add options argument.  Update.
	(_initialize_valprint): Use user_print_options.
	(output_format): Remove.
	(set_output_radix_1): Use user_print_options.
	* typeprint.c: Include valprint.h.
	(objectprint): Don't declare.
	(whatis_exp): Use get_user_print_options.
	* tui/tui-regs.c: Include valprint.h.
	(tui_register_format): Use get_formatted_print_options.
	* tracepoint.c: Include valprint.h.
	(addressprint): Don't declare.
	(trace_mention): Use get_user_print_options.
	(tracepoints_info): Likewise.
	* stack.c (print_frame_args): Use get_raw_print_options.
	(print_frame_info): Use get_user_print_options.
	(print_frame): Likewise.
	* sh64-tdep.c: Include valprint.h
	(sh64_do_register): Use get_formatted_print_options.
	* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
	pretty arguments; add options.
	(scm_scmlist_print): Likewise.  Update.
	(scm_scmval_print): Likewise.
	(scm_val_print): Likewise.
	(scm_value_print): Remove format, pretty arguments; add options.
	Update.
	* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
	Update.
	* scm-lang.c (scm_printstr): Add options argument.
	* python/python-value.c: Include valprint.h.
	(valpy_str): Use get_user_print_options.
	* printcmd.c: Include valprint.h.
	(addressprint): Don't declare.
	(inspect_it): Remove.
	(print_formatted): Remove format option; add options.  Update.
	(print_scalar_formatted): Likewise.
	(print_address_demangle): Use get_user_print_options.
	(do_examine): Use get_formatted_print_options.
	(print_command_1): Likewise.
	(output_command): Use get_formatted_print_options.
	(do_one_display): Likewise.
	(print_variable_value): Use get_user_print_options.
	* p-valprint.c (pascal_val_print): Remove format, deref_ref,
	pretty arguments; add options.  Update.
	(pascal_value_print): Remove format, pretty arguments; add
	options.  Update.
	(vtblprint, objectprint): Don't declare.
	(pascal_static_field_print): Remove.
	(pascal_object_print_value_fields): Remove format, pretty
	arguments; add options.  Update.
	(pascal_object_print_static_field): Likewise.
	(_initialize_pascal_valprint): Use user_print_options.  Update.
	* p-lang.h (pascal_val_print, pascal_value_print,
	pascal_printstr, pascal_object_print_value_fields): Update.
	(vtblprint, static_field_print): Don't declare.
	* p-lang.c (pascal_printstr): Add options argument.  Update.
	* objc-lang.c (objc_printstr): Add options argument.  Update.
	* mt-tdep.c: Include valprint.h.
	(mt_registers_info): Use get_raw_print_options.
	* mips-tdep.c: Include valprint.h.
	(mips_print_fp_register): Use get_formatted_print_options.
	(mips_print_register): Likewise.
	* mi/mi-main.c: Include valprint.h.
	(get_register): Use get_user_print_options.
	(mi_cmd_data_evaluate_expression): Likewise.
	(mi_cmd_data_read_memory): Use get_formatted_print_options.
	* mi/mi-cmd-stack.c: Include valprint.h.
	(list_args_or_locals): Use get_raw_print_options.
	* m2-valprint.c (print_function_pointer_address): Add addressprint
	argument.
	(m2_print_long_set): Remove format, pretty arguments.
	(m2_print_unbounded_array): Remove format, deref_ref, pretty
	arguments; add options.  Update.
	(print_unpacked_pointer): Remove format argument; add options.
	Now static.  Update.
	(print_variable_at_address): Remove format, deref_ref, pretty
	arguments; add options.  Update.
	(m2_print_array_contents): Likewise.
	(m2_val_print): Likewise.
	* m2-lang.h (m2_val_print): Update.
	* m2-lang.c (m2_printstr): Add options argument. Update.
	* language.h (struct value_print_options): Declare.
	(struct language_defn) <la_printstr>: Add options argument.
	<la_val_print>: Remove format, deref_ref, pretty argument; add
	options.
	<la_value_print>: Remove format, pretty arguments; add options.
	<la_print_array_index>: Likewise.
	(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
	LA_PRINT_ARRAY_INDEX): Update.
	(default_print_array_index): Update.
	* language.c (default_print_array_index): Remove format, pretty
	arguments; add options.  Update.
	(unk_lang_printstr): Add options argument.
	(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
	add options.
	(unk_lang_value_print): Remove format, pretty arguments; add
	options.
	* jv-valprint.c (java_value_print): Remove format, pretty
	arguments; add options.  Update.
	(java_print_value_fields): Likewise.
	(java_val_print): Remove format, deref_ref, pretty arguments; add
	options.  Update.
	* jv-lang.h (java_val_print, java_value_print): Declare.
	* infcmd.c: Include valprint.h.
	(print_return_value): Use get_raw_print_options.
	(default_print_registers_info): Use get_user_print_options,
	get_formatted_print_options.
	(registers_info): Use get_formatted_print_options.
	* gdbtypes.h (struct value_print_options): Declare.
	(print_scalar_formatted): Update.
	* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
	pretty arguments; add options.  Update.
	(f77_print_array): Likewise.
	(f_val_print): Likewise.
	* f-lang.h (f_val_print): Update.
	* f-lang.c (f_printstr): Add options argument.  Update.
	(c_value_print): Update declaration.
	* expprint.c: Include valprint.h.
	(print_subexp_standard): Use get_raw_print_options,
	get_user_print_options.
	* eval.c: Include valprint.h.
	(objectprint): Don't declare.
	(evaluate_subexp_standard): Use get_user_print_options.
	* cp-valprint.c (vtblprint, objectprint, static_field_print):
	Remove.
	(cp_print_value_fields): Remove format, pretty arguments; add
	options.  Update.
	(cp_print_value): Likewise.
	(cp_print_static_field): Likewise.
	(_initialize_cp_valprint): Use user_print_options.  Update.
	* c-valprint.c (print_function_pointer_address): Add addressprint
	argument.
	(c_val_print): Remove format, deref_ref, pretty arguments; add
	options.  Update.
	(c_value_print): Add options argument.  Update.
	* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
	(vtblprint, static_field_print): Don't declare.
	(cp_print_value_fields): Update.
	* c-lang.c (c_printstr): Add options argument.  Update.
	* breakpoint.c: Include valprint.h.
	(addressprint): Don't declare.
	(watchpoint_value_print): Use get_user_print_options.
	(print_one_breakpoint_location): Likewise.
	(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
	print_exception_catchpoint): Likewise.
	* auxv.c (fprint_target_auxv): Don't declare addressprint.  Use
	get_user_print_options.
	* ada-valprint.c (struct ada_val_print_args): Remove format,
	deref_ref, and pretty; add options.
	(print_optional_low_bound): Add options argument.
	(val_print_packed_array_elements): Remove format and pretty
	arguments; add options.  Update.
	(printstr): Add options argument.  Update.
	(ada_printstr): Likewise.
	(ada_val_print): Remove format, deref_ref, pretty arguments; add
	options argument.  Update.
	(ada_val_print_stub): Update.
	(ada_val_print_array): Remove format, deref_ref, pretty arguments;
	add options.  Update.
	(ada_val_print_1): Likewise.
	(print_variant_part): Likewise.
	(ada_value_print): Remove format, pretty arguments; add options.
	Update.
	(print_record): Likewise.
	(print_field_values): Likewise.
	* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
	Update.
	* ada-lang.c (ada_print_array_index): Add options argument; remove
	format and pretty arguments.
	(print_one_exception): Use get_user_print_options.

2008-10-27  Tom Tromey  <tromey@redhat.com>

	* gdb.base/exprs.exp (test_expr): Add enum formatting tests.


[-- Attachment #2: final patch --]
[-- Type: application/octet-stream, Size: 207720 bytes --]

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index cce7da9..9fdd944 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -353,9 +353,9 @@ ada_get_gdb_completer_word_break_characters (void)
 
 static void
 ada_print_array_index (struct value *index_value, struct ui_file *stream,
-                       int format, enum val_prettyprint pretty)
+                       const struct value_print_options *options)
 {
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, " => ");
 }
 
@@ -10100,7 +10100,10 @@ static void
 print_one_exception (enum exception_catchpoint_kind ex,
                      struct breakpoint *b, CORE_ADDR *last_addr)
 { 
-  if (addressprint)
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     {
       annotate_field (4);
       ui_out_field_core_addr (uiout, "addr", b->loc->address);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index ce6be4b..562a867 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -249,11 +249,11 @@ extern void ada_print_type (struct type *, char *, struct ui_file *, int,
                             int);
 
 extern int ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-                          struct ui_file *, int, int, int,
-                          enum val_prettyprint);
+                          struct ui_file *, int,
+			  const struct value_print_options *);
 
-extern int ada_value_print (struct value *, struct ui_file *, int,
-                            enum val_prettyprint);
+extern int ada_value_print (struct value *, struct ui_file *,
+			    const struct value_print_options *);
 
                                 /* Defined in ada-lang.c */
 
@@ -266,7 +266,8 @@ extern void ada_emit_char (int, struct ui_file *, int, int);
 extern void ada_printchar (int, struct ui_file *);
 
 extern void ada_printstr (struct ui_file *, const gdb_byte *,
-			  unsigned int, int, int);
+			  unsigned int, int, int,
+			  const struct value_print_options *);
 
 struct value *ada_convert_actual (struct value *actual,
                                   struct type *formal_type0,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index e2f7740..cc8352f 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -43,18 +43,17 @@ struct ada_val_print_args
   int embedded_offset;
   CORE_ADDR address;
   struct ui_file *stream;
-  int format;
-  int deref_ref;
   int recurse;
-  enum val_prettyprint pretty;
+  const struct value_print_options *options;
 };
 
 static void print_record (struct type *, const gdb_byte *, struct ui_file *,
-			  int, int, enum val_prettyprint);
+			  int, const struct value_print_options *);
 
 static int print_field_values (struct type *, const gdb_byte *,
-			       struct ui_file *, int, int,
-			       enum val_prettyprint, int, struct type *,
+			       struct ui_file *, int,
+			       const struct value_print_options *,
+			       int, struct type *,
 			       const gdb_byte *);
 
 static void adjust_type_signedness (struct type *);
@@ -62,8 +61,8 @@ static void adjust_type_signedness (struct type *);
 static int ada_val_print_stub (void *args0);
 
 static int ada_val_print_1 (struct type *, const gdb_byte *, int, CORE_ADDR,
-			    struct ui_file *, int, int, int,
-			    enum val_prettyprint);
+			    struct ui_file *, int,
+			    const struct value_print_options *);
 \f
 
 /* Make TYPE unsigned if its range of values includes no negatives.  */
@@ -81,13 +80,14 @@ adjust_type_signedness (struct type *type)
    otherwise 0.  */
 
 static int
-print_optional_low_bound (struct ui_file *stream, struct type *type)
+print_optional_low_bound (struct ui_file *stream, struct type *type,
+			  const struct value_print_options *options)
 {
   struct type *index_type;
   long low_bound;
   long high_bound;
 
-  if (print_array_indexes_p ())
+  if (options->print_array_indexes)
     return 0;
 
   if (!get_array_bounds (type, &low_bound, &high_bound))
@@ -137,16 +137,15 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
 
 /*  Version of val_print_array_elements for GNAT-style packed arrays.
     Prints elements of packed array of type TYPE at bit offset
-    BITOFFSET from VALADDR on STREAM.  Formats according to FORMAT and
+    BITOFFSET from VALADDR on STREAM.  Formats according to OPTIONS and
     separates with commas.  RECURSE is the recursion (nesting) level.
-    If PRETTY, uses "prettier" format.  TYPE must have been decoded (as
-    by ada_coerce_to_simple_array).  */
+    TYPE must have been decoded (as by ada_coerce_to_simple_array).  */
 
 static void
 val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 				 int bitoffset, struct ui_file *stream,
-				 int format, int recurse,
-				 enum val_prettyprint pretty)
+				 int recurse,
+				 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -172,14 +171,14 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
   i = 0;
   annotate_array_section_begin (i, elttype);
 
-  while (i < len && things_printed < print_max)
+  while (i < len && things_printed < options->print_max)
     {
       struct value *v0, *v1;
       int i0;
 
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -190,7 +189,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    }
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
-      maybe_print_array_index (index_type, i + low, stream, format, pretty);
+      maybe_print_array_index (index_type, i + low, stream, options);
 
       i0 = i;
       v0 = ada_value_primitive_packed_val (NULL, valaddr,
@@ -210,10 +209,12 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    break;
 	}
 
-      if (i - i0 > repeat_count_threshold)
+      if (i - i0 > options->repeat_count_threshold)
 	{
-	  val_print (elttype, value_contents (v0), 0, 0, stream, format,
-		     0, recurse + 1, pretty, current_language);
+	  struct value_print_options opts = *options;
+	  opts.deref_ref = 0;
+	  val_print (elttype, value_contents (v0), 0, 0, stream,
+		     recurse + 1, &opts, current_language);
 	  annotate_elt_rep (i - i0);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), i - i0);
 	  annotate_elt_rep_end ();
@@ -222,11 +223,13 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
       else
 	{
 	  int j;
+	  struct value_print_options opts = *options;
+	  opts.deref_ref = 0;
 	  for (j = i0; j < i; j += 1)
 	    {
 	      if (j > i0)
 		{
-		  if (prettyprint_arrays)
+		  if (options->prettyprint_arrays)
 		    {
 		      fprintf_filtered (stream, ",\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -237,10 +240,10 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 		    }
 		  wrap_here (n_spaces (2 + 2 * recurse));
 		  maybe_print_array_index (index_type, j + low,
-					   stream, format, pretty);
+					   stream, options);
 		}
-	      val_print (elttype, value_contents (v0), 0, 0, stream, format,
-			 0, recurse + 1, pretty, current_language);
+	      val_print (elttype, value_contents (v0), 0, 0, stream,
+			 recurse + 1, &opts, current_language);
 	      annotate_elt ();
 	    }
 	}
@@ -452,7 +455,8 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 
 static void
 printstr (struct ui_file *stream, const gdb_byte *string,
-	  unsigned int length, int force_ellipses, int type_len)
+	  unsigned int length, int force_ellipses, int type_len,
+	  const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -465,7 +469,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; i += 1)
+  for (i = 0; i < length && things_printed < options->print_max; i += 1)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -491,11 +495,11 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  reps += 1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -507,14 +511,14 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 	  fputs_filtered ("'", stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -529,7 +533,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
@@ -541,36 +545,28 @@ printstr (struct ui_file *stream, const gdb_byte *string,
 
 void
 ada_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
-  printstr (stream, string, length, force_ellipses, width);
+  printstr (stream, string, length, force_ellipses, width, options);
 }
 
 
 /* Print data of type TYPE located at VALADDR (within GDB), which came from
    the inferior at address ADDRESS, onto stdio stream STREAM according to
-   FORMAT (a letter as for the printf % codes or 0 for natural format).
-   The data at VALADDR is in target byte order.
+   OPTIONS.  The data at VALADDR is in target byte order.
 
    If the data is printed as a string, returns the number of string characters
    printed.
 
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
    RECURSE indicates the amount of indentation to supply before
-   continuation lines; this amount is roughly twice the value of RECURSE.
-
-   When PRETTY is non-zero, prints record fields on separate lines.
-   (For some reason, the current version of gdb instead uses a global
-   variable---prettyprint_arrays--- to causes a similar effect on
-   arrays.)  */
+   continuation lines; this amount is roughly twice the value of RECURSE.  */
 
 int
 ada_val_print (struct type *type, const gdb_byte *valaddr0,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   struct ada_val_print_args args;
   args.type = type;
@@ -578,10 +574,8 @@ ada_val_print (struct type *type, const gdb_byte *valaddr0,
   args.embedded_offset = embedded_offset;
   args.address = address;
   args.stream = stream;
-  args.format = format;
-  args.deref_ref = deref_ref;
   args.recurse = recurse;
-  args.pretty = pretty;
+  args.options = options;
 
   return catch_errors (ada_val_print_stub, &args, NULL, RETURN_MASK_ALL);
 }
@@ -594,8 +588,7 @@ ada_val_print_stub (void *args0)
   struct ada_val_print_args *argsp = (struct ada_val_print_args *) args0;
   return ada_val_print_1 (argsp->type, argsp->valaddr0,
 			  argsp->embedded_offset, argsp->address,
-			  argsp->stream, argsp->format, argsp->deref_ref,
-			  argsp->recurse, argsp->pretty);
+			  argsp->stream, argsp->recurse, argsp->options);
 }
 
 /* Assuming TYPE is a simple array, print the value of this array located
@@ -605,8 +598,8 @@ ada_val_print_stub (void *args0)
 
 static int
 ada_val_print_array (struct type *type, const gdb_byte *valaddr,
-		     CORE_ADDR address, struct ui_file *stream, int format,
-		     int deref_ref, int recurse, enum val_prettyprint pretty)
+		     CORE_ADDR address, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
 {
   struct type *elttype = TYPE_TARGET_TYPE (type);
   unsigned int eltlen;
@@ -623,40 +616,40 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
     len = TYPE_LENGTH (type) / eltlen;
 
   /* For an array of chars, print with string syntax.  */
-  if (ada_is_string_type (type) && (format == 0 || format == 's'))
+  if (ada_is_string_type (type)
+      && (options->format == 0 || options->format == 's'))
     {
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
         print_spaces_filtered (2 + 2 * recurse, stream);
 
       /* If requested, look for the first null char and only print
          elements up to it.  */
-      if (stop_print_at_null)
+      if (options->stop_print_at_null)
         {
           int temp_len;
 
           /* Look for a NULL char.  */
           for (temp_len = 0;
                (temp_len < len
-                && temp_len < print_max
+                && temp_len < options->print_max
                 && char_at (valaddr, temp_len, eltlen) != 0);
                temp_len += 1);
           len = temp_len;
         }
 
-      printstr (stream, valaddr, len, 0, eltlen);
+      printstr (stream, valaddr, len, 0, eltlen, options);
       result = len;
     }
   else
     {
       fprintf_filtered (stream, "(");
-      print_optional_low_bound (stream, type);
+      print_optional_low_bound (stream, type, options);
       if (TYPE_FIELD_BITSIZE (type, 0) > 0)
         val_print_packed_array_elements (type, valaddr, 0, stream,
-                                         format, recurse, pretty);
+                                         recurse, options);
       else
         val_print_array_elements (type, valaddr, address, stream,
-                                  format, deref_ref, recurse,
-                                  pretty, 0);
+                                  recurse, options, 0);
       fprintf_filtered (stream, ")");
     }
 
@@ -669,8 +662,8 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
 static int
 ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 		 int embedded_offset, CORE_ADDR address,
-		 struct ui_file *stream, int format,
-		 int deref_ref, int recurse, enum val_prettyprint pretty)
+		 struct ui_file *stream, int recurse,
+		 const struct value_print_options *options)
 {
   unsigned int len;
   int i;
@@ -695,8 +688,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	retn = ada_val_print_1 (value_type (val), value_contents (val), 0,
-				VALUE_ADDRESS (val), stream, format,
-				deref_ref, recurse, pretty);
+				VALUE_ADDRESS (val), stream, recurse, options);
       value_free_to_mark (mark);
       return retn;
     }
@@ -709,12 +701,12 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
     {
     default:
       return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
 
     case TYPE_CODE_PTR:
       {
 	int ret = c_val_print (type, valaddr0, embedded_offset, address, 
-			       stream, format, deref_ref, recurse, pretty);
+			       stream, recurse, options);
 	if (ada_is_tag_type (type))
 	  {
 	    struct value *val = 
@@ -778,20 +770,22 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 					    value_from_contents_and_address
 					    (type, valaddr, 0));
 	      return ada_val_print_1 (target_type, value_contents (v), 0, 0,
-				      stream, format, 0, recurse + 1, pretty);
+				      stream, recurse + 1, options);
 	    }
 	  else
 	    return ada_val_print_1 (TYPE_TARGET_TYPE (type),
 				    valaddr0, embedded_offset,
-				    address, stream, format, deref_ref,
-				    recurse, pretty);
+				    address, stream, recurse, options);
 	}
       else
 	{
-	  format = format ? format : output_format;
+	  int format = (options->format ? options->format
+			: options->output_format);
 	  if (format)
 	    {
-	      print_scalar_formatted (valaddr, type, format, 0, stream);
+	      struct value_print_options opts = *options;
+	      opts.format = format;
+	      print_scalar_formatted (valaddr, type, &opts, 0, stream);
 	    }
           else if (ada_is_system_address_type (type)
 		   && TYPE_OBJFILE (type) != NULL)
@@ -830,9 +824,9 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -860,16 +854,16 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->format)
+	print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->format)
 	return c_val_print (type, valaddr0, embedded_offset, address, stream,
-			    format, deref_ref, recurse, pretty);
+			    recurse, options);
       else
 	ada_print_floating (valaddr0 + embedded_offset, type, stream);
       break;
@@ -883,13 +877,13 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 	}
       else
 	{
-	  print_record (type, valaddr, stream, format, recurse, pretty);
+	  print_record (type, valaddr, stream, recurse, options);
 	  return 0;
 	}
 
     case TYPE_CODE_ARRAY:
-      return ada_val_print_array (type, valaddr, address, stream, format,
-                                  deref_ref, recurse, pretty);
+      return ada_val_print_array (type, valaddr, address, stream,
+				  recurse, options);
 
     case TYPE_CODE_REF:
       /* For references, the debugger is expected to print the value as
@@ -910,8 +904,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
                                 deref_val_int));
               val_print (value_type (deref_val),
                          value_contents (deref_val), 0,
-                         VALUE_ADDRESS (deref_val), stream, format,
-                         deref_ref, recurse + 1, pretty, current_language);
+                         VALUE_ADDRESS (deref_val), stream, recurse + 1,
+			 options, current_language);
             }
           else
             fputs_filtered ("(null)", stream);
@@ -927,8 +921,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
 
 static int
 print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options, int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
@@ -941,13 +935,13 @@ print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
       (TYPE_FIELD_TYPE (var_type, which),
        valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
        + TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
-       stream, format, recurse, pretty,
+       stream, recurse, options,
        comma_needed, outer_type, outer_valaddr);
 }
 
 int
-ada_value_print (struct value *val0, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+ada_value_print (struct value *val0, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
   const gdb_byte *valaddr = value_contents (val0);
   CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
@@ -955,6 +949,7 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
     ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);
   struct value *val =
     value_from_contents_and_address (type, valaddr, address);
+  struct value_print_options opts;
 
   /* If it is a pointer, indicate what it points to.  */
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
@@ -984,21 +979,23 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
       return 0;
     }
 
+  opts = *options;
+  opts.deref_ref = 1;
   return (val_print (type, value_contents (val), 0, address,
-		     stream, format, 1, 0, pretty, current_language));
+		     stream, 0, &opts, current_language));
 }
 
 static void
 print_record (struct type *type, const gdb_byte *valaddr,
-	      struct ui_file *stream, int format, int recurse,
-	      enum val_prettyprint pretty)
+	      struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   type = ada_check_typedef (type);
 
   fprintf_filtered (stream, "(");
 
-  if (print_field_values (type, valaddr, stream, format, recurse, pretty,
-			  0, type, valaddr) != 0 && pretty)
+  if (print_field_values (type, valaddr, stream, recurse, options,
+			  0, type, valaddr) != 0 && options->pretty)
     {
       fprintf_filtered (stream, "\n");
       print_spaces_filtered (2 * recurse, stream);
@@ -1009,7 +1006,7 @@ print_record (struct type *type, const gdb_byte *valaddr,
 
 /* Print out fields of value at VALADDR having structure type TYPE.
 
-   TYPE, VALADDR, STREAM, FORMAT, RECURSE, and PRETTY have the
+   TYPE, VALADDR, STREAM, RECURSE, and OPTIONS have the
    same meanings as in ada_print_value and ada_val_print.
 
    OUTER_TYPE and OUTER_VALADDR give type and address of enclosing record
@@ -1023,8 +1020,9 @@ print_record (struct type *type, const gdb_byte *valaddr,
 
 static int
 print_field_values (struct type *type, const gdb_byte *valaddr,
-		    struct ui_file *stream, int format, int recurse,
-		    enum val_prettyprint pretty, int comma_needed,
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options,
+		    int comma_needed,
 		    struct type *outer_type, const gdb_byte *outer_valaddr)
 {
   int i, len;
@@ -1042,7 +1040,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	    print_field_values (TYPE_FIELD_TYPE (type, i),
 				valaddr
 				+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-				stream, format, recurse, pretty,
+				stream, recurse, options,
 				comma_needed, type, valaddr);
 	  continue;
 	}
@@ -1050,7 +1048,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  comma_needed =
 	    print_variant_part (type, i, valaddr,
-				stream, format, recurse, pretty, comma_needed,
+				stream, recurse, options, comma_needed,
 				outer_type, outer_valaddr);
 	  continue;
 	}
@@ -1059,7 +1057,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, ", ");
       comma_needed = 1;
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1068,7 +1066,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	{
 	  wrap_here (n_spaces (2 + 2 * recurse));
 	}
-      if (inspect_it)
+      if (options->inspect_it)
 	{
 	  if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 	    fputs_filtered ("\"( ptr \"", stream);
@@ -1107,6 +1105,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	    {
 	      int bit_pos = TYPE_FIELD_BITPOS (type, i);
 	      int bit_size = TYPE_FIELD_BITSIZE (type, i);
+	      struct value_print_options opts;
 
 	      adjust_type_signedness (TYPE_FIELD_TYPE (type, i));
 	      v = ada_value_primitive_packed_val (NULL, valaddr,
@@ -1114,15 +1113,20 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 						  bit_pos % HOST_CHAR_BIT,
 						  bit_size,
 						  TYPE_FIELD_TYPE (type, i));
+	      opts = *options;
+	      opts.deref_ref = 0;
 	      val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0, 0,
-			 stream, format, 0, recurse + 1, pretty,
-			 current_language);
+			 stream, recurse + 1, &opts, current_language);
 	    }
 	}
       else
-	ada_val_print (TYPE_FIELD_TYPE (type, i),
-		       valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
-		       0, 0, stream, format, 0, recurse + 1, pretty);
+	{
+	  struct value_print_options opts = *options;
+	  opts.deref_ref = 0;
+	  ada_val_print (TYPE_FIELD_TYPE (type, i),
+			 valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
+			 0, 0, stream, recurse + 1, &opts);
+	}
       annotate_field_end ();
     }
 
diff --git a/gdb/auxv.c b/gdb/auxv.c
index afc7fdd..121a749 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -172,7 +172,6 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 
   while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
     {
-      extern int addressprint;
       const char *name = "???";
       const char *description = "";
       enum { dec, hex, str } flavor = hex;
@@ -240,10 +239,14 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 	  fprintf_filtered (file, "0x%s\n", paddr_nz (val));
 	  break;
 	case str:
-	  if (addressprint)
-	    fprintf_filtered (file, "0x%s", paddr_nz (val));
-	  val_print_string (val, -1, 1, file);
-	  fprintf_filtered (file, "\n");
+	  {
+	    struct value_print_options opts;
+	    get_user_print_options (&opts);
+	    if (opts.addressprint)
+	      fprintf_filtered (file, "0x%s", paddr_nz (val));
+	    val_print_string (val, -1, 1, file, &opts);
+	    fprintf_filtered (file, "\n");
+	  }
 	  break;
 	}
       ++ents;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 180f6c9..01b2990 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -56,6 +56,7 @@
 #include "ada-lang.h"
 #include "top.h"
 #include "wrapper.h"
+#include "valprint.h"
 
 #include "mi/mi-common.h"
 
@@ -283,8 +284,6 @@ breakpoints_always_inserted_mode (void)
 
 void _initialize_breakpoint (void);
 
-extern int addressprint;	/* Print machine addresses? */
-
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
@@ -2259,7 +2258,11 @@ watchpoint_value_print (struct value *val, struct ui_file *stream)
   if (val == NULL)
     fprintf_unfiltered (stream, _("<unreadable>"));
   else
-    value_print (val, stream, 0, Val_pretty_default);
+    {
+      struct value_print_options opts;
+      get_user_print_options (&opts);
+      value_print (val, stream, &opts);
+    }
 }
 
 /* This is the normal print function for a bpstat.  In the future,
@@ -3577,6 +3580,9 @@ print_one_breakpoint_location (struct breakpoint *b,
 
   int header_of_multiple = 0;
   int part_of_multiple = (loc != NULL);
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
 
   gdb_assert (!loc || loc_number != 0);
   /* See comment in print_one_breakpoint concerning
@@ -3640,7 +3646,7 @@ print_one_breakpoint_location (struct breakpoint *b,
   
   /* 5 and 6 */
   strcpy (wrap_indent, "                           ");
-  if (addressprint)
+  if (opts.addressprint)
     {
       if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	strcat (wrap_indent, "           ");
@@ -3672,7 +3678,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	print_expression (b->exp, stb->stream);
@@ -3684,7 +3690,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->dll_pathname == NULL)
@@ -3704,7 +3710,7 @@ print_one_breakpoint_location (struct breakpoint *b,
 	/* Field 4, the address, is omitted (which makes the columns
 	   not line up too nicely with the headers, but the effect
 	   is relatively readable).  */
-	if (addressprint)
+	if (opts.addressprint)
 	  ui_out_field_skip (uiout, "addr");
 	annotate_field (5);
 	if (b->exec_pathname != NULL)
@@ -3727,7 +3733,7 @@ print_one_breakpoint_location (struct breakpoint *b,
       case bp_shlib_event:
       case bp_thread_event:
       case bp_overlay_event:
-	if (addressprint)
+	if (opts.addressprint)
 	  {
 	    annotate_field (4);
 	    if (header_of_multiple)
@@ -3933,7 +3939,10 @@ breakpoint_1 (int bnum, int allflag)
   CORE_ADDR last_addr = (CORE_ADDR) -1;
   int nr_printable_breakpoints;
   struct cleanup *bkpttbl_chain;
+  struct value_print_options opts;
   
+  get_user_print_options (&opts);
+
   /* Compute the number of rows in the table. */
   nr_printable_breakpoints = 0;
   ALL_BREAKPOINTS (b)
@@ -3944,7 +3953,7 @@ breakpoint_1 (int bnum, int allflag)
 	  nr_printable_breakpoints++;
       }
 
-  if (addressprint)
+  if (opts.addressprint)
     bkpttbl_chain 
       = make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
                                              "BreakpointTable");
@@ -3967,7 +3976,7 @@ breakpoint_1 (int bnum, int allflag)
   if (nr_printable_breakpoints > 0)
     annotate_field (3);
   ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb");	/* 4 */
-  if (addressprint)
+  if (opts.addressprint)
 	{
 	  if (nr_printable_breakpoints > 0)
 	    annotate_field (4);
@@ -4760,10 +4769,14 @@ print_it_catch_fork (struct breakpoint *b)
 static void
 print_one_catch_fork (struct breakpoint *b, CORE_ADDR *last_addr)
 {
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
+
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (opts.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "fork");
@@ -4838,10 +4851,13 @@ print_it_catch_vfork (struct breakpoint *b)
 static void
 print_one_catch_vfork (struct breakpoint *b, CORE_ADDR *last_addr)
 {
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
   /* Field 4, the address, is omitted (which makes the columns
      not line up too nicely with the headers, but the effect
      is relatively readable).  */
-  if (addressprint)
+  if (opts.addressprint)
     ui_out_field_skip (uiout, "addr");
   annotate_field (5);
   ui_out_text (uiout, "vfork");
@@ -5072,6 +5088,9 @@ mention (struct breakpoint *b)
   int say_where = 0;
   struct cleanup *old_chain, *ui_out_chain;
   struct ui_stream *stb;
+  struct value_print_options opts;
+
+  get_user_print_options (&opts);
 
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -5184,7 +5203,7 @@ mention (struct breakpoint *b)
 	}
       else
 	{
-	  if (addressprint || b->source_file == NULL)
+	  if (opts.addressprint || b->source_file == NULL)
 	    {
 	      printf_filtered (" at ");
 	      fputs_filtered (paddress (b->loc->address), gdb_stdout);
@@ -6746,7 +6765,9 @@ print_exception_catchpoint (struct breakpoint *b)
 static void
 print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
 {
-  if (addressprint)
+  struct value_print_options opts;
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     {
       annotate_field (4);
       if (b->loc == NULL || b->loc->shlib_disabled)
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a978b17..067e429 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -86,7 +86,8 @@ c_printchar (int c, struct ui_file *stream)
 
 void
 c_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -108,7 +109,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -137,11 +138,11 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -150,14 +151,14 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 	  LA_PRINT_CHAR (current_char, stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -171,7 +172,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index fe1939a..cc9abde 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -40,11 +40,11 @@ extern void c_print_type (struct type *, char *, struct ui_file *, int,
 extern void c_print_typedef (struct type *, struct symbol *, struct ui_file *);
 
 extern int c_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 /* These are in c-lang.c: */
 
@@ -52,7 +52,8 @@ extern void c_printchar (int, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, const gdb_byte *string,
 			unsigned int length, int width,
-			int force_ellipses);
+			int force_ellipses,
+			const struct value_print_options *options);
 
 extern void scan_macro_expansion (char *expansion);
 extern int scanning_macro_expansion (void);
@@ -70,17 +71,13 @@ extern void c_type_print_base (struct type *, struct ui_file *, int, int);
 
 /* These are in cp-valprint.c */
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void cp_print_class_member (const gdb_byte *, struct type *,
 				   struct ui_file *, char *);
 
 extern void cp_print_value_fields (struct type *, struct type *,
 				   const gdb_byte *, int, CORE_ADDR,
 				   struct ui_file *, int,
-				   int, enum val_prettyprint,
+				   const struct value_print_options *,
 				   struct type **, int);
 
 extern int cp_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 1dff6cb..b639e8b 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -36,7 +36,8 @@
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -102,21 +103,15 @@ textual_element_type (struct type *type, char format)
 
 /* Print data of type TYPE located at VALADDR (within GDB), which came from
    the inferior at address ADDRESS, onto stdio stream STREAM according to
-   FORMAT (a letter or 0 for natural format).  The data at VALADDR is in
-   target byte order.
+   OPTIONS.  The data at VALADDR is in target byte order.
 
    If the data are a string pointer, returns the number of string characters
-   printed.
-
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
-   The PRETTY parameter controls prettyprinting.  */
+   printed.  */
 
 int
 c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -134,29 +129,29 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	{
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
 
 	  /* Print arrays of textual chars with a string syntax.  */
-          if (textual_element_type (elttype, format))
+          if (textual_element_type (elttype, options->format))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0, options);
 	      i = len;
 	    }
 	  else
@@ -174,7 +169,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -184,9 +179,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_MEMBERPTR:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
@@ -197,19 +193,20 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->format && options->format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
 	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.) */
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	  break;
 	}
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -220,21 +217,24 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
 	    {
 	      /* Try to print what function it points to.  */
-	      print_function_pointer_address (addr, stream);
+	      print_function_pointer_address (addr, stream,
+					      options->addressprint);
 	      /* Return value is irrelevant except for string pointers.  */
 	      return (0);
 	    }
 
-	  if (addressprint)
+	  if (options->addressprint)
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to a textual type, also print the string
 	     pointed to, unless pointer is null.  */
 	  /* FIXME: need to handle wchar_t here... */
 
-	  if (textual_element_type (elttype, format) && addr != 0)
+	  if (textual_element_type (elttype, options->format)
+	      && addr != 0)
 	    {
-	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	      i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				    options);
 	    }
 	  else if (cp_is_vtbl_member (type))
 	    {
@@ -250,7 +250,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -271,10 +271,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format,
-				    deref_ref, recurse + 1, pretty,
+		  common_val_print (vt_val, stream, recurse + 1, options,
 				    current_language);
-		  if (pretty)
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -291,17 +290,17 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -309,8 +308,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -318,7 +317,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -326,7 +325,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
       /*FIXME: Abstract this away */
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -337,17 +336,18 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + offset, field_type);
 
-	  print_function_pointer_address (addr, stream);
+	  print_function_pointer_address (addr, stream, options->addressprint);
 	}
       else
-	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
-			       recurse, pretty, NULL, 0);
+	cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream,
+			       recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -371,17 +371,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -394,9 +396,14 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
+	}
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -420,10 +427,13 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->format || options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
 	}
       else
 	{
@@ -432,7 +442,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	     Since we don't know whether the value is really intended to
 	     be used as an integer or a character, print the character
 	     equivalent as well.  */
-	  if (textual_element_type (type, format))
+	  if (textual_element_type (type, options->format))
 	    {
 	      fputs_filtered (" ", stream);
 	      LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
@@ -442,10 +452,13 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->format || options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
 	}
       else
 	{
@@ -460,9 +473,10 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -471,8 +485,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_DECFLOAT:
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->format)
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options, 0, stream);
       else
 	print_decimal_floating (valaddr + embedded_offset, type, stream);
       break;
@@ -493,19 +508,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_COMPLEX:
-      if (format)
+      if (options->format)
 	print_scalar_formatted (valaddr + embedded_offset,
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
 			stream);
       fprintf_filtered (stream, " + ");
-      if (format)
+      if (options->format)
 	print_scalar_formatted (valaddr + embedded_offset
 				+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
 				TYPE_TARGET_TYPE (type),
-				format, 0, stream);
+				options, 0, stream);
       else
 	print_floating (valaddr + embedded_offset
 			+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
@@ -522,11 +537,14 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 }
 \f
 int
-c_value_print (struct value *val, struct ui_file *stream, int format,
-	       enum val_prettyprint pretty)
+c_value_print (struct value *val, struct ui_file *stream, 
+	       const struct value_print_options *options)
 {
   struct type *type, *real_type;
   int full, top, using_enc;
+  struct value_print_options opts = *options;
+
+  opts.deref_ref = 1;
 
   /* If it is a pointer, indicate what it points to.
 
@@ -551,7 +569,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	{
 	  /* Print nothing */
 	}
-      else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+      else if (options->objectprint
+	       && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
 	{
 
 	  if (TYPE_CODE(type) == TYPE_CODE_REF)
@@ -602,7 +621,7 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   if (!value_initialized (val))
     fprintf_filtered (stream, " [uninitialized] ");
 
-  if (objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
+  if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
     {
       /* Attempt to determine real type of object */
       real_type = value_rtti_type (val, &full, &top, &using_enc);
@@ -616,8 +635,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 	  /* Print out object: enclosing type is same as real_type if full */
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    &opts, current_language);
           /* Note: When we look up RTTI entries, we don't get any information on
              const or volatile attributes */
 	}
@@ -628,8 +647,8 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
 			    TYPE_NAME (value_enclosing_type (val)));
 	  return val_print (value_enclosing_type (val),
 			    value_contents_all (val), 0,
-			    VALUE_ADDRESS (val), stream, format, 1, 0,
-			    pretty, current_language);
+			    VALUE_ADDRESS (val), stream, 0,
+			    &opts, current_language);
 	}
       /* Otherwise, we end up at the return outside this "if" */
     }
@@ -637,5 +656,5 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
   return val_print (type, value_contents_all (val),
 		    value_embedded_offset (val),
 		    VALUE_ADDRESS (val) + value_offset (val),
-		    stream, format, 1, 0, pretty, current_language);
+		    stream, 0, &opts, current_language);
 }
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 61559af..2968953 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -38,7 +38,6 @@
 #include "language.h"
 
 /* Controls printing of vtbl's */
-int vtblprint;
 static void
 show_vtblprint (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -50,7 +49,6 @@ Printing of C++ virtual function tables is %s.\n"),
 
 /* Controls looking up an object's derived type using what we find in
    its vtables.  */
-int objectprint;
 static void
 show_objectprint (struct ui_file *file, int from_tty,
 		  struct cmd_list_element *c,
@@ -61,7 +59,6 @@ Printing of object's derived type based on vtable info is %s.\n"),
 		    value);
 }
 
-int static_field_print;		/* Controls printing of static fields. */
 static void
 show_static_field_print (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -77,12 +74,12 @@ static struct obstack dont_print_statmem_obstack;
 extern void _initialize_cp_valprint (void);
 
 static void cp_print_static_field (struct type *, struct value *,
-				   struct ui_file *, int, int,
-				   enum val_prettyprint);
+				   struct ui_file *, int,
+				   const struct value_print_options *);
 
 static void cp_print_value (struct type *, struct type *, const gdb_byte *,
-			    int, CORE_ADDR, struct ui_file *, int, int,
-			    enum val_prettyprint, struct type **);
+			    int, CORE_ADDR, struct ui_file *, int,
+			    const struct value_print_options *, struct type **);
 
 
 /* GCC versions after 2.4.5 use this.  */
@@ -139,7 +136,7 @@ cp_is_vtbl_member (struct type *type)
 /* Mutually recursive subroutines of cp_print_value and c_val_print to
    print out a structure's fields: cp_print_value_fields and cp_print_value.
 
-   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
+   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
    same meanings as in cp_print_value and c_val_print.
 
    2nd argument REAL_TYPE is used to carry over the type of the derived
@@ -151,9 +148,9 @@ cp_is_vtbl_member (struct type *type)
 void
 cp_print_value_fields (struct type *type, struct type *real_type,
 		       const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		       struct ui_file *stream, int format, int recurse,
-		       enum val_prettyprint pretty,
-		       struct type **dont_print_vb,int dont_print_statmem)
+		       struct ui_file *stream, int recurse,
+		       const struct value_print_options *options,
+		       struct type **dont_print_vb, int dont_print_statmem)
 {
   int i, len, n_baseclasses;
   char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
@@ -170,7 +167,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
   if (n_baseclasses > 0)
     cp_print_value (type, real_type, valaddr, offset, address, stream,
-		    format, recurse + 1, pretty, dont_print_vb);
+		    recurse + 1, options, dont_print_vb);
 
   /* Second, print out data fields */
 
@@ -192,7 +189,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!static_field_print
+	  if (!options->static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 
@@ -200,7 +197,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -211,7 +208,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -220,7 +217,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -266,11 +263,13 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  v = value_from_longest
 		    (TYPE_FIELD_TYPE (type, i), 
 		     unpack_field_as_long (type, valaddr + offset, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1, pretty,
+		  common_val_print (v, stream, recurse + 1, &opts,
 				    current_language);
 		}
 	    }
@@ -287,15 +286,16 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		    fputs_filtered ("<optimized out>", stream);
 		  else
 		    cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
-					   stream, format, recurse + 1,
-					   pretty);
+					   stream, recurse + 1, options);
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, &opts,
 			     current_language);
 		}
 	    }
@@ -310,7 +310,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -326,8 +326,9 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 static void
 cp_print_value (struct type *type, struct type *real_type,
 		const gdb_byte *valaddr, int offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int recurse,
-		enum val_prettyprint pretty, struct type **dont_print_vb)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options,
+		struct type **dont_print_vb)
 {
   struct type **last_dont_print
     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
@@ -402,7 +403,7 @@ cp_print_value (struct type *type, struct type *real_type,
 	base_valaddr = valaddr;
 
       /* now do the printing */
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -419,8 +420,7 @@ cp_print_value (struct type *type, struct type *real_type,
       else
 	cp_print_value_fields (baseclass, thistype, base_valaddr,
 			       thisoffset + boffset, address + boffset,
-			       stream, format,
-			       recurse, pretty,
+			       stream, recurse, options,
 			       ((struct type **)
 				obstack_base (&dont_print_vb_obstack)),
 			       0);
@@ -447,17 +447,17 @@ cp_print_value (struct type *type, struct type *real_type,
    static member classes in an obstack and refuse to print them more
    than once.
 
-   VAL contains the value to print, TYPE, STREAM, RECURSE, and PRETTY
+   VAL contains the value to print, TYPE, STREAM, RECURSE, and OPTIONS
    have the same meanings as in c_val_print.  */
 
 static void
 cp_print_static_field (struct type *type,
 		       struct value *val,
 		       struct ui_file *stream,
-		       int format,
 		       int recurse,
-		       enum val_prettyprint pretty)
+		       const struct value_print_options *options)
 {
+  struct value_print_options opts;
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
       CORE_ADDR *first_dont_print;
@@ -485,12 +485,15 @@ cp_print_static_field (struct type *type,
       CHECK_TYPEDEF (type);
       cp_print_value_fields (type, type, value_contents_all (val),
 			     value_embedded_offset (val), VALUE_ADDRESS (val),
-			     stream, format, recurse, pretty, NULL, 1);
+			     stream, recurse, options, NULL, 1);
       return;
     }
+
+  opts = *options;
+  opts.deref_ref = 0;
   val_print (type, value_contents_all (val), 
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stream, format, 0, recurse, pretty, current_language);
+	     stream, recurse, &opts, current_language);
 }
 
 
@@ -589,32 +592,29 @@ void
 _initialize_cp_valprint (void)
 {
   add_setshow_boolean_cmd ("static-members", class_support,
-			   &static_field_print, _("\
+			   &user_print_options.static_field_print, _("\
 Set printing of C++ static members."), _("\
 Show printing of C++ static members."), NULL,
 			   NULL,
 			   show_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  static_field_print = 1;
 
-  add_setshow_boolean_cmd ("vtbl", class_support, &vtblprint, _("\
+  add_setshow_boolean_cmd ("vtbl", class_support,
+			   &user_print_options.vtblprint, _("\
 Set printing of C++ virtual function tables."), _("\
 Show printing of C++ virtual function tables."), NULL,
 			   NULL,
 			   show_vtblprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("object", class_support, &objectprint, _("\
+  add_setshow_boolean_cmd ("object", class_support,
+			   &user_print_options.objectprint, _("\
 Set printing of object's derived type based on vtable info."), _("\
 Show printing of object's derived type based on vtable info."), NULL,
 			   NULL,
 			   show_objectprint,
 			   &setprintlist, &showprintlist);
 
-  /* Give people the defaults which they are used to.  */
-  objectprint = 0;
-  vtblprint = 0;
   obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
   obstack_specify_allocation (&dont_print_statmem_obstack,
 			      32 * sizeof (CORE_ADDR), sizeof (CORE_ADDR),
diff --git a/gdb/eval.c b/gdb/eval.c
index cf3e876..4394aa1 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -39,16 +39,13 @@
 #include "exceptions.h"
 #include "regcache.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 
 /* This is defined in valops.c */
 extern int overload_resolution;
 
-/* JYG: lookup rtti type of STRUCTOP_PTR when this is set to continue
-   on with successful lookup for member/method of the rtti type. */
-extern int objectprint;
-
 /* Prototypes for local functions. */
 
 static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
@@ -1628,8 +1625,10 @@ evaluate_subexp_standard (struct type *expect_type,
         struct type *type = value_type (arg1);
         struct type *real_type;
         int full, top, using_enc;
-        
-        if (objectprint && TYPE_TARGET_TYPE(type) &&
+	struct value_print_options opts;
+
+	get_user_print_options (&opts);
+        if (opts.objectprint && TYPE_TARGET_TYPE(type) &&
             (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
           {
             real_type = value_rtti_target_type (arg1, &full, &top, &using_enc);
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 079f2a9..756a02e 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -31,6 +31,7 @@
 #include "block.h"
 #include "objfiles.h"
 #include "gdb_assert.h"
+#include "valprint.h"
 
 #ifdef HAVE_CTYPE_H
 #include <ctype.h>
@@ -92,17 +93,25 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_LONG:
-      (*pos) += 3;
-      value_print (value_from_longest (exp->elts[pc + 1].type,
-				       exp->elts[pc + 2].longconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_longest (exp->elts[pc + 1].type,
+					 exp->elts[pc + 2].longconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_DOUBLE:
-      (*pos) += 3;
-      value_print (value_from_double (exp->elts[pc + 1].type,
-				      exp->elts[pc + 2].doubleconst),
-		   stream, 0, Val_no_prettyprint);
+      {
+	struct value_print_options opts;
+	get_raw_print_options (&opts);
+	(*pos) += 3;
+	value_print (value_from_double (exp->elts[pc + 1].type,
+					exp->elts[pc + 2].doubleconst),
+		     stream, &opts);
+      }
       return;
 
     case OP_VAR_VALUE:
@@ -169,12 +178,17 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_STRING:
-      nargs = longest_to_int (exp->elts[pc + 1].longconst);
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
-      /* LA_PRINT_STRING will print using the current repeat count threshold.
-         If necessary, we can temporarily set it to zero, or pass it as an
-         additional parameter to LA_PRINT_STRING.  -fnf */
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+      {
+	struct value_print_options opts;
+	nargs = longest_to_int (exp->elts[pc + 1].longconst);
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+	/* LA_PRINT_STRING will print using the current repeat count threshold.
+	   If necessary, we can temporarily set it to zero, or pass it as an
+	   additional parameter to LA_PRINT_STRING.  -fnf */
+	get_user_print_options (&opts);
+	LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+			 &opts);
+      }
       return;
 
     case OP_BITSTRING:
@@ -185,11 +199,16 @@ print_subexp_standard (struct expression *exp, int *pos,
       return;
 
     case OP_OBJC_NSSTRING:	/* Objective-C Foundation Class NSString constant.  */
-      nargs = longest_to_int (exp->elts[pc + 1].longconst);
-      (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
-      fputs_filtered ("@\"", stream);
-      LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
-      fputs_filtered ("\"", stream);
+      {
+	struct value_print_options opts;
+	nargs = longest_to_int (exp->elts[pc + 1].longconst);
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+	fputs_filtered ("@\"", stream);
+	get_user_print_options (&opts);
+	LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+			 &opts);
+	fputs_filtered ("\"", stream);
+      }
       return;
 
     case OP_OBJC_MSGCALL:
@@ -270,7 +289,10 @@ print_subexp_standard (struct expression *exp, int *pos,
 	}
       if (tem > 0)
 	{
-	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
+	  struct value_print_options opts;
+	  get_user_print_options (&opts);
+	  LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
+			   &opts);
 	  (*pos) = pc;
 	}
       else
@@ -394,6 +416,8 @@ print_subexp_standard (struct expression *exp, int *pos,
       if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
 	  exp->elts[pc + 3].opcode == OP_LONG)
 	{
+	  struct value_print_options opts;
+
 	  /* We have a minimal symbol fn, probably.  It's encoded
 	     as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
 	     Swallow the OP_LONG (including both its opcodes); ignore
@@ -401,7 +425,8 @@ print_subexp_standard (struct expression *exp, int *pos,
 	  (*pos) += 4;
 	  val = value_at_lazy (exp->elts[pc + 1].type,
 			       (CORE_ADDR) exp->elts[pc + 5].longconst);
-	  value_print (val, stream, 0, Val_no_prettyprint);
+	  get_raw_print_options (&opts);
+	  value_print (val, stream, &opts);
 	}
       else
 	{
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 736d6c6..4d4d4d7 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -142,7 +142,8 @@ f_printchar (int c, struct ui_file *stream)
 
 static void
 f_printstr (struct ui_file *stream, const gdb_byte *string,
-	    unsigned int length, int width, int force_ellipses)
+	    unsigned int length, int width, int force_ellipses,
+	    const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -155,7 +156,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -179,11 +180,11 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -192,14 +193,14 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
 	  f_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -213,7 +214,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
@@ -305,8 +306,8 @@ f_language_arch_info (struct gdbarch *gdbarch,
 
 /* This is declared in c-lang.h but it is silly to import that file for what
    is already just a hack. */
-extern int c_value_print (struct value *, struct ui_file *, int,
-			  enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+			  const struct value_print_options *);
 
 const struct language_defn f_language_defn =
 {
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 252d25d..3b3487e 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -29,8 +29,8 @@ extern void f_print_type (struct type *, char *, struct ui_file *, int,
 			  int);
 
 extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int, int, int,
-			enum val_prettyprint);
+			struct ui_file *, int,
+			const struct value_print_options *);
 
 /* Language-specific data structures */
 
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 672e95c..f893b49 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -164,42 +164,42 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
 static void
 f77_print_array_1 (int nss, int ndimensions, struct type *type,
 		   const gdb_byte *valaddr, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty,
+		   struct ui_file *stream, int recurse,
+		   const struct value_print_options *options,
 		   int *elts)
 {
   int i;
 
   if (nss != ndimensions)
     {
-      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++)
+      for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++)
 	{
 	  fprintf_filtered (stream, "( ");
 	  f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
 			     valaddr + i * F77_DIM_OFFSET (nss),
 			     address + i * F77_DIM_OFFSET (nss),
-			     stream, format, deref_ref, recurse, pretty, elts);
+			     stream, recurse, options, elts);
 	  fprintf_filtered (stream, ") ");
 	}
-      if (*elts >= print_max && i < F77_DIM_SIZE (nss)) 
+      if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) 
 	fprintf_filtered (stream, "...");
     }
   else
     {
-      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < print_max; 
+      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
 	   i++, (*elts)++)
 	{
 	  val_print (TYPE_TARGET_TYPE (type),
 		     valaddr + i * F77_DIM_OFFSET (ndimensions),
 		     0,
 		     address + i * F77_DIM_OFFSET (ndimensions),
-		     stream, format, deref_ref, recurse, pretty,
-		     current_language);
+		     stream, recurse, options, current_language);
 
 	  if (i != (F77_DIM_SIZE (nss) - 1))
 	    fprintf_filtered (stream, ", ");
 
-	  if ((*elts == print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1)))
+	  if ((*elts == options->print_max - 1)
+	      && (i != (F77_DIM_SIZE (nss) - 1)))
 	    fprintf_filtered (stream, "...");
 	}
     }
@@ -211,8 +211,7 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
 static void
 f77_print_array (struct type *type, const gdb_byte *valaddr,
 		 CORE_ADDR address, struct ui_file *stream,
-		 int format, int deref_ref, int recurse,
-		 enum val_prettyprint pretty)
+		 int recurse, const struct value_print_options *options)
 {
   int ndimensions;
   int elts = 0;
@@ -229,28 +228,22 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
 
   f77_create_arrayprint_offset_tbl (type, stream);
 
-  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream, format,
-		     deref_ref, recurse, pretty, &elts);
+  f77_print_array_1 (1, ndimensions, type, valaddr, address, stream,
+		     recurse, options, &elts);
 }
 \f
 
 /* Print data of type TYPE located at VALADDR (within GDB), which came from
    the inferior at address ADDRESS, onto stdio stream STREAM according to
-   FORMAT (a letter or 0 for natural format).  The data at VALADDR is in
-   target byte order.
+   OPTIONS.  The data at VALADDR is in target byte order.
 
    If the data are a string pointer, returns the number of string characters
-   printed.
-
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
-   The PRETTY parameter controls prettyprinting.  */
+   printed.  */
 
 int
 f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int format,
-	     int deref_ref, int recurse, enum val_prettyprint pretty)
+	     CORE_ADDR address, struct ui_file *stream, int recurse,
+	     const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *elttype;
@@ -263,20 +256,19 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     {
     case TYPE_CODE_STRING:
       f77_get_dynamic_length_of_aggregate (type);
-      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0);
+      LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0, options);
       break;
 
     case TYPE_CODE_ARRAY:
       fprintf_filtered (stream, "(");
-      f77_print_array (type, valaddr, address, stream, format,
-		       deref_ref, recurse, pretty);
+      f77_print_array (type, valaddr, address, stream, recurse, options);
       fprintf_filtered (stream, ")");
       break;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->format && options->format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
       else
@@ -292,16 +284,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      return 0;
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->format != 's')
 	    fputs_filtered (paddress (addr), stream);
 
 	  /* For a pointer to char or unsigned char, also print the string
 	     pointed to, unless pointer is null.  */
 	  if (TYPE_LENGTH (elttype) == 1
 	      && TYPE_CODE (elttype) == TYPE_CODE_INT
-	      && (format == 0 || format == 's')
+	      && (options->format == 0 || options->format == 's')
 	      && addr != 0)
-	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+	    i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+				  options);
 
 	  /* Return number of characters printed, including the terminating
 	     '\0' if we reached the end.  val_print_string takes care including
@@ -312,17 +305,17 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -330,8 +323,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref, recurse,
-				pretty, current_language);
+	      common_val_print (deref_val, stream, recurse,
+				options, current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -339,9 +332,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -354,9 +347,13 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr, type, &opts, 0, stream);
+	}
       else
 	{
 	  val_print_type_code_int (type, valaddr, stream);
@@ -374,15 +371,15 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->format)
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr, stream);
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->format)
+	print_scalar_formatted (valaddr, type, options, 0, stream);
       else
 	print_floating (valaddr, type, stream);
       break;
@@ -401,9 +398,13 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr, type, &opts, 0, stream);
+	}
       else
 	{
 	  val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
@@ -417,8 +418,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	    {
 	      /* Bash the type code temporarily.  */
 	      TYPE_CODE (type) = TYPE_CODE_INT;
-	      f_val_print (type, valaddr, 0, address, stream, format,
-			   deref_ref, recurse, pretty);
+	      f_val_print (type, valaddr, 0, address, stream, recurse, options);
 	      /* Restore the type code so later uses work as intended. */
 	      TYPE_CODE (type) = TYPE_CODE_BOOL;
 	    }
@@ -450,8 +450,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
         {
           int offset = TYPE_FIELD_BITPOS (type, index) / 8;
           f_val_print (TYPE_FIELD_TYPE (type, index), valaddr + offset,
-                       embedded_offset, address, stream,
-                       format, deref_ref, recurse, pretty);
+                       embedded_offset, address, stream, recurse, options);
           if (index != TYPE_NFIELDS (type) - 1)
             fputs_filtered (", ", stream);
         }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2a41c5b..333eb31 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -28,6 +28,7 @@
 /* Forward declarations for prototypes.  */
 struct field;
 struct block;
+struct value_print_options;
 
 /* Some macros for char-based bitfields.  */
 
@@ -1246,8 +1247,9 @@ extern int field_is_static (struct field *);
 
 /* printcmd.c */
 
-extern void print_scalar_formatted (const void *, struct type *, int, int,
-				    struct ui_file *);
+extern void print_scalar_formatted (const void *, struct type *,
+				    const struct value_print_options *,
+				    int, struct ui_file *);
 
 extern int can_dereference (struct type *);
 
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 06e3bc5..c65d3ef 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -51,6 +51,7 @@
 #include "exceptions.h"
 #include "cli/cli-decode.h"
 #include "gdbthread.h"
+#include "valprint.h"
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -1282,6 +1283,8 @@ print_return_value (struct type *func_type, struct type *value_type)
 
   if (value)
     {
+      struct value_print_options opts;
+
       /* Print it.  */
       stb = ui_out_stream_new (uiout);
       old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -1289,7 +1292,8 @@ print_return_value (struct type *func_type, struct type *value_type)
       ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
 			record_latest_value (value));
       ui_out_text (uiout, " = ");
-      value_print (value, stb->stream, 0, Val_no_prettyprint);
+      get_raw_print_options (&opts);
+      value_print (value, stb->stream, &opts);
       ui_out_field_stream (uiout, "return-value", stb);
       ui_out_text (uiout, "\n");
       do_cleanups (old_chain);
@@ -1803,9 +1807,12 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	  || TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_DECFLOAT)
 	{
 	  int j;
+	  struct value_print_options opts;
 
+	  get_user_print_options (&opts);
+	  opts.deref_ref = 1;
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 0, 1, 0, Val_pretty_default, current_language);
+		     file, 0, &opts, current_language);
 
 	  fprintf_filtered (file, "\t(raw 0x");
 	  for (j = 0; j < register_size (gdbarch, i); j++)
@@ -1821,16 +1828,23 @@ default_print_registers_info (struct gdbarch *gdbarch,
 	}
       else
 	{
+	  struct value_print_options opts;
+
 	  /* Print the register in hex.  */
+	  get_formatted_print_options (&opts, 'x');
+	  opts.deref_ref = 1;
 	  val_print (register_type (gdbarch, i), buffer, 0, 0,
-		     file, 'x', 1, 0, Val_pretty_default, current_language);
+		     file, 0, &opts,
+		     current_language);
           /* If not a vector register, print it also according to its
              natural format.  */
 	  if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
 	    {
+	      get_user_print_options (&opts);
+	      opts.deref_ref = 1;
 	      fprintf_filtered (file, "\t");
 	      val_print (register_type (gdbarch, i), buffer, 0, 0,
-			 file, 0, 1, 0, Val_pretty_default, current_language);
+			 file, 0, &opts, current_language);
 	    }
 	}
 
@@ -1896,12 +1910,14 @@ registers_info (char *addr_exp, int fpregs)
 	    if (regnum >= gdbarch_num_regs (gdbarch)
 			  + gdbarch_num_pseudo_regs (gdbarch))
 	      {
+		struct value_print_options opts;
 		struct value *val = value_of_user_reg (regnum, frame);
 
 		printf_filtered ("%s: ", start);
+		get_formatted_print_options (&opts, 'x');
 		print_scalar_formatted (value_contents (val),
 					check_typedef (value_type (val)),
-					'x', 0, gdb_stdout);
+					&opts, 0, gdb_stdout);
 		printf_filtered ("\n");
 	      }
 	    else
diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h
index 51bada2..04ba383 100644
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -41,11 +41,11 @@ extern struct type *java_double_type;
 extern struct type *java_void_type;
 
 extern int java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			   struct ui_file *, int, int, int,
-			   enum val_prettyprint);
+			   struct ui_file *, int,
+			   const struct value_print_options *);
 
-extern int java_value_print (struct value *, struct ui_file *, int,
-			     enum val_prettyprint);
+extern int java_value_print (struct value *, struct ui_file *,
+			     const struct value_print_options *);
 
 extern struct value *java_class_from_object (struct value *);
 
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 9e36aa4..0714e07 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -35,13 +35,14 @@
 /* Local functions */
 
 int
-java_value_print (struct value *val, struct ui_file *stream, int format,
-		  enum val_prettyprint pretty)
+java_value_print (struct value *val, struct ui_file *stream, 
+		  const struct value_print_options *options)
 {
   struct type *type;
   CORE_ADDR address;
   int i;
   char *name;
+  struct value_print_options opts;
 
   type = value_type (val);
   address = VALUE_ADDRESS (val) + value_offset (val);
@@ -89,7 +90,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
 	  address += JAVA_OBJECT_SIZE + 4;	/* Skip object header and length. */
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      gdb_byte *buf;
 
@@ -145,7 +146,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	  VALUE_ADDRESS (v) = address + JAVA_OBJECT_SIZE + 4;
 	  VALUE_ADDRESS (next_v) = VALUE_ADDRESS (v);
 
-	  while (i < length && things_printed < print_max)
+	  while (i < length && things_printed < options->print_max)
 	    {
 	      fputs_filtered (", ", stream);
 	      wrap_here (n_spaces (2));
@@ -180,8 +181,9 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 	      else
 		fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
 
-	      common_val_print (v, stream, format, 2, 1, pretty,
-				current_language);
+	      opts = *options;
+	      opts.deref_ref = 1;
+	      common_val_print (v, stream, 1, &opts, current_language);
 
 	      things_printed++;
 	      i += reps;
@@ -203,7 +205,7 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
       && TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
       && strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)),
 		 "java.lang.String") == 0
-      && (format == 0 || format == 's')
+      && (options->format == 0 || options->format == 's')
       && address != 0
       && value_as_address (val) != 0)
     {
@@ -228,16 +230,17 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 
       value_free_to_mark (mark);	/* Release unnecessary values */
 
-      val_print_string (data + boffset, count, 2, stream);
+      val_print_string (data + boffset, count, 2, stream, options);
 
       return 0;
     }
 
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  opts = *options;
+  opts.deref_ref = 1;
+  return common_val_print (val, stream, 0, &opts, current_language);
 }
 
-/* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
+/* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
    same meanings as in cp_print_value and c_val_print.
 
    DONT_PRINT is an array of baseclass types that we
@@ -246,7 +249,8 @@ java_value_print (struct value *val, struct ui_file *stream, int format,
 static void
 java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 			 CORE_ADDR address, struct ui_file *stream,
-			 int format, int recurse, enum val_prettyprint pretty)
+			 int recurse,
+			 const struct value_print_options *options)
 {
   int i, len, n_baseclasses;
 
@@ -275,7 +279,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 
 	  boffset = 0;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 * (recurse + 1), stream);
@@ -289,7 +293,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  base_valaddr = valaddr;
 
 	  java_print_value_fields (baseclass, base_valaddr, address + boffset,
-				   stream, format, recurse + 1, pretty);
+				   stream, recurse + 1, options);
 	  fputs_filtered (", ", stream);
 	}
 
@@ -307,7 +311,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  if (field_is_static (&TYPE_FIELD (type, i)))
 	    {
 	      char *name = TYPE_FIELD_NAME (type, i);
-	      if (!static_field_print)
+	      if (!options->static_field_print)
 		continue;
 	      if (name != NULL && strcmp (name, "class") == 0)
 		continue;
@@ -316,7 +320,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -327,7 +331,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -336,7 +340,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -380,11 +384,15 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		}
 	      else
 		{
+		  struct value_print_options opts;
+
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  opts = *options;
+		  opts.deref_ref = 0;
+		  common_val_print (v, stream, recurse + 1,
+				    &opts, current_language);
 		}
 	    }
 	  else
@@ -400,28 +408,33 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		    fputs_filtered ("<optimized out>", stream);
 		  else
 		    {
+		      struct value_print_options opts;
 		      struct type *t = check_typedef (value_type (v));
 		      if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
 			v = value_addr (v);
-		      common_val_print (v, stream, format, 0, recurse + 1,
-					pretty, current_language);
+		      opts = *options;
+		      opts.deref_ref = 0;
+		      common_val_print (v, stream, recurse + 1,
+					&opts, current_language);
 		    }
 		}
 	      else if (TYPE_FIELD_TYPE (type, i) == NULL)
 		fputs_filtered ("<unknown type>", stream);
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr + TYPE_FIELD_BITPOS (type, i) / 8, 0,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, &opts,
 			     current_language);
 		}
 	    }
 	  annotate_field_end ();
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -432,22 +445,16 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 
 /* Print data of type TYPE located at VALADDR (within GDB), which came from
    the inferior at address ADDRESS, onto stdio stream STREAM according to
-   FORMAT (a letter or 0 for natural format).  The data at VALADDR is in
-   target byte order.
+   OPTIONS.  The data at VALADDR is in target byte order.
 
    If the data are a string pointer, returns the number of string characters
-   printed.
-
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
-   The PRETTY parameter controls prettyprinting.  */
+   printed.  */
 
 int
 java_val_print (struct type *type, const gdb_byte *valaddr,
 		int embedded_offset, CORE_ADDR address,
-		struct ui_file *stream, int format, int deref_ref,
-		int recurse, enum val_prettyprint pretty)
+		struct ui_file *stream, int recurse,
+		const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   struct type *target_type;
@@ -457,13 +464,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->format && options->format != 's')
 	{
-	  print_scalar_formatted (valaddr, type, format, 0, stream);
+	  print_scalar_formatted (valaddr, type, options, 0, stream);
 	  break;
 	}
 #if 0
-      if (vtblprint && cp_is_vtbl_ptr_type (type))
+      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -490,7 +497,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
 	  return (0);
 	}
 
-      if (addressprint && format != 's')
+      if (options->addressprint && options->format != 's')
 	{
 	  fputs_filtered ("@", stream);
 	  print_longest (stream, 'x', 0, (ULONGEST) addr);
@@ -502,9 +509,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
     case TYPE_CODE_INT:
       /* Can't just call c_val_print because that prints bytes as C
 	 chars.  */
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr, type, format, 0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr, type, &opts, 0, stream);
+	}
       else if (TYPE_CODE (type) == TYPE_CODE_CHAR
 	       || (TYPE_CODE (type) == TYPE_CODE_INT
 		   && TYPE_LENGTH (type) == 2
@@ -515,13 +526,13 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_STRUCT:
-      java_print_value_fields (type, valaddr, address, stream, format,
-			       recurse, pretty);
+      java_print_value_fields (type, valaddr, address, stream, recurse,
+			       options);
       break;
 
     default:
       return c_val_print (type, valaddr, embedded_offset, address, stream,
-			  format, deref_ref, recurse, pretty);
+			  recurse, options);
     }
 
   return 0;
diff --git a/gdb/language.c b/gdb/language.c
index 121fc55..46e238d 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -72,7 +72,8 @@ static void unk_lang_printchar (int c, struct ui_file *stream);
 static void unk_lang_print_type (struct type *, char *, struct ui_file *,
 				 int, int);
 
-static int unk_lang_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+static int unk_lang_value_print (struct value *, struct ui_file *,
+				 const struct value_print_options *);
 
 static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
 
@@ -1035,10 +1036,10 @@ default_word_break_characters (void)
 
 void
 default_print_array_index (struct value *index_value, struct ui_file *stream,
-                           int format, enum val_prettyprint pretty)
+			   const struct value_print_options *options)
 {
   fprintf_filtered (stream, "[");
-  LA_VALUE_PRINT (index_value, stream, format, pretty);
+  LA_VALUE_PRINT (index_value, stream, options);
   fprintf_filtered (stream, "] = ");
 }
 
@@ -1070,7 +1071,8 @@ unk_lang_printchar (int c, struct ui_file *stream)
 
 static void
 unk_lang_printstr (struct ui_file *stream, const gdb_byte *string,
-		   unsigned int length, int width, int force_ellipses)
+		   unsigned int length, int width, int force_ellipses,
+		   const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_printstr called."));
 }
@@ -1085,15 +1087,15 @@ unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
 static int
 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
 		    int embedded_offset, CORE_ADDR address,
-		    struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+		    struct ui_file *stream, int recurse,
+		    const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_val_print called."));
 }
 
 static int
-unk_lang_value_print (struct value *val, struct ui_file *stream, int format,
-		      enum val_prettyprint pretty)
+unk_lang_value_print (struct value *val, struct ui_file *stream,
+		      const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_value_print called."));
 }
diff --git a/gdb/language.h b/gdb/language.h
index cc10ff2..c92c57c 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -30,6 +30,7 @@ struct objfile;
 struct frame_info;
 struct expression;
 struct ui_file;
+struct value_print_options;
 
 #define MAX_FORTRAN_DIMS  7	/* Maximum number of F77 array dims */
 
@@ -189,7 +190,8 @@ struct language_defn
 
     void (*la_printstr) (struct ui_file * stream, const gdb_byte *string,
 			 unsigned int length, int width,
-			 int force_ellipses);
+			 int force_ellipses,
+			 const struct value_print_options *);
 
     void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
 
@@ -208,13 +210,13 @@ struct language_defn
     /* Print a value using syntax appropriate for this language. */
 
     int (*la_val_print) (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
     /* Print a top-level value using syntax appropriate for this language. */
 
     int (*la_value_print) (struct value *, struct ui_file *,
-			   int, enum val_prettyprint);
+			   const struct value_print_options *);
 
     /* PC is possibly an unknown languages trampoline.
        If that PC falls in a trampoline belonging to this language,
@@ -274,8 +276,7 @@ struct language_defn
     /* Print the index of an element of an array.  */
     void (*la_print_array_index) (struct value *index_value,
                                   struct ui_file *stream,
-                                  int format,
-                                  enum val_prettyprint pretty);
+                                  const struct value_print_options *options);
 
     /* Return non-zero if TYPE should be passed (and returned) by
        reference at the language level.  */
@@ -366,21 +367,22 @@ extern enum language set_language (enum language);
 #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
   (current_language->la_print_typedef(type,new_symbol,stream))
 
-#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,fmt,deref,recurse,pretty) \
-  (current_language->la_val_print(type,valaddr,offset,addr,stream,fmt,deref, \
-				  recurse,pretty))
-#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
-  (current_language->la_value_print(val,stream,fmt,pretty))
+#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,recurse,options) \
+  (current_language->la_val_print(type,valaddr,offset,addr,stream, \
+				  recurse,options))
+#define LA_VALUE_PRINT(val,stream,options) \
+  (current_language->la_value_print(val,stream,options))
 
 #define LA_PRINT_CHAR(ch, stream) \
   (current_language->la_printchar(ch, stream))
-#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
-  (current_language->la_printstr(stream, string, length, width, force_ellipses))
+#define LA_PRINT_STRING(stream, string, length, width, force_ellipses,options) \
+  (current_language->la_printstr(stream, string, length, width, \
+				 force_ellipses,options))
 #define LA_EMIT_CHAR(ch, stream, quoter) \
   (current_language->la_emitchar(ch, stream, quoter))
 
-#define LA_PRINT_ARRAY_INDEX(index_value, stream, format, pretty) \
-  (current_language->la_print_array_index(index_value, stream, format, pretty))
+#define LA_PRINT_ARRAY_INDEX(index_value, stream, optins) \
+  (current_language->la_print_array_index(index_value, stream, options))
 
 /* Test a character to decide whether it can be printed in literal form
    or needs to be printed in another representation.  For example,
@@ -472,8 +474,7 @@ extern char *default_word_break_characters (void);
 /* Print the index of an array element using the C99 syntax.  */
 extern void default_print_array_index (struct value *index_value,
                                        struct ui_file *stream,
-                                       int format,
-                                       enum val_prettyprint pretty);
+				       const struct value_print_options *options);
 
 /* Return non-zero if TYPE should be passed (and returned) by
    reference at the language level.  */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index ea59403..e09b64b 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -104,7 +104,8 @@ m2_printchar (int c, struct ui_file *stream)
 
 static void
 m2_printstr (struct ui_file *stream, const gdb_byte *string,
-	     unsigned int length, int width, int force_ellipses)
+	     unsigned int length, int width, int force_ellipses,
+	     const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -117,7 +118,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -141,11 +142,11 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -154,14 +155,14 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
 	  m2_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -175,7 +176,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 8ce458c..f99e31a 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -33,8 +33,8 @@ extern int m2_is_long_set (struct type *type);
 extern int m2_is_unbounded_array (struct type *type);
 
 extern int m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int, int, int,
-			 enum val_prettyprint);
+			 struct ui_file *, int,
+			 const struct value_print_options *);
 
 extern int get_long_set_bounds (struct type *type, LONGEST *low,
 				LONGEST *high);
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 82ff30e..d48108f 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -30,22 +30,24 @@
 #include "m2-lang.h"
 #include "target.h"
 
-int print_unpacked_pointer (struct type *type,
-			    CORE_ADDR address, CORE_ADDR addr,
-			    int format, struct ui_file *stream);
+static int print_unpacked_pointer (struct type *type,
+				   CORE_ADDR address, CORE_ADDR addr,
+				   const struct value_print_options *options,
+				   struct ui_file *stream);
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len);
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len);
 
 
 /* Print function pointer with inferior address ADDRESS onto stdio
    stream STREAM.  */
 
 static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+				int addressprint)
 {
   CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
 							    address,
@@ -88,8 +90,7 @@ get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high)
 static void
 m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int format,
-		   enum val_prettyprint pretty)
+		   struct ui_file *stream)
 {
   int empty_set        = 1;
   int element_seen     = 0;
@@ -184,9 +185,8 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 static void
 m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
 			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int format,
-			  int deref_ref, enum val_prettyprint pretty,
-			  int recurse)
+			  struct ui_file *stream, int recurse,
+			  const struct value_print_options *options)
 {
   struct type *content_type;
   CORE_ADDR addr;
@@ -207,26 +207,27 @@ m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
   fprintf_filtered (stream, "{");  
   m2_print_array_contents (value_type (val), value_contents(val),
 			   value_embedded_offset (val), addr, stream,
-			   format, deref_ref, pretty, recurse, len);
+			   recurse, options, len);
   fprintf_filtered (stream, ", HIGH = %d}", (int) len);
 }
 
-int
+static int
 print_unpacked_pointer (struct type *type,
 			CORE_ADDR address, CORE_ADDR addr,
-			int format, struct ui_file *stream)
+			const struct value_print_options *options,
+			struct ui_file *stream)
 {
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
 
   if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
     {
       /* Try to print what function it points to.  */
-      print_function_pointer_address (addr, stream);
+      print_function_pointer_address (addr, stream, options->addressprint);
       /* Return value is irrelevant except for string pointers.  */
       return 0;
     }
 
-  if (addressprint && format != 's')
+  if (options->addressprint && options->format != 's')
     fputs_filtered (paddress (address), stream);
 
   /* For a pointer to char or unsigned char, also print the string
@@ -234,9 +235,9 @@ print_unpacked_pointer (struct type *type,
 
   if (TYPE_LENGTH (elttype) == 1
       && TYPE_CODE (elttype) == TYPE_CODE_INT
-      && (format == 0 || format == 's')
+      && (options->format == 0 || options->format == 's')
       && addr != 0)
-      return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+    return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options);
   
   return 0;
 }
@@ -244,9 +245,9 @@ print_unpacked_pointer (struct type *type,
 static void
 print_variable_at_address (struct type *type,
 			   const gdb_byte *valaddr,
-			   struct ui_file *stream, int format,
-			   int deref_ref, int recurse,
-			   enum val_prettyprint pretty)
+			   struct ui_file *stream,
+			   int recurse,
+			   const struct value_print_options *options)
 {
   CORE_ADDR addr = unpack_pointer (type, valaddr);
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -259,8 +260,7 @@ print_variable_at_address (struct type *type,
     {
       struct value *deref_val =
 	value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr));
-      common_val_print (deref_val, stream, format, deref_ref,
-			recurse, pretty, current_language);
+      common_val_print (deref_val, stream, recurse, options, current_language);
     }
   else
     fputs_filtered ("???", stream);
@@ -276,9 +276,9 @@ print_variable_at_address (struct type *type,
 static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int format,
-			 enum val_prettyprint pretty,
-			 int deref_ref, int recurse, int len)
+			 struct ui_file *stream, int recurse,
+			 const struct value_print_options *options,
+			 int len)
 {
   int eltlen;
   CHECK_TYPEDEF (type);
@@ -286,21 +286,20 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
   if (TYPE_LENGTH (type) > 0)
     {
       eltlen = TYPE_LENGTH (type);
-      if (prettyprint_arrays)
+      if (options->prettyprint_arrays)
 	print_spaces_filtered (2 + 2 * recurse, stream);
       /* For an array of chars, print with string syntax.  */
       if (eltlen == 1 &&
 	  ((TYPE_CODE (type) == TYPE_CODE_INT)
 	   || ((current_language->la_language == language_m2)
 	       && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
-	  && (format == 0 || format == 's'))
-	val_print_string (address, len+1, eltlen, stream);
+	  && (options->format == 0 || options->format == 's'))
+	val_print_string (address, len+1, eltlen, stream, options);
       else
 	{
 	  fprintf_filtered (stream, "{");
 	  val_print_array_elements (type, valaddr + embedded_offset,
-				    address, stream, format,
-				    deref_ref, recurse, pretty, 0);
+				    address, stream, recurse, options, 0);
 	  fprintf_filtered (stream, "}");
 	}
     }
@@ -309,21 +308,15 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 
 /* Print data of type TYPE located at VALADDR (within GDB), which came from
    the inferior at address ADDRESS, onto stdio stream STREAM according to
-   FORMAT (a letter or 0 for natural format).  The data at VALADDR is in
-   target byte order.
+   OPTIONS.  The data at VALADDR is in target byte order.
 
    If the data are a string pointer, returns the number of string characters
-   printed.
-
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
-   The PRETTY parameter controls prettyprinting.  */
+   printed.  */
 
 int
 m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int format,
-	      int deref_ref, int recurse, enum val_prettyprint pretty)
+	      CORE_ADDR address, struct ui_file *stream, int recurse,
+	      const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -343,74 +336,73 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    print_spaces_filtered (2 + 2 * recurse, stream);
 	  /* For an array of chars, print with string syntax.  */
 	  if (eltlen == 1 &&
 	      ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_m2)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->format == 0 || options->format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-			 && temp_len < len && temp_len < print_max;
+			 && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
 	    {
 	      fprintf_filtered (stream, "{");
 	      val_print_array_elements (type, valaddr + embedded_offset,
-					address, stream, format, deref_ref,
-					recurse, pretty, 0);
+					address, stream, recurse, options, 0);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
 	}
       /* Array of unspecified length: treat like pointer to first elt.  */
-      print_unpacked_pointer (type, address, address, format, stream);
+      print_unpacked_pointer (type, address, address, options, stream);
       break;
 
     case TYPE_CODE_PTR:
       if (TYPE_CONST (type))
 	print_variable_at_address (type, valaddr + embedded_offset,
-				   stream, format, deref_ref, recurse,
-				   pretty);
-      else if (format && format != 's')
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+				   stream, recurse, options);
+      else if (options->format && options->format != 's')
+	print_scalar_formatted (valaddr + embedded_offset, type,
+				options, 0, stream);
       else
 	{
 	  addr = unpack_pointer (type, valaddr + embedded_offset);
-	  print_unpacked_pointer (type, addr, address, format, stream);
+	  print_unpacked_pointer (type, addr, address, options, stream);
 	}
       break;
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  CORE_ADDR addr
 	    = extract_typed_address (valaddr + embedded_offset, type);
 	  fprintf_filtered (stream, "@");
 	  fputs_filtered (paddress (addr), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -418,8 +410,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		value_at
 		(TYPE_TARGET_TYPE (type),
 		 unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -427,7 +419,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
@@ -436,22 +428,20 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     case TYPE_CODE_STRUCT:
       if (m2_is_long_set (type))
 	m2_print_long_set (type, valaddr, embedded_offset, address,
-			   stream, format, pretty);
+			   stream);
       else if (m2_is_unbounded_array (type))
 	m2_print_unbounded_array (type, valaddr, embedded_offset,
-				  address, stream, format, deref_ref,
-				  pretty, recurse);
+				  address, stream, recurse, options);
       else
 	cp_print_value_fields (type, type, valaddr, embedded_offset,
-			       address, stream, format,
-			       recurse, pretty, NULL, 0);
+			       address, stream, recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -475,10 +465,10 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->format)
 	{
 	  print_scalar_formatted (valaddr + embedded_offset, type,
-				  format, 0, stream);
+				  options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -491,10 +481,14 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
+	}
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -511,7 +505,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
 	{
 	  m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset,
-			address, stream, format, deref_ref, recurse, pretty);
+			address, stream, recurse, options);
 	  break;
 	}
       /* FIXME: create_range_type does not set the unsigned bit in a
@@ -524,19 +518,27 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format,
-				0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
+	}
       else
 	val_print_type_code_int (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
+	}
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -550,9 +552,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->format)
 	print_scalar_formatted (valaddr + embedded_offset, type,
-				format, 0, stream);
+				options, 0, stream);
       else
 	print_floating (valaddr + embedded_offset, type, stream);
       break;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index baf9b6d..33cc890 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -30,6 +30,7 @@
 #include "dictionary.h"
 #include "gdb_string.h"
 #include "language.h"
+#include "valprint.h"
 
 static void list_args_or_locals (int locals, int values, struct frame_info *fi);
 
@@ -280,21 +281,29 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
 		      && TYPE_CODE (type) != TYPE_CODE_STRUCT
 		      && TYPE_CODE (type) != TYPE_CODE_UNION)
 		    {
+		      struct value_print_options opts;
 		      val = read_var_value (sym2, fi);
+		      get_raw_print_options (&opts);
+		      opts.deref_ref = 1;
 		      common_val_print
-			(val, stb->stream, 0, 1, 0, Val_no_prettyprint,
+			(val, stb->stream, 0, &opts,
 			 language_def (SYMBOL_LANGUAGE (sym2)));
 		      ui_out_field_stream (uiout, "value", stb);
 		    }
 		  do_cleanups (cleanup_tuple);
 		  break;
 		case PRINT_ALL_VALUES:
-		  val = read_var_value (sym2, fi);
-		  common_val_print
-		    (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
-		     language_def (SYMBOL_LANGUAGE (sym2)));
-		  ui_out_field_stream (uiout, "value", stb);
-		  do_cleanups (cleanup_tuple);
+		  {
+		    struct value_print_options opts;
+		    val = read_var_value (sym2, fi);
+		    get_raw_print_options (&opts);
+		    opts.deref_ref = 1;
+		    common_val_print
+		      (val, stb->stream, 0, &opts,
+		       language_def (SYMBOL_LANGUAGE (sym2)));
+		    ui_out_field_stream (uiout, "value", stb);
+		    do_cleanups (cleanup_tuple);
+		  }
 		  break;
 		}
 	    }
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 7780207..a9fbcad 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -45,6 +45,7 @@
 #include "frame.h"
 #include "mi-main.h"
 #include "language.h"
+#include "valprint.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -499,9 +500,11 @@ get_register (int regnum, int format)
     }
   else
     {
+      struct value_print_options opts;
+      get_user_print_options (&opts);
+      opts.deref_ref = 1;
       val_print (register_type (current_gdbarch, regnum), buffer, 0, 0,
-		 stb->stream, format, 1, 0, Val_pretty_default,
-		 current_language);
+		 stb->stream, 0, &opts, current_language);
       ui_out_field_stream (uiout, "value", stb);
       ui_out_stream_delete (stb);
     }
@@ -570,6 +573,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   struct cleanup *old_chain = NULL;
   struct value *val;
   struct ui_stream *stb = NULL;
+  struct value_print_options opts;
 
   stb = ui_out_stream_new (uiout);
 
@@ -586,9 +590,11 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   val = evaluate_expression (expr);
 
   /* Print the result of the expression evaluation.  */
+  get_user_print_options (&opts);
+  opts.deref_ref = 0;
   val_print (value_type (val), value_contents (val),
 	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stb->stream, 0, 0, 0, 0, current_language);
+	     stb->stream, 0, &opts, current_language);
 
   ui_out_field_stream (uiout, "value", stb);
   ui_out_stream_delete (stb);
@@ -743,10 +749,13 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
 	int col_byte;
 	struct cleanup *cleanup_tuple;
 	struct cleanup *cleanup_list_data;
+	struct value_print_options opts;
+
 	cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
 	ui_out_field_core_addr (uiout, "addr", addr + row_byte);
 	/* ui_out_field_core_addr_symbolic (uiout, "saddr", addr + row_byte); */
 	cleanup_list_data = make_cleanup_ui_out_list_begin_end (uiout, "data");
+	get_formatted_print_options (&opts, word_format);
 	for (col = 0, col_byte = row_byte;
 	     col < nr_cols;
 	     col++, col_byte += word_size)
@@ -758,7 +767,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
 	    else
 	      {
 		ui_file_rewind (stream->stream);
-		print_scalar_formatted (mbuf + col_byte, word_type, word_format,
+		print_scalar_formatted (mbuf + col_byte, word_type, &opts,
 					word_asize, stream->stream);
 		ui_out_field_stream (uiout, NULL, stream);
 	      }
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 1babcce..0774266 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -57,6 +57,7 @@
 #include "target-descriptions.h"
 #include "dwarf2-frame.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 static const struct objfile_data *mips_pdr_data;
 
@@ -4378,12 +4379,15 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame,
 
   if (register_size (gdbarch, regnum) == 4 || mips2_fp_compat (frame))
     {
+      struct value_print_options opts;
+
       /* 4-byte registers: Print hex and floating.  Also print even
          numbered registers as doubles.  */
       mips_read_fp_register_single (frame, regnum, raw_buffer);
       flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
 
-      print_scalar_formatted (raw_buffer, builtin_type_uint32, 'x', 'w',
+      get_formatted_print_options (&opts, 'x');
+      print_scalar_formatted (raw_buffer, builtin_type_uint32, &opts, 'w',
 			      file);
 
       fprintf_filtered (file, " flt: ");
@@ -4407,6 +4411,8 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame,
     }
   else
     {
+      struct value_print_options opts;
+
       /* Eight byte registers: print each one as hex, float and double.  */
       mips_read_fp_register_single (frame, regnum, raw_buffer);
       flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
@@ -4414,8 +4420,8 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame,
       mips_read_fp_register_double (frame, regnum, raw_buffer);
       doub = unpack_double (mips_double_register_type (), raw_buffer, &inv2);
 
-
-      print_scalar_formatted (raw_buffer, builtin_type_uint64, 'x', 'g',
+      get_formatted_print_options (&opts, 'x');
+      print_scalar_formatted (raw_buffer, builtin_type_uint64, &opts, 'g',
 			      file);
 
       fprintf_filtered (file, " flt: ");
@@ -4439,6 +4445,7 @@ mips_print_register (struct ui_file *file, struct frame_info *frame,
   struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte raw_buffer[MAX_REGISTER_SIZE];
   int offset;
+  struct value_print_options opts;
 
   if (TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT)
     {
@@ -4471,8 +4478,9 @@ mips_print_register (struct ui_file *file, struct frame_info *frame,
   else
     offset = 0;
 
+  get_formatted_print_options (&opts, 'x');
   print_scalar_formatted (raw_buffer + offset,
-			  register_type (gdbarch, regnum), 'x', 0,
+			  register_type (gdbarch, regnum), &opts, 0,
 			  file);
 }
 
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index da4afe3..db42e90 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -37,6 +37,7 @@
 #include "infcall.h"
 #include "gdb_assert.h"
 #include "language.h"
+#include "valprint.h"
 
 enum mt_arch_constants
 {
@@ -675,6 +676,7 @@ mt_registers_info (struct gdbarch *gdbarch,
 	{
 	  /* Special output handling for the 'coprocessor' register.  */
 	  gdb_byte *buf;
+	  struct value_print_options opts;
 
 	  buf = alloca (register_size (gdbarch, MT_COPRO_REGNUM));
 	  frame_register_read (frame, MT_COPRO_REGNUM, buf);
@@ -685,8 +687,10 @@ mt_registers_info (struct gdbarch *gdbarch,
 	  print_spaces_filtered (15 - strlen (gdbarch_register_name
 					        (gdbarch, regnum)),
 				 file);
+	  get_raw_print_options (&opts);
+	  opts.deref_ref = 1;
 	  val_print (register_type (gdbarch, regnum), buf,
-		     0, 0, file, 0, 1, 0, Val_no_prettyprint,
+		     0, 0, file, 0, &opts,
 		     current_language);
 	  fputs_filtered ("\n", file);
 	}
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 7d287a0..3a952f5 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -341,7 +341,8 @@ objc_printchar (int c, struct ui_file *stream)
 
 static void
 objc_printstr (struct ui_file *stream, const gdb_byte *string, 
-	       unsigned int length, int width, int force_ellipses)
+	       unsigned int length, int width, int force_ellipses,
+	       const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -360,7 +361,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining to see whether it
 	 is repeated.  */
@@ -384,11 +385,11 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\", ", stream);
 	      else
 		fputs_filtered ("\", ", stream);
@@ -397,14 +398,14 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
 	  objc_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
 	{
 	  if (!in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\\"", stream);
 	      else
 		fputs_filtered ("\"", stream);
@@ -418,7 +419,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\\"", stream);
       else
 	fputs_filtered ("\"", stream);
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 7ecdd8d..cd4285d 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -207,7 +207,8 @@ pascal_printchar (int c, struct ui_file *stream)
 
 void
 pascal_printstr (struct ui_file *stream, const gdb_byte *string,
-		 unsigned int length, int width, int force_ellipses)
+		 unsigned int length, int width, int force_ellipses,
+		 const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -226,7 +227,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -250,11 +251,11 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  ++reps;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
 	  if (in_quotes)
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\', ", stream);
 	      else
 		fputs_filtered ("', ", stream);
@@ -263,7 +264,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  pascal_printchar (string[i], stream);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	  need_comma = 1;
 	}
       else
@@ -271,7 +272,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
 	  int c = string[i];
 	  if ((!in_quotes) && (PRINT_LITERAL_FORM (c)))
 	    {
-	      if (inspect_it)
+	      if (options->inspect_it)
 		fputs_filtered ("\\'", stream);
 	      else
 		fputs_filtered ("'", stream);
@@ -285,7 +286,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
 	fputs_filtered ("\\'", stream);
       else
 	fputs_filtered ("'", stream);
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index a4f878f..4ebfbc1 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -35,10 +35,11 @@ extern void pascal_print_typedef (struct type *, struct symbol *,
 				  struct ui_file *);
 
 extern int pascal_val_print (struct type *, const gdb_byte *, int,
-			     CORE_ADDR, struct ui_file *, int, int,
-			     int, enum val_prettyprint);
+			     CORE_ADDR, struct ui_file *, int,
+			     const struct value_print_options *);
 
-extern int pascal_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+extern int pascal_value_print (struct value *, struct ui_file *,
+			       const struct value_print_options *);
 
 extern void pascal_type_print_method_args (char *, char *,
 					   struct ui_file *);
@@ -51,7 +52,8 @@ extern int
 extern void pascal_printchar (int, struct ui_file *);
 
 extern void pascal_printstr (struct ui_file *, const gdb_byte *,
-			     unsigned int, int, int);
+			     unsigned int, int, int,
+			     const struct value_print_options *);
 
 extern struct type **const (pascal_builtin_types[]);
 
@@ -63,15 +65,10 @@ extern void
 extern void
   pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int);
 
-/* These are in cp-valprint.c */
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-
-extern int static_field_print;
-
 extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
 					      CORE_ADDR, struct ui_file *,
-					      int, int, enum val_prettyprint,
+					      int,
+					      const struct value_print_options *,
 					      struct type **, int);
 
 extern int pascal_object_is_vtbl_ptr_type (struct type *);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index bc4fbe1..65ab8a1 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -44,23 +44,17 @@
 
 /* Print data of type TYPE located at VALADDR (within GDB), which came from
    the inferior at address ADDRESS, onto stdio stream STREAM according to
-   FORMAT (a letter or 0 for natural format).  The data at VALADDR is in
-   target byte order.
+   OPTIONS.  The data at VALADDR is in target byte order.
 
    If the data are a string pointer, returns the number of string characters
-   printed.
-
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
-   The PRETTY parameter controls prettyprinting.  */
+   printed.  */
 
 
 int
 pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  int embedded_offset, CORE_ADDR address,
-		  struct ui_file *stream, int format, int deref_ref,
-		  int recurse, enum val_prettyprint pretty)
+		  struct ui_file *stream, int recurse,
+		  const struct value_print_options *options)
 {
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
@@ -80,7 +74,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
 	  eltlen = TYPE_LENGTH (elttype);
 	  len = TYPE_LENGTH (type) / eltlen;
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      print_spaces_filtered (2 + 2 * recurse, stream);
 	    }
@@ -89,23 +83,24 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      && ((TYPE_CODE (elttype) == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_pascal)
 		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (format == 0 || format == 's'))
+	      && (options->format == 0 || options->format == 's'))
 	    {
 	      /* If requested, look for the first null char and only print
 	         elements up to it.  */
-	      if (stop_print_at_null)
+	      if (options->stop_print_at_null)
 		{
 		  unsigned int temp_len;
 
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       (valaddr + embedded_offset)[temp_len]
-		       && temp_len < len && temp_len < print_max;
+		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
 		}
 
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+			       options);
 	      i = len;
 	    }
 	  else
@@ -123,7 +118,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  i = 0;
 		}
 	      val_print_array_elements (type, valaddr + embedded_offset, address, stream,
-				     format, deref_ref, recurse, pretty, i);
+					recurse, options, i);
 	      fprintf_filtered (stream, "}");
 	    }
 	  break;
@@ -133,12 +128,13 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_PTR:
-      if (format && format != 's')
+      if (options->format && options->format != 's')
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if we ARE using
@@ -162,7 +158,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      return (0);
 	    }
 
-	  if (addressprint && format != 's')
+	  if (options->addressprint && options->format != 's')
 	    {
 	      fputs_filtered (paddress (addr), stream);
 	    }
@@ -172,11 +168,11 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	  if (TYPE_LENGTH (elttype) == 1
 	      && (TYPE_CODE (elttype) == TYPE_CODE_INT
 		  || TYPE_CODE(elttype) == TYPE_CODE_CHAR)
-	      && (format == 0 || format == 's')
+	      && (options->format == 0 || options->format == 's')
 	      && addr != 0)
 	    {
 	      /* no wide string yet */
-	      i = val_print_string (addr, -1, 1, stream);
+	      i = val_print_string (addr, -1, 1, stream, options);
 	    }
 	  /* also for pointers to pascal strings */
 	  /* Note: this is Free Pascal specific:
@@ -193,7 +189,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
               read_memory (addr + length_pos, buffer, length_size);
 	      string_length = extract_unsigned_integer (buffer, length_size);
               xfree (buffer);
-              i = val_print_string (addr + string_pos, string_length, char_size, stream);
+              i = val_print_string (addr + string_pos, string_length, char_size, stream, options);
 	    }
 	  else if (pascal_object_is_vtbl_member (type))
 	    {
@@ -209,7 +205,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
 		  fputs_filtered (">", stream);
 		}
-	      if (vt_address && vtblprint)
+	      if (vt_address && options->vtblprint)
 		{
 		  struct value *vt_val;
 		  struct symbol *wsym = (struct symbol *) NULL;
@@ -230,9 +226,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		      wtype = TYPE_TARGET_TYPE (type);
 		    }
 		  vt_val = value_at (wtype, vt_address);
-		  common_val_print (vt_val, stream, format, deref_ref,
-				    recurse + 1, pretty, current_language);
-		  if (pretty)
+		  common_val_print (vt_val, stream, recurse + 1, options,
+				    current_language);
+		  if (options->pretty)
 		    {
 		      fprintf_filtered (stream, "\n");
 		      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -249,18 +245,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fprintf_filtered (stream, "@");
 	  /* Extract the address, assume that it is unsigned.  */
 	  fputs_filtered (paddress (
 	    extract_unsigned_integer (valaddr + embedded_offset,
 	       gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT)), stream);
-	  if (deref_ref)
+	  if (options->deref_ref)
 	    fputs_filtered (": ", stream);
 	}
       /* De-reference the reference.  */
-      if (deref_ref)
+      if (options->deref_ref)
 	{
 	  if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
 	    {
@@ -268,8 +264,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      value_at
 	      (TYPE_TARGET_TYPE (type),
 	       unpack_pointer (type, valaddr + embedded_offset));
-	      common_val_print (deref_val, stream, format, deref_ref,
-				recurse + 1, pretty, current_language);
+	      common_val_print (deref_val, stream, recurse + 1, options,
+				current_language);
 	    }
 	  else
 	    fputs_filtered ("???", stream);
@@ -277,14 +273,14 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !unionprint)
+      if (recurse && !options->unionprint)
 	{
 	  fprintf_filtered (stream, "{...}");
 	  break;
 	}
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
-      if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
 	{
 	  /* Print the unmangled name if desired.  */
 	  /* Print vtable entry - we only get here if NOT using
@@ -301,18 +297,19 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
                                      &string_pos, &char_size, NULL))
 	    {
 	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
-	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0);
+	      LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0, options);
 	    }
 	  else
-	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream, format,
-					      recurse, pretty, NULL, 0);
+	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
+					      recurse, options, NULL, 0);
 	}
       break;
 
     case TYPE_CODE_ENUM:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       len = TYPE_NFIELDS (type);
@@ -336,16 +333,18 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLAGS:
-      if (format)
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->format)
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
       else
 	val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FUNC:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	  break;
 	}
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -358,9 +357,14 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_BOOL:
-      format = format ? format : output_format;
-      if (format)
-	print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
+	}
       else
 	{
 	  val = unpack_long (type, valaddr + embedded_offset);
@@ -387,10 +391,13 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      format = format ? format : output_format;
-      if (format)
+      if (options->format || options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
 	}
       else
 	{
@@ -399,10 +406,13 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_CHAR:
-      format = format ? format : output_format;
-      if (format)
+      if (options->format || options->output_format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  struct value_print_options opts = *options;
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  &opts, 0, stream);
 	}
       else
 	{
@@ -417,9 +427,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_FLT:
-      if (format)
+      if (options->format)
 	{
-	  print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+	  print_scalar_formatted (valaddr + embedded_offset, type,
+				  options, 0, stream);
 	}
       else
 	{
@@ -517,8 +528,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 }
 \f
 int
-pascal_value_print (struct value *val, struct ui_file *stream, int format,
-		    enum val_prettyprint pretty)
+pascal_value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options)
 {
   struct type *type = value_type (val);
 
@@ -547,19 +558,10 @@ pascal_value_print (struct value *val, struct ui_file *stream, int format,
 	  fprintf_filtered (stream, ") ");
 	}
     }
-  return common_val_print (val, stream, format, 1, 0, pretty,
-			   current_language);
+  return common_val_print (val, stream, 0, options, current_language);
 }
 
 
-/******************************************************************************
-                    Inserted from cp-valprint
-******************************************************************************/
-
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-static int pascal_static_field_print;	/* Controls printing of static fields. */
 static void
 show_pascal_static_field_print (struct ui_file *file, int from_tty,
 				struct cmd_list_element *c, const char *value)
@@ -572,12 +574,12 @@ static struct obstack dont_print_vb_obstack;
 static struct obstack dont_print_statmem_obstack;
 
 static void pascal_object_print_static_field (struct value *,
-					      struct ui_file *, int, int,
-					      enum val_prettyprint);
+					      struct ui_file *, int,
+					      const struct value_print_options *);
 
 static void pascal_object_print_value (struct type *, const gdb_byte *,
-				       CORE_ADDR, struct ui_file *,
-				       int, int, enum val_prettyprint,
+				       CORE_ADDR, struct ui_file *, int,
+				       const struct value_print_options *,
 				       struct type **);
 
 /* It was changed to this after 2.4.5.  */
@@ -624,7 +626,7 @@ pascal_object_is_vtbl_member (struct type *type)
    c_val_print to print out a structure's fields:
    pascal_object_print_value_fields and pascal_object_print_value.
 
-   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
+   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
    same meanings as in pascal_object_print_value and c_val_print.
 
    DONT_PRINT is an array of baseclass types that we
@@ -633,8 +635,8 @@ pascal_object_is_vtbl_member (struct type *type)
 void
 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 				  CORE_ADDR address, struct ui_file *stream,
-				  int format, int recurse,
-				  enum val_prettyprint pretty,
+				  int recurse,
+				  const struct value_print_options *options,
 				  struct type **dont_print_vb,
 				  int dont_print_statmem)
 {
@@ -651,7 +653,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
      duplicates of virtual baseclasses.  */
   if (n_baseclasses > 0)
     pascal_object_print_value (type, valaddr, address, stream,
-			       format, recurse + 1, pretty, dont_print_vb);
+			       recurse + 1, options, dont_print_vb);
 
   if (!len && n_baseclasses == 1)
     fprintf_filtered (stream, "<No data fields>");
@@ -671,14 +673,14 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!pascal_static_field_print
+	  if (!options->pascal_static_field_print
 	      && field_is_static (&TYPE_FIELD (type, i)))
 	    continue;
 	  if (fields_seen)
 	    fprintf_filtered (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (pretty)
+	      if (options->pretty)
 		{
 		  fprintf_filtered (stream, "\n");
 		  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -689,7 +691,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    }
 	  fields_seen = 1;
 
-	  if (pretty)
+	  if (options->pretty)
 	    {
 	      fprintf_filtered (stream, "\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -698,7 +700,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	    {
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
-	  if (inspect_it)
+	  if (options->inspect_it)
 	    {
 	      if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
 		fputs_filtered ("\"( ptr \"", stream);
@@ -742,11 +744,13 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
 		  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
 				   unpack_field_as_long (type, valaddr, i));
 
-		  common_val_print (v, stream, format, 0, recurse + 1,
-				    pretty, current_language);
+		  opts.deref_ref = 0;
+		  common_val_print (v, stream, recurse + 1, &opts,
+				    current_language);
 		}
 	    }
 	  else
@@ -765,11 +769,13 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  if (v == NULL)
 		    fputs_filtered ("<optimized out>", stream);
 		  else
-		    pascal_object_print_static_field (v, stream, format,
-						      recurse + 1, pretty);
+		    pascal_object_print_static_field (v, stream, recurse + 1,
+						      options);
 		}
 	      else
 		{
+		  struct value_print_options opts = *options;
+		  opts.deref_ref = 0;
 		  /* val_print (TYPE_FIELD_TYPE (type, i),
 		     valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
 		     address + TYPE_FIELD_BITPOS (type, i) / 8, 0,
@@ -777,7 +783,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 		  val_print (TYPE_FIELD_TYPE (type, i),
 			     valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
 			     address + TYPE_FIELD_BITPOS (type, i) / 8,
-			     stream, format, 0, recurse + 1, pretty,
+			     stream, recurse + 1, &opts,
 			     current_language);
 		}
 	    }
@@ -792,7 +798,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -807,8 +813,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 static void
 pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 			   CORE_ADDR address, struct ui_file *stream,
-			   int format, int recurse,
-			   enum val_prettyprint pretty,
+			   int recurse,
+			   const struct value_print_options *options,
 			   struct type **dont_print_vb)
 {
   struct type **last_dont_print
@@ -849,7 +855,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 
       boffset = baseclass_offset (type, i, valaddr, address);
 
-      if (pretty)
+      if (options->pretty)
 	{
 	  fprintf_filtered (stream, "\n");
 	  print_spaces_filtered (2 * recurse, stream);
@@ -881,7 +887,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 	fprintf_filtered (stream, "<invalid address>");
       else
 	pascal_object_print_value_fields (baseclass, base_valaddr, address + boffset,
-					  stream, format, recurse, pretty,
+					  stream, recurse, options,
 		     (struct type **) obstack_base (&dont_print_vb_obstack),
 					  0);
       fputs_filtered (", ", stream);
@@ -907,15 +913,17 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
    static member classes in an obstack and refuse to print them more
    than once.
 
-   VAL contains the value to print, STREAM, RECURSE, and PRETTY
+   VAL contains the value to print, STREAM, RECURSE, and OPTIONS
    have the same meanings as in c_val_print.  */
 
 static void
 pascal_object_print_static_field (struct value *val,
-				  struct ui_file *stream, int format,
-				  int recurse, enum val_prettyprint pretty)
+				  struct ui_file *stream,
+				  int recurse,
+				  const struct value_print_options *options)
 {
   struct type *type = value_type (val);
+  struct value_print_options opts;
 
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
@@ -942,11 +950,13 @@ pascal_object_print_static_field (struct value *val,
 
       CHECK_TYPEDEF (type);
       pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
-				  stream, format, recurse, pretty, NULL, 1);
+					stream, recurse, options, NULL, 1);
       return;
     }
-  common_val_print (val, stream, format, 0, recurse, pretty,
-		    current_language);
+
+  opts = *options;
+  opts.deref_ref = 0;
+  common_val_print (val, stream, recurse, &opts, current_language);
 }
 
 extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototypes */
@@ -955,13 +965,10 @@ void
 _initialize_pascal_valprint (void)
 {
   add_setshow_boolean_cmd ("pascal_static-members", class_support,
-			   &pascal_static_field_print, _("\
+			   &user_print_options.pascal_static_field_print, _("\
 Set printing of pascal static members."), _("\
 Show printing of pascal static members."), NULL,
 			   NULL,
 			   show_pascal_static_field_print,
 			   &setprintlist, &showprintlist);
-  /* Turn on printing of static fields.  */
-  pascal_static_field_print = 1;
-
 }
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 021e191..355552d 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -42,6 +42,7 @@
 #include "block.h"
 #include "disasm.h"
 #include "dfp.h"
+#include "valprint.h"
 
 #ifdef TUI
 #include "tui/tui.h"		/* For tui_active et.al.   */
@@ -55,7 +56,6 @@
 #endif
 
 extern int asm_demangle;	/* Whether to demangle syms in asm printouts */
-extern int addressprint;	/* Whether to print hex addresses in HLL " */
 
 struct format_data
   {
@@ -120,13 +120,6 @@ Printing of source filename and line number with <symbol> is %s.\n"),
 
 int current_display_number;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-
-int inspect_it = 0;
-
 struct display
   {
     /* Chain link to next auto-display item.  */
@@ -254,15 +247,15 @@ decode_format (char **string_ptr, int oformat, int osize)
   return val;
 }
 \f
-/* Print value VAL on stream according to FORMAT, a letter or 0.
+/* Print value VAL on stream according to OPTIONS.
    Do not end with a newline.
-   0 means print VAL according to its own type.
    SIZE is the letter for the size of datum being printed.
    This is used to pad hex numbers so they line up.  SIZE is 0
    for print / output and set for examine.  */
 
 static void
-print_formatted (struct value *val, int format, int size,
+print_formatted (struct value *val, int size,
+		 const struct value_print_options *options,
 		 struct ui_file *stream)
 {
   struct type *type = check_typedef (value_type (val));
@@ -273,12 +266,13 @@ print_formatted (struct value *val, int format, int size,
 
   if (size)
     {
-      switch (format)
+      switch (options->format)
 	{
 	case 's':
 	  /* FIXME: Need to handle wchar_t's here... */
 	  next_address = VALUE_ADDRESS (val)
-	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
+	    + val_print_string (VALUE_ADDRESS (val), -1, 1, stream,
+				options);
 	  return;
 
 	case 'i':
@@ -291,22 +285,19 @@ print_formatted (struct value *val, int format, int size,
 	}
     }
 
-  if (format == 0 || format == 's'
+  if (options->format == 0 || options->format == 's'
       || TYPE_CODE (type) == TYPE_CODE_REF
       || TYPE_CODE (type) == TYPE_CODE_ARRAY
       || TYPE_CODE (type) == TYPE_CODE_STRING
       || TYPE_CODE (type) == TYPE_CODE_STRUCT
       || TYPE_CODE (type) == TYPE_CODE_UNION
       || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
-    /* If format is 0, use the 'natural' format for that type of
-       value.  If the type is non-scalar, we have to use language
-       rules to print it as a series of scalars.  */
-    value_print (val, stream, format, Val_pretty_default);
+    value_print (val, stream, options);
   else
     /* User specified format, so don't look to the the type to
        tell us what to do.  */
     print_scalar_formatted (value_contents (val), type,
-			    format, size, stream);
+			    options, size, stream);
 }
 
 /* Return builtin floating point type of same length as TYPE.
@@ -328,15 +319,16 @@ float_type_from_length (struct gdbarch *gdbarch, struct type *type)
 }
 
 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
-   according to letters FORMAT and SIZE on STREAM.
-   FORMAT may not be zero.  Formats s and i are not supported at this level.
+   according to OPTIONS and SIZE on STREAM.
+   Formats s and i are not supported at this level.
 
    This is how the elements of an array or structure are printed
    with a format.  */
 
 void
 print_scalar_formatted (const void *valaddr, struct type *type,
-			int format, int size, struct ui_file *stream)
+			const struct value_print_options *options,
+			int size, struct ui_file *stream)
 {
   LONGEST val_long = 0;
   unsigned int len = TYPE_LENGTH (type);
@@ -345,9 +337,12 @@ print_scalar_formatted (const void *valaddr, struct type *type,
   /* If we get here with a string format, try again without it.  Go
      all the way back to the language printers, which may call us
      again.  */
-  if (format == 's')
+  if (options->format == 's')
     {
-      val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default,
+      struct value_print_options opts = *options;
+      opts.format = 0;
+      opts.deref_ref = 0;
+      val_print (type, valaddr, 0, 0, stream, 0, &opts,
 		 current_language);
       return;
     }
@@ -356,7 +351,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       (TYPE_CODE (type) == TYPE_CODE_INT
        || TYPE_CODE (type) == TYPE_CODE_ENUM))
     {
-      switch (format)
+      switch (options->format)
 	{
 	case 'o':
 	  print_octal_chars (stream, valaddr, len, byte_order);
@@ -379,7 +374,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
 	};
     }
 
-  if (format != 'f')
+  if (options->format != 'f')
     val_long = unpack_long (type, valaddr);
 
   /* If the value is a pointer, and pointers and addresses are not the
@@ -391,13 +386,13 @@ print_scalar_formatted (const void *valaddr, struct type *type,
   /* If we are printing it as unsigned, truncate it in case it is actually
      a negative signed value (e.g. "print/u (short)-1" should print 65535
      (if shorts are 16 bits) instead of 4294967295).  */
-  if (format != 'd')
+  if (options->format != 'd')
     {
       if (len < sizeof (LONGEST))
 	val_long &= ((LONGEST) 1 << HOST_CHAR_BIT * len) - 1;
     }
 
-  switch (format)
+  switch (options->format)
     {
     case 'x':
       if (!size)
@@ -442,13 +437,17 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       break;
 
     case 'c':
-      if (TYPE_UNSIGNED (type))
-	value_print (value_from_longest (builtin_type_true_unsigned_char,
-					 val_long),
-		     stream, 0, Val_pretty_default);
-      else
-	value_print (value_from_longest (builtin_type_true_char, val_long),
-		     stream, 0, Val_pretty_default);
+      {
+	struct value_print_options opts = *options;
+	opts.format = 0;
+	if (TYPE_UNSIGNED (type))
+	  value_print (value_from_longest (builtin_type_true_unsigned_char,
+					   val_long),
+		       stream, &opts);
+	else
+	  value_print (value_from_longest (builtin_type_true_char, val_long),
+		       stream, &opts);
+      }
       break;
 
     case 'f':
@@ -508,7 +507,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       break;
 
     default:
-      error (_("Undefined output format \"%c\"."), format);
+      error (_("Undefined output format \"%c\"."), options->format);
     }
 }
 
@@ -707,11 +706,13 @@ void
 print_address_demangle (CORE_ADDR addr, struct ui_file *stream,
 			int do_demangle)
 {
+  struct value_print_options opts;
+  get_user_print_options (&opts);
   if (addr == 0)
     {
       fprintf_filtered (stream, "0");
     }
-  else if (addressprint)
+  else if (opts.addressprint)
     {
       fputs_filtered (paddress (addr), stream);
       print_address_symbolic (addr, stream, do_demangle, " ");
@@ -745,6 +746,7 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
   struct type *val_type = NULL;
   int i;
   int maxelts;
+  struct value_print_options opts;
 
   format = fmt.format;
   size = fmt.size;
@@ -775,6 +777,8 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
   if (format == 's' || format == 'i')
     maxelts = 1;
 
+  get_formatted_print_options (&opts, format);
+
   /* Print as many objects as specified in COUNT, at most maxelts per line,
      with the address of the next one at the start of each line.  */
 
@@ -809,7 +813,7 @@ do_examine (struct format_data fmt, CORE_ADDR addr)
 	  if (last_examine_value)
 	    release_value (last_examine_value);
 
-	  print_formatted (last_examine_value, format, size, gdb_stdout);
+	  print_formatted (last_examine_value, size, &opts, gdb_stdout);
 
 	  /* Display any branch delay slots following the final insn.  */
 	  if (format == 'i' && count == 1)
@@ -847,10 +851,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
   struct format_data fmt;
   int cleanup = 0;
 
-  /* Pass inspect flag to the rest of the print routines in a global
-     (sigh).  */
-  inspect_it = inspect;
-
   if (exp && *exp == '/')
     {
       exp++;
@@ -879,6 +879,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
   if (voidprint || (val && value_type (val) &&
 		    TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
     {
+      struct value_print_options opts;
       int histindex = record_latest_value (val);
 
       if (histindex >= 0)
@@ -895,7 +896,10 @@ print_command_1 (char *exp, int inspect, int voidprint)
       if (histindex >= 0)
 	annotate_value_history_value ();
 
-      print_formatted (val, format, fmt.size, gdb_stdout);
+      get_formatted_print_options (&opts, format);
+      opts.inspect_it = inspect;
+
+      print_formatted (val, fmt.size, &opts, gdb_stdout);
       printf_filtered ("\n");
 
       if (histindex >= 0)
@@ -909,7 +913,6 @@ print_command_1 (char *exp, int inspect, int voidprint)
 
   if (cleanup)
     do_cleanups (old_chain);
-  inspect_it = 0;		/* Reset print routines to normal.  */
 }
 
 static void
@@ -942,6 +945,7 @@ output_command (char *exp, int from_tty)
   char format = 0;
   struct value *val;
   struct format_data fmt;
+  struct value_print_options opts;
 
   fmt.size = 0;
 
@@ -960,7 +964,8 @@ output_command (char *exp, int from_tty)
 
   annotate_value_begin (value_type (val));
 
-  print_formatted (val, format, fmt.size, gdb_stdout);
+  get_formatted_print_options (&opts, format);
+  print_formatted (val, fmt.size, &opts, gdb_stdout);
 
   annotate_value_end ();
 
@@ -1507,6 +1512,8 @@ do_one_display (struct display *d)
     }
   else
     {
+      struct value_print_options opts;
+
       annotate_display_format ();
 
       if (d->format.format)
@@ -1521,8 +1528,9 @@ do_one_display (struct display *d)
 
       annotate_display_expression ();
 
+      get_formatted_print_options (&opts, d->format.format);
       print_formatted (evaluate_expression (d->exp),
-		       d->format.format, d->format.size, gdb_stdout);
+		       d->format.size, &opts, gdb_stdout);
       printf_filtered ("\n");
     }
 
@@ -1677,8 +1685,10 @@ print_variable_value (struct symbol *var, struct frame_info *frame,
 		      struct ui_file *stream)
 {
   struct value *val = read_var_value (var, frame);
+  struct value_print_options opts;
 
-  value_print (val, stream, 0, Val_pretty_default);
+  get_user_print_options (&opts);
+  value_print (val, stream, &opts);
 }
 
 static void
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index d957273..8bf4ec8 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -23,6 +23,7 @@
 #include "exceptions.h"
 #include "language.h"
 #include "dfp.h"
+#include "valprint.h"
 
 /* List of all values which are currently exposed to Python. It is
    maintained so that when an objfile is discarded, preserve_values
@@ -189,15 +190,19 @@ valpy_str (PyObject *self)
   struct ui_file *stb;
   struct cleanup *old_chain;
   PyObject *result;
+  struct value_print_options opts;
   volatile struct gdb_exception except;
 
+  get_user_print_options (&opts);
+  opts.deref_ref = 0;
+
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
-      common_val_print (((value_object *) self)->value, stb, 0, 0, 0,
-			Val_pretty_default, current_language);
+      common_val_print (((value_object *) self)->value, stb, 0,
+			&opts, current_language);
       s = ui_file_xstrdup (stb, &dummy);
     }
   GDB_PY_HANDLE_EXCEPTION (except);
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 42d2502..0b25590 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -50,7 +50,8 @@ scm_printchar (int c, struct ui_file *stream)
 
 static void
 scm_printstr (struct ui_file *stream, const gdb_byte *string,
-	      unsigned int length, int width, int force_ellipses)
+	      unsigned int length, int width, int force_ellipses,
+	      const struct value_print_options *options)
 {
   fprintf_filtered (stream, "\"%s\"", string);
 }
diff --git a/gdb/scm-lang.h b/gdb/scm-lang.h
index 654095c..369905b 100644
--- a/gdb/scm-lang.h
+++ b/gdb/scm-lang.h
@@ -46,16 +46,16 @@
 struct value;
 
 extern int scm_value_print (struct value *, struct ui_file *,
-			    int, enum val_prettyprint);
+			    const struct value_print_options *);
 
 extern int scm_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			  struct ui_file *, int, int, int,
-			  enum val_prettyprint);
+			  struct ui_file *, int,
+			  const struct value_print_options *);
 
 extern LONGEST scm_get_field (LONGEST, int);
 
-extern void scm_scmval_print (LONGEST, struct ui_file *, int, int, int,
-			      enum val_prettyprint);
+extern void scm_scmval_print (LONGEST, struct ui_file *, int,
+			      const struct value_print_options *);
 
 extern int is_scmvalue_type (struct type *);
 
diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
index feb43dd..006f280 100644
--- a/gdb/scm-valprint.c
+++ b/gdb/scm-valprint.c
@@ -33,18 +33,18 @@
 #include "objfiles.h"
 
 static void scm_ipruk (char *, LONGEST, struct ui_file *);
-static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
-static int scm_inferior_print (LONGEST, struct ui_file *, int, int,
-			       int, enum val_prettyprint);
+static void scm_scmlist_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
+static int scm_inferior_print (LONGEST, struct ui_file *, int,
+			       const struct value_print_options *);
 
 /* Prints the SCM value VALUE by invoking the inferior, if appropraite.
    Returns >= 0 on success;  return -1 if the inferior cannot/should not
    print VALUE. */
 
 static int
-scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
-		    int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_inferior_print (LONGEST value, struct ui_file *stream,
+		    int recurse, const struct value_print_options *options)
 {
   struct objfile *objf;
   struct gdbarch *gdbarch;
@@ -129,17 +129,16 @@ static char *scm_isymnames[] =
 };
 
 static void
-scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
-		   int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int recurse,
+		   const struct value_print_options *options)
 {
-  unsigned int more = print_max;
+  unsigned int more = options->print_max;
   if (recurse > 6)
     {
       fputs_filtered ("...", stream);
       return;
     }
-  scm_scmval_print (SCM_CAR (svalue), stream, format,
-		    deref_ref, recurse + 1, pretty);
+  scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
   svalue = SCM_CDR (svalue);
   for (; SCM_NIMP (svalue); svalue = SCM_CDR (svalue))
     {
@@ -151,14 +150,12 @@ scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
 	  fputs_filtered ("...", stream);
 	  return;
 	}
-      scm_scmval_print (SCM_CAR (svalue), stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
     }
   if (SCM_NNULLP (svalue))
     {
       fputs_filtered (" . ", stream);
-      scm_scmval_print (svalue, stream, format,
-			deref_ref, recurse + 1, pretty);
+      scm_scmval_print (svalue, stream, recurse + 1, options);
     }
 }
 
@@ -174,15 +171,17 @@ scm_ipruk (char *hdr, LONGEST ptr, struct ui_file *stream)
 }
 
 void
-scm_scmval_print (LONGEST svalue, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmval_print (LONGEST svalue, struct ui_file *stream,
+		  int recurse, const struct value_print_options *options)
 {
 taloop:
   switch (7 & (int) svalue)
     {
     case 2:
     case 6:
-      print_longest (stream, format ? format : 'd', 1, svalue >> 2);
+      print_longest (stream,
+		     options->format ? options->format : 'd',
+		     1, svalue >> 2);
       break;
     case 4:
       if (SCM_ICHRP (svalue))
@@ -243,14 +242,12 @@ taloop:
 	case scm_tcs_cons_imcar:
 	case scm_tcs_cons_nimcar:
 	  fputs_filtered ("(", stream);
-	  scm_scmlist_print (svalue, stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (svalue, stream, recurse + 1, options);
 	  fputs_filtered (")", stream);
 	  break;
 	case scm_tcs_closures:
 	  fputs_filtered ("#<CLOSURE ", stream);
-	  scm_scmlist_print (SCM_CODE (svalue), stream, format,
-			     deref_ref, recurse + 1, pretty);
+	  scm_scmlist_print (SCM_CODE (svalue), stream, recurse + 1, options);
 	  fputs_filtered (">", stream);
 	  break;
 	case scm_tc7_string:
@@ -261,9 +258,9 @@ taloop:
 	    int done = 0;
 	    int buf_size;
 	    gdb_byte buffer[64];
-	    int truncate = print_max && len > (int) print_max;
+	    int truncate = options->print_max && len > (int) options->print_max;
 	    if (truncate)
-	      len = print_max;
+	      len = options->print_max;
 	    fputs_filtered ("\"", stream);
 	    for (; done < len; done += buf_size)
 	      {
@@ -305,8 +302,8 @@ taloop:
 	      {
 		if (i > 0)
 		  fputs_filtered (" ", stream);
-		scm_scmval_print (scm_get_field (elements, i), stream, format,
-				  deref_ref, recurse + 1, pretty);
+		scm_scmval_print (scm_get_field (elements, i), stream,
+				  recurse + 1, options);
 	      }
 	    fputs_filtered (")", stream);
 	  }
@@ -401,21 +398,19 @@ taloop:
 int
 scm_val_print (struct type *type, const gdb_byte *valaddr,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int format, int deref_ref,
-	       int recurse, enum val_prettyprint pretty)
+	       struct ui_file *stream, int recurse,
+	       const struct value_print_options *options)
 {
   if (is_scmvalue_type (type))
     {
       LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
 
-      if (scm_inferior_print (svalue, stream, format,
-			      deref_ref, recurse, pretty) >= 0)
+      if (scm_inferior_print (svalue, stream, recurse, options) >= 0)
 	{
 	}
       else
 	{
-	  scm_scmval_print (svalue, stream, format,
-			    deref_ref, recurse, pretty);
+	  scm_scmval_print (svalue, stream, recurse, options);
 	}
 
       gdb_flush (stream);
@@ -423,15 +418,15 @@ scm_val_print (struct type *type, const gdb_byte *valaddr,
     }
   else
     {
-      return c_val_print (type, valaddr, 0, address, stream, format,
-			  deref_ref, recurse, pretty);
+      return c_val_print (type, valaddr, 0, address, stream, recurse, options);
     }
 }
 
 int
-scm_value_print (struct value *val, struct ui_file *stream, int format,
-		 enum val_prettyprint pretty)
+scm_value_print (struct value *val, struct ui_file *stream,
+		 const struct value_print_options *options)
 {
-  return (common_val_print (val, stream, format, 1, 0, pretty,
-			    current_language));
+  struct value_print_options opts = *options;
+  opts.deref_ref = 1;
+  return (common_val_print (val, stream, 0, &opts, current_language));
 }
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 474d49a..988e8cb 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -40,6 +40,7 @@
 #include "arch-utils.h"
 #include "regcache.h"
 #include "osabi.h"
+#include "valprint.h"
 
 #include "elf-bfd.h"
 
@@ -2092,6 +2093,7 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
 		  struct frame_info *frame, int regnum)
 {
   unsigned char raw_buffer[MAX_REGISTER_SIZE];
+  struct value_print_options opts;
 
   fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
   print_spaces_filtered (15 - strlen (gdbarch_register_name
@@ -2100,12 +2102,16 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
   /* Get the data in raw format.  */
   if (!frame_register_read (frame, regnum, raw_buffer))
     fprintf_filtered (file, "*value not available*\n");
-      
+
+  get_formatted_print_options (&opts, 'x');
+  opts.deref_ref = 1;
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 'x', 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\t");
+  get_formatted_print_options (&opts, 0);
+  opts.deref_ref = 1;
   val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
-	     file, 0, 1, 0, Val_pretty_default, current_language);
+	     file, 0, &opts, current_language);
   fprintf_filtered (file, "\n");
 }
 
diff --git a/gdb/stack.c b/gdb/stack.c
index 2c3c0bb..3c1019b 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -368,6 +368,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
 	      if (val)
 	        {
                   const struct language_defn *language;
+		  struct value_print_options opts;
 
                   /* Use the appropriate language to display our symbol,
                      unless the user forced the language to a specific
@@ -377,8 +378,10 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
                   else
                     language = current_language;
 
-		  common_val_print (val, stb->stream, 0, 0, 2,
-				    Val_no_prettyprint, language);
+		  get_raw_print_options (&opts);
+		  opts.deref_ref = 0;
+		  common_val_print (val, stb->stream, 2,
+				    &opts, language);
 		  ui_out_field_stream (uiout, "value", stb);
 	        }
 	      else
@@ -547,6 +550,8 @@ print_frame_info (struct frame_info *frame, int print_level,
 						      sal.line + 1, 0);
 	  else
 	    {
+	      struct value_print_options opts;
+	      get_user_print_options (&opts);
 	      /* We used to do this earlier, but that is clearly
 		 wrong. This function is used by many different
 		 parts of gdb, including normal_stop in infrun.c,
@@ -555,7 +560,7 @@ print_frame_info (struct frame_info *frame, int print_level,
 		 line. Only the command line really wants this
 		 behavior. Other UIs probably would like the
 		 ability to decide for themselves if it is desired.  */
-	      if (addressprint && mid_statement)
+	      if (opts.addressprint && mid_statement)
 		{
 		  ui_out_field_core_addr (uiout, "addr", get_frame_pc (frame));
 		  ui_out_text (uiout, "\t");
@@ -584,6 +589,7 @@ print_frame (struct frame_info *frame, int print_level,
   enum language funlang = language_unknown;
   struct ui_stream *stb;
   struct cleanup *old_chain, *list_chain;
+  struct value_print_options opts;
 
   stb = ui_out_stream_new (uiout);
   old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -665,7 +671,8 @@ print_frame (struct frame_info *frame, int print_level,
       ui_out_field_fmt_int (uiout, 2, ui_left, "level",
 			    frame_relative_level (frame));
     }
-  if (addressprint)
+  get_user_print_options (&opts);
+  if (opts.addressprint)
     if (get_frame_pc (frame) != sal.pc || !sal.symtab
 	|| print_what == LOC_AND_ADDRESS)
       {
@@ -1405,10 +1412,12 @@ print_block_frame_labels (struct block *b, int *have_default,
       if (SYMBOL_CLASS (sym) == LOC_LABEL)
 	{
 	  struct symtab_and_line sal;
+	  struct value_print_options opts;
 	  sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
 	  values_printed = 1;
 	  fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
-	  if (addressprint)
+	  get_user_print_options (&opts);
+	  if (opts.addressprint)
 	    {
 	      fprintf_filtered (stream, " ");
 	      fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (sym)), stream);
diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp
index 484b5a4..f12a234 100644
--- a/gdb/testsuite/gdb.base/exprs.exp
+++ b/gdb/testsuite/gdb.base/exprs.exp
@@ -252,3 +252,10 @@ gdb_test "print (void*) (~((long long)(unsigned long) -1) - 1)" \
 # String concatentation.
 test_expr "print \"x\" \"y\"" "\\$\[0-9\]* = \"xy\""
 test_expr "print \"x\" \"y\" \"z\"" "\\$\[0-9\]* = \"xyz\""
+
+# Enum formatting tests.
+test_expr "print red" "\\$\[0-9\]* = red"
+gdb_test "set output-radix 8" ""
+test_expr "print red" "\\$\[0-9\]* = red"
+test_expr "print/d red" "\\$\[0-9\]* = 0"
+gdb_test "set output-radix 10" ""
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4f5c56a..4646ab1 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -38,6 +38,7 @@
 #include "dictionary.h"
 #include "observer.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
@@ -67,7 +68,6 @@
 extern void (*deprecated_readline_begin_hook) (char *, ...);
 extern char *(*deprecated_readline_hook) (char *);
 extern void (*deprecated_readline_end_hook) (void);
-extern int addressprint;	/* Print machine addresses? */
 
 /* GDB commands implemented in other modules:
  */  
@@ -434,9 +434,11 @@ trace_command (char *arg, int from_tty)
 static void
 trace_mention (struct tracepoint *tp)
 {
+  struct value_print_options opts;
   printf_filtered ("Tracepoint %d", tp->number);
 
-  if (addressprint || (tp->source_file == NULL))
+  get_user_print_options (&opts);
+  if (opts.addressprint || (tp->source_file == NULL))
     {
       printf_filtered (" at ");
       printf_filtered ("%s", paddress (tp->address));
@@ -467,12 +469,12 @@ tracepoints_info (char *tpnum_exp, int from_tty)
   ALL_TRACEPOINTS (t)
     if (tpnum == -1 || tpnum == t->number)
     {
-      extern int addressprint;	/* Print machine addresses?  */
-
+      struct value_print_options opts;
+      get_user_print_options (&opts);
       if (!found_a_tracepoint++)
 	{
 	  printf_filtered ("Num Enb ");
-	  if (addressprint)
+	  if (opts.addressprint)
 	    {
 	      if (gdbarch_addr_bit (current_gdbarch) <= 32)
 		printf_filtered ("Address    ");
@@ -482,7 +484,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 	  printf_filtered ("PassC StepC What\n");
 	}
       strcpy (wrap_indent, "                           ");
-      if (addressprint)
+      if (opts.addressprint)
 	{
 	  if (gdbarch_addr_bit (current_gdbarch) <= 32)
 	    strcat (wrap_indent, "           ");
@@ -492,7 +494,7 @@ tracepoints_info (char *tpnum_exp, int from_tty)
 
       printf_filtered ("%-3d %-3s ", t->number,
 		       t->enabled_p ? "y" : "n");
-      if (addressprint)
+      if (opts.addressprint)
 	{
 	  char *tmp;
 
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 39580e6..b2428ef 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -37,6 +37,7 @@
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-file.h"
 #include "reggroups.h"
+#include "valprint.h"
 
 #include "gdb_curses.h"
 
@@ -689,11 +690,13 @@ tui_register_format (struct gdbarch *gdbarch,
     {
       gdb_byte buf[MAX_REGISTER_SIZE];
       int len;
+      struct value_print_options opts;
 
       len = register_size (current_gdbarch, regnum);
       fprintf_filtered (stream, "%-14s ", name);
       get_frame_register (frame, regnum, buf);
-      print_scalar_formatted (buf, type, 'f', len, stream);
+      get_formatted_print_options (&opts, 'f');
+      print_scalar_formatted (buf, type, &opts, len, stream);
     }
   else
     {
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 44f1a77..edf87cd 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -33,12 +33,9 @@
 #include "cp-abi.h"
 #include "typeprint.h"
 #include "gdb_string.h"
+#include "valprint.h"
 #include <errno.h>
 
-/* For real-type printing in whatis_exp() */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
-
 extern void _initialize_typeprint (void);
 
 static void ptype_command (char *, int);
@@ -95,6 +92,7 @@ whatis_exp (char *exp, int show)
   int full = 0;
   int top = -1;
   int using_enc = 0;
+  struct value_print_options opts;
 
   if (exp)
     {
@@ -107,7 +105,8 @@ whatis_exp (char *exp, int show)
 
   type = value_type (val);
 
-  if (objectprint)
+  get_user_print_options (&opts);
+  if (opts.objectprint)
     {
       if (((TYPE_CODE (type) == TYPE_CODE_PTR)
 	   || (TYPE_CODE (type) == TYPE_CODE_REF))
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 99c376f..5086a70 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -60,13 +60,55 @@ static void set_output_radix_1 (int, unsigned);
 
 void _initialize_valprint (void);
 
-/* Maximum number of chars to print for a string pointer value or vector
-   contents, or UINT_MAX for no limit.  Note that "set print elements 0"
-   stores UINT_MAX in print_max, which displays in a show command as
-   "unlimited". */
-
-unsigned int print_max;
 #define PRINT_MAX_DEFAULT 200	/* Start print_max off at this value. */
+
+struct value_print_options user_print_options =
+{
+  Val_pretty_default,		/* pretty */
+  0,				/* prettyprint_arrays */
+  0,				/* prettyprint_structs */
+  0,				/* vtblprint */
+  1,				/* unionprint */
+  1,				/* addressprint */
+  0,				/* objectprint */
+  PRINT_MAX_DEFAULT,		/* print_max */
+  10,				/* repeat_count_threshold */
+  0,				/* output_format */
+  0,				/* format */
+  0,				/* stop_print_at_null */
+  0,				/* inspect_it */
+  0,				/* print_array_indexes */
+  0,				/* deref_ref */
+  1,				/* static_field_print */
+  1				/* pascal_static_field_print */
+};
+
+/* Initialize *OPTS to be a copy of the user print options.  */
+void
+get_user_print_options (struct value_print_options *opts)
+{
+  *opts = user_print_options;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+void
+get_raw_print_options (struct value_print_options *opts)
+{  
+  *opts = user_print_options;
+  opts->pretty = Val_no_prettyprint;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+void
+get_formatted_print_options (struct value_print_options *opts,
+			     char format)
+{
+  *opts = user_print_options;
+  opts->format = format;
+}
+
 static void
 show_print_max (struct ui_file *file, int from_tty,
 		struct cmd_list_element *c, const char *value)
@@ -98,12 +140,10 @@ show_output_radix (struct ui_file *file, int from_tty,
 Default output radix for printing of values is %s.\n"),
 		    value);
 }
-int output_format = 0;
 
 /* By default we print arrays without printing the index of each element in
    the array.  This behavior can be changed by setting PRINT_ARRAY_INDEXES.  */
 
-static int print_array_indexes = 0;
 static void
 show_print_array_indexes (struct ui_file *file, int from_tty,
 		          struct cmd_list_element *c, const char *value)
@@ -115,7 +155,6 @@ show_print_array_indexes (struct ui_file *file, int from_tty,
    element in an array.  Referenced by the low level language dependent
    print routines. */
 
-unsigned int repeat_count_threshold = 10;
 static void
 show_repeat_count_threshold (struct ui_file *file, int from_tty,
 			     struct cmd_list_element *c, const char *value)
@@ -126,7 +165,6 @@ show_repeat_count_threshold (struct ui_file *file, int from_tty,
 
 /* If nonzero, stops printing of char arrays at first null. */
 
-int stop_print_at_null;
 static void
 show_stop_print_at_null (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -138,7 +176,6 @@ Printing of char arrays to stop at first null char is %s.\n"),
 
 /* Controls pretty printing of structures. */
 
-int prettyprint_structs;
 static void
 show_prettyprint_structs (struct ui_file *file, int from_tty,
 			  struct cmd_list_element *c, const char *value)
@@ -148,7 +185,6 @@ show_prettyprint_structs (struct ui_file *file, int from_tty,
 
 /* Controls pretty printing of arrays.  */
 
-int prettyprint_arrays;
 static void
 show_prettyprint_arrays (struct ui_file *file, int from_tty,
 			 struct cmd_list_element *c, const char *value)
@@ -159,7 +195,6 @@ show_prettyprint_arrays (struct ui_file *file, int from_tty,
 /* If nonzero, causes unions inside structures or other unions to be
    printed. */
 
-int unionprint;			/* Controls printing of nested unions.  */
 static void
 show_unionprint (struct ui_file *file, int from_tty,
 		 struct cmd_list_element *c, const char *value)
@@ -171,7 +206,6 @@ Printing of unions interior to structures is %s.\n"),
 
 /* If nonzero, causes machine addresses to be printed in certain contexts. */
 
-int addressprint;		/* Controls printing of machine addresses */
 static void
 show_addressprint (struct ui_file *file, int from_tty,
 		   struct cmd_list_element *c, const char *value)
@@ -182,13 +216,7 @@ show_addressprint (struct ui_file *file, int from_tty,
 
 /* Print using the given LANGUAGE the data of type TYPE located at VALADDR
    (within GDB), which came from the inferior at address ADDRESS, onto
-   stdio stream STREAM according to FORMAT (a letter, or 0 for natural
-   format using TYPE).
-
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
-   The PRETTY parameter controls prettyprinting.
+   stdio stream STREAM according to OPTIONS.
 
    If the data are a string pointer, returns the number of string characters
    printed.
@@ -203,17 +231,18 @@ show_addressprint (struct ui_file *file, int from_tty,
 
 int
 val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-	   CORE_ADDR address, struct ui_file *stream, int format,
-	   int deref_ref, int recurse, enum val_prettyprint pretty,
+	   CORE_ADDR address, struct ui_file *stream, int recurse,
+	   const struct value_print_options *options,
 	   const struct language_defn *language)
 {
   volatile struct gdb_exception except;
-  volatile enum val_prettyprint real_pretty = pretty;
   int ret = 0;
-
+  struct value_print_options local_opts = *options;
   struct type *real_type = check_typedef (type);
-  if (pretty == Val_pretty_default)
-    real_pretty = prettyprint_structs ? Val_prettyprint : Val_no_prettyprint;
+
+  if (local_opts.pretty == Val_pretty_default)
+    local_opts.pretty = (local_opts.prettyprint_structs
+			 ? Val_prettyprint : Val_no_prettyprint);
 
   QUIT;
 
@@ -231,8 +260,7 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
   TRY_CATCH (except, RETURN_MASK_ERROR)
     {
       ret = language->la_val_print (type, valaddr, embedded_offset, address,
-				    stream, format, deref_ref, recurse,
-				    real_pretty);
+				    stream, recurse, &local_opts);
     }
   if (except.reason < 0)
     fprintf_filtered (stream, _("<error reading variable>"));
@@ -263,12 +291,7 @@ value_check_printable (struct value *val, struct ui_file *stream)
 }
 
 /* Print using the given LANGUAGE the value VAL onto stream STREAM according
-   to FORMAT (a letter, or 0 for natural format using TYPE).
-
-   If DEREF_REF is nonzero, then dereference references, otherwise just print
-   them like pointers.
-
-   The PRETTY parameter controls prettyprinting.
+   to OPTIONS.
 
    If the data are a string pointer, returns the number of string characters
    printed.
@@ -277,8 +300,8 @@ value_check_printable (struct value *val, struct ui_file *stream)
    GDB's value mechanism.  */
 
 int
-common_val_print (struct value *val, struct ui_file *stream, int format,
-		  int deref_ref, int recurse, enum val_prettyprint pretty,
+common_val_print (struct value *val, struct ui_file *stream, int recurse,
+		  const struct value_print_options *options,
 		  const struct language_defn *language)
 {
   if (!value_check_printable (val, stream))
@@ -286,23 +309,22 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
 
   return val_print (value_type (val), value_contents_all (val),
 		    value_embedded_offset (val), VALUE_ADDRESS (val),
-		    stream, format, deref_ref, recurse, pretty,
-		    language);
+		    stream, recurse, options, language);
 }
 
-/* Print the value VAL in C-ish syntax on stream STREAM.
-   FORMAT is a format-letter, or 0 for print in natural format of data type.
+/* Print the value VAL in C-ish syntax on stream STREAM according to
+   OPTIONS.
    If the object printed is a string pointer, returns
    the number of string bytes printed.  */
 
 int
-value_print (struct value *val, struct ui_file *stream, int format,
-	     enum val_prettyprint pretty)
+value_print (struct value *val, struct ui_file *stream,
+	     const struct value_print_options *options)
 {
   if (!value_check_printable (val, stream))
     return 0;
 
-  return LA_VALUE_PRINT (val, stream, format, pretty);
+  return LA_VALUE_PRINT (val, stream, options);
 }
 
 /* Called by various <lang>_val_print routines to print
@@ -928,15 +950,6 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
     }
 }
 
-/* Return non-zero if the debugger should print the index of each element
-   when printing array values.  */
-
-int
-print_array_indexes_p (void)
-{              
-  return print_array_indexes;
-} 
-
 /* Assuming TYPE is a simple, non-empty array type, compute its upper
    and lower bound.  Save the low bound into LOW_BOUND if not NULL.
    Save the high bound into HIGH_BOUND if not NULL.
@@ -992,23 +1005,23 @@ get_array_bounds (struct type *type, long *low_bound, long *high_bound)
   return 1;
 }
 
-/* Print on STREAM using the given FORMAT the index for the element
+/* Print on STREAM using the given OPTIONS the index for the element
    at INDEX of an array whose index type is INDEX_TYPE.  */
     
 void  
 maybe_print_array_index (struct type *index_type, LONGEST index,
-                         struct ui_file *stream, int format,
-                         enum val_prettyprint pretty)
+                         struct ui_file *stream,
+			 const struct value_print_options *options)
 {
   struct value *index_value;
 
-  if (!print_array_indexes)
+  if (!options->print_array_indexes)
     return; 
     
   index_value = value_from_longest (index_type, index);
 
-  LA_PRINT_ARRAY_INDEX (index_value, stream, format, pretty);
-}   
+  LA_PRINT_ARRAY_INDEX (index_value, stream, options);
+}
 
 /*  Called by various <lang>_val_print routines to print elements of an
    array in the form "<elem1>, <elem2>, <elem3>, ...".
@@ -1022,8 +1035,8 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
 void
 val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 			  CORE_ADDR address, struct ui_file *stream,
-			  int format, int deref_ref,
-			  int recurse, enum val_prettyprint pretty,
+			  int recurse,
+			  const struct value_print_options *options,
 			  unsigned int i)
 {
   unsigned int things_printed = 0;
@@ -1070,11 +1083,11 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 
   annotate_array_section_begin (i, elttype);
 
-  for (; i < len && things_printed < print_max; i++)
+  for (; i < len && things_printed < options->print_max; i++)
     {
       if (i != 0)
 	{
-	  if (prettyprint_arrays)
+	  if (options->prettyprint_arrays)
 	    {
 	      fprintf_filtered (stream, ",\n");
 	      print_spaces_filtered (2 + 2 * recurse, stream);
@@ -1086,7 +1099,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	}
       wrap_here (n_spaces (2 + 2 * recurse));
       maybe_print_array_index (index_type, i + low_bound_index,
-                               stream, format, pretty);
+                               stream, options);
 
       rep1 = i + 1;
       reps = 1;
@@ -1097,21 +1110,21 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
 	  ++rep1;
 	}
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt_rep (reps);
 	  fprintf_filtered (stream, " <repeats %u times>", reps);
 	  annotate_elt_rep_end ();
 
 	  i = rep1 - 1;
-	  things_printed += repeat_count_threshold;
+	  things_printed += options->repeat_count_threshold;
 	}
       else
 	{
-	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
-		     deref_ref, recurse + 1, pretty, current_language);
+	  val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+		     recurse + 1, options, current_language);
 	  annotate_elt ();
 	  things_printed++;
 	}
@@ -1173,7 +1186,8 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int *errnoptr
 /* FIXME: Use target_read_string.  */
 
 int
-val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
+val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
+		  const struct value_print_options *options)
 {
   int force_ellipsis = 0;	/* Force ellipsis to be printed if nonzero. */
   int errcode;			/* Errno returned from bad reads. */
@@ -1194,7 +1208,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      because finding the null byte (or available memory) is what actually
      limits the fetch. */
 
-  fetchlimit = (len == -1 ? print_max : min (len, print_max));
+  fetchlimit = (len == -1 ? options->print_max : min (len, options->print_max));
 
   /* Now decide how large of chunks to try to read in one operation.  This
      is also pretty simple.  If LEN >= zero, then we want fetchlimit chars,
@@ -1317,11 +1331,11 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
      and then the error message.  */
   if (errcode == 0 || bufptr > buffer)
     {
-      if (addressprint)
+      if (options->addressprint)
 	{
 	  fputs_filtered (" ", stream);
 	}
-      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis);
+      LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis, options);
     }
 
   if (errcode != 0)
@@ -1394,13 +1408,13 @@ set_output_radix_1 (int from_tty, unsigned radix)
   switch (radix)
     {
     case 16:
-      output_format = 'x';	/* hex */
+      user_print_options.output_format = 'x';	/* hex */
       break;
     case 10:
-      output_format = 0;	/* decimal */
+      user_print_options.output_format = 0;	/* decimal */
       break;
     case 8:
-      output_format = 'o';	/* octal */
+      user_print_options.output_format = 'o';	/* octal */
       break;
     default:
       /* FIXME: cagney/2002-03-17: This needs to revert the bad radix
@@ -1494,7 +1508,8 @@ _initialize_valprint (void)
   add_alias_cmd ("p", "print", no_class, 1, &showlist);
   add_alias_cmd ("pr", "print", no_class, 1, &showlist);
 
-  add_setshow_uinteger_cmd ("elements", no_class, &print_max, _("\
+  add_setshow_uinteger_cmd ("elements", no_class,
+			    &user_print_options.print_max, _("\
 Set limit on string chars or array elements to print."), _("\
 Show limit on string chars or array elements to print."), _("\
 \"set print elements 0\" causes there to be no limit."),
@@ -1502,7 +1517,8 @@ Show limit on string chars or array elements to print."), _("\
 			    show_print_max,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("null-stop", no_class, &stop_print_at_null, _("\
+  add_setshow_boolean_cmd ("null-stop", no_class,
+			   &user_print_options.stop_print_at_null, _("\
 Set printing of char arrays to stop at first null char."), _("\
 Show printing of char arrays to stop at first null char."), NULL,
 			   NULL,
@@ -1510,7 +1526,7 @@ Show printing of char arrays to stop at first null char."), NULL,
 			   &setprintlist, &showprintlist);
 
   add_setshow_uinteger_cmd ("repeats", no_class,
-			    &repeat_count_threshold, _("\
+			    &user_print_options.repeat_count_threshold, _("\
 Set threshold for repeated print elements."), _("\
 Show threshold for repeated print elements."), _("\
 \"set print repeats 0\" causes all elements to be individually printed."),
@@ -1518,28 +1534,32 @@ Show threshold for repeated print elements."), _("\
 			    show_repeat_count_threshold,
 			    &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("pretty", class_support, &prettyprint_structs, _("\
+  add_setshow_boolean_cmd ("pretty", class_support,
+			   &user_print_options.prettyprint_structs, _("\
 Set prettyprinting of structures."), _("\
 Show prettyprinting of structures."), NULL,
 			   NULL,
 			   show_prettyprint_structs,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("union", class_support, &unionprint, _("\
+  add_setshow_boolean_cmd ("union", class_support,
+			   &user_print_options.unionprint, _("\
 Set printing of unions interior to structures."), _("\
 Show printing of unions interior to structures."), NULL,
 			   NULL,
 			   show_unionprint,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("array", class_support, &prettyprint_arrays, _("\
+  add_setshow_boolean_cmd ("array", class_support,
+			   &user_print_options.prettyprint_arrays, _("\
 Set prettyprinting of arrays."), _("\
 Show prettyprinting of arrays."), NULL,
 			   NULL,
 			   show_prettyprint_arrays,
 			   &setprintlist, &showprintlist);
 
-  add_setshow_boolean_cmd ("address", class_support, &addressprint, _("\
+  add_setshow_boolean_cmd ("address", class_support,
+			   &user_print_options.addressprint, _("\
 Set printing of addresses."), _("\
 Show printing of addresses."), NULL,
 			   NULL,
@@ -1578,15 +1598,8 @@ Use 'show input-radix' or 'show output-radix' to independently show each."),
 	   &showlist);
 
   add_setshow_boolean_cmd ("array-indexes", class_support,
-                           &print_array_indexes, _("\
+                           &user_print_options.print_array_indexes, _("\
 Set printing of array indexes."), _("\
 Show printing of array indexes"), NULL, NULL, show_print_array_indexes,
                            &setprintlist, &showprintlist);
-
-  /* Give people the defaults which they are used to.  */
-  prettyprint_structs = 0;
-  prettyprint_arrays = 0;
-  unionprint = 1;
-  addressprint = 1;
-  print_max = PRINT_MAX_DEFAULT;
 }
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 3b20516..47a2c4f 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -21,45 +21,98 @@
 #ifndef VALPRINT_H
 #define VALPRINT_H
 
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
-extern int prettyprint_structs;	/* Controls pretty printing of structures */
-extern int prettyprint_arrays;	/* Controls pretty printing of arrays.  */
+/* This is used to pass formatting options to various value-printing
+   functions.  */
+struct value_print_options
+{
+  /* Pretty-printing control.  */
+  enum val_prettyprint pretty;
 
-extern int vtblprint;		/* Controls printing of vtbl's */
-extern int unionprint;		/* Controls printing of nested unions.  */
-extern int addressprint;	/* Controls pretty printing of addresses.  */
-extern int objectprint;		/* Controls looking up an object's derived type
-				   using what we find in its vtables.  */
+  /* Controls pretty printing of arrays.  */
+  int prettyprint_arrays;
 
-extern unsigned int print_max;	/* Max # of chars for strings/vectors */
+  /* Controls pretty printing of structures.  */
+  int prettyprint_structs;
 
-/* Flag to low-level print routines that this value is being printed
-   in an epoch window.  We'd like to pass this as a parameter, but
-   every routine would need to take it.  Perhaps we can encapsulate
-   this in the I/O stream once we have GNU stdio. */
-extern int inspect_it;
+  /* Controls printing of virtual tables.  */
+  int vtblprint;
 
-/* Print repeat counts if there are more than this many repetitions of an
-   element in an array.  Referenced by the low level language dependent
-   print routines. */
-extern unsigned int repeat_count_threshold;
+  /* Controls printing of nested unions.  */
+  int unionprint;
 
-extern int output_format;
+  /* Controls printing of addresses.  */
+  int addressprint;
 
-extern int stop_print_at_null;	/* Stop printing at null char? */
+  /* Controls looking up an object's derived type using what we find
+     in its vtables.  */
+  int objectprint;
+
+  /* Maximum number of chars to print for a string pointer value or vector
+     contents, or UINT_MAX for no limit.  Note that "set print elements 0"
+     stores UINT_MAX in print_max, which displays in a show command as
+     "unlimited". */
+  unsigned int print_max;
+
+  /* Print repeat counts if there are more than this many repetitions
+     of an element in an array.  */
+  unsigned int repeat_count_threshold;
+
+  /* The global output format letter.  */
+  int output_format;
+
+  /* The current format letter.  This is set locally for a given call,
+     e.g. when the user passes a format to "print".  */
+  int format;
+
+  /* Stop printing at null character?  */
+  int stop_print_at_null;
+
+  /* True if this value is being printed in an epoch window.  */
+  int inspect_it;
+
+  /* True if we should print the index of each element when printing
+     an array.  */
+  int print_array_indexes;
+
+  /* If nonzero, then dereference references, otherwise just print
+     them like pointers.  */
+  int deref_ref;
+
+  /* If nonzero, print static fields.  */
+  int static_field_print;
+
+  /* If nonzero, print static fields for Pascal.  FIXME: C++ and Java
+     share one flag, why not Pascal too?  */
+  int pascal_static_field_print;
+};
+
+/* The global print options set by the user.  In general this should
+   not be directly accessed, except by set/show commands.  Ordinary
+   code should call get_user_print_options instead.  */
+extern struct value_print_options user_print_options;
+
+/* Initialize *OPTS to be a copy of the user print options.  */
+extern void get_user_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+   pretty-printing disabled.  */
+extern void get_raw_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+   FORMAT as the formatting option.  */
+extern void get_formatted_print_options (struct value_print_options *opts,
+					 char format);
 
-extern int print_array_indexes_p (void);
- 
 extern int get_array_bounds (struct type *type, long *low_bound,
 			     long *high_bound);
 
 extern void maybe_print_array_index (struct type *index_type, LONGEST index,
-                                     struct ui_file *stream, int format,
-                                     enum val_prettyprint pretty);
+                                     struct ui_file *stream,
+				     const struct value_print_options *options);
 
 extern void val_print_array_elements (struct type *, const gdb_byte *,
 				      CORE_ADDR, struct ui_file *, int,
-				      int, int, enum val_prettyprint,
+				      const struct value_print_options *,
 				      unsigned int);
 
 extern void val_print_type_code_int (struct type *, const gdb_byte *,
diff --git a/gdb/value.c b/gdb/value.c
index 0b530f0..1fa376d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -36,6 +36,7 @@
 #include "block.h"
 #include "dfp.h"
 #include "objfiles.h"
+#include "valprint.h"
 
 #include "python/python.h"
 
@@ -708,9 +709,11 @@ show_values (char *num_exp, int from_tty)
 
   for (i = num; i < num + 10 && i <= value_history_count; i++)
     {
+      struct value_print_options opts;
       val = access_value_history (i);
       printf_filtered (("$%d = "), i);
-      value_print (val, gdb_stdout, 0, Val_pretty_default);
+      get_user_print_options (&opts);
+      value_print (val, gdb_stdout, &opts);
       printf_filtered (("\n"));
     }
 
@@ -969,7 +972,9 @@ show_convenience (char *ignore, int from_tty)
 {
   struct internalvar *var;
   int varseen = 0;
+  struct value_print_options opts;
 
+  get_user_print_options (&opts);
   for (var = internalvars; var; var = var->next)
     {
       if (!varseen)
@@ -978,7 +983,7 @@ show_convenience (char *ignore, int from_tty)
 	}
       printf_filtered (("$%s = "), var->name);
       value_print (value_of_internalvar (var), gdb_stdout,
-		   0, Val_pretty_default);
+		   &opts);
       printf_filtered (("\n"));
     }
   if (!varseen)
diff --git a/gdb/value.h b/gdb/value.h
index f53d333..65fea99 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -32,6 +32,7 @@ struct symbol;
 struct type;
 struct ui_file;
 struct language_defn;
+struct value_print_options;
 
 /* The structure which defines the type of a value.  It should never
    be possible for a program lval value to survive over a call to the
@@ -526,8 +527,8 @@ extern void print_floating (const gdb_byte *valaddr, struct type *type,
 extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
 				    struct ui_file *stream);
 
-extern int value_print (struct value *val, struct ui_file *stream, int format,
-			enum val_prettyprint pretty);
+extern int value_print (struct value *val, struct ui_file *stream,
+			const struct value_print_options *options);
 
 extern void value_print_array_elements (struct value *val,
 					struct ui_file *stream, int format,
@@ -537,19 +538,18 @@ extern struct value *value_release_to_mark (struct value *mark);
 
 extern int val_print (struct type *type, const gdb_byte *valaddr,
 		      int embedded_offset, CORE_ADDR address,
-		      struct ui_file *stream, int format,
-		      int deref_ref, int recurse,
-		      enum val_prettyprint pretty,
+		      struct ui_file *stream, int recurse,
+		      const struct value_print_options *options,
 		      const struct language_defn *language);
 
 extern int common_val_print (struct value *val,
-			     struct ui_file *stream, int format,
-			     int deref_ref, int recurse,
-			     enum val_prettyprint pretty,
+			     struct ui_file *stream, int recurse,
+			     const struct value_print_options *options,
 			     const struct language_defn *language);
 
 extern int val_print_string (CORE_ADDR addr, int len, int width,
-			     struct ui_file *stream);
+			     struct ui_file *stream,
+			     const struct value_print_options *options);
 
 extern void print_variable_value (struct symbol *var,
 				  struct frame_info *frame,
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 15cbd45..ab369a2 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -25,6 +25,7 @@
 #include "wrapper.h"
 #include "gdbcmd.h"
 #include "block.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 #include "gdb_string.h"
@@ -1791,6 +1792,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   struct ui_file *stb;
   struct cleanup *old_chain;
   char *thevalue;
+  struct value_print_options opts;
 
   if (value == NULL)
     return NULL;
@@ -1798,8 +1800,9 @@ value_get_print_value (struct value *value, enum varobj_display_formats format)
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
-  common_val_print (value, stb, format_code[(int) format], 1, 0, 0,
-		    current_language);
+  get_formatted_print_options (&opts, format_code[(int) format]);
+  opts.deref_ref = 0;
+  common_val_print (value, stb, 0, &opts, current_language);
   thevalue = ui_file_xstrdup (stb, &dummy);
 
   do_cleanups (old_chain);

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-27 17:07                       ` Tom Tromey
@ 2008-10-28 16:27                         ` Ulrich Weigand
  2008-10-28 18:17                           ` Tom Tromey
  0 siblings, 1 reply; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-28 16:27 UTC (permalink / raw)
  To: tromey; +Cc: Joel Brobecker, gdb-patches

Tom Tromey wrote:

> 2008-10-27  Tom Tromey  <tromey@redhat.com>
> 
> 	* varobj.c (value_get_print_value): Include valprint.h.
> 	(value_get_print_value): Use get_formatted_print_options.
> 	* value.h (struct value_print_options): Declare.
> 	(value_print, val_print, common_val_print, val_print_string):
> 	Update.
> 	* value.c: Include valprint.h.
> 	(show_values): Use get_user_print_options.
> 	(show_convenience): Likewise.
> 	* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
> 	declare.
> 	(struct value_print_options): New type.
> 	(vtblprint, unionprint, addressprint, objectprint, print_max,
> 	inspect_it, repeat_count_threshold, output_format,
> 	stop_print_at_null): Don't declare.
> 	(user_print_options, get_user_print_options,
> 	get_raw_print_options, get_formatted_print_options): Declare.
> 	(print_array_indexes_p): Don't declare.
> 	(maybe_print_array_index, val_print_array_elements): Update.
> 	* valprint.c (print_max): Remove.
> 	(user_print_options): New global.
> 	(get_user_print_options, get_raw_print_options,
> 	get_formatted_print_options): New functions.
> 	(print_array_indexes, repeat_count_threshold, stop_print_at_null,
> 	prettyprint_structs, prettyprint_arrays, unionprint,
> 	addressprint): Remove.
> 	(val_print): Remove format, deref_ref, pretty arguments; add
> 	options.  Update.
> 	(common_val_print): Likewise.
> 	(print_array_indexes_p): Remove.
> 	(maybe_print_array_index): Remove format, pretty arguments; add
> 	options.  Update.
> 	(val_print_array_elements): Remove format, deref_ref, pretty
> 	arguments; add options.  Update.
> 	(val_print_string): Add options argument.  Update.
> 	(_initialize_valprint): Use user_print_options.
> 	(output_format): Remove.
> 	(set_output_radix_1): Use user_print_options.
> 	* typeprint.c: Include valprint.h.
> 	(objectprint): Don't declare.
> 	(whatis_exp): Use get_user_print_options.
> 	* tui/tui-regs.c: Include valprint.h.
> 	(tui_register_format): Use get_formatted_print_options.
> 	* tracepoint.c: Include valprint.h.
> 	(addressprint): Don't declare.
> 	(trace_mention): Use get_user_print_options.
> 	(tracepoints_info): Likewise.
> 	* stack.c (print_frame_args): Use get_raw_print_options.
> 	(print_frame_info): Use get_user_print_options.
> 	(print_frame): Likewise.
> 	* sh64-tdep.c: Include valprint.h
> 	(sh64_do_register): Use get_formatted_print_options.
> 	* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
> 	pretty arguments; add options.
> 	(scm_scmlist_print): Likewise.  Update.
> 	(scm_scmval_print): Likewise.
> 	(scm_val_print): Likewise.
> 	(scm_value_print): Remove format, pretty arguments; add options.
> 	Update.
> 	* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
> 	Update.
> 	* scm-lang.c (scm_printstr): Add options argument.
> 	* python/python-value.c: Include valprint.h.
> 	(valpy_str): Use get_user_print_options.
> 	* printcmd.c: Include valprint.h.
> 	(addressprint): Don't declare.
> 	(inspect_it): Remove.
> 	(print_formatted): Remove format option; add options.  Update.
> 	(print_scalar_formatted): Likewise.
> 	(print_address_demangle): Use get_user_print_options.
> 	(do_examine): Use get_formatted_print_options.
> 	(print_command_1): Likewise.
> 	(output_command): Use get_formatted_print_options.
> 	(do_one_display): Likewise.
> 	(print_variable_value): Use get_user_print_options.
> 	* p-valprint.c (pascal_val_print): Remove format, deref_ref,
> 	pretty arguments; add options.  Update.
> 	(pascal_value_print): Remove format, pretty arguments; add
> 	options.  Update.
> 	(vtblprint, objectprint): Don't declare.
> 	(pascal_static_field_print): Remove.
> 	(pascal_object_print_value_fields): Remove format, pretty
> 	arguments; add options.  Update.
> 	(pascal_object_print_static_field): Likewise.
> 	(_initialize_pascal_valprint): Use user_print_options.  Update.
> 	* p-lang.h (pascal_val_print, pascal_value_print,
> 	pascal_printstr, pascal_object_print_value_fields): Update.
> 	(vtblprint, static_field_print): Don't declare.
> 	* p-lang.c (pascal_printstr): Add options argument.  Update.
> 	* objc-lang.c (objc_printstr): Add options argument.  Update.
> 	* mt-tdep.c: Include valprint.h.
> 	(mt_registers_info): Use get_raw_print_options.
> 	* mips-tdep.c: Include valprint.h.
> 	(mips_print_fp_register): Use get_formatted_print_options.
> 	(mips_print_register): Likewise.
> 	* mi/mi-main.c: Include valprint.h.
> 	(get_register): Use get_user_print_options.
> 	(mi_cmd_data_evaluate_expression): Likewise.
> 	(mi_cmd_data_read_memory): Use get_formatted_print_options.
> 	* mi/mi-cmd-stack.c: Include valprint.h.
> 	(list_args_or_locals): Use get_raw_print_options.
> 	* m2-valprint.c (print_function_pointer_address): Add addressprint
> 	argument.
> 	(m2_print_long_set): Remove format, pretty arguments.
> 	(m2_print_unbounded_array): Remove format, deref_ref, pretty
> 	arguments; add options.  Update.
> 	(print_unpacked_pointer): Remove format argument; add options.
> 	Now static.  Update.
> 	(print_variable_at_address): Remove format, deref_ref, pretty
> 	arguments; add options.  Update.
> 	(m2_print_array_contents): Likewise.
> 	(m2_val_print): Likewise.
> 	* m2-lang.h (m2_val_print): Update.
> 	* m2-lang.c (m2_printstr): Add options argument. Update.
> 	* language.h (struct value_print_options): Declare.
> 	(struct language_defn) <la_printstr>: Add options argument.
> 	<la_val_print>: Remove format, deref_ref, pretty argument; add
> 	options.
> 	<la_value_print>: Remove format, pretty arguments; add options.
> 	<la_print_array_index>: Likewise.
> 	(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
> 	LA_PRINT_ARRAY_INDEX): Update.
> 	(default_print_array_index): Update.
> 	* language.c (default_print_array_index): Remove format, pretty
> 	arguments; add options.  Update.
> 	(unk_lang_printstr): Add options argument.
> 	(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
> 	add options.
> 	(unk_lang_value_print): Remove format, pretty arguments; add
> 	options.
> 	* jv-valprint.c (java_value_print): Remove format, pretty
> 	arguments; add options.  Update.
> 	(java_print_value_fields): Likewise.
> 	(java_val_print): Remove format, deref_ref, pretty arguments; add
> 	options.  Update.
> 	* jv-lang.h (java_val_print, java_value_print): Declare.
> 	* infcmd.c: Include valprint.h.
> 	(print_return_value): Use get_raw_print_options.
> 	(default_print_registers_info): Use get_user_print_options,
> 	get_formatted_print_options.
> 	(registers_info): Use get_formatted_print_options.
> 	* gdbtypes.h (struct value_print_options): Declare.
> 	(print_scalar_formatted): Update.
> 	* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
> 	pretty arguments; add options.  Update.
> 	(f77_print_array): Likewise.
> 	(f_val_print): Likewise.
> 	* f-lang.h (f_val_print): Update.
> 	* f-lang.c (f_printstr): Add options argument.  Update.
> 	(c_value_print): Update declaration.
> 	* expprint.c: Include valprint.h.
> 	(print_subexp_standard): Use get_raw_print_options,
> 	get_user_print_options.
> 	* eval.c: Include valprint.h.
> 	(objectprint): Don't declare.
> 	(evaluate_subexp_standard): Use get_user_print_options.
> 	* cp-valprint.c (vtblprint, objectprint, static_field_print):
> 	Remove.
> 	(cp_print_value_fields): Remove format, pretty arguments; add
> 	options.  Update.
> 	(cp_print_value): Likewise.
> 	(cp_print_static_field): Likewise.
> 	(_initialize_cp_valprint): Use user_print_options.  Update.
> 	* c-valprint.c (print_function_pointer_address): Add addressprint
> 	argument.
> 	(c_val_print): Remove format, deref_ref, pretty arguments; add
> 	options.  Update.
> 	(c_value_print): Add options argument.  Update.
> 	* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
> 	(vtblprint, static_field_print): Don't declare.
> 	(cp_print_value_fields): Update.
> 	* c-lang.c (c_printstr): Add options argument.  Update.
> 	* breakpoint.c: Include valprint.h.
> 	(addressprint): Don't declare.
> 	(watchpoint_value_print): Use get_user_print_options.
> 	(print_one_breakpoint_location): Likewise.
> 	(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
> 	print_exception_catchpoint): Likewise.
> 	* auxv.c (fprint_target_auxv): Don't declare addressprint.  Use
> 	get_user_print_options.
> 	* ada-valprint.c (struct ada_val_print_args): Remove format,
> 	deref_ref, and pretty; add options.
> 	(print_optional_low_bound): Add options argument.
> 	(val_print_packed_array_elements): Remove format and pretty
> 	arguments; add options.  Update.
> 	(printstr): Add options argument.  Update.
> 	(ada_printstr): Likewise.
> 	(ada_val_print): Remove format, deref_ref, pretty arguments; add
> 	options argument.  Update.
> 	(ada_val_print_stub): Update.
> 	(ada_val_print_array): Remove format, deref_ref, pretty arguments;
> 	add options.  Update.
> 	(ada_val_print_1): Likewise.
> 	(print_variant_part): Likewise.
> 	(ada_value_print): Remove format, pretty arguments; add options.
> 	Update.
> 	(print_record): Likewise.
> 	(print_field_values): Likewise.
> 	* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
> 	Update.
> 	* ada-lang.c (ada_print_array_index): Add options argument; remove
> 	format and pretty arguments.
> 	(print_one_exception): Use get_user_print_options.
> 
> 2008-10-27  Tom Tromey  <tromey@redhat.com>
> 
> 	* gdb.base/exprs.exp (test_expr): Add enum formatting tests.


This is OK, thanks!


I've noticed couple of things that might still be cleaned up somewhat,
but this can be done as a follow-up patch (if at all):

- As all the top-level val_print callers set deref_ref to 1, maybe the
  default user_print_options should have that value, making most (all?)
  of the explicit opts.deref_ref = 1 statements obsolete.

- Maybe the "size" argument (to the print_formatted routines) should
  also move into the struct, together with "format"?

- In some cases (e.g. print_subexp_standard) you have multiple instances
  within the same function where a local "opts" variable is created; 
  maybe it would be clearer to have a common "opts" initialized once
  for the whole function?

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-28 16:27                         ` Ulrich Weigand
@ 2008-10-28 18:17                           ` Tom Tromey
  2008-10-28 20:00                             ` Ulrich Weigand
  0 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2008-10-28 18:17 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Joel Brobecker, gdb-patches

>>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:

Ulrich> This is OK, thanks!

Thanks -- I checked it in.

Ulrich> - As all the top-level val_print callers set deref_ref to 1, maybe the
Ulrich>   default user_print_options should have that value, making most (all?)
Ulrich>   of the explicit opts.deref_ref = 1 statements obsolete.

Ulrich> - Maybe the "size" argument (to the print_formatted routines) should
Ulrich>   also move into the struct, together with "format"?

I'll look at these two.

Ulrich> - In some cases (e.g. print_subexp_standard) you have multiple instances
Ulrich>   within the same function where a local "opts" variable is created; 
Ulrich>   maybe it would be clearer to have a common "opts" initialized once
Ulrich>   for the whole function?

In a long function, like print_subexp_standard, I find it clearer to
have variables declared as locally as possible, because it is simpler
to see all the code referencing the local at once.

Tom


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC/RFA] add struct parse_context to all command functions
  2008-10-28 18:17                           ` Tom Tromey
@ 2008-10-28 20:00                             ` Ulrich Weigand
  0 siblings, 0 replies; 32+ messages in thread
From: Ulrich Weigand @ 2008-10-28 20:00 UTC (permalink / raw)
  To: tromey; +Cc: Joel Brobecker, gdb-patches

Tom Tromey wrote:

> Ulrich> - In some cases (e.g. print_subexp_standard) you have multiple instances
> Ulrich>   within the same function where a local "opts" variable is created; 
> Ulrich>   maybe it would be clearer to have a common "opts" initialized once
> Ulrich>   for the whole function?
> 
> In a long function, like print_subexp_standard, I find it clearer to
> have variables declared as locally as possible, because it is simpler
> to see all the code referencing the local at once.

I agree, if the variables are really independent.  In this case, my thought
was that we really want all parts of print_subexp_standard to use the *same*
consistent set of printing options, so it might make sense to make this
explicit by using a single variable to hold them.  (Also, this would make it
simple to pull the options out as an argument, if we ever see the need for
invoking print_subexp_standard with different print modes ...)

But this is really just a minor issue; I'm fine with the way it is.

Bye,
Ulrich

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2008-10-28 18:43 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-09 14:05 [RFC/RFA] add struct parse_context to all command functions 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox