[PATCH 2/4] Remove deprecated_throw_reason from mips_error.
Andrew Burgess
aburgess@broadcom.com
Wed Jul 31 12:37:00 GMT 2013
On 30/07/2013 8:14 PM, Pedro Alves wrote:
> On 07/30/2013 05:11 PM, Andrew Burgess wrote:
>>
>> diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
>> index 1619622..791aa8a 100644
>> --- a/gdb/remote-mips.c
>> +++ b/gdb/remote-mips.c
>> @@ -510,7 +510,7 @@ mips_error (char *string,...)
>> if (!ptid_equal (inferior_ptid, null_ptid))
>> target_mourn_inferior ();
>>
>> - deprecated_throw_reason (RETURN_ERROR);
>> + throw_error (GENERIC_ERROR, "Remote debugging terminated");
>
> Throw TARGET_CLOSE_ERROR instead. Add i18n, and period at end
> of sentence. Okay with that change.
>
> I'd suggest removing or merging the earlier printf_unfiltered with
> the error message, they're a bit redundant, and having the text
> in the error is better in that a frontend usually displays errors
> in a special way (a messagebox or some such), while console prints
> end up hidden in the console...
So, following the advice in your second paragraph I've got a new patch
below, given that it's totally different to the first I'm reposting for
a review before committing.
The only testing I've done of this code is to compile it
(--enable-targets=all), then add in a fake call to mips_error
and check that the output looks reasonable.
I've removed the use of error_pre_print given that all the output
is now passing through throw_verror, I assume that does the "correct"
thing, though interestingly I notice that error_pre_print, and
quit_pre_print are no longer used anywhere after this patch....
If this change seems too disruptive then I can always go back to
the original patch and just change the error code to TARGET_CLOSE_ERROR.
What do you think? OK to apply?
Thanks,
Andrew
gdb/ChangeLog
2013-07-31 Andrew Burgess <aburgess@broadcom.com>
* remote-mips.c (mips_error): Replace use of deprecated_throw_reason
with throw_verror. Use the error message passed to mips_error as the
error message for throw_verror.
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 1619622..df96997 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -488,17 +488,12 @@ static void ATTRIBUTE_NORETURN
mips_error (char *string,...)
{
va_list args;
-
- va_start (args, string);
+ char *fmt;
+ int status;
target_terminal_ours ();
wrap_here (""); /* Force out any buffered output. */
gdb_flush (gdb_stdout);
- if (error_pre_print)
- fputs_filtered (error_pre_print, gdb_stderr);
- vfprintf_filtered (gdb_stderr, string, args);
- fprintf_filtered (gdb_stderr, "\n");
- va_end (args);
gdb_flush (gdb_stderr);
/* Clean up in such a way that mips_close won't try to talk to the
@@ -506,11 +501,18 @@ mips_error (char *string,...)
it). */
close_ports ();
- printf_unfiltered ("Ending remote MIPS debugging.\n");
if (!ptid_equal (inferior_ptid, null_ptid))
target_mourn_inferior ();
- deprecated_throw_reason (RETURN_ERROR);
+ status = asprintf (&fmt, "Ending remote MIPS debugging: %s", string);
+ if (fmt == NULL || status < 0)
+ fmt = string;
+ else
+ make_cleanup (xfree, fmt);
+
+ va_start (args, string);
+ throw_verror (TARGET_CLOSE_ERROR, fmt, args);
+ va_end (args);
}
/* putc_readable - print a character, displaying non-printable chars in
More information about the Gdb-patches
mailing list