gdb: make target_ops::make_corefile_notes return a unique ptr

Since we converted gdbarch_make_corefile_notes to returning a
gdb::unique_xmalloc_ptr, I figured it would make sense to converted
target_ops::make_corefile_notes as well.

The only implementation of that is in procfs.c, and it should ideally be
re-written as a gdbarch method (see comment in write_gcore_file_1), but
in the mean time I guess it doesn't hurt to throw some unique pointer at
it.

I tested that it builds on Solaris 11 (gcc compile farm machine gcc211),
but I am not able to test it, because I can't get GDB to start a
process (I'll look at that separately).

gdb/ChangeLog:

	* target.h (struct target_ops) <make_corefile_notes>:
	Change return type to unique pointer.
	* target.c (dummy_make_corefile_notes): Likewise.
	* exec.c (struct exec_target) <make_corefile_notes>:
	Likewise.
	(exec_target::make_corefile_notes): Likewise.
	* procfs.c (class procfs_target) <make_corefile_notes>:
	Likewise.
	(procfs_do_thread_registers): Adjust to unique pointer.
	(struct procfs_corefile_thread_data): Add constructor.
	<note_data>: Change type to unique pointer.
	(procfs_corefile_thread_callback): Adjust to unique pointer.
	(procfs_target::make_corefile_notes): Change return type to
	unique pointer.
	* target-delegates.c: Re-generate.
	* gcore.c (write_gcore_file_1): Adjust.
	* target-debug.h (target_debug_print_gdb_unique_xmalloc_ptr_char):
	New.

Change-Id: I768fb17ac0f7adc67d2fe95e952c784fe0ac37ab
This commit is contained in:
Simon Marchi 2020-10-22 12:58:11 -04:00 committed by Simon Marchi
parent 5fb4027fae
commit 24f5300a53
8 changed files with 81 additions and 56 deletions

View file

@ -89,8 +89,8 @@ static int dummy_find_memory_regions (struct target_ops *self,
find_memory_region_ftype ignore1,
void *ignore2);
static char *dummy_make_corefile_notes (struct target_ops *self,
bfd *ignore1, int *ignore2);
static gdb::unique_xmalloc_ptr<char> dummy_make_corefile_notes
(struct target_ops *self, bfd *ignore1, int *ignore2);
static std::string default_pid_to_str (struct target_ops *ops, ptid_t ptid);
@ -3058,7 +3058,7 @@ dummy_find_memory_regions (struct target_ops *self,
}
/* Error-catcher for target_make_corefile_notes. */
static char *
static gdb::unique_xmalloc_ptr<char>
dummy_make_corefile_notes (struct target_ops *self,
bfd *ignore1, int *ignore2)
{