-
- return note_data;
-}
-
-/* Structure for passing information from
- linux_collect_thread_registers via an iterator to
- linux_collect_regset_section_cb. */
-
-struct linux_collect_regset_section_cb_data
-{
- struct gdbarch *gdbarch;
- const struct regcache *regcache;
- bfd *obfd;
- char *note_data;
- int *note_size;
- unsigned long lwp;
- enum gdb_signal stop_signal;
- int abort_iteration;
-};
-
-/* Callback for iterate_over_regset_sections that records a single
- regset in the corefile note section. */
-
-static void
-linux_collect_regset_section_cb (const char *sect_name, int size,
- const struct regset *regset,
- const char *human_name, void *cb_data)
-{
- char *buf;
- struct linux_collect_regset_section_cb_data *data
- = (struct linux_collect_regset_section_cb_data *) cb_data;
-
- if (data->abort_iteration)
- return;
-
- gdb_assert (regset && regset->collect_regset);
-
- buf = (char *) xmalloc (size);
- regset->collect_regset (regset, data->regcache, -1, buf, size);
-
- /* PRSTATUS still needs to be treated specially. */
- if (strcmp (sect_name, ".reg") == 0)
- data->note_data = (char *) elfcore_write_prstatus
- (data->obfd, data->note_data, data->note_size, data->lwp,
- gdb_signal_to_host (data->stop_signal), buf);
- else
- data->note_data = (char *) elfcore_write_register_note
- (data->obfd, data->note_data, data->note_size,
- sect_name, buf, size);
- xfree (buf);
-
- if (data->note_data == NULL)
- data->abort_iteration = 1;
-}
-
-/* Records the thread's register state for the corefile note
- section. */
-
-static char *
-linux_collect_thread_registers (const struct regcache *regcache,
- ptid_t ptid, bfd *obfd,
- char *note_data, int *note_size,
- enum gdb_signal stop_signal)
-{
- struct gdbarch *gdbarch = regcache->arch ();
- struct linux_collect_regset_section_cb_data data;
-
- data.gdbarch = gdbarch;
- data.regcache = regcache;
- data.obfd = obfd;
- data.note_data = note_data;
- data.note_size = note_size;
- data.stop_signal = stop_signal;
- data.abort_iteration = 0;
-
- /* For remote targets the LWP may not be available, so use the TID. */
- data.lwp = ptid.lwp ();
- if (!data.lwp)
- data.lwp = ptid_get_tid (ptid);
-
- gdbarch_iterate_over_regset_sections (gdbarch,
- linux_collect_regset_section_cb,
- &data, regcache);
- return data.note_data;