This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Rename TARGET_XFER_E_UNAVAILABLE to TARGET_XFER_UNAVAILABLE (Re: [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial)


On 02/23/2014 11:52 AM, Yao Qi wrote:
>> (Hmm, the _E_ in TARGET_XFER_E_UNAVAILABLE is now starting
>> > to look a little odd and confusing to me.  E.g., it's not
>> > really an error in this case.  I'm pondering renaming it to
>> > TARGET_XFER_UNAVAILABLE.)
> It isn't an error.  Will rename it in a follow-up patch too.

Nowadays, TARGET_XFER_E_UNAVAILABLE isn't regarded as an error in
to_xfer_partial interface, so _E_ looks odd.  This patch is to
replace TARGET_XFER_E_UNAVAILABLE with TARGET_XFER_UNAVAILABLE,
and change its value from -2 to 2.  Since there is no comparison
on the value of 'enum target_xfer_status', so it should be safe.

Regression tested on x86_64-linux.  Patch is pushed in.

-- 
Yao (éå)

gdb:

2014-02-24  Yao Qi  <yao@codesourcery.com>

	* target.h (enum target_xfer_status)
	<TARGET_XFER_E_UNAVAILABLE>: Rename it to ...
	<TARGET_XFER_UNAVAILABLE>: ... it with setting value 2
	explicitly.  New.
	* corefile.c (memory_error_message): User updated.
	* exec.c (section_table_read_available_memory): Likewise.
	* record-btrace.c (record_btrace_xfer_partial): Likewise.
	* target.c (target_xfer_status_to_string): Likewise.
	(raw_memory_xfer_partial): Likewise.
	(memory_xfer_partial_1, target_xfer_partial): Likewise.
	* valops.c (read_value_memory): Likewise.
	* exec.h: Update comments.
---
 gdb/ChangeLog       |   15 +++++++++++++++
 gdb/corefile.c      |    4 ++--
 gdb/exec.c          |    4 ++--
 gdb/exec.h          |    2 +-
 gdb/record-btrace.c |    6 +++---
 gdb/target.c        |    8 ++++----
 gdb/target.h        |    9 ++++-----
 gdb/valops.c        |    2 +-
 8 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9778f7e..5fdbf4f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,20 @@
 2014-02-24  Yao Qi  <yao@codesourcery.com>
 
+	* target.h (enum target_xfer_status)
+	<TARGET_XFER_E_UNAVAILABLE>: Rename it to ...
+	<TARGET_XFER_UNAVAILABLE>: ... it with setting value 2
+	explicitly.  New.
+	* corefile.c (memory_error_message): User updated.
+	* exec.c (section_table_read_available_memory): Likewise.
+	* record-btrace.c (record_btrace_xfer_partial): Likewise.
+	* target.c (target_xfer_status_to_string): Likewise.
+	(raw_memory_xfer_partial): Likewise.
+	(memory_xfer_partial_1, target_xfer_partial): Likewise.
+	* valops.c (read_value_memory): Likewise.
+	* exec.h: Update comments.
+
+2014-02-24  Yao Qi  <yao@codesourcery.com>
+
 	* target.c (target_xfer_status_to_string): Rename argument err
 	to status.
 	* target.h (target_xfer_status_to_string): Update declaration.
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 815adaf..8a96d75 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -204,7 +204,7 @@ memory_error_message (enum target_xfer_status err,
 	 bounds.  */
       return xstrprintf (_("Cannot access memory at address %s"),
 			 paddress (gdbarch, memaddr));
-    case TARGET_XFER_E_UNAVAILABLE:
+    case TARGET_XFER_UNAVAILABLE:
       return xstrprintf (_("Memory at address %s unavailable."),
 			 paddress (gdbarch, memaddr));
     default:
@@ -233,7 +233,7 @@ memory_error (enum target_xfer_status err, CORE_ADDR memaddr)
     case TARGET_XFER_E_IO:
       exception = MEMORY_ERROR;
       break;
-    case TARGET_XFER_E_UNAVAILABLE:
+    case TARGET_XFER_UNAVAILABLE:
       exception = NOT_AVAILABLE_ERROR;
       break;
     }
diff --git a/gdb/exec.c b/gdb/exec.c
index 758e382..44dddc1 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -661,7 +661,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
 	  else
 	    {
 	      *xfered_len = r->start - offset;
-	      status = TARGET_XFER_E_UNAVAILABLE;
+	      status = TARGET_XFER_UNAVAILABLE;
 	    }
 	  do_cleanups (old_chain);
 	  return status;
@@ -670,7 +670,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
   do_cleanups (old_chain);
 
   *xfered_len = len;
-  return TARGET_XFER_E_UNAVAILABLE;
+  return TARGET_XFER_UNAVAILABLE;
 }
 
 enum target_xfer_status
diff --git a/gdb/exec.h b/gdb/exec.h
index 4d9de90..44f1367 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -82,7 +82,7 @@ extern enum target_xfer_status
 
 /* Read from mappable read-only sections of BFD executable files.
    Similar to exec_read_partial_read_only, but return
-   TARGET_XFER_E_UNAVAILABLE if data is unavailable.  */
+   TARGET_XFER_UNAVAILABLE if data is unavailable.  */
 
 extern enum target_xfer_status
   section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index c326c8d..05e7713 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -827,7 +827,7 @@ record_btrace_xfer_partial (struct target_ops *ops, enum target_object object,
 	    if (writebuf != NULL)
 	      {
 		*xfered_len = len;
-		return TARGET_XFER_E_UNAVAILABLE;
+		return TARGET_XFER_UNAVAILABLE;
 	      }
 
 	    /* We allow reading readonly memory.  */
@@ -846,7 +846,7 @@ record_btrace_xfer_partial (struct target_ops *ops, enum target_object object,
 	      }
 
 	    *xfered_len = len;
-	    return TARGET_XFER_E_UNAVAILABLE;
+	    return TARGET_XFER_UNAVAILABLE;
 	  }
 	}
     }
@@ -858,7 +858,7 @@ record_btrace_xfer_partial (struct target_ops *ops, enum target_object object,
 				   offset, len, xfered_len);
 
   *xfered_len = len;
-  return TARGET_XFER_E_UNAVAILABLE;
+  return TARGET_XFER_UNAVAILABLE;
 }
 
 /* The to_insert_breakpoint method of target record-btrace.  */
diff --git a/gdb/target.c b/gdb/target.c
index 25f1cf7..e4bf2e9 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -886,7 +886,7 @@ target_xfer_status_to_string (enum target_xfer_status status)
   switch (status)
     {
       CASE(TARGET_XFER_E_IO);
-      CASE(TARGET_XFER_E_UNAVAILABLE);
+      CASE(TARGET_XFER_UNAVAILABLE);
     default:
       return "<unknown>";
     }
@@ -1099,7 +1099,7 @@ raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
 	break;
 
       /* Stop if the target reports that the memory is not available.  */
-      if (res == TARGET_XFER_E_UNAVAILABLE)
+      if (res == TARGET_XFER_UNAVAILABLE)
 	break;
 
       /* We want to continue past core files to executables, but not
@@ -1212,7 +1212,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
 		  /* No use trying further, we know some memory starting
 		     at MEMADDR isn't available.  */
 		  *xfered_len = len;
-		  return TARGET_XFER_E_UNAVAILABLE;
+		  return TARGET_XFER_UNAVAILABLE;
 		}
 	    }
 
@@ -1479,7 +1479,7 @@ target_xfer_partial (struct target_ops *ops,
   /* Check implementations of to_xfer_partial update *XFERED_LEN
      properly.  Do assertion after printing debug messages, so that we
      can find more clues on assertion failure from debugging messages.  */
-  if (retval == TARGET_XFER_OK || retval == TARGET_XFER_E_UNAVAILABLE)
+  if (retval == TARGET_XFER_OK || retval == TARGET_XFER_UNAVAILABLE)
     gdb_assert (*xfered_len > 0);
 
   return retval;
diff --git a/gdb/target.h b/gdb/target.h
index 9143ee2..db248a8 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -213,15 +213,14 @@ enum target_xfer_status
   /* No further transfer is possible.  */
   TARGET_XFER_EOF = 0,
 
+  /* The piece of the object requested is unavailable.  */
+  TARGET_XFER_UNAVAILABLE = 2,
+
   /* Generic I/O error.  Note that it's important that this is '-1',
      as we still have target_xfer-related code returning hardcoded
      '-1' on error.  */
   TARGET_XFER_E_IO = -1,
 
-  /* Transfer failed because the piece of the object requested is
-     unavailable.  */
-  TARGET_XFER_E_UNAVAILABLE = -2,
-
   /* Keep list in sync with target_xfer_status_to_string.  */
 };
 
@@ -628,7 +627,7 @@ struct target_ops
        'enum target_xfer_status' value).  Save the number of bytes
        actually transferred in *XFERED_LEN if transfer is successful
        (TARGET_XFER_OK) or the number unavailable bytes if the requested
-       data is unavailable (TARGET_XFER_E_UNAVAILABLE).  *XFERED_LEN
+       data is unavailable (TARGET_XFER_UNAVAILABLE).  *XFERED_LEN
        smaller than LEN does not indicate the end of the object, only
        the end of the transfer; higher level code should continue
        transferring if desired.  This is handled in target.c.
diff --git a/gdb/valops.c b/gdb/valops.c
index 0d726d0..82417dac 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -964,7 +964,7 @@ read_value_memory (struct value *val, int embedded_offset,
 
       if (status == TARGET_XFER_OK)
 	/* nothing */;
-      else if (status == TARGET_XFER_E_UNAVAILABLE)
+      else if (status == TARGET_XFER_UNAVAILABLE)
 	mark_value_bytes_unavailable (val, embedded_offset + xfered,
 				      xfered_len);
       else if (status == TARGET_XFER_EOF)
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]