2002-04-22 Michael Snyder <msnyder@redhat.com>

* arm-tdep.c: Some whitespace and coding standards tweaks.
This commit is contained in:
Michael Snyder 2002-04-22 23:22:04 +00:00
parent a33f755889
commit da3c6d4a30
2 changed files with 73 additions and 53 deletions

View File

@ -1,3 +1,7 @@
2002-04-22 Michael Snyder <msnyder@redhat.com>
* arm-tdep.c: Some whitespace and coding standards tweaks.
2002-04-22 Jason Thorpe <thorpej@wasabisystems.com> 2002-04-22 Jason Thorpe <thorpej@wasabisystems.com>
* vax-tdep.c: Include regcache.h. * vax-tdep.c: Include regcache.h.

View File

@ -134,7 +134,8 @@ static const char **valid_flavors;
/* Disassembly flavor to use. Default to "std" register names. */ /* Disassembly flavor to use. Default to "std" register names. */
static const char *disassembly_flavor; static const char *disassembly_flavor;
static int current_option; /* Index to that option in the opcodes table. */ /* Index to that option in the opcodes table. */
static int current_option;
/* This is used to keep the bfd arch_info in sync with the disassembly /* This is used to keep the bfd arch_info in sync with the disassembly
flavor. */ flavor. */
@ -348,13 +349,16 @@ static CORE_ADDR
thumb_skip_prologue (CORE_ADDR pc, CORE_ADDR func_end) thumb_skip_prologue (CORE_ADDR pc, CORE_ADDR func_end)
{ {
CORE_ADDR current_pc; CORE_ADDR current_pc;
int findmask = 0; /* findmask: /* findmask:
bit 0 - push { rlist } bit 0 - push { rlist }
bit 1 - mov r7, sp OR add r7, sp, #imm (setting of r7) bit 1 - mov r7, sp OR add r7, sp, #imm (setting of r7)
bit 2 - sub sp, #simm OR add sp, #simm (adjusting of sp) bit 2 - sub sp, #simm OR add sp, #simm (adjusting of sp)
*/ */
int findmask = 0;
for (current_pc = pc; current_pc + 2 < func_end && current_pc < pc + 40; current_pc += 2) for (current_pc = pc;
current_pc + 2 < func_end && current_pc < pc + 40;
current_pc += 2)
{ {
unsigned short insn = read_memory_unsigned_integer (current_pc, 2); unsigned short insn = read_memory_unsigned_integer (current_pc, 2);
@ -362,7 +366,8 @@ thumb_skip_prologue (CORE_ADDR pc, CORE_ADDR func_end)
{ {
findmask |= 1; /* push found */ findmask |= 1; /* push found */
} }
else if ((insn & 0xff00) == 0xb000) /* add sp, #simm OR sub sp, #simm */ else if ((insn & 0xff00) == 0xb000) /* add sp, #simm OR
sub sp, #simm */
{ {
if ((findmask & 1) == 0) /* before push ? */ if ((findmask & 1) == 0) /* before push ? */
continue; continue;
@ -379,18 +384,21 @@ thumb_skip_prologue (CORE_ADDR pc, CORE_ADDR func_end)
} }
else if (findmask == (4+2+1)) else if (findmask == (4+2+1))
{ {
break; /* We have found one of each type of prologue instruction */ /* We have found one of each type of prologue instruction */
break;
} }
else else
continue; /* something in the prolog that we don't care about or some /* something in the prolog that we don't care about or some
instruction from outside the prolog scheduled here for optimization */ instruction from outside the prolog scheduled here for
optimization */
continue;
} }
return current_pc; return current_pc;
} }
/* Advance the PC across any function entry prologue instructions to reach /* Advance the PC across any function entry prologue instructions to
some "real" code. reach some "real" code.
The APCS (ARM Procedure Call Standard) defines the following The APCS (ARM Procedure Call Standard) defines the following
prologue: prologue:
@ -500,8 +508,8 @@ arm_skip_prologue (CORE_ADDR pc)
The frame size would thus be 36 bytes, and the frame offset would be The frame size would thus be 36 bytes, and the frame offset would be
12 bytes. The frame register is R7. 12 bytes. The frame register is R7.
The comments for thumb_skip_prolog() describe the algorithm we use to detect The comments for thumb_skip_prolog() describe the algorithm we use
the end of the prolog */ to detect the end of the prolog. */
/* *INDENT-ON* */ /* *INDENT-ON* */
static void static void
@ -510,12 +518,14 @@ thumb_scan_prologue (struct frame_info *fi)
CORE_ADDR prologue_start; CORE_ADDR prologue_start;
CORE_ADDR prologue_end; CORE_ADDR prologue_end;
CORE_ADDR current_pc; CORE_ADDR current_pc;
int saved_reg[16]; /* which register has been copied to register n? */ /* Which register has been copied to register n? */
int findmask = 0; /* findmask: int saved_reg[16];
bit 0 - push { rlist } /* findmask:
bit 1 - mov r7, sp OR add r7, sp, #imm (setting of r7) bit 0 - push { rlist }
bit 2 - sub sp, #simm OR add sp, #simm (adjusting of sp) bit 1 - mov r7, sp OR add r7, sp, #imm (setting of r7)
*/ bit 2 - sub sp, #simm OR add sp, #simm (adjusting of sp)
*/
int findmask = 0;
int i; int i;
if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end)) if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end))
@ -528,8 +538,9 @@ thumb_scan_prologue (struct frame_info *fi)
prologue_end = sal.end; /* (probably means no prologue) */ prologue_end = sal.end; /* (probably means no prologue) */
} }
else else
prologue_end = prologue_start + 40; /* We're in the boondocks: allow for */ /* We're in the boondocks: allow for
/* 16 pushes, an add, and "mv fp,sp" */ 16 pushes, an add, and "mv fp,sp". */
prologue_end = prologue_start + 40;
prologue_end = min (prologue_end, fi->pc); prologue_end = min (prologue_end, fi->pc);
@ -568,10 +579,12 @@ thumb_scan_prologue (struct frame_info *fi)
fi->extra_info->framesize += 4; fi->extra_info->framesize += 4;
fi->saved_regs[saved_reg[regno]] = fi->saved_regs[saved_reg[regno]] =
-(fi->extra_info->framesize); -(fi->extra_info->framesize);
saved_reg[regno] = regno; /* reset saved register map */ /* Reset saved register map. */
saved_reg[regno] = regno;
} }
} }
else if ((insn & 0xff00) == 0xb000) /* add sp, #simm OR sub sp, #simm */ else if ((insn & 0xff00) == 0xb000) /* add sp, #simm OR
sub sp, #simm */
{ {
if ((findmask & 1) == 0) /* before push ? */ if ((findmask & 1) == 0) /* before push ? */
continue; continue;
@ -602,13 +615,15 @@ thumb_scan_prologue (struct frame_info *fi)
} }
else if ((insn & 0xffc0) == 0x4640) /* mov r0-r7, r8-r15 */ else if ((insn & 0xffc0) == 0x4640) /* mov r0-r7, r8-r15 */
{ {
int lo_reg = insn & 7; /* dest. register (r0-r7) */ int lo_reg = insn & 7; /* dest. register (r0-r7) */
int hi_reg = ((insn >> 3) & 7) + 8; /* source register (r8-15) */ int hi_reg = ((insn >> 3) & 7) + 8; /* source register (r8-15) */
saved_reg[lo_reg] = hi_reg; /* remember hi reg was saved */ saved_reg[lo_reg] = hi_reg; /* remember hi reg was saved */
} }
else else
continue; /* something in the prolog that we don't care about or some /* Something in the prolog that we don't care about or some
instruction from outside the prolog scheduled here for optimization */ instruction from outside the prolog scheduled here for
optimization. */
continue;
} }
} }
@ -936,7 +951,7 @@ arm_find_callers_reg (struct frame_info *fi, int regnum)
{ {
for (; fi; fi = fi->next) for (; fi; fi = fi->next)
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
return generic_read_register_dummy (fi->pc, fi->frame, regnum); return generic_read_register_dummy (fi->pc, fi->frame, regnum);
else else
@ -955,7 +970,7 @@ arm_find_callers_reg (struct frame_info *fi, int regnum)
static CORE_ADDR static CORE_ADDR
arm_frame_chain (struct frame_info *fi) arm_frame_chain (struct frame_info *fi)
{ {
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
CORE_ADDR fn_start, callers_pc, fp; CORE_ADDR fn_start, callers_pc, fp;
/* is this a dummy frame? */ /* is this a dummy frame? */
@ -1053,11 +1068,11 @@ arm_init_extra_frame_info (int fromleaf, struct frame_info *fi)
memset (fi->saved_regs, '\000', sizeof fi->saved_regs); memset (fi->saved_regs, '\000', sizeof fi->saved_regs);
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
{ {
/* We need to setup fi->frame here because run_stack_dummy gets it wrong /* We need to setup fi->frame here because run_stack_dummy gets
by assuming it's always FP. */ it wrong by assuming it's always FP. */
fi->frame = generic_read_register_dummy (fi->pc, fi->frame, fi->frame = generic_read_register_dummy (fi->pc, fi->frame,
ARM_SP_REGNUM); ARM_SP_REGNUM);
fi->extra_info->framesize = 0; fi->extra_info->framesize = 0;
@ -1067,8 +1082,8 @@ arm_init_extra_frame_info (int fromleaf, struct frame_info *fi)
else else
#endif #endif
/* Compute stack pointer for this frame. We use this value for both the /* Compute stack pointer for this frame. We use this value for both
sigtramp and call dummy cases. */ the sigtramp and call dummy cases. */
if (!fi->next) if (!fi->next)
sp = read_sp(); sp = read_sp();
else else
@ -1168,7 +1183,7 @@ arm_init_extra_frame_info (int fromleaf, struct frame_info *fi)
static CORE_ADDR static CORE_ADDR
arm_frame_saved_pc (struct frame_info *fi) arm_frame_saved_pc (struct frame_info *fi)
{ {
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
return generic_read_register_dummy (fi->pc, fi->frame, ARM_PC_REGNUM); return generic_read_register_dummy (fi->pc, fi->frame, ARM_PC_REGNUM);
else else
@ -1456,10 +1471,10 @@ arm_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
return sp; return sp;
} }
/* Pop the current frame. So long as the frame info has been initialized /* Pop the current frame. So long as the frame info has been
properly (see arm_init_extra_frame_info), this code works for dummy frames initialized properly (see arm_init_extra_frame_info), this code
as well as regular frames. I.e, there's no need to have a special case works for dummy frames as well as regular frames. I.e, there's no
for dummy frames. */ need to have a special case for dummy frames. */
static void static void
arm_pop_frame (void) arm_pop_frame (void)
{ {
@ -2022,10 +2037,11 @@ gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info)
if (csym.native == NULL) if (csym.native == NULL)
{ {
/* Create a fake symbol vector containing a Thumb symbol. This is /* Create a fake symbol vector containing a Thumb symbol.
solely so that the code in print_insn_little_arm() and This is solely so that the code in print_insn_little_arm()
print_insn_big_arm() in opcodes/arm-dis.c will detect the presence and print_insn_big_arm() in opcodes/arm-dis.c will detect
of a Thumb symbol and switch to decoding Thumb instructions. */ the presence of a Thumb symbol and switch to decoding
Thumb instructions. */
fake_target.flavour = bfd_target_coff_flavour; fake_target.flavour = bfd_target_coff_flavour;
fake_bfd.xvec = &fake_target; fake_bfd.xvec = &fake_target;
@ -2381,10 +2397,10 @@ arm_skip_stub (CORE_ADDR pc)
return 0; /* not a stub */ return 0; /* not a stub */
} }
/* If the user changes the register disassembly flavor used for info register /* If the user changes the register disassembly flavor used for info
and other commands, we have to also switch the flavor used in opcodes register and other commands, we have to also switch the flavor used
for disassembly output. in opcodes for disassembly output. This function is run in the set
This function is run in the set disassembly_flavor command, and does that. */ disassembly_flavor command, and does that. */
static void static void
set_disassembly_flavor_sfunc (char *args, int from_tty, set_disassembly_flavor_sfunc (char *args, int from_tty,
@ -2732,12 +2748,12 @@ arm_gdbarch_register_os_abi (enum arm_abi abi,
(*handler_p)->init_abi = init_abi; (*handler_p)->init_abi = init_abi;
} }
/* Initialize the current architecture based on INFO. If possible, re-use an /* Initialize the current architecture based on INFO. If possible,
architecture from ARCHES, which is a list of architectures already created re-use an architecture from ARCHES, which is a list of
during this debugging session. architectures already created during this debugging session.
Called e.g. at program startup, when reading a core file, and when reading Called e.g. at program startup, when reading a core file, and when
a binary file. */ reading a binary file. */
static struct gdbarch * static struct gdbarch *
arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)