gdb: make target_desc_info::filename an std::string
authorSimon Marchi <simon.marchi@polymtl.ca>
Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)
commit91e3c425d6adb4797a2137dd9126a2f19e1833d8
tree9de2cd0babb207e59089247ca6f3eab478dc10ad
parent0b2f7ade5352e698ded54760ee8b34092fdd164f
gdb: make target_desc_info::filename an std::string

To make the management of memory automatic.

As to why I chose to make this an std::string and not an
std::unique_xmalloc_ptr<char>: some parts of the code consider both a
NULL value and an empty string value to mean "no filename".
target_desc_info_from_user_p, however, doesn't check for a non-NULL but
empty string value.  So it seems like having two ways of denoting "no
filename" can lead to these kinds of inconsistencies.  Using
std::string, "no filename" is only represented by an empty value.

As a bonus, using an std::string lets us copy target_desc_info objects
using the default assignment operator.

gdb/ChangeLog:

* target-descriptions.c (struct target_desc_info) <filename>:
Make std::string.
(copy_inferior_target_desc_info): Adjust.
(target_desc_info_free): Adjust.
(target_find_description): Adjust.
(set_tdesc_filename_cmd): Adjust.
(show_tdesc_filename_cmd): Adjust.
(unset_tdesc_filename_cmd): Adjust.
(maint_print_c_tdesc_cmd): Adjust.

Change-Id: I4e3a6ad8ccda2b88c202471d4f54249753cad127
gdb/ChangeLog
gdb/target-descriptions.c