public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Andrew Burgess" <aburgess@broadcom.com>
To: gdb-patches@sourceware.org
Cc: "Pedro Alves" <palves@redhat.com>
Subject: Re: PING: Re: [PATCH] Print <unavailable> for unavailable registers
Date: Wed, 16 Oct 2013 14:26:00 -0000	[thread overview]
Message-ID: <525EA208.7000107@broadcom.com> (raw)
In-Reply-To: <5239CF96.4050800@redhat.com>

On 18/09/2013 5:06 PM, Pedro Alves wrote:

>> Index: ./gdb/infcmd.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/infcmd.c,v
>> retrieving revision 1.335
>> diff -u -p -r1.335 infcmd.c
>> --- ./gdb/infcmd.c	18 Sep 2013 14:02:31 -0000	1.335
>> +++ ./gdb/infcmd.c	18 Sep 2013 14:43:13 -0000
>> @@ -2030,7 +2030,8 @@ default_print_one_register_info (struct 
>>  
>>    if (!value_entirely_available (val))
>>      {
>> -      fprintf_filtered (file, "*value not available*\n");
>> +      val_print_unavailable (file);
>> +      fprintf_filtered (file, "\n");
>>        return;
>>      }
>>    else if (value_optimized_out (val))
> 
> Why do we do this instead of just deferring to val_print though?
> val_print would be able to print partially available registers,
> for instance.
> 
> (We'd need to do something about the "raw" printing bits below
> though.)

OK that's a reasonable point.  I've rewritten this patch to make use
of the val_print call to print the <not-saved> / <unavailable>.

For now I unconditionally skip the second attempt to print the value,
the "raw" form, for optimized-out and unavailable values, we might
be able to do better in the future but I was keen to avoid output
like this: "rax:  <unavailable> <unavailable>" with the
<unavailable> being repeated.  If the value of a register is
partially unavailable, and so we did manage to print something then
it might make sense to try and print the raw form... 

Is this OK to apply?

Thanks,
Andrew


gdb/ChangeLog
    
2013-10-16  Andrew Burgess  <aburgess@broadcom.com>

	* infcmd.c (default_print_one_register_info): Use val_print to
	print all values even optimized out or unavailable ones.  Don't
	try to print a raw form of optimized out or unavailable values.

gdb/testsuite/ChangeLog
    
2013-10-16  Andrew Burgess  <aburgess@broadcom.com>

	* gdb.trace/unavailable.exp (gdb_unavailable_registers_test):
	Expect <unavailable> pattern.

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 20f8857..3b41837 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2024,21 +2024,13 @@ default_print_one_register_info (struct ui_file *file,
 				 struct value *val)
 {
   struct type *regtype = value_type (val);
+  int print_raw_format;
 
   fputs_filtered (name, file);
   print_spaces_filtered (15 - strlen (name), file);
 
-  if (!value_entirely_available (val))
-    {
-      fprintf_filtered (file, "*value not available*\n");
-      return;
-    }
-  else if (value_optimized_out (val))
-    {
-      val_print_optimized_out (val, file);
-      fprintf_filtered (file, "\n");
-      return;
-    }
+  print_raw_format = (value_entirely_available (val)
+		      && !value_optimized_out (val));
 
   /* If virtual format is floating, print it that way, and in raw
      hex.  */
@@ -2058,9 +2050,12 @@ default_print_one_register_info (struct ui_file *file,
 		 value_embedded_offset (val), 0,
 		 file, 0, val, &opts, current_language);
 
-      fprintf_filtered (file, "\t(raw ");
-      print_hex_chars (file, valaddr, TYPE_LENGTH (regtype), byte_order);
-      fprintf_filtered (file, ")");
+      if (print_raw_format)
+	{
+	  fprintf_filtered (file, "\t(raw ");
+	  print_hex_chars (file, valaddr, TYPE_LENGTH (regtype), byte_order);
+	  fprintf_filtered (file, ")");
+	}
     }
   else
     {
@@ -2075,7 +2070,7 @@ default_print_one_register_info (struct ui_file *file,
 		 file, 0, val, &opts, current_language);
       /* If not a vector register, print it also according to its
 	 natural format.  */
-      if (TYPE_VECTOR (regtype) == 0)
+      if (print_raw_format && TYPE_VECTOR (regtype) == 0)
 	{
 	  get_user_print_options (&opts);
 	  opts.deref_ref = 1;
diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index 8e2e105..ed14798 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -297,11 +297,11 @@ proc gdb_unavailable_registers_test { } {
 	test_register "\$pc"
 
 	gdb_test "info registers" \
-	    "\\*value not available\\*.*\\*value not available\\*" \
+	    "<unavailable>.*<unavailable>" \
 	    "info registers, multiple registers not available"
 
 	gdb_test "info registers \$$spreg" \
-	    "\\*value not available\\*" \
+	    "<unavailable>" \
 	    "info registers \$$spreg reports not available"
 
 	gdb_test "tfind none" "#0  end .*" "cease trace debugging"


  reply	other threads:[~2013-10-16 14:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 13:09 Andrew Burgess
2013-08-28 15:26 ` PING: " Andrew Burgess
2013-09-18 14:48 ` PING: " Andrew Burgess
2013-09-18 16:06   ` Pedro Alves
2013-10-16 14:26     ` Andrew Burgess [this message]
2013-10-24 19:44       ` Pedro Alves
2013-10-29 13:37         ` 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=525EA208.7000107@broadcom.com \
    --to=aburgess@broadcom.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

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

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