This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[01/03] Update target_gdbarch for current inferior
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 10 Jan 2010 21:15:20 +0100
- Subject: [01/03] Update target_gdbarch for current inferior
Hi,
currently if you load different inferior arch `target_gdbarch' is not being
switched with inferior switches:
./gdb -nx -ex 'file ./x64' -ex add-inferior -ex 'inferior 2' -ex 'file ./x32' -ex 'info inferior'
`target_gdbarch' could be moved into current_program_space as has been done
for `symfile_objfile':
#define symfile_objfile current_program_space->symfile_object_file
but it is useful to know gdbarch even at places where we know only
address_space
[patch 03/15] PIE: breakpoint_address_match gdbarch_addr_bit workaround
http://sourceware.org/ml/gdb-patches/2009-11/msg00170.html
Therefore suggesting to move `target_gdbarch' into `address_space' instead
- which may be even more logical. Attached.
(Not investigating here a possibility to move gdbarch to program_space and its
gdbarch_addr_bit part as a copy to address_space.)
Regression tested together with [02/03] on
{x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
Thanks,
Jan
2010-01-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdbarch.c (target_gdbarch): Remove.
(deprecated_target_gdbarch_select_hack): Call set_address_space_gdbarch.
* gdbarch.h (target_gdbarch): Remove.
(startup_gdbarch): New declaration.
* dsrec.c, i386-nat.c, memattr.c, target-descriptions.c: Include
progspace.h.
* progspace.c (struct address_space <gdbarch>): New.
(new_address_space): Initialize GDBARCH.
(address_space_gdbarch, set_address_space_gdbarch): New.
(update_address_spaces): New variable gdbarch, preserve PSPACE->ASPACE's
gdbarch using it.
* progspace.h (target_gdbarch, address_space_gdbarch)
(set_address_space_gdbarch): New.
--- a/gdb/dsrec.c
+++ b/gdb/dsrec.c
@@ -23,6 +23,7 @@
#include <time.h>
#include "gdb_assert.h"
#include "gdb_string.h"
+#include "progspace.h"
extern void report_transfer_performance (unsigned long, time_t, time_t);
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -396,8 +396,6 @@ struct gdbarch startup_gdbarch =
/* startup_gdbarch() */
};
-struct gdbarch *target_gdbarch = &startup_gdbarch;
-
/* Create a new ``struct gdbarch'' based on information provided by
``struct gdbarch_info''. */
@@ -3927,7 +3925,7 @@ deprecated_target_gdbarch_select_hack (struct gdbarch *new_gdbarch)
{
gdb_assert (new_gdbarch != NULL);
gdb_assert (new_gdbarch->initialized_p);
- target_gdbarch = new_gdbarch;
+ set_address_space_gdbarch (current_program_space->aspace, new_gdbarch);
observer_notify_architecture_changed (new_gdbarch);
registers_changed ();
}
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -54,18 +54,6 @@ struct displaced_step_closure;
struct core_regset_section;
struct syscall;
-/* The architecture associated with the connection to the target.
-
- The architecture vector provides some information that is really
- a property of the target: The layout of certain packets, for instance;
- or the solib_ops vector. Etc. To differentiate architecture accesses
- to per-target properties from per-thread/per-frame/per-objfile properties,
- accesses to per-target properties should be made through target_gdbarch.
-
- Eventually, when support for multiple targets is implemented in
- GDB, this global should be made target-specific. */
-extern struct gdbarch *target_gdbarch;
-
/* The following are pre-initialized by GDBARCH. */
@@ -1125,6 +1113,7 @@ extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
extern void set_gdbarch_from_file (bfd *);
+extern struct gdbarch startup_gdbarch;
/* Initialize the current architecture to the "first" one we find on
our list. */
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -25,6 +25,7 @@
#include "gdbcmd.h"
#include "target.h"
#include "gdb_assert.h"
+#include "progspace.h"
/* Support for hardware watchpoints and breakpoints using the i386
debug registers.
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -27,6 +27,7 @@
#include "language.h"
#include "vec.h"
#include "gdb_string.h"
+#include "progspace.h"
const struct mem_attrib default_mem_attrib =
{
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -50,6 +50,9 @@ static void program_space_free_data (struct program_space *);
struct address_space
{
int num;
+
+ /* The architecture associated with the connection to the target. */
+ struct gdbarch *gdbarch;
};
/* Create a new address space object, and add it to the list. */
@@ -61,6 +64,7 @@ new_address_space (void)
aspace = XZALLOC (struct address_space);
aspace->num = ++highest_address_space_num;
+ aspace->gdbarch = &startup_gdbarch;
return aspace;
}
@@ -95,6 +99,19 @@ address_space_num (struct address_space *aspace)
return aspace->num;
}
+struct gdbarch *
+address_space_gdbarch (struct address_space *aspace)
+{
+ return aspace->gdbarch;
+}
+
+void
+set_address_space_gdbarch (struct address_space *aspace,
+ struct gdbarch *gdbarch)
+{
+ aspace->gdbarch = gdbarch;
+}
+
/* Start counting over from scratch. */
static void
@@ -451,6 +468,8 @@ update_address_spaces (void)
ALL_PSPACES (pspace)
{
+ struct gdbarch *gdbarch = address_space_gdbarch (pspace->aspace);
+
free_address_space (pspace->aspace);
if (shared_aspace)
@@ -461,6 +480,8 @@ update_address_spaces (void)
}
else
pspace->aspace = new_address_space ();
+
+ set_address_space_gdbarch (pspace->aspace, gdbarch);
}
}
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -190,6 +190,16 @@ struct program_space
unsigned num_data;
};
+/* The architecture associated with the connection to the target.
+
+ The architecture vector provides some information that is really
+ a property of the target: The layout of certain packets, for instance;
+ or the solib_ops vector. Etc. To differentiate architecture accesses
+ to per-target properties from per-thread/per-frame/per-objfile properties,
+ accesses to per-target properties should be made through target_gdbarch. */
+
+#define target_gdbarch address_space_gdbarch (current_program_space->aspace)
+
/* The object file that the main symbol table was loaded from (e.g. the
argument to the "symbol-file" or "file" command). */
@@ -261,6 +271,13 @@ extern struct address_space *maybe_new_address_space (void);
/* Returns the integer address space id of ASPACE. */
extern int address_space_num (struct address_space *aspace);
+/* Returns gdbarch of ASPACE. */
+extern struct gdbarch *address_space_gdbarch (struct address_space *aspace);
+
+/* Set gdbarch of ASPACE to GDBARCH. */
+extern void set_address_space_gdbarch (struct address_space *aspace,
+ struct gdbarch *gdbarch);
+
/* Update all program spaces matching to address spaces. The user may
have created several program spaces, and loaded executables into
them before connecting to the target interface that will create the
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -33,6 +33,7 @@
#include "gdb_assert.h"
#include "gdb_obstack.h"
#include "hashtab.h"
+#include "progspace.h"
/* Types. */