Ping: [RFA] ARM : prologue scan

Jerome Guitton
2003-09-01T15:45:16Z

No reaction about this patch... Any opinion from the ARM maintainers?
This patch should not interfere with Daniel Jacobowitz' work to modernize
the arm-tdep.c.

Jerome Guitton (guitton@act-europe.fr):

>
> I have done some minor corrections on the previous patch, discard it.
> In attachment, the new version. No regression, no fixed.
>
> --
> Jerome.

> 2003-07-21 J. Guitton <guitton@gnat.com>
>
> * arm-tdep.c (arm_skip_prologue): Add the handling of "sub ip, sp #n"
> and "add ip, sp #n", as these instructions can be found in a ATPCS
> compliant prologue.
> (arm_scan_prologue): Ditto.
>
> Index: arm-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/arm-tdep.c,v
> retrieving revision 1.143
> diff -u -3 -p -r1.143 arm-tdep.c
> --- arm-tdep.c 13 Jun 2003 14:15:51 -0000 1.143
> +++ arm-tdep.c 22 Jul 2003 11:43:10 -0000
> @@ -449,6 +449,12 @@ arm_skip_prologue (CORE_ADDR pc)
> if (inst == 0xe1a0c00d) /* mov ip, sp */
> continue;
>
> + if ((inst & 0xfffff000) == 0xe28dc000) /* add ip, sp #n */
> + continue;
> +
> + if ((inst & 0xfffff000) == 0xe24dc000) /* sub ip, sp #n */
> + continue;
> +
> /* Some prologues begin with "str lr, [sp, #-4]!". */
> if (inst == 0xe52de004) /* str lr, [sp, #-4]! */
> continue;
> @@ -708,7 +714,7 @@ thumb_scan_prologue (struct frame_info *
> static void
> arm_scan_prologue (struct frame_info *fi)
> {
> - int regno, sp_offset, fp_offset;
> + int regno, sp_offset, fp_offset, ip_offset;
> LONGEST return_value;
> CORE_ADDR prologue_start, prologue_end, current_pc;
>
> @@ -799,7 +805,7 @@ arm_scan_prologue (struct frame_info *fi
> in which case it is often (but not always) replaced by
> "str lr, [sp, #-4]!". - Michael Snyder, 2002-04-23] */
>
> - sp_offset = fp_offset = 0;
> + sp_offset = fp_offset = ip_offset = 0;
>
> for (current_pc = prologue_start;
> current_pc < prologue_end;
> @@ -809,6 +815,23 @@ arm_scan_prologue (struct frame_info *fi
>
> if (insn == 0xe1a0c00d) /* mov ip, sp */
> {
> + ip_offset = 0;
> + continue;
> + }
> + else if ((insn & 0xfffff000) == 0xe28dc000) /* add ip, sp #n */
> + {
> + unsigned imm = insn & 0xff; /* immediate value */
> + unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */
> + imm = (imm >> rot) | (imm << (32 - rot));
> + ip_offset = imm;
> + continue;
> + }
> + else if ((insn & 0xfffff000) == 0xe24dc000) /* sub ip, sp #n */
> + {
> + unsigned imm = insn & 0xff; /* immediate value */
> + unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */
> + imm = (imm >> rot) | (imm << (32 - rot));
> + ip_offset = -imm;
> continue;
> }
> else if (insn == 0xe52de004) /* str lr, [sp, #-4]! */
> @@ -850,7 +873,7 @@ arm_scan_prologue (struct frame_info *fi
> unsigned imm = insn & 0xff; /* immediate value */
> unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */
> imm = (imm >> rot) | (imm << (32 - rot));
> - fp_offset = -imm;
> + fp_offset = -imm + ip_offset;
> get_frame_extra_info (fi)->framereg = ARM_FP_REGNUM;
> }
> else if ((insn & 0xfffff000) == 0xe24dd000) /* sub sp, sp #n */