The throw_* family of functions use the varargs constructor for
gdb_exception, which then calls string_vprintf. This means that
styling cannot be applied here by gdb.
This patch changes this code to use a client-supplied formatting
function. For gdbserver this remains string_vprintf, but for gdb it
now allows styling.
I did look at unifying 'error' and the throw_* functions a bit more,
but this would have meant unravelling some IPA code.
}
}
+/* See common-exceptions.h. */
+
+std::string
+vformat_exception (const char *fmt, va_list args)
+{
+ string_file text (true);
+ text.vprintf (fmt, args);
+ return text.release ();
+}
+
/* Print an error message and return to command level.
The first argument STRING is the error message, used as a fprintf string,
and the remaining args are passed as arguments to it. */
{
return phex_nz (addr);
}
+
+#ifndef IN_PROCESS_AGENT
+
+/* See common-exceptions.h. */
+
+std::string
+vformat_exception (const char *fmt, va_list args)
+{
+ return string_vprintf (fmt, args);
+}
+
+#endif /* IN_PROCESS_AGENT */
NR_ERRORS
};
+/* The client application must provide this. It is a printf-like that
+ formats a string for an exception. */
+std::string vformat_exception (const char *fmt, va_list args)
+ ATTRIBUTE_PRINTF (1, 0);
+
struct gdb_exception
{
gdb_exception ()
ATTRIBUTE_PRINTF (4, 0)
: reason (r),
error (e),
- message (std::make_shared<std::string> (string_vprintf (fmt, ap)))
+ message (std::make_shared<std::string> (vformat_exception (fmt, ap)))
{
}