public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 29/55] Initial rewrite of generic_value_print
Date: Sun, 08 Dec 2019 18:31:00 -0000	[thread overview]
Message-ID: <20191208182958.10181-30-tom@tromey.com> (raw)
In-Reply-To: <20191208182958.10181-1-tom@tromey.com>

This rewrites generic_value_print, by copying in the body of
generic_val_print and making the needed adjustments.

gdb/ChangeLog
2019-12-08  Tom Tromey  <tom@tromey.com>

	* valprint.c (generic_value_print): Rewrite.

Change-Id: I4bef96d94afee1ff4673f995d0306e059863a03d
---
 gdb/ChangeLog  |   4 ++
 gdb/valprint.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 106 insertions(+), 3 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index b2506dc6fc4..562a2acdda1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1014,9 +1014,108 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 		     const struct value_print_options *options,
 		     const struct generic_val_print_decorations *decorations)
 {
-  generic_val_print (value_type (val), value_embedded_offset (val),
-		     value_address (val), stream, recurse, val, options,
-		     decorations);
+  struct type *type = value_type (val);
+  struct type *unresolved_type = type;
+
+  type = check_typedef (type);
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_ARRAY:
+      generic_val_print_array (type, 0, value_address (val), stream,
+			       recurse, val, options, decorations);
+      break;
+
+    case TYPE_CODE_MEMBERPTR:
+      generic_val_print_memberptr (type, 0, stream,
+				   val, options);
+      break;
+
+    case TYPE_CODE_PTR:
+      generic_val_print_ptr (type, 0, stream,
+			     val, options);
+      break;
+
+    case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
+      generic_val_print_ref (type, 0, stream, recurse,
+			     val, options);
+      break;
+
+    case TYPE_CODE_ENUM:
+      generic_val_print_enum (type, 0, stream,
+			      val, options);
+      break;
+
+    case TYPE_CODE_FLAGS:
+      generic_val_print_flags (type, 0, stream,
+			       val, options);
+      break;
+
+    case TYPE_CODE_FUNC:
+    case TYPE_CODE_METHOD:
+      generic_val_print_func (type, 0, value_address (val), stream,
+			      val, options);
+      break;
+
+    case TYPE_CODE_BOOL:
+      generic_val_print_bool (type, 0, stream,
+			      val, options, decorations);
+      break;
+
+    case TYPE_CODE_RANGE:
+      /* FIXME: create_static_range_type does not set the unsigned bit in a
+         range type (I think it probably should copy it from the
+         target type), so we won't print values which are too large to
+         fit in a signed integer correctly.  */
+      /* FIXME: Doesn't handle ranges of enums correctly.  (Can't just
+         print with the target type, though, because the size of our
+         type and the target type might differ).  */
+
+      /* FALLTHROUGH */
+
+    case TYPE_CODE_INT:
+      generic_val_print_int (type, 0, stream,
+			     val, options);
+      break;
+
+    case TYPE_CODE_CHAR:
+      generic_val_print_char (type, unresolved_type, 0,
+			      stream, val, options);
+      break;
+
+    case TYPE_CODE_FLT:
+    case TYPE_CODE_DECFLOAT:
+      generic_val_print_float (type, 0, stream,
+			       val, options);
+      break;
+
+    case TYPE_CODE_VOID:
+      fputs_filtered (decorations->void_name, stream);
+      break;
+
+    case TYPE_CODE_ERROR:
+      fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
+      break;
+
+    case TYPE_CODE_UNDEF:
+      /* This happens (without TYPE_STUB set) on systems which don't use
+         dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
+         and no complete type for struct foo in that file.  */
+      fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
+      break;
+
+    case TYPE_CODE_COMPLEX:
+      generic_val_print_complex (type, 0, stream,
+				 val, options, decorations);
+      break;
+
+    case TYPE_CODE_UNION:
+    case TYPE_CODE_STRUCT:
+    case TYPE_CODE_METHODPTR:
+    default:
+      error (_("Unhandled type code %d in symbol table."),
+	     TYPE_CODE (type));
+    }
 }
 
 /* Helper function for val_print and common_val_print that does the
-- 
2.17.2

  parent reply	other threads:[~2019-12-08 18:31 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
2019-12-08 18:30 ` [PATCH 07/55] Use common_val_print in f-valprint.c Tom Tromey
2019-12-08 18:30 ` [PATCH 19/55] Introduce pascal_value_print_inner Tom Tromey
2019-12-08 18:30 ` [PATCH 24/55] Convert D printing to value-based API Tom Tromey
2019-12-08 18:30 ` [PATCH 25/55] Convert Modula-2 " Tom Tromey
2019-12-08 18:30 ` [PATCH 10/55] Introduce la_value_print_inner Tom Tromey
2019-12-08 18:30 ` [PATCH 35/55] Introduce generic_value_print_int Tom Tromey
2019-12-08 18:30 ` [PATCH 13/55] Two simple uses of value_print_scalar_formatted Tom Tromey
2019-12-08 18:30 ` [PATCH 09/55] Use common_val_print in c-valprint.c Tom Tromey
2020-01-15  5:09   ` Simon Marchi
2020-01-24  1:03     ` Tom Tromey
2020-03-14  9:18       ` [committted][gdb/testsuite] Fix FAIL in gdb.base/printcmds.exp Tom de Vries
2019-12-08 18:30 ` [PATCH 11/55] Introduce generic_value_print Tom Tromey
2019-12-09  4:05   ` Christian Biesinger via gdb-patches
2019-12-09 23:40     ` Tom Tromey
2019-12-08 18:30 ` [PATCH 41/55] Introduce c_value_print_int Tom Tromey
2019-12-08 18:30 ` [PATCH 30/55] Introduce generic_value_print_ptr Tom Tromey
2019-12-08 18:30 ` [PATCH 32/55] Remove generic_val_print_flags Tom Tromey
2019-12-08 18:30 ` [PATCH 22/55] Convert Rust printing to value-based API Tom Tromey
2019-12-08 18:30 ` [PATCH 20/55] Introduce f_value_print_innner Tom Tromey
2019-12-08 18:30 ` [PATCH 04/55] Use common_val_print in infcmd.c Tom Tromey
2019-12-08 18:30 ` [PATCH 06/55] Use common_val_print in riscv-tdep.c Tom Tromey
2019-12-08 18:30 ` [PATCH 48/55] Rewrite ada_value_print_1 floating point case Tom Tromey
2019-12-08 18:30 ` [PATCH 16/55] Make pascal_object_print_value_fields static Tom Tromey
2019-12-08 18:31 ` [PATCH 02/55] Refactor val_print and common_val_print Tom Tromey
2019-12-08 18:31 ` [PATCH 26/55] Convert Fortran printing to value-based API Tom Tromey
2019-12-08 18:31 ` [PATCH 33/55] Simplify generic_val_print_func Tom Tromey
2019-12-08 18:31 ` [PATCH 05/55] Use common_val_print in mi-main.c Tom Tromey
2019-12-08 18:31 ` [PATCH 18/55] Introduce m2_value_print_inner Tom Tromey
2019-12-08 18:31 ` [PATCH 14/55] Introduce value_print_array_elements Tom Tromey
2020-01-15  5:47   ` Simon Marchi
2020-01-23 23:39     ` Tom Tromey
2019-12-08 18:31 ` [PATCH 42/55] Introduce c_value_print_memberptr Tom Tromey
2019-12-08 18:31 ` [PATCH 34/55] Introduce generic_value_print_bool Tom Tromey
2019-12-08 18:31 ` [PATCH 38/55] Introduce generic_value_print_complex Tom Tromey
2019-12-08 18:31 ` [PATCH 46/55] Rewrite ada_value_print_inner Tom Tromey
2019-12-08 18:31 ` Tom Tromey [this message]
2019-12-08 18:31 ` [PATCH 03/55] Introduce common_val_print_checked Tom Tromey
2019-12-09  4:06   ` Christian Biesinger via gdb-patches
2019-12-09 23:37     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 39/55] Rewrite c_value_print_inner Tom Tromey
2019-12-08 18:32 ` [PATCH 15/55] Simplify c_val_print_array Tom Tromey
2019-12-08 18:32 ` [PATCH 51/55] Convert ada_value_print to value-based API Tom Tromey
2019-12-08 18:32 ` [PATCH 54/55] Change extension language pretty-printers to use value API Tom Tromey
2019-12-08 18:32 ` [PATCH 01/55] Use scoped_value_mark in value_print Tom Tromey
2019-12-08 18:32 ` [PATCH 40/55] Introduce c_value_print_ptr Tom Tromey
2020-01-15  6:01   ` Simon Marchi
2020-01-23 23:47     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct Tom Tromey
2020-01-15  6:15   ` Simon Marchi
2020-01-24  0:54     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 27/55] Rewrite pascal_value_print_inner Tom Tromey
2019-12-08 18:32 ` [PATCH 08/55] Use common_val_print in cp-valprint.c Tom Tromey
2019-12-08 18:32 ` [PATCH 43/55] Introduce c_value_print_array Tom Tromey
2019-12-08 18:32 ` [PATCH 52/55] Introduce ada_value_print_array Tom Tromey
2019-12-08 18:32 ` [PATCH 28/55] Convert Pascal to value-based API Tom Tromey
2020-01-15  5:57   ` Simon Marchi
2020-01-23 23:41     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 23/55] Convert Go printing " Tom Tromey
2019-12-08 18:32 ` [PATCH 12/55] Introduce value_print_scalar_formatted Tom Tromey
2020-01-15  5:15   ` Simon Marchi
2020-01-23 23:37     ` Tom Tromey
2019-12-08 18:50 ` [PATCH 55/55] Remove val_print Tom Tromey
2019-12-08 18:51 ` [PATCH 50/55] Convert ada_val_print_ref to value-based API Tom Tromey
2019-12-08 18:51 ` [PATCH 17/55] Introduce c_value_print_inner Tom Tromey
2019-12-08 18:51 ` [PATCH 53/55] Change print_field_values to use value-based API Tom Tromey
2019-12-08 18:51 ` [PATCH 21/55] Introduce ada_value_print_inner Tom Tromey
2019-12-08 18:52 ` [PATCH 45/55] Introduce cp_print_value Tom Tromey
2019-12-08 18:52 ` [PATCH 37/55] Simplify generic_val_print_float Tom Tromey
2019-12-08 18:54 ` [PATCH 47/55] Introduce ada_value_print_ptr Tom Tromey
2019-12-08 18:54 ` [PATCH 49/55] Introduce ada_value_print_num Tom Tromey
2019-12-08 18:54 ` [PATCH 31/55] Fix generic_val_print_enum for value-based printing Tom Tromey
2019-12-08 18:54 ` [PATCH 36/55] Introduce generic_value_print_char Tom Tromey
2020-01-15  0:37 ` [PATCH 00/55] Remove val_print Tom Tromey
2020-01-15 11:52   ` Simon Marchi
2020-03-14  0:02     ` Tom Tromey

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=20191208182958.10181-30-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

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

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