public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Simplify generic_val_print_func
Date: Sat, 14 Mar 2020 00:07:12 +0000 (GMT)	[thread overview]
Message-ID: <20200314000712.1EFC9393FC25@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4112d2e602fed7157ce6bb30f46969129633d0f2

commit 4112d2e602fed7157ce6bb30f46969129633d0f2
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Mar 13 17:39:52 2020 -0600

    Simplify generic_val_print_func
    
    This removes the call to val_print_scalar_formatted from
    generic_val_print_func, allowing generic_value_print to call the
    value-based variant instead.
    
    gdb/ChangeLog
    2020-03-13  Tom Tromey  <tom@tromey.com>
    
            * valprint.c (generic_val_print_func): Simplify.
            (generic_val_print, generic_value_print): Update.

Diff:
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 41 +++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 38e9fb7e483..c969b12bcad 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-13  Tom Tromey  <tom@tromey.com>
+
+	* valprint.c (generic_val_print_func): Simplify.
+	(generic_val_print, generic_value_print): Update.
+
 2020-03-13  Tom Tromey  <tom@tromey.com>
 
 	* valprint.c (generic_val_print_flags): Remove.
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 499d03f16dc..0517bf089f3 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -742,22 +742,16 @@ generic_val_print_func (struct type *type,
 {
   struct gdbarch *gdbarch = get_type_arch (type);
 
-  if (options->format)
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-    }
-  else
-    {
-      /* FIXME, we should consider, at least for ANSI C language,
-         eliminating the distinction made between FUNCs and POINTERs
-         to FUNCs.  */
-      fprintf_filtered (stream, "{");
-      type_print (type, "", stream, -1);
-      fprintf_filtered (stream, "} ");
-      /* Try to print what function it points to, and its address.  */
-      print_address_demangle (options, gdbarch, address, stream, demangle);
-    }
+  gdb_assert (!options->format);
+
+  /* FIXME, we should consider, at least for ANSI C language,
+     eliminating the distinction made between FUNCs and POINTERs to
+     FUNCs.  */
+  fprintf_filtered (stream, "{");
+  type_print (type, "", stream, -1);
+  fprintf_filtered (stream, "} ");
+  /* Try to print what function it points to, and its address.  */
+  print_address_demangle (options, gdbarch, address, stream, demangle);
 }
 
 /* generic_val_print helper for TYPE_CODE_BOOL.  */
@@ -971,8 +965,12 @@ generic_val_print (struct type *type,
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      generic_val_print_func (type, embedded_offset, address, stream,
-			      original_value, options);
+      if (options->format)
+	val_print_scalar_formatted (type, embedded_offset,
+				    original_value, options, 0, stream);
+      else
+	generic_val_print_func (type, embedded_offset, address, stream,
+				original_value, options);
       break;
 
     case TYPE_CODE_BOOL:
@@ -1084,8 +1082,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      generic_val_print_func (type, 0, value_address (val), stream,
-			      val, options);
+      if (options->format)
+	value_print_scalar_formatted (val, options, 0, stream);
+      else
+	generic_val_print_func (type, 0, value_address (val), stream,
+				val, options);
       break;
 
     case TYPE_CODE_BOOL:


                 reply	other threads:[~2020-03-14  0:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200314000712.1EFC9393FC25@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).