[PATCH v7 13/18] [gdb/generic] Get rid of linux-core-thread-data

Luis Machado via Gdb-patches
2023-09-18T21:29:31Z

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.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
---
gdb/linux-tdep.c | 49 +++++++++++++++---------------------------------
1 file changed, 15 insertions(+), 34 deletions(-)

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)
--
2.25.1