This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/3] Introduce field_unsigned
>> + void field_unsigned (const char *fldname, ULONGEST value)
>> + {
>> + field_string (fldname, pulongest (value));
>> + }
[...]
>> This is quite different from how other types are handled, e.g.
>> ui_out::field_int (const char *fldname, int value)
>> {
>> int fldno;
>> int width;
>> ui_align align;
>> verify_field (&fldno, &width, &align);
>> do_field_int (fldno, width, align, fldname, value);
>> }
>> Is there a reason for not treating int and unsigned int in a similar way?
There just didn't seem to be a benefit, and the field_int approach is
wordier.
In the end all the existing do_field_int methods actually just end up in
their respective do_field_string methods anyway. E.g., mi-out.c:
void
mi_ui_out::do_field_int (int fldno, int width, ui_align alignment,
const char *fldname, int value)
{
char buffer[20]; /* FIXME: how many chars long a %d can become? */
xsnprintf (buffer, sizeof (buffer), "%d", value);
do_field_string (fldno, width, alignment, fldname, buffer,
ui_out_style_kind::DEFAULT);
}
Here the new approach is actually a bit better because pulongest doesn't
have this FIXME. Perhaps we should instead switch field_int to take a
LONGEST and follow the approach used in this new patch.
Tom