aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDhananjay Deshpande <dhananjayd@kpitcummins.com>2003-12-11 06:21:12 +0000
committerDhananjay Deshpande <dhananjayd@kpitcummins.com>2003-12-11 06:21:12 +0000
commit454d05118bc21bb4966c0cb13d3bfc526c26e3b8 (patch)
tree2710dbfbea877706f2abd2d6dc28101636aca660 /gdb
parent8f02783d3a649edcfc7bbce568918c39f1c844e9 (diff)
downloadgdb-454d05118bc21bb4966c0cb13d3bfc526c26e3b8.zip
gdb-454d05118bc21bb4966c0cb13d3bfc526c26e3b8.tar.gz
gdb-454d05118bc21bb4966c0cb13d3bfc526c26e3b8.tar.bz2
Fix GDB crash problem when object file of different H8 cpu is loaded
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog23
-rw-r--r--gdb/config/h8300/tm-h8300.h15
-rw-r--r--gdb/h8300-tdep.c79
-rw-r--r--gdb/remote-e7000.c34
4 files changed, 98 insertions, 53 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0bec025..581b0be 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,26 @@
+2003-12-11 Dhananjay Deshpande <dhananjayd@kpitcummins.com>
+
+ * config/h8300/tm-h8300.h (h8300hmode): Remove.
+ (h8300hmode): Likewise.
+ (h8300smode): Likewise.
+ (h8300sxmode): Likewise.
+ (h8300_normal_mode): Likewise.
+ (GDB_TARGET_IS_H8300): Likewise.
+ (NUM_REALREGS): Use TARGET_ARCHITECTURE->mach instead of global.
+ * h8300-tdep.c (is_h8300hmode): New function.
+ (is_h8300smode): New function.
+ (is_h8300sxmode): New function.
+ (is_h8300_normal_mode): New function.
+ (BINWORD): Use new functions.
+ (h8300_examine_prologue): Likewise.
+ (h8300_print_register): Likewise.
+ (h8300_print_registers_info): Likewise.
+ (h8300_register_type): Likewise.
+ (h8300_gdbarch_init): Remove use of globals like h8300hmode.
+ * remote-e7000.c (e7000_open): Remove use of GDB_TARGET_IS_H8300.
+ (e7000_fetch_registers): Use TARGET_ARCHITECTURE->mach instead.
+ (e7000_wait): Use TARGET_ARCHITECTURE->mach instead of global.
+
2003-12-10 J. Brobecker <brobecker@gnat.com>
* frame.c (select_frame): Get the current frame PC using
diff --git a/gdb/config/h8300/tm-h8300.h b/gdb/config/h8300/tm-h8300.h
index 807d7c0..a1c337e 100644
--- a/gdb/config/h8300/tm-h8300.h
+++ b/gdb/config/h8300/tm-h8300.h
@@ -20,20 +20,13 @@
Boston, MA 02111-1307, USA. */
/* Contributed by Steve Chamberlain sac@cygnus.com */
-/* NOTE: ezannoni 2000-07-18: these variables are part of sim, defined
- in sim/h8300/compile.c. They really should not be used this
- way. Because of this we cannot get rid of the macro
- GDB_TARGET_IS_H8300 in remote-e7000.c */
-extern int h8300hmode;
-extern int h8300smode;
-extern int h8300_normal_mode; /* 1 - Normal Mode , 0 - Advanced mode */
-extern int h8300sxmode;
-#define GDB_TARGET_IS_H8300
-
/* Needed for remote.c */
#define DEPRECATED_REMOTE_BREAKPOINT { 0x57, 0x30} /* trapa #3 */
/* Needed for remote-hms.c */
#define CCR_REGNUM 8
/* Needed for remote-e7000.c */
-#define NUM_REALREGS (h8300smode?11:10)
+#define NUM_REALREGS ((TARGET_ARCHITECTURE->mach == bfd_mach_h8300s || \
+ TARGET_ARCHITECTURE->mach == bfd_mach_h8300sn || \
+ TARGET_ARCHITECTURE->mach == bfd_mach_h8300sx || \
+ TARGET_ARCHITECTURE->mach == bfd_mach_h8300sxn) ? 11 : 10)
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index ec05f01..4a66d80 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -49,7 +49,14 @@ enum
h8300h_reg_size = 4,
h8300_max_reg_size = 4,
};
-#define BINWORD (h8300hmode && !h8300_normal_mode ? h8300h_reg_size : h8300_reg_size)
+
+static int is_h8300hmode (struct gdbarch *gdbarch);
+static int is_h8300smode (struct gdbarch *gdbarch);
+static int is_h8300sxmode (struct gdbarch *gdbarch);
+static int is_h8300_normal_mode (struct gdbarch *gdbarch);
+
+#define BINWORD (is_h8300hmode (current_gdbarch) && \
+ !is_h8300_normal_mode (current_gdbarch) ? h8300h_reg_size : h8300_reg_size)
enum gdb_regnum
{
@@ -350,7 +357,8 @@ h8300_examine_prologue (CORE_ADDR ip, CORE_ADDR limit,
}
/* If the PC isn't valid, quit now. */
- if (ip == 0 || ip & (h8300hmode && !h8300_normal_mode ? ~0xffffff : ~0xffff))
+ if (ip == 0 || ip & (is_h8300hmode (current_gdbarch) &&
+ !is_h8300_normal_mode (current_gdbarch) ? ~0xffffff : ~0xffff))
return 0;
next_ip = h8300_next_prologue_insn (ip, limit, &insn_word);
@@ -947,7 +955,8 @@ h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
rval = get_frame_register_signed (frame, regno);
fprintf_filtered (file, "%-14s ", name);
- if (regno == E_PSEUDO_CCR_REGNUM || (regno == E_PSEUDO_EXR_REGNUM && h8300smode))
+ if (regno == E_PSEUDO_CCR_REGNUM ||
+ (regno == E_PSEUDO_EXR_REGNUM && is_h8300smode (current_gdbarch)))
{
fprintf_filtered (file, "0x%02x ", (unsigned char)rval);
print_longest (file, 'u', 1, rval);
@@ -996,7 +1005,7 @@ h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
if ((Z | (N ^ V)) == 1)
fprintf_filtered (file, "<= ");
}
- else if (regno == E_PSEUDO_EXR_REGNUM && h8300smode)
+ else if (regno == E_PSEUDO_EXR_REGNUM && is_h8300smode (current_gdbarch))
{
/* EXR register */
unsigned char l = rval & 0xff;
@@ -1019,10 +1028,10 @@ h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
h8300_print_register (gdbarch, file, frame, regno);
h8300_print_register (gdbarch, file, frame, E_PSEUDO_CCR_REGNUM);
h8300_print_register (gdbarch, file, frame, E_PC_REGNUM);
- if (h8300smode)
+ if (is_h8300smode (current_gdbarch))
{
h8300_print_register (gdbarch, file, frame, E_PSEUDO_EXR_REGNUM);
- if (h8300sxmode)
+ if (is_h8300sxmode (current_gdbarch))
{
h8300_print_register (gdbarch, file, frame, E_SBR_REGNUM);
h8300_print_register (gdbarch, file, frame, E_VBR_REGNUM);
@@ -1044,7 +1053,7 @@ h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
{
if (regno == E_CCR_REGNUM)
h8300_print_register (gdbarch, file, frame, E_PSEUDO_CCR_REGNUM);
- else if (regno == E_PSEUDO_EXR_REGNUM && h8300smode)
+ else if (regno == E_PSEUDO_EXR_REGNUM && is_h8300smode (current_gdbarch))
h8300_print_register (gdbarch, file, frame, E_PSEUDO_EXR_REGNUM);
else
h8300_print_register (gdbarch, file, frame, regno);
@@ -1078,7 +1087,7 @@ h8300_register_type (struct gdbarch *gdbarch, int regno)
return builtin_type_uint8;
else if (regno == E_PSEUDO_EXR_REGNUM)
return builtin_type_uint8;
- else if (h8300hmode)
+ else if (is_h8300hmode (current_gdbarch))
return builtin_type_int32;
else
return builtin_type_int16;
@@ -1192,9 +1201,6 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
switch (info.bfd_arch_info->mach)
{
case bfd_mach_h8300:
- h8300sxmode = 0;
- h8300smode = 0;
- h8300hmode = 0;
set_gdbarch_num_regs (gdbarch, 13);
set_gdbarch_num_pseudo_regs (gdbarch, 1);
set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
@@ -1210,9 +1216,6 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
break;
case bfd_mach_h8300h:
case bfd_mach_h8300hn:
- h8300sxmode = 0;
- h8300smode = 0;
- h8300hmode = 1;
set_gdbarch_num_regs (gdbarch, 13);
set_gdbarch_num_pseudo_regs (gdbarch, 1);
set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
@@ -1222,13 +1225,11 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_register_name (gdbarch, h8300_register_name);
if(info.bfd_arch_info->mach != bfd_mach_h8300hn)
{
- h8300_normal_mode = 0;
set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
}
else
{
- h8300_normal_mode = 1;
set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
}
@@ -1238,9 +1239,6 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
break;
case bfd_mach_h8300s:
case bfd_mach_h8300sn:
- h8300sxmode = 0;
- h8300smode = 1;
- h8300hmode = 1;
set_gdbarch_num_regs (gdbarch, 16);
set_gdbarch_num_pseudo_regs (gdbarch, 2);
set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
@@ -1250,13 +1248,11 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_register_name (gdbarch, h8300s_register_name);
if(info.bfd_arch_info->mach != bfd_mach_h8300sn)
{
- h8300_normal_mode = 0;
set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
}
else
{
- h8300_normal_mode = 1;
set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
}
@@ -1266,9 +1262,6 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
break;
case bfd_mach_h8300sx:
case bfd_mach_h8300sxn:
- h8300sxmode = 1;
- h8300smode = 1;
- h8300hmode = 1;
set_gdbarch_num_regs (gdbarch, 18);
set_gdbarch_num_pseudo_regs (gdbarch, 2);
set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
@@ -1278,13 +1271,11 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_register_name (gdbarch, h8300sx_register_name);
if(info.bfd_arch_info->mach != bfd_mach_h8300sxn)
{
- h8300_normal_mode = 0;
set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
}
else
{
- h8300_normal_mode = 1;
set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
}
@@ -1370,3 +1361,39 @@ _initialize_h8300_tdep (void)
{
register_gdbarch_init (bfd_arch_h8300, h8300_gdbarch_init);
}
+
+static int
+is_h8300hmode (struct gdbarch *gdbarch)
+{
+ return gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sx
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sxn
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300s
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sn
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300h
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300hn;
+}
+
+static int
+is_h8300smode (struct gdbarch *gdbarch)
+{
+ return gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sx
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sxn
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300s
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sn;
+}
+
+static int
+is_h8300sxmode (struct gdbarch *gdbarch)
+{
+ return gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sx
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sxn;
+}
+
+static int
+is_h8300_normal_mode (struct gdbarch *gdbarch)
+{
+ return gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sxn
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300sn
+ || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_h8300hn;
+}
+
diff --git a/gdb/remote-e7000.c b/gdb/remote-e7000.c
index 10d7362..c422c94 100644
--- a/gdb/remote-e7000.c
+++ b/gdb/remote-e7000.c
@@ -657,10 +657,6 @@ e7000_open (char *args, int from_tty)
}
serial_raw (e7000_desc);
-#ifdef GDB_TARGET_IS_H8300
- h8300hmode = 1;
-#endif
-
/* Start the remote connection; if error (0), discard this target.
In particular, if the user quits, be sure to discard it
(we'd be in an inconsistent state otherwise). */
@@ -909,15 +905,18 @@ e7000_fetch_registers (void)
wanted = want_sh3;
}
}
-#ifdef GDB_TARGET_IS_H8300
if (TARGET_ARCHITECTURE->arch == bfd_arch_h8300)
{
- if (h8300smode)
- wanted = want_h8300s;
- else
- wanted = want_h8300h;
+ wanted = want_h8300h;
+ switch (TARGET_ARCHITECTURE->mach)
+ {
+ case bfd_mach_h8300s:
+ case bfd_mach_h8300sn:
+ case bfd_mach_h8300sx:
+ case bfd_mach_h8300sxn:
+ wanted = want_h8300s;
+ }
}
-#endif
fetch_regs_from_dump (gch, wanted);
@@ -2046,15 +2045,18 @@ e7000_wait (ptid_t ptid, struct target_waitstatus *status)
wanted_nopc = want_nopc_sh3;
}
}
-#ifdef GDB_TARGET_IS_H8300
if (TARGET_ARCHITECTURE->arch == bfd_arch_h8300)
{
- if (h8300smode)
- wanted_nopc = want_nopc_h8300s;
- else
- wanted_nopc = want_nopc_h8300h;
+ wanted_nopc = want_nopc_h8300h;
+ switch (TARGET_ARCHITECTURE->mach)
+ {
+ case bfd_mach_h8300s:
+ case bfd_mach_h8300sn:
+ case bfd_mach_h8300sx:
+ case bfd_mach_h8300sxn:
+ wanted_nopc = want_nopc_h8300s;
+ }
}
-#endif
fetch_regs_from_dump (gch, wanted_nopc);
/* And supply the extra ones the simulator uses */