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]

[users/palves/format_strings] Introduce string_field


On 7/1/19 6:38 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> I'm not sure whether we could portably save the varargs like
> Pedro> above, though.  So that might be moot.
> 
> I'm not sure it matters a whole lot.
> 
> I looked through all the field_fmt calls, and many of them can be
> replaced with some other call.
> 
> The few that remain can be rewritten in terms of string_printf if need
> be.
> 
> Pedro> -      uiout->text ("[Inferior ");
> Pedro> -      uiout->text (plongest (inf->num));
> Pedro> -      uiout->text (" (");
> Pedro> -      uiout->text (pidstr.c_str ());
> Pedro> -      uiout->text (") exited with code ");
> Pedro> -      uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus);
> Pedro> -      uiout->text ("]\n");
> Pedro> +      std::string exit_code_str
> Pedro> +	= string_printf ("0%o", (unsigned int) exitstatus);
> Pedro> +      uiout->message ("[Inferior %s (%s) exited with code %pF]\n",
> Pedro> +		      plongest (inf->num), pidstr.c_str (),
> Pedro> +		      string_field ("exit-code", exit_code_str.c_str ()));
> 
> This is so much better.

I merged this one to users/palves/format_strings too.

Thanks,
Pedro Alves


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