Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@gnu.org>
To: Joel Brobecker <brobecker@gnat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] mips-tdep.c small cleanup
Date: Thu, 02 Sep 2004 02:25:00 -0000	[thread overview]
Message-ID: <4136844C.2010601@gnu.org> (raw)
In-Reply-To: <20040901234951.GN969@gnat.com>

> I removed some dead code, did some reformatting, and also did one little
> code factoring, to make the code look prettier. That's actually the last
> part of the change that made me choose a RFA rather than a PATCH. It
> looks obvious, and tests ok, but I'd appreciate a second pair of eyes
> looking at the change too.
> 
> The idea is to clean this code up a little bit, so I can see better
> how to implement Andrew's suggestion re- inlining.
> 
> 2004-09-01  Joel Brobecker  <brobecker@gnat.com>
> 
>         * mips-tdep.c (mips_insn32_frame_cache): Remove some dead code.
>         Minor reformatting. Some code factoring.
> 
> tested on mips-irix 6.5.
> OK to apply?

Yep!
Andrew

> --- mips-tdep.c.new_ref	2004-09-01 17:38:33.996866250 -0400
> +++ mips-tdep.c	2004-09-01 18:27:47.336020442 -0400
> @@ -2118,28 +2118,16 @@ mips_insn32_frame_cache (struct frame_in
>        /* Bitmasks; set if we have found a save for the register.  */
>        unsigned long gen_save_found = 0;
>        unsigned long float_save_found = 0;
> -      int mips16;
>  
> -      /* If the address is odd, assume this is MIPS16 code.  */
>        addr = PROC_LOW_ADDR (proc_desc);
> -      mips16 = pc_is_mips16 (addr);
>  
>        /* Scan through this function's instructions preceding the
>           current PC, and look for those that save registers.  */
>        while (addr < frame_pc_unwind (next_frame))
>  	{
> -	  if (mips16)
> -	    {
> -	      mips16_decode_reg_save (mips16_fetch_instruction (addr),
> -				      &gen_save_found);
> -	      addr += MIPS16_INSTLEN;
> -	    }
> -	  else
> -	    {
> -	      mips32_decode_reg_save (mips32_fetch_instruction (addr),
> -				      &gen_save_found, &float_save_found);
> -	      addr += MIPS_INSTLEN;
> -	    }
> +          mips32_decode_reg_save (mips32_fetch_instruction (addr),
> +                                  &gen_save_found, &float_save_found);
> +          addr += MIPS_INSTLEN;
>  	}
>        gen_mask = gen_save_found;
>        float_mask = float_save_found;
> @@ -2159,48 +2147,20 @@ mips_insn32_frame_cache (struct frame_in
>  	}
>    }
>  
> -  /* The MIPS16 entry instruction saves $s0 and $s1 in the reverse
> -     order of that normally used by gcc.  Therefore, we have to fetch
> -     the first instruction of the function, and if it's an entry
> -     instruction that saves $s0 or $s1, correct their saved addresses.  */
> -  if (pc_is_mips16 (PROC_LOW_ADDR (proc_desc)))
> -    {
> -      ULONGEST inst = mips16_fetch_instruction (PROC_LOW_ADDR (proc_desc));
> -      if ((inst & 0xf81f) == 0xe809 && (inst & 0x700) != 0x700)
> -	/* entry */
> -	{
> -	  int reg;
> -	  int sreg_count = (inst >> 6) & 3;
> -
> -	  /* Check if the ra register was pushed on the stack.  */
> -	  CORE_ADDR reg_position = (cache->base
> -				    + PROC_REG_OFFSET (proc_desc));
> -	  if (inst & 0x20)
> -	    reg_position -= mips_abi_regsize (gdbarch);
> -
> -	  /* Check if the s0 and s1 registers were pushed on the
> -	     stack.  */
> -	  /* NOTE: cagney/2004-02-08: Huh?  This is doing no such
> -             check.  */
> -	  for (reg = 16; reg < sreg_count + 16; reg++)
> -	    {
> -	      cache->saved_regs[NUM_REGS + reg].addr = reg_position;
> -	      reg_position -= mips_abi_regsize (gdbarch);
> -	    }
> -	}
> -    }
> -
>    /* Fill in the offsets for the registers which float_mask says were
>       saved.  */
>    {
> -    CORE_ADDR reg_position = (cache->base
> -			      + PROC_FREG_OFFSET (proc_desc));
> +    CORE_ADDR reg_position = (cache->base + PROC_FREG_OFFSET (proc_desc));
>      int ireg;
> +
>      /* Fill in the offsets for the float registers which float_mask
>         says were saved.  */
>      for (ireg = MIPS_NUMREGS - 1; float_mask; --ireg, float_mask <<= 1)
>        if (float_mask & 0x80000000)
>  	{
> +          const int regno =
> +            NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg;
> +
>  	  if (mips_abi_regsize (gdbarch) == 4
>  	      && TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
>  	    {
> @@ -2227,15 +2187,14 @@ mips_insn32_frame_cache (struct frame_in
>  	         reg_position is decremented each time through the
>  	         loop).  */
>  	      if ((ireg & 1))
> -		cache->saved_regs[NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg]
> -		  .addr = reg_position - mips_abi_regsize (gdbarch);
> +		cache->saved_regs[regno].addr =
> +                  reg_position - mips_abi_regsize (gdbarch);
>  	      else
> -		cache->saved_regs[NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg]
> -		  .addr = reg_position + mips_abi_regsize (gdbarch);
> +		cache->saved_regs[regno].addr =
> +                 reg_position + mips_abi_regsize (gdbarch);
>  	    }
>  	  else
> -	    cache->saved_regs[NUM_REGS + mips_regnum (current_gdbarch)->fp0 + ireg]
> -	      .addr = reg_position;
> +	    cache->saved_regs[regno].addr = reg_position;
>  	  reg_position -= mips_abi_regsize (gdbarch);
>  	}
>  


  reply	other threads:[~2004-09-02  2:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-01 23:49 Joel Brobecker
2004-09-02  2:25 ` Andrew Cagney [this message]
2004-09-02 22:58   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4136844C.2010601@gnu.org \
    --to=cagney@gnu.org \
    --cc=brobecker@gnat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox