diff options
author | Andrew Cagney <cagney@redhat.com> | 2002-05-01 22:02:20 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2002-05-01 22:02:20 +0000 |
commit | 52bca491319eb9b4b6be09bdf79400e1443512d2 (patch) | |
tree | 3daa22725b99f34ed8af3c73d1e667d6efd38068 /gdb | |
parent | a018e15b9d15eeb40da1d5ab7149a0370a024786 (diff) | |
download | gdb-52bca491319eb9b4b6be09bdf79400e1443512d2.zip gdb-52bca491319eb9b4b6be09bdf79400e1443512d2.tar.gz gdb-52bca491319eb9b4b6be09bdf79400e1443512d2.tar.bz2 |
* gdbarch.sh (gdbarch_update_p): Swap out the old architecture
before probing for a new one. Detect errorenous gdbarch_init
functions.
* gdbarch.c: Regenerate.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/gdbarch.c | 35 | ||||
-rwxr-xr-x | gdb/gdbarch.sh | 35 |
3 files changed, 49 insertions, 28 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 90c06f4..8a235dd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2002-05-02 Andrew Cagney <cagney@redhat.com> + + * gdbarch.sh (gdbarch_update_p): Swap out the old architecture + before probing for a new one. Detect errorenous gdbarch_init + functions. + * gdbarch.c: Regenerate. + 2002-05-01 Andrew Cagney <cagney@redhat.com> * config/mn10200/tm-mn10200.h: Include "symfile.h" and "symtab.h". diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index f7248fc..ff5072d 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -4887,6 +4887,7 @@ int gdbarch_update_p (struct gdbarch_info info) { struct gdbarch *new_gdbarch; + struct gdbarch *old_gdbarch; struct gdbarch_registration *rego; /* Fill in missing parts of the INFO struct using a number of @@ -4955,30 +4956,40 @@ gdbarch_update_p (struct gdbarch_info info) return 0; } + /* Swap the data belonging to the old target out. This stops the + ->init() function trying to refer to the previous architecture. */ + swapout_gdbarch_swap (current_gdbarch); + init_gdbarch_swap (current_gdbarch); + old_gdbarch = current_gdbarch; + current_gdbarch = NULL; + /* Ask the target for a replacement architecture. */ new_gdbarch = rego->init (info, rego->arches); - /* Did the target like it? No. Reject the change. */ + /* Did the target like it? No. Reject the change and revert to the + old architecture. */ if (new_gdbarch == NULL) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update: Target rejected architecture\n"); + swapin_gdbarch_swap (old_gdbarch); + current_gdbarch = old_gdbarch; return 0; } - /* Did the architecture change? No. Do nothing. */ - if (current_gdbarch == new_gdbarch) + /* Did the architecture change? No. Oops, put the old architecture + back. */ + if (old_gdbarch == new_gdbarch) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update: Architecture 0x%08lx (%s) unchanged\n", (long) new_gdbarch, new_gdbarch->bfd_arch_info->printable_name); + swapin_gdbarch_swap (old_gdbarch); + current_gdbarch = old_gdbarch; return 1; } - /* Swap all data belonging to the old target out */ - swapout_gdbarch_swap (current_gdbarch); - /* Is this a pre-existing architecture? Yes. Move it to the front of the list of architectures (keeping the list sorted Most Recently Used) and then copy it in. */ @@ -5035,14 +5046,10 @@ gdbarch_update_p (struct gdbarch_info info) new_gdbarch->dump_tdep = rego->dump_tdep; verify_gdbarch (new_gdbarch); - /* Initialize the per-architecture memory (swap) areas. - CURRENT_GDBARCH must be update before these modules are - called. */ - init_gdbarch_swap (new_gdbarch); - - /* Initialize the per-architecture data-pointer of all parties that - registered an interest in this architecture. CURRENT_GDBARCH - must be updated before these modules are called. */ + /* Initialize the per-architecture data-pointers and swap areas for + all parties that registered an interest in this architecture. + CURRENT_GDBARCH must be updated before these modules are called. + The swap area's will have already been initialized to zero. */ init_gdbarch_data (new_gdbarch); architecture_changed_event (); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index e1442f3..f99d29a 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -2079,6 +2079,7 @@ int gdbarch_update_p (struct gdbarch_info info) { struct gdbarch *new_gdbarch; + struct gdbarch *old_gdbarch; struct gdbarch_registration *rego; /* Fill in missing parts of the INFO struct using a number of @@ -2147,30 +2148,40 @@ gdbarch_update_p (struct gdbarch_info info) return 0; } + /* Swap the data belonging to the old target out. This stops the + ->init() function trying to refer to the previous architecture. */ + swapout_gdbarch_swap (current_gdbarch); + init_gdbarch_swap (current_gdbarch); + old_gdbarch = current_gdbarch; + current_gdbarch = NULL; + /* Ask the target for a replacement architecture. */ new_gdbarch = rego->init (info, rego->arches); - /* Did the target like it? No. Reject the change. */ + /* Did the target like it? No. Reject the change and revert to the + old architecture. */ if (new_gdbarch == NULL) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update: Target rejected architecture\\n"); + swapin_gdbarch_swap (old_gdbarch); + current_gdbarch = old_gdbarch; return 0; } - /* Did the architecture change? No. Do nothing. */ - if (current_gdbarch == new_gdbarch) + /* Did the architecture change? No. Oops, put the old architecture + back. */ + if (old_gdbarch == new_gdbarch) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update: Architecture 0x%08lx (%s) unchanged\\n", (long) new_gdbarch, new_gdbarch->bfd_arch_info->printable_name); + swapin_gdbarch_swap (old_gdbarch); + current_gdbarch = old_gdbarch; return 1; } - /* Swap all data belonging to the old target out */ - swapout_gdbarch_swap (current_gdbarch); - /* Is this a pre-existing architecture? Yes. Move it to the front of the list of architectures (keeping the list sorted Most Recently Used) and then copy it in. */ @@ -2227,14 +2238,10 @@ gdbarch_update_p (struct gdbarch_info info) new_gdbarch->dump_tdep = rego->dump_tdep; verify_gdbarch (new_gdbarch); - /* Initialize the per-architecture memory (swap) areas. - CURRENT_GDBARCH must be update before these modules are - called. */ - init_gdbarch_swap (new_gdbarch); - - /* Initialize the per-architecture data-pointer of all parties that - registered an interest in this architecture. CURRENT_GDBARCH - must be updated before these modules are called. */ + /* Initialize the per-architecture data-pointers and swap areas for + all parties that registered an interest in this architecture. + CURRENT_GDBARCH must be updated before these modules are called. + The swap area's will have already been initialized to zero. */ init_gdbarch_data (new_gdbarch); architecture_changed_event (); |