Re: [PATCH] Change some arguments to gdb::string_view instead of name+len

Pedro Alves
2019-09-30T14:38:51Z

On 9/30/19 3:28 PM, Tom Tromey wrote:
>>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

> Christian> if (symtab_create_debug >= 2)
> Christian> printf_unfiltered ("Recording minsym: %-21s %18s %4d %s\n",
> Christian> - mst_str (ms_type), hex_string (address), section, name);
> Christian> + mst_str (ms_type), hex_string (address), section,
> Christian> + name.data ());
>
> This part made me hesitate a bit, because it seems to be at odds with
> the idea that an arbitrary string view can be passed in -- for all we
> know the string isn't \0-terminated, and this will cause bad behavior.
>
> On the other hand, this error already existed, and is only used for
> logging.
>
> Maybe safest is just to transform it to a std::string here?

Or

"%.*s", name.size (), name.data ()

Thanks,
Pedro Alves