From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6307 invoked by alias); 22 Jun 2007 12:54:47 -0000 Received: (qmail 6298 invoked by uid 22791); 22 Jun 2007 12:54:45 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate7.de.ibm.com (HELO mtagate7.de.ibm.com) (195.212.29.156) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 22 Jun 2007 12:54:42 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.13.8/8.13.8) with ESMTP id l5MCseeB206286 for ; Fri, 22 Jun 2007 12:54:40 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l5MCsd42757990 for ; Fri, 22 Jun 2007 14:54:39 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l5MCsdYN028241 for ; Fri, 22 Jun 2007 14:54:39 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id l5MCsd9w028238; Fri, 22 Jun 2007 14:54:39 +0200 Message-Id: <200706221254.l5MCsd9w028238@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 22 Jun 2007 14:54:39 +0200 Subject: Re: [3/3] Remove deprecated_register_gdbarch_swap infrastructure To: uweigand@de.ibm.com (Ulrich Weigand) Date: Fri, 22 Jun 2007 12:54:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <200706082323.l58NNWf5019714@d12av02.megacenter.de.ibm.com> from "Ulrich Weigand" at Jun 09, 2007 01:23:32 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-06/txt/msg00422.txt.bz2 > * gdbarch.sh (gdbarch_swap_ftype, deprecated_register_gdbarch_swap, > DEPRECATED_REGISTER_GDBARCH_SWAP): Remove. > (struct gdbarch_swap, struct gdbarch_swap_registration, > struct gdbarch_swap_registry, gdbarch_swap_registry, > current_gdbarch_swap_init_hack, current_gdbarch_swap_out_hack, > current_gdbarch_swap_in_hack): Remove. > (find_arch_by_info): Do not call current_gdbarch_swap_init_hack. > (gdbarch_find_by_info): Do not call current_gdbarch_swap_in_hack > and current_gdbarch_swap_out_hack, update current_gdbarch directly. > (deprecated_current_gdbarch_select_hack): Likewise. I've now committed the following version of this patch. Bye, Ulrich * gdbarch.sh (gdbarch_swap_ftype, deprecated_register_gdbarch_swap, DEPRECATED_REGISTER_GDBARCH_SWAP): Remove. (struct gdbarch_swap, struct gdbarch_swap_registration, struct gdbarch_swap_registry, gdbarch_swap_registry, current_gdbarch_swap_init_hack, current_gdbarch_swap_out_hack, current_gdbarch_swap_in_hack): Remove. (find_arch_by_info): Do not call current_gdbarch_swap_init_hack. (gdbarch_find_by_info): Do not call current_gdbarch_swap_in_hack and current_gdbarch_swap_out_hack, update current_gdbarch directly. (deprecated_current_gdbarch_select_hack): Likewise. * gdbarch.h, gdbarch.c: Regenerate. diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c --- gdb-orig/gdb/gdbarch.c 2007-06-09 17:20:05.060973165 +0200 +++ gdb-head/gdb/gdbarch.c 2007-06-09 17:26:15.847882154 +0200 @@ -3468,107 +3468,6 @@ gdbarch_data (struct gdbarch *gdbarch, s } - -/* 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; -} - - /* Keep a registry of the architectures known by GDB. */ struct gdbarch_registration @@ -3812,13 +3711,6 @@ find_arch_by_info (struct gdbarch_info i verify_gdbarch (new_gdbarch); new_gdbarch->initialized_p = 1; - /* Initialize any per-architecture swap areas. This phase requires - a valid global CURRENT_GDBARCH. Set it momentarially, and then - swap the entire architecture out. */ - current_gdbarch = new_gdbarch; - current_gdbarch_swap_init_hack (); - current_gdbarch_swap_out_hack (); - if (gdbarch_debug) gdbarch_dump (new_gdbarch, gdb_stdlog); @@ -3828,26 +3720,28 @@ find_arch_by_info (struct gdbarch_info i struct gdbarch * gdbarch_find_by_info (struct gdbarch_info info) { + struct gdbarch *new_gdbarch; + /* Save the previously selected architecture, setting the global to NULL. This stops things like gdbarch->init() trying to use the previous architecture's configuration. The previous architecture may not even be of the same architecture family. The most recent architecture of the same family is found at the head of the rego->arches list. */ - struct gdbarch *old_gdbarch = current_gdbarch_swap_out_hack (); + struct gdbarch *old_gdbarch = current_gdbarch; + current_gdbarch = NULL; /* Find the specified architecture. */ - struct gdbarch *new_gdbarch = find_arch_by_info (info); + new_gdbarch = find_arch_by_info (info); /* Restore the existing architecture. */ gdb_assert (current_gdbarch == NULL); - current_gdbarch_swap_in_hack (old_gdbarch); + current_gdbarch = old_gdbarch; return new_gdbarch; } -/* Make the specified architecture current, swapping the existing one - out. */ +/* Make the specified architecture current. */ void deprecated_current_gdbarch_select_hack (struct gdbarch *new_gdbarch) @@ -3855,8 +3749,7 @@ deprecated_current_gdbarch_select_hack ( gdb_assert (new_gdbarch != NULL); gdb_assert (current_gdbarch != NULL); gdb_assert (new_gdbarch->initialized_p); - current_gdbarch_swap_out_hack (); - current_gdbarch_swap_in_hack (new_gdbarch); + current_gdbarch = new_gdbarch; architecture_changed_event (); reinit_frame_cache (); } diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h --- gdb-orig/gdb/gdbarch.h 2007-06-09 17:20:05.105966692 +0200 +++ gdb-head/gdb/gdbarch.h 2007-06-09 17:26:15.902007403 +0200 @@ -1253,25 +1253,6 @@ extern void deprecated_set_gdbarch_data extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *); - -/* Register per-architecture memory region. - - Provide a memory-region swap mechanism. Per-architecture memory - region are created. These memory regions are swapped whenever the - architecture is changed. For a new architecture, the memory region - is initialized with zero (0) and the INIT function is called. - - Memory regions are swapped / initialized in the order that they are - registered. NULL DATA and/or INIT values can be specified. - - New code should use gdbarch_data_register_*(). */ - -typedef void (gdbarch_swap_ftype) (void); -extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init); -#define DEPRECATED_REGISTER_GDBARCH_SWAP(VAR) deprecated_register_gdbarch_swap (&(VAR), sizeof ((VAR)), NULL) - - - /* Set the dynamic target-system-dependent parameters (architecture, byte-order, ...) using information found in the BFD */ diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh --- gdb-orig/gdb/gdbarch.sh 2007-06-09 17:20:05.114965398 +0200 +++ gdb-head/gdb/gdbarch.sh 2007-06-09 17:26:15.949000642 +0200 @@ -1125,25 +1125,6 @@ extern void deprecated_set_gdbarch_data extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *); - -/* Register per-architecture memory region. - - Provide a memory-region swap mechanism. Per-architecture memory - region are created. These memory regions are swapped whenever the - architecture is changed. For a new architecture, the memory region - is initialized with zero (0) and the INIT function is called. - - Memory regions are swapped / initialized in the order that they are - registered. NULL DATA and/or INIT values can be specified. - - New code should use gdbarch_data_register_*(). */ - -typedef void (gdbarch_swap_ftype) (void); -extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init); -#define DEPRECATED_REGISTER_GDBARCH_SWAP(VAR) deprecated_register_gdbarch_swap (&(VAR), sizeof ((VAR)), NULL) - - - /* Set the dynamic target-system-dependent parameters (architecture, byte-order, ...) using information found in the BFD */ @@ -1850,107 +1831,6 @@ gdbarch_data (struct gdbarch *gdbarch, s } - -/* 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; -} - - /* Keep a registry of the architectures known by GDB. */ struct gdbarch_registration @@ -2194,13 +2074,6 @@ find_arch_by_info (struct gdbarch_info i verify_gdbarch (new_gdbarch); new_gdbarch->initialized_p = 1; - /* Initialize any per-architecture swap areas. This phase requires - a valid global CURRENT_GDBARCH. Set it momentarially, and then - swap the entire architecture out. */ - current_gdbarch = new_gdbarch; - current_gdbarch_swap_init_hack (); - current_gdbarch_swap_out_hack (); - if (gdbarch_debug) gdbarch_dump (new_gdbarch, gdb_stdlog); @@ -2210,26 +2083,28 @@ find_arch_by_info (struct gdbarch_info i struct gdbarch * gdbarch_find_by_info (struct gdbarch_info info) { + struct gdbarch *new_gdbarch; + /* Save the previously selected architecture, setting the global to NULL. This stops things like gdbarch->init() trying to use the previous architecture's configuration. The previous architecture may not even be of the same architecture family. The most recent architecture of the same family is found at the head of the rego->arches list. */ - struct gdbarch *old_gdbarch = current_gdbarch_swap_out_hack (); + struct gdbarch *old_gdbarch = current_gdbarch; + current_gdbarch = NULL; /* Find the specified architecture. */ - struct gdbarch *new_gdbarch = find_arch_by_info (info); + new_gdbarch = find_arch_by_info (info); /* Restore the existing architecture. */ gdb_assert (current_gdbarch == NULL); - current_gdbarch_swap_in_hack (old_gdbarch); + current_gdbarch = old_gdbarch; return new_gdbarch; } -/* Make the specified architecture current, swapping the existing one - out. */ +/* Make the specified architecture current. */ void deprecated_current_gdbarch_select_hack (struct gdbarch *new_gdbarch) @@ -2237,8 +2112,7 @@ deprecated_current_gdbarch_select_hack ( gdb_assert (new_gdbarch != NULL); gdb_assert (current_gdbarch != NULL); gdb_assert (new_gdbarch->initialized_p); - current_gdbarch_swap_out_hack (); - current_gdbarch_swap_in_hack (new_gdbarch); + current_gdbarch = new_gdbarch; architecture_changed_event (); reinit_frame_cache (); } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com