+2017-09-03 Tom Tromey <tom@tromey.com>
+
+ * valprint.c (val_print_string): Update.
+ * gdbcore.h (memory_error_message): Return std::string.
+ * corefile.c (memory_error_message): Return std::string.
+ (memory_error): Update.
+ * breakpoint.c (insert_bp_location): Update.
+
2017-09-03 Simon Marchi <simon.marchi@ericsson.com>
* target/waitstatus.h (target_waitstatus_to_string): Change
{
if (bp_err_message == NULL)
{
- char *message
+ std::string message
= memory_error_message (TARGET_XFER_E_IO,
bl->gdbarch, bl->address);
- struct cleanup *old_chain = make_cleanup (xfree, message);
fprintf_unfiltered (tmp_error_stream,
"Cannot insert breakpoint %d.\n"
"%s\n",
- bl->owner->number, message);
- do_cleanups (old_chain);
+ bl->owner->number, message.c_str ());
}
else
{
}
\f
-char *
+std::string
memory_error_message (enum target_xfer_status err,
struct gdbarch *gdbarch, CORE_ADDR memaddr)
{
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));
+ return string_printf (_("Cannot access memory at address %s"),
+ paddress (gdbarch, memaddr));
case TARGET_XFER_UNAVAILABLE:
- return xstrprintf (_("Memory at address %s unavailable."),
- paddress (gdbarch, memaddr));
+ return string_printf (_("Memory at address %s unavailable."),
+ paddress (gdbarch, memaddr));
default:
internal_error (__FILE__, __LINE__,
"unhandled target_xfer_status: %s (%s)",
void
memory_error (enum target_xfer_status err, CORE_ADDR memaddr)
{
- char *str;
enum errors exception = GDB_NO_ERROR;
/* Build error string. */
- str = memory_error_message (err, target_gdbarch (), memaddr);
- make_cleanup (xfree, str);
+ std::string str = memory_error_message (err, target_gdbarch (), memaddr);
/* Choose the right error to throw. */
switch (err)
}
/* Throw it. */
- throw_error (exception, ("%s"), str);
+ throw_error (exception, ("%s"), str.c_str ());
}
/* Helper function. */
extern void memory_error (enum target_xfer_status status, CORE_ADDR memaddr);
-/* The string 'memory_error' would use as exception message. Space
- for the result is malloc'd, caller must free. */
+/* The string 'memory_error' would use as exception message. */
-extern char *memory_error_message (enum target_xfer_status err,
- struct gdbarch *gdbarch, CORE_ADDR memaddr);
+extern std::string memory_error_message (enum target_xfer_status err,
+ struct gdbarch *gdbarch,
+ CORE_ADDR memaddr);
/* Like target_read_memory, but report an error if can't read. */
if (err != 0)
{
- char *str;
-
- str = memory_error_message (TARGET_XFER_E_IO, gdbarch, addr);
- make_cleanup (xfree, str);
+ std::string str = memory_error_message (TARGET_XFER_E_IO, gdbarch, addr);
fprintf_filtered (stream, "<error: ");
- fputs_filtered (str, stream);
+ fputs_filtered (str.c_str (), stream);
fprintf_filtered (stream, ">");
}