-
-/* Keep a registry of swapped data required by GDB modules. */
-
-struct gdbarch_swap
-{
- void *swap;
- struct gdbarch_swap_registration *source;
- struct gdbarch_swap *next;
-};
-
-struct gdbarch_swap_registration
-{
- void *data;
- unsigned long sizeof_data;
- gdbarch_swap_ftype *init;
- struct gdbarch_swap_registration *next;
-};
-
-struct gdbarch_swap_registry
-{
- int nr;
- struct gdbarch_swap_registration *registrations;
-};
-
-struct gdbarch_swap_registry gdbarch_swap_registry =
-{
- 0, NULL,
-};
-
-void
-deprecated_register_gdbarch_swap (void *data,
- unsigned long sizeof_data,
- gdbarch_swap_ftype *init)
-{
- struct gdbarch_swap_registration **rego;
- for (rego = &gdbarch_swap_registry.registrations;
- (*rego) != NULL;
- rego = &(*rego)->next);
- (*rego) = XMALLOC (struct gdbarch_swap_registration);
- (*rego)->next = NULL;
- (*rego)->init = init;
- (*rego)->data = data;
- (*rego)->sizeof_data = sizeof_data;
-}
-
-static void
-current_gdbarch_swap_init_hack (void)
-{
- struct gdbarch_swap_registration *rego;
- struct gdbarch_swap **curr = ¤t_gdbarch->swap;
- for (rego = gdbarch_swap_registry.registrations;
- rego != NULL;
- rego = rego->next)
- {
- if (rego->data != NULL)
- {
- (*curr) = GDBARCH_OBSTACK_ZALLOC (current_gdbarch,
- struct gdbarch_swap);
- (*curr)->source = rego;
- (*curr)->swap = gdbarch_obstack_zalloc (current_gdbarch,
- rego->sizeof_data);
- (*curr)->next = NULL;
- curr = &(*curr)->next;
- }
- if (rego->init != NULL)
- rego->init ();
- }
-}
-
-static struct gdbarch *
-current_gdbarch_swap_out_hack (void)
-{
- struct gdbarch *old_gdbarch = current_gdbarch;
- struct gdbarch_swap *curr;
-
- gdb_assert (old_gdbarch != NULL);
- for (curr = old_gdbarch->swap;
- curr != NULL;
- curr = curr->next)
- {
- memcpy (curr->swap, curr->source->data, curr->source->sizeof_data);
- memset (curr->source->data, 0, curr->source->sizeof_data);
- }
- current_gdbarch = NULL;
- return old_gdbarch;
-}
-
-static void
-current_gdbarch_swap_in_hack (struct gdbarch *new_gdbarch)
-{
- struct gdbarch_swap *curr;
-
- gdb_assert (current_gdbarch == NULL);
- for (curr = new_gdbarch->swap;
- curr != NULL;
- curr = curr->next)
- memcpy (curr->source->data, curr->swap, curr->source->sizeof_data);
- current_gdbarch = new_gdbarch;
-}
-
-