Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <lgustavo@codesourcery.com>
Cc: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: Re: [PATCH, v2] Fix ARM machine state testcase failures
Date: Tue, 21 Oct 2014 12:49:00 -0000	[thread overview]
Message-ID: <87oat5ioae.fsf@codesourcery.com> (raw)
In-Reply-To: <54464B82.6030703@codesourcery.com> (Luis Machado's message of	"Tue, 21 Oct 2014 10:03:14 -0200")

Luis Machado <lgustavo@codesourcery.com> writes:

> While at it, i noticed the original functions had some issues like
> unused variables and broken identation, so i went ahead and completely
> rewrote the functions handling ARM mode opcodes 010 and 100.

It's great to make code cleaner, but better to put code refactor and bug
fixing into separate patches.

> I see the same results as before, with no regressions.
>
> How does it look now?
>
> Luis
>
> 2014-10-21  Luis Machado  <lgustavo@codesourcery.com>
>
> 	* arm-tdep.c (INSN_S_L_BIT_NUM): Document.
> 	(arm_record_ld_st_imm_offset): Reimplement to cover all
> 	load/store cases for ARM opcode 010.
> 	(arm_record_ld_st_multiple): Reimplement to cover all
> 	load/store cases for ARM opcode 100.
>

With these comments below addressed, this patch is OK to me.

>  
> -/* Handling opcode 100 insns.  */
> +/* Handle ARM mode instructions with opcode 100.  */
>  
>  static int
>  arm_record_ld_st_multiple (insn_decode_record *arm_insn_r)
>  {
>    struct regcache *reg_cache = arm_insn_r->regcache;
> -
> -  uint32_t register_list[16] = {0}, register_count = 0, register_bits = 0;
> -  uint32_t reg_src1 = 0, addr_mode = 0, no_of_regs = 0;
> -  uint32_t start_address = 0, index = 0;
> +  uint32_t register_count = 0, register_bits;
> +  uint32_t reg_base, addr_mode;
>    uint32_t record_buf[24], record_buf_mem[48];
> +  uint32_t wback;
> +  ULONGEST u_regval;
>  
> -  ULONGEST u_regval[2] = {0};
> +  /* Fetch the list of registers.  */
> +  register_bits = bits (arm_insn_r->arm_insn, 0, 15);
> +  arm_insn_r->reg_rec_count = 0;
> +
> +  /* Fetch the base register that contains the address we are loading data
> +     to.  */
> +  reg_base = bits (arm_insn_r->arm_insn, 16, 19);
>  
> -  /* This mode is exclusively for load and store multiple.  */
> -  /* Handle incremenrt after/before and decrment after.before mode;
> -     Rn is changing depending on W bit, but as of now we store Rn too
> -     without optimization.  */
> +  /* Calculate wback.  */
> +  wback = (bit (arm_insn_r->arm_insn, 24) == 0)
> +	  || (bit (arm_insn_r->arm_insn, 21) == 1);

Bit 24 is zero, so we only need to check bit 21.

>  
>    if (bit (arm_insn_r->arm_insn, INSN_S_L_BIT_NUM))
>      {
> -      /* LDM  (1,2,3) where LDM  (3) changes CPSR too.  */
> +      /* LDM/LDMIA/LDMFD, LDMDA/LDMFA, LDMDB and LDMIB.  */
>  
> -      if (bit (arm_insn_r->arm_insn, 20) && !bit (arm_insn_r->arm_insn, 22))
> -        {
> -          register_bits = bits (arm_insn_r->arm_insn, 0, 15);
> -          no_of_regs = 15;
> -        }
> -      else
> -        {
> -          register_bits = bits (arm_insn_r->arm_insn, 0, 14);
> -          no_of_regs = 14;
> -        }
> -      /* Get Rn.  */
> -      reg_src1 = bits (arm_insn_r->arm_insn, 16, 19);
> +      /* Find out which registers are going to be loaded from memory.  */
>        while (register_bits)
> -      {
> -        if (register_bits & 0x00000001)
> -          record_buf[index++] = register_count;
> -        register_bits = register_bits >> 1;
> -        register_count++;
> -      }
> +	{
> +	  if (register_bits & 0x00000001)
> +	    record_buf[arm_insn_r->reg_rec_count++] = register_count;
> +	  register_bits = register_bits >> 1;
> +	  register_count++;
> +	}
>  
> -        /* Extra space for Base Register and CPSR; wihtout optimization.  */
> -        record_buf[index++] = reg_src1;
> -        record_buf[index++] = ARM_PS_REGNUM;
> -        arm_insn_r->reg_rec_count = index;
> +      /* Extra space for Base Register and CPSR; wihtout optimization.  */

s/wihtout/without/

-- 
Yao (齐尧)


  parent reply	other threads:[~2014-10-21 12:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 12:03 Luis Machado
2014-10-21 12:16 ` Luis Machado
2014-10-21 12:49 ` Yao Qi [this message]
2014-10-21 13:07 ` Yao Qi
2014-10-22  0:52   ` Luis Machado
2014-10-27 11:03     ` Luis Machado

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=87oat5ioae.fsf@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lgustavo@codesourcery.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