[RFA 3/3] Special case NULL when using printf's %s format
Pedro Alves
palves@redhat.com
Fri Feb 16 12:25:00 GMT 2018
On 02/16/2018 12:08 PM, Pedro Alves wrote:
> On 02/15/2018 08:50 PM, Tom Tromey wrote:
>> This changes the printf command's %s and %ls formats to special-case
>> NULL, and print "(null)" for these. This is PR cli/14977. This
>> behavior seems a bit friendlier; I was undecided on whether other
>> invalid pointers should be handled specially somehow, so for the time
>> being I've left those out.
>
> A question here is what to do on targets that actually map things at
> address zero. IIRC, some ARM chips do that. For such ports, I think you'd
> want to be able to read/print that memory. I thought we had a gdbarch hook
> for that, but I'm not finding it right now. Maybe I was thinking of
> has_section_at_zero in dwarf2read.c.
Then again, I don't think it's likely that programs map
strings at 0 (I think it's more like interrupt vectors), so for %s,
it's likely that nobody would miss printing 0 as a string.
So with that in mind, this is fine with me.
Thanks,
Pedro Alves
More information about the Gdb-patches
mailing list