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

Pedro Alves palves@redhat.com
Mon Sep 30 14:38:00 GMT 2019


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



More information about the Gdb-patches mailing list