+char *
+memory_error_message (enum target_xfer_status err,
+ struct gdbarch *gdbarch, CORE_ADDR memaddr)
+{
+ switch (err)
+ {
+ case TARGET_XFER_E_IO:
+ /* Actually, address between memaddr and memaddr + len was out of
+ bounds. */
+ return xstrprintf (_("Cannot access memory at address %s"),
+ paddress (gdbarch, memaddr));
+ case TARGET_XFER_UNAVAILABLE:
+ return xstrprintf (_("Memory at address %s unavailable."),
+ paddress (gdbarch, memaddr));
+ default:
+ internal_error (__FILE__, __LINE__,
+ "unhandled target_xfer_status: %s (%s)",
+ target_xfer_status_to_string (err),
+ plongest (err));
+ }
+}
+
+/* Report a memory error by throwing a suitable exception. */