[v6,13/17,gdb/generic] Get rid of linux-core-thread-data

Message ID 20230913101815.178154-14-luis.machado@arm.com
State New
Headers
Series SME support for AArch64 gdb/gdbserver on Linux |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Luis Machado Sept. 13, 2023, 10:18 a.m. UTC
  This struct type seems to have been used in the past as a callback
parameter.  Now it seems that case is no longer true, so we can simplify
things by passing the individual parameters linux_core_thread_data
encapsulates directly to the functions.

This is just a cleanup before the next change.
---
 gdb/linux-tdep.c | 49 +++++++++++++++---------------------------------
 1 file changed, 15 insertions(+), 34 deletions(-)
  

Comments

Simon Marchi Sept. 13, 2023, 2:10 p.m. UTC | #1
On 9/13/23 06:18, Luis Machado wrote:
> This struct type seems to have been used in the past as a callback
> parameter.  Now it seems that case is no longer true, so we can simplify
> things by passing the individual parameters linux_core_thread_data
> encapsulates directly to the functions.
> 
> This is just a cleanup before the next change.

Thanks, LGTM.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  

Patch

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index b5eee5e108c..a4a86b01bdb 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1820,47 +1820,29 @@  linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch)
   return buf;
 }
 
-struct linux_corefile_thread_data
-{
-  linux_corefile_thread_data (struct gdbarch *gdbarch, bfd *obfd,
-			      gdb::unique_xmalloc_ptr<char> &note_data,
-			      int *note_size, gdb_signal stop_signal)
-    : gdbarch (gdbarch), obfd (obfd), note_data (note_data),
-      note_size (note_size), stop_signal (stop_signal)
-  {}
-
-  struct gdbarch *gdbarch;
-  bfd *obfd;
-  gdb::unique_xmalloc_ptr<char> &note_data;
-  int *note_size;
-  enum gdb_signal stop_signal;
-};
-
 /* Records the thread's register state for the corefile note
    section.  */
 
 static void
 linux_corefile_thread (struct thread_info *info,
-		       struct linux_corefile_thread_data *args)
+		       struct gdbarch *gdbarch, bfd *obfd,
+		       gdb::unique_xmalloc_ptr<char> &note_data,
+		       int *note_size, gdb_signal stop_signal)
 {
-  gcore_elf_build_thread_register_notes (args->gdbarch, info,
-					 args->stop_signal,
-					 args->obfd, &args->note_data,
-					 args->note_size);
+  gcore_elf_build_thread_register_notes (gdbarch, info, stop_signal, obfd,
+					 &note_data, note_size);
 
   /* Don't return anything if we got no register information above,
      such a core file is useless.  */
-  if (args->note_data != NULL)
+  if (note_data != nullptr)
     {
       gdb::byte_vector siginfo_data
-	= linux_get_siginfo_data (info, args->gdbarch);
+	= linux_get_siginfo_data (info, gdbarch);
       if (!siginfo_data.empty ())
-	args->note_data.reset (elfcore_write_note (args->obfd,
-						   args->note_data.release (),
-						   args->note_size,
-						   "CORE", NT_SIGINFO,
-						   siginfo_data.data (),
-						   siginfo_data.size ()));
+	note_data.reset (elfcore_write_note (obfd, note_data.release (),
+					     note_size, "CORE", NT_SIGINFO,
+					     siginfo_data.data (),
+					     siginfo_data.size ()));
     }
 }
 
@@ -2095,17 +2077,16 @@  linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
   else
     stop_signal = GDB_SIGNAL_0;
 
-  linux_corefile_thread_data thread_args (gdbarch, obfd, note_data, note_size,
-					  stop_signal);
-
   if (signalled_thr != nullptr)
-    linux_corefile_thread (signalled_thr, &thread_args);
+    linux_corefile_thread (signalled_thr, gdbarch, obfd, note_data, note_size,
+			   stop_signal);
   for (thread_info *thr : current_inferior ()->non_exited_threads ())
     {
       if (thr == signalled_thr)
 	continue;
 
-      linux_corefile_thread (thr, &thread_args);
+      linux_corefile_thread (thr, gdbarch, obfd, note_data, note_size,
+			     stop_signal);
     }
 
   if (!note_data)