This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Make target_waitstatus_to_string return an std::string
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Pedro Alves <palves at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Sun, 3 Sep 2017 10:25:06 +0200
- Subject: Re: [PATCH] Make target_waitstatus_to_string return an std::string
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon dot marchi at ericsson dot com;
- References: <1502526609-31934-1-git-send-email-simon.marchi@ericsson.com> <98fad953-5007-6894-766b-7ac118a1156f@redhat.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 2017-08-14 05:03 PM, Pedro Alves wrote:
> On 08/12/2017 09:30 AM, Simon Marchi wrote:
>
>
>> --- a/gdb/record-btrace.c
>> +++ b/gdb/record-btrace.c
>> @@ -2477,8 +2477,10 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid,
>> {
>> *status = btrace_step_no_resumed ();
>>
>> + std::string statstr = target_waitstatus_to_string (status);
>> +
>> DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid),
>> - target_waitstatus_to_string (status));
>> + statstr.c_str ());
>
> I think:
>
> DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid),
> target_waitstatus_to_string (status).c_str ());
>
> would be better, to avoid heap-allocating the string if
> debugging is not active.
Yes, and it's simpler, not sure why I didn't do that in the first place.
>> @@ -2567,10 +2569,12 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid,
>> /* We moved the replay position but did not update registers. */
>> registers_changed_ptid (eventing->ptid);
>>
>> + std::string statstr = target_waitstatus_to_string (status);
>> +
>> DEBUG ("wait ended by thread %s (%s): %s",
>> print_thread_id (eventing),
>> target_pid_to_str (eventing->ptid),
>> - target_waitstatus_to_string (status));
>> + statstr.c_str ());
>
> Ditto.
>
> Otherwise looks fine to me.
Pushed with those fixed, thanks!
Simon