From 24f5300a537e0a8b31ec0391e45babf8a160ce56 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 22 Oct 2020 12:58:11 -0400 Subject: 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) : Change return type to unique pointer. * target.c (dummy_make_corefile_notes): Likewise. * exec.c (struct exec_target) : Likewise. (exec_target::make_corefile_notes): Likewise. * procfs.c (class procfs_target) : Likewise. (procfs_do_thread_registers): Adjust to unique pointer. (struct procfs_corefile_thread_data): Add constructor. : 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 --- gdb/target-delegates.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'gdb/target-delegates.c') diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index e9c349f..437b19b 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -88,7 +88,7 @@ struct dummy_target : public target_ops bool supports_non_stop () override; bool always_non_stop_p () override; int find_memory_regions (find_memory_region_ftype arg0, void *arg1) override; - char *make_corefile_notes (bfd *arg0, int *arg1) override; + gdb::unique_xmalloc_ptr make_corefile_notes (bfd *arg0, int *arg1) override; gdb_byte *get_bookmark (const char *arg0, int arg1) override; void goto_bookmark (const gdb_byte *arg0, int arg1) override; CORE_ADDR get_thread_local_address (ptid_t arg0, CORE_ADDR arg1, CORE_ADDR arg2) override; @@ -259,7 +259,7 @@ struct debug_target : public target_ops bool supports_non_stop () override; bool always_non_stop_p () override; int find_memory_regions (find_memory_region_ftype arg0, void *arg1) override; - char *make_corefile_notes (bfd *arg0, int *arg1) override; + gdb::unique_xmalloc_ptr make_corefile_notes (bfd *arg0, int *arg1) override; gdb_byte *get_bookmark (const char *arg0, int arg1) override; void goto_bookmark (const gdb_byte *arg0, int arg1) override; CORE_ADDR get_thread_local_address (ptid_t arg0, CORE_ADDR arg1, CORE_ADDR arg2) override; @@ -2292,22 +2292,22 @@ debug_target::find_memory_regions (find_memory_region_ftype arg0, void *arg1) return result; } -char * +gdb::unique_xmalloc_ptr target_ops::make_corefile_notes (bfd *arg0, int *arg1) { return this->beneath ()->make_corefile_notes (arg0, arg1); } -char * +gdb::unique_xmalloc_ptr dummy_target::make_corefile_notes (bfd *arg0, int *arg1) { return dummy_make_corefile_notes (this, arg0, arg1); } -char * +gdb::unique_xmalloc_ptr debug_target::make_corefile_notes (bfd *arg0, int *arg1) { - char * result; + gdb::unique_xmalloc_ptr result; fprintf_unfiltered (gdb_stdlog, "-> %s->make_corefile_notes (...)\n", this->beneath ()->shortname ()); result = this->beneath ()->make_corefile_notes (arg0, arg1); fprintf_unfiltered (gdb_stdlog, "<- %s->make_corefile_notes (", this->beneath ()->shortname ()); @@ -2315,7 +2315,7 @@ debug_target::make_corefile_notes (bfd *arg0, int *arg1) fputs_unfiltered (", ", gdb_stdlog); target_debug_print_int_p (arg1); fputs_unfiltered (") = ", gdb_stdlog); - target_debug_print_char_p (result); + target_debug_print_gdb_unique_xmalloc_ptr_char (result); fputs_unfiltered ("\n", gdb_stdlog); return result; } -- cgit v1.1