Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Andrew Burgess" <aburgess@broadcom.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 07/12] Generic print unavailable or optimized out function.
Date: Mon, 12 Aug 2013 12:28:00 -0000	[thread overview]
Message-ID: <5208D4DD.8080309@broadcom.com> (raw)
In-Reply-To: <5208D1DF.1090201@broadcom.com>

Following on from the patch #6, this factors out a common pattern:
given a value print either <optimized-out> or <unavailable>.

OK to apply?

Thanks,
Andrew



gdb/ChangeLog

2013-08-08  Andrew Burgess  <aburgess@broadcom.com>

	* cp-valprint.c (cp_print_value_fields): Use
	val_print_unavailability_reason.
	* jv-valprint.c (java_print_value_fields): Use
	val_print_unavailability_reason.
	* p-valprint.c (pascal_object_print_value_fields): Use
	val_print_unavailability_reason.
	* valprint.c (valprint_check_validity, value_check_printable)
	(val_print_scalar_formatted): Use val_print_unavailability_reason.
	(val_print_unavailability_reason): New function.
	* valprint.h (val_print_unavailability_reason): New function.

diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 5dd98b0..6b66092 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -298,13 +298,7 @@ cp_print_value_fields (struct type *type, struct
type *real_type,
 					      TYPE_FIELD_BITPOS (type, i),
 					      TYPE_FIELD_BITSIZE (type, i)))
 		{
-		  int optimizedp, unavailablep;
-
-		  value_availability_flags (val, &optimizedp, &unavailablep);
-		  if (optimizedp)
-		    val_print_optimized_out (stream);
-		  else
-		    val_print_unavailable (stream);
+		  val_print_unavailability_reason (val, stream);
 		}
 	      else
 		{
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index edcd769..dfa2d38 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -394,15 +394,7 @@ java_print_value_fields (struct type *type, const
gdb_byte *valaddr,
 		}
 	      else if (!value_bits_available (val, TYPE_FIELD_BITPOS (type, i),
 					      TYPE_FIELD_BITSIZE (type, i)))
-		{
-		  int optimizedp, unavailablep;
-
-		  value_availability_flags (val, &optimizedp, &unavailablep);
-		  if (optimizedp)
-		    val_print_optimized_out (stream);
-		  else
-		    val_print_unavailable (stream);
-		}
+		val_print_unavailability_reason (val, stream);
 	      else
 		{
 		  struct value_print_options opts;
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index bc57541..0bd0022 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -628,15 +628,7 @@ pascal_object_print_value_fields (struct type
*type, const gdb_byte *valaddr,
 		}
 	      else if (!value_bits_available (val, TYPE_FIELD_BITPOS (type, i),
 					      TYPE_FIELD_BITSIZE (type, i)))
-		{
-		  int optimizedp, unavailablep;
-		  -		  value_availability_flags (val, &optimizedp, &unavailablep);
-		  if (optimizedp)
-		    val_print_optimized_out (stream);
-		  else
-		    val_print_unavailable (stream);
-		}
+		val_print_unavailability_reason (val, stream);
 	      else
 		{
 		  struct value_print_options opts = *options;
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 4e165b4..0443737 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -314,13 +314,7 @@ valprint_check_validity (struct ui_file *stream,
       if (!value_bits_available (val, TARGET_CHAR_BIT * embedded_offset,
 				 TARGET_CHAR_BIT * TYPE_LENGTH (type)))
 	{
-	  int optimizedp, unavailablep;
-	  -	  value_availability_flags (val, &optimizedp, &unavailablep);
-	  if (optimizedp)
-	    val_print_optimized_out (stream);
-	  else
-	    val_print_unavailable (stream);
+	  val_print_unavailability_reason (val, stream);
 	  return 0;
 	}
 @@ -353,6 +347,19 @@ val_print_invalid_address (struct ui_file *stream)
   fprintf_filtered (stream, _("<invalid address>"));
 }
 +void
+val_print_unavailability_reason (const struct value *value,
+				 struct ui_file *stream)
+{
+  int optimizedp, unavailablep;
+
+  value_availability_flags (value, &optimizedp, &unavailablep);
+  if (optimizedp)
+    val_print_optimized_out (stream);
+  else
+    val_print_unavailable (stream);
+}
+
 /* A generic val_print that is suitable for use by language
    implementations of the la_val_print method.  This function can
    handle most type codes, though not all, notably exception
@@ -805,15 +812,7 @@ value_check_printable (struct value *val, struct
ui_file *stream,
       if (options->summary && !scalar_type_p (value_type (val)))
 	fprintf_filtered (stream, "...");
       else
-	{
-	  int optimizedp, unavailablep;
-
-	  value_availability_flags (val, &optimizedp, &unavailablep);
-	  if (optimizedp)
-	    val_print_optimized_out (stream);
-	  else
-	    val_print_unavailable (stream);
-	}
+	val_print_unavailability_reason (val, stream);
       return 0;
     }
 @@ -973,15 +972,7 @@ val_print_scalar_formatted (struct type *type,
   /* A scalar object that does not have all bits available can't be
      printed, because all bits contribute to its representation.  */
   if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
-    {
-      int optimizedp, unavailablep;
-      -      value_availability_flags (val, &optimizedp, &unavailablep);
-      if (optimizedp)
-	val_print_optimized_out (stream);
-      else
-	val_print_unavailable (stream);
-    }
+    val_print_unavailability_reason (val, stream);
   else
     print_scalar_formatted (valaddr + embedded_offset, type,
 			    options, size, stream);
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 2959098..5d7f211 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -166,6 +166,12 @@ extern void val_print_unavailable (struct ui_file
*stream);
  extern void val_print_invalid_address (struct ui_file *stream);
 +/* For VALUE call the most appropriate of val_print_optimized_out or
+   val_print_unavailable on STREAM.  */
+
+void val_print_unavailability_reason (const struct value *value,
+				      struct ui_file *stream);
+
 /* An instance of this is passed to generic_val_print and describes
    some language-specific ways to print things.  */



  parent reply	other threads:[~2013-08-12 12:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-12 12:15 [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-08-12 12:16 ` [PATCH 01/12] Introduce is_unavailable_error Andrew Burgess
2013-08-12 12:18 ` [PATCH 02/12]: Remove set_value_optimized_out Andrew Burgess
2013-08-12 12:20 ` [PATCH 03/12] Mark optimized out values as non-lazy Andrew Burgess
2013-11-26 16:38   ` Pedro Alves
2013-11-26 19:19     ` Andrew Burgess
2013-08-12 12:22 ` [PATCH 04/12] Introduce OPTIMIZED_OUT_ERROR Andrew Burgess
2013-08-12 12:24 ` [PATCH 05/12] Convert the unavailable to be bit based Andrew Burgess
2013-08-12 12:27 ` [PATCH 06/12] Delete value_bits_valid Andrew Burgess
2013-11-25 21:41   ` [PATCH] Print entirely unavailable struct/union values as a single <unavailable>. (Re: [PATCH 06/12] Delete value_bits_valid.) Pedro Alves
2013-11-26 10:13     ` Andrew Burgess
2013-11-28 20:14       ` Pedro Alves
2013-08-12 12:28 ` Andrew Burgess [this message]
2013-08-12 12:29 ` [PATCH 08/12] Replace some value_optimized_out with value_entirely_available Andrew Burgess
2013-11-27 17:52   ` [COMMITTED PATCH 0/2] "set debug frame 1" and not saved registers (was: Re: [PATCH 08/12] Replace some value_optimized_out with value_entirely_available) Pedro Alves
2013-11-27 18:14     ` [PATCH 1/2] Make "set debug frame 1" use the standard print routine for optimized out values Pedro Alves
2013-11-27 18:35     ` [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out> Pedro Alves
2013-11-27 18:41       ` Pedro Alves
2013-11-27 18:53         ` [pushed] Fix type of not saved registers. (was: Re: [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out>.) Pedro Alves
2013-08-12 12:30 ` [PATCH 09/12] DWARF value, mark unavailable in bits not bytes Andrew Burgess
2013-08-12 12:31 ` [PATCH 10/12] Merge optimized_out into unavailable vector Andrew Burgess
2013-08-12 12:32 ` [PATCH 11/12] Add test mechanism for value " Andrew Burgess
2013-08-12 12:33 ` [PATCH 12/12] Remove old lval check valid functions Andrew Burgess
2013-08-29 17:21 ` PING: Re: [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-11-12  9:37   ` Andrew Burgess
2013-11-29 22:31 ` Pedro Alves
2013-12-04 14:54   ` Andrew Burgess

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=5208D4DD.8080309@broadcom.com \
    --to=aburgess@broadcom.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