From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24020 invoked by alias); 14 Nov 2003 08:58:25 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23952 invoked from network); 14 Nov 2003 08:58:22 -0000 Received: from unknown (HELO sohm.kpit.com) (203.129.230.82) by sources.redhat.com with SMTP; 14 Nov 2003 08:58:22 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: H8300 Patch - Fix GDB crash problem when object file of different H8 cpu is loaded Date: Fri, 14 Nov 2003 08:58:00 -0000 Message-ID: <69595093233BB547BB70CF5E492B63F202B1061C@sohm.kpit.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: From: "Dhananjay R. Deshpande" To: X-SW-Source: 2003-11/txt/msg00289.txt.bz2 Hi, Currently if you are debugging one object and load another object of differ= ent=20 H8 CPU then the GDB crashes in h8300_register_name() saying "invalid regist= er number". This is because in gdbarch_init we are returning existing gdbar= ch but=20 the globals h8300hmode, h8300smode, etc. are not set again corresponding to= =20 newly loaded object. The patch below initializes these globals before returning existing gdbarch. Regards, Dhananjay Changelog -=20 2003-11-14 Dhananjay Deshpande * gdb/h8300-tdep.c (h8300_gdbarch_init): Set globals before returni= ng existing gdbarch =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D --- gdb/h8300-tdep.c.old 2003-11-12 13:51:36.000000000 +0530 +++ gdb/h8300-tdep.c 2003-11-14 11:08:29.000000000 +0530 @@ -1176,6 +1176,53 @@ h8300_gdbarch_init (struct gdbarch_info=20 struct gdbarch_tdep *tdep =3D NULL; struct gdbarch *gdbarch; =20 + /* Set globals */ + switch (info.bfd_arch_info->mach) + { + case bfd_mach_h8300: + h8300_normal_mode =3D 0; + h8300sxmode =3D 0; + h8300smode =3D 0; + h8300hmode =3D 0; + break; + case bfd_mach_h8300h: + h8300_normal_mode =3D 0; + h8300sxmode =3D 0; + h8300smode =3D 0; + h8300hmode =3D 1; + break; + case bfd_mach_h8300hn: + h8300_normal_mode =3D 1; + h8300sxmode =3D 0; + h8300smode =3D 0; + h8300hmode =3D 1; + break; + case bfd_mach_h8300s: + h8300_normal_mode =3D 0; + h8300sxmode =3D 0; + h8300smode =3D 1; + h8300hmode =3D 1; + break; + case bfd_mach_h8300sn: + h8300_normal_mode =3D 1; + h8300sxmode =3D 0; + h8300smode =3D 1; + h8300hmode =3D 1; + break; + case bfd_mach_h8300sx: + h8300_normal_mode =3D 0; + h8300sxmode =3D 1; + h8300smode =3D 1; + h8300hmode =3D 1; + break; + case bfd_mach_h8300sxn: + h8300_normal_mode =3D 1; + h8300sxmode =3D 1; + h8300smode =3D 1; + h8300hmode =3D 1; + break; + } + arches =3D gdbarch_list_lookup_by_info (arches, &info); if (arches !=3D NULL) return arches->gdbarch; @@ -1192,9 +1239,6 @@ h8300_gdbarch_init (struct gdbarch_info=20 switch (info.bfd_arch_info->mach) { case bfd_mach_h8300: - h8300sxmode =3D 0; - h8300smode =3D 0; - h8300hmode =3D 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 +1254,6 @@ h8300_gdbarch_init (struct gdbarch_info=20 break; case bfd_mach_h8300h: case bfd_mach_h8300hn: - h8300sxmode =3D 0; - h8300smode =3D 0; - h8300hmode =3D 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 +1263,11 @@ h8300_gdbarch_init (struct gdbarch_info=20 set_gdbarch_register_name (gdbarch, h8300_register_name); if(info.bfd_arch_info->mach !=3D bfd_mach_h8300hn) { - h8300_normal_mode =3D 0; set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT); } else { - h8300_normal_mode =3D 1; set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT); set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT); } @@ -1238,9 +1277,6 @@ h8300_gdbarch_init (struct gdbarch_info=20 break; case bfd_mach_h8300s: case bfd_mach_h8300sn: - h8300sxmode =3D 0; - h8300smode =3D 1; - h8300hmode =3D 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 +1286,11 @@ h8300_gdbarch_init (struct gdbarch_info=20 set_gdbarch_register_name (gdbarch, h8300s_register_name); if(info.bfd_arch_info->mach !=3D bfd_mach_h8300sn) { - h8300_normal_mode =3D 0; set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT); } else { - h8300_normal_mode =3D 1; set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT); set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT); } @@ -1266,9 +1300,6 @@ h8300_gdbarch_init (struct gdbarch_info=20 break; case bfd_mach_h8300sx: case bfd_mach_h8300sxn: - h8300sxmode =3D 1; - h8300smode =3D 1; - h8300hmode =3D 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 +1309,11 @@ h8300_gdbarch_init (struct gdbarch_info=20 set_gdbarch_register_name (gdbarch, h8300sx_register_name); if(info.bfd_arch_info->mach !=3D bfd_mach_h8300sxn) { - h8300_normal_mode =3D 0; set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT); } else { - h8300_normal_mode =3D 1; set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT); set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT); } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D