This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make target_waitstatus_to_string return an std::string


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]