From mboxrd@z Thu Jan 1 00:00:00 1970 From: Orjan Friberg To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [rfc] Swap out current when creating a new architecture Date: Mon, 01 Oct 2001 04:34:00 -0000 Message-id: <3BB854B3.208DC17A@axis.com> References: <3BB16441.30805@cygnus.com> <3BB771A1.4070201@cygnus.com> X-SW-Source: 2001-10/msg00001.html Andrew Cagney wrote: > > The CRIS target also dumps core with it applied. Like rs6000 was, it is > refering to the previous (current_gdbarch) architecture. > > I'll sit on this for a bit longer. Could I encourage target maintainers > to check their XXX_gdbarch_init() function for references to > current_gdbarch. Just a quick recap: what the old code was doing by referring to current_gdbarch was to avoid changing the ABI (which I infer from the bfd) if one of the other target specific commands were being used. The patch below sets the abfd field in the info struct to exec_bfd before calling gdbarch_update_p, so that information on the current bfd is passed along, just as it is when gdbarch_update_p is called from set_gdbarch_from_file. Is this an acceptable way of doing it? I know I'm in the risky business of dealing with global pointers. (I'm assuming a commit could go on both trunk and branch.) 2001-10-01 Orjan Friberg * cris-tdep.c (cris_gdbarch_init): Remove reference to current_gdbarch. (cris_version_update, cris_mode_update, cris_abi_update): Set abfd in info struct to exec_bfd. Index: cris-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/cris-tdep.c,v retrieving revision 1.4 diff -c -3 -p -r1.4 cris-tdep.c *** cris-tdep.c 2001/09/24 08:04:10 1.4 --- cris-tdep.c 2001/10/01 10:58:11 *************** cris_version_update (char *ignore_args, *** 3596,3601 **** --- 3596,3605 ---- /* Update the current architecture, if needed. */ memset (&info, 0, sizeof info); + + /* Supply the current bfd (if any). */ + info.abfd = exec_bfd; + if (!gdbarch_update_p (info)) internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture."); } *************** cris_mode_update (char *ignore_args, int *** 3614,3619 **** --- 3618,3627 ---- /* Update the current architecture, if needed. */ memset (&info, 0, sizeof info); + + /* Supply the current bfd (if any). */ + info.abfd = exec_bfd; + if (!gdbarch_update_p (info)) internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture."); } *************** cris_abi_update (char *ignore_args, int *** 3632,3637 **** --- 3640,3649 ---- /* Update the current architecture, if needed. */ memset (&info, 0, sizeof info); + + /* Supply the current bfd (if any). */ + info.abfd = exec_bfd; + if (!gdbarch_update_p (info)) internal_error (__FILE__, __LINE__, "cris_gdbarch_update: failed to update architecture."); } *************** cris_gdbarch_init (struct gdbarch_info i *** 3736,3748 **** /* Unknown bfd flavour. Assume it's the new ABI. */ cris_abi = CRIS_ABI_V2; } - } - else if (gdbarch_tdep (current_gdbarch)) - { - /* No bfd available. Stick with whatever ABI we're currently using. - (This is to avoid changing the ABI when the user updates the - architecture with the 'set cris-version' command.) */ - cris_abi = gdbarch_tdep (current_gdbarch)->cris_abi; } else { --- 3748,3753 ---- -- Orjan Friberg E-mail: orjan.friberg@axis.com Axis Communications AB Phone: +46 46 272 17 68