32 int byte_order_for_code,
33 int has_thumb2_breakpoint,
37 self->byte_order = byte_order;
38 self->byte_order_for_code = byte_order_for_code;
39 self->has_thumb2_breakpoint = has_thumb2_breakpoint;
48 static std::vector<CORE_ADDR>
51 int byte_order_for_code =
self->byte_order_for_code;
55 unsigned short insn1, insn2;
58 int last_breakpoint = 0;
59 const int atomic_sequence_length = 16;
64 itstate = ((
status >> 8) & 0xfc) | ((
status >> 25) & 0x3);
69 insn1 =
self->ops->read_mem_uint (
loc, 2, byte_order_for_code);
75 insn2 =
self->ops->read_mem_uint (
loc, 2, byte_order_for_code);
78 if (!((insn1 & 0xfff0) == 0xe850
79 || ((insn1 & 0xfff0) == 0xe8d0 && (insn2 & 0x00c0) == 0x0040)))
84 for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
86 insn1 =
self->ops->read_mem_uint (
loc, 2,byte_order_for_code);
94 if ((insn1 & 0xf000) == 0xd000 &&
bits (insn1, 8, 11) != 0x0f)
96 if (last_breakpoint > 0)
100 breaks[1] =
loc + 2 + (
sbits (insn1, 0, 7) << 1);
113 insn2 =
self->ops->read_mem_uint (
loc, 2, byte_order_for_code);
120 if ((insn1 & 0xf800) == 0xf000
121 && (insn2 & 0xd000) == 0x8000
122 && (insn1 & 0x0380) != 0x0380)
124 int sign, j1, j2, imm1, imm2;
127 sign =
sbits (insn1, 10, 10);
128 imm1 =
bits (insn1, 0, 5);
129 imm2 =
bits (insn2, 0, 10);
130 j1 =
bit (insn2, 13);
131 j2 =
bit (insn2, 11);
133 offset = (sign << 20) + (j2 << 19) + (j1 << 18);
134 offset += (imm1 << 12) + (imm2 << 1);
136 if (last_breakpoint > 0)
152 if ((insn1 & 0xfff0) == 0xe840
153 || ((insn1 & 0xfff0) == 0xe8c0 && (insn2 & 0x00c0) == 0x0040))
159 if (insn_count == atomic_sequence_length)
168 && (breaks[1] == breaks[0]
169 || (breaks[1] >= pc && breaks[1] <
loc)))
172 std::vector<CORE_ADDR> next_pcs;
175 for (index = 0; index <= last_breakpoint; index++)
186 static std::vector<CORE_ADDR>
189 int byte_order_for_code =
self->byte_order_for_code;
196 int last_breakpoint = 0;
197 const int atomic_sequence_length = 16;
202 insn =
self->ops->read_mem_uint (
loc, 4, byte_order_for_code);
205 if ((insn & 0xff9000f0) != 0xe1900090)
210 for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
212 insn =
self->ops->read_mem_uint (
loc, 4, byte_order_for_code);
219 if (
bits (insn, 24, 27) == 0xa)
221 if (last_breakpoint > 0)
236 if ((insn & 0xff9000f0) == 0xe1800090)
241 if (insn_count == atomic_sequence_length)
250 && (breaks[1] == breaks[0]
251 || (breaks[1] >= pc && breaks[1] <
loc)))
254 std::vector<CORE_ADDR> next_pcs;
257 for (index = 0; index <= last_breakpoint; index++)
258 next_pcs.push_back (breaks[index]);
265 static std::vector<CORE_ADDR>
268 int byte_order =
self->byte_order;
269 int byte_order_for_code =
self->byte_order_for_code;
271 unsigned long pc_val = ((
unsigned long) pc) + 4;
272 unsigned short inst1;
277 std::vector<CORE_ADDR> next_pcs;
282 inst1 =
self->ops->read_mem_uint (pc, 2, byte_order_for_code);
293 itstate = ((
status >> 8) & 0xfc) | ((
status >> 25) & 0x3);
303 if (self->has_thumb2_breakpoint)
305 if ((inst1 & 0xff00) == 0xbf00 && (inst1 & 0x000f) != 0)
310 itstate = inst1 & 0x00ff;
315 inst1 =
self->ops->read_mem_uint (pc, 2,byte_order_for_code);
323 else if (itstate != 0)
334 inst1 =
self->ops->read_mem_uint (pc, 2, byte_order_for_code);
343 else if ((itstate & 0x0f) == 0x08)
368 cond_negated = (itstate >> 4) & 1;
377 inst1 =
self->ops->read_mem_uint (pc, 2, byte_order_for_code);
381 while (itstate != 0 && ((itstate >> 4) & 1) == cond_negated);
389 else if (itstate & 0x0f)
392 int cond = itstate >> 4;
406 if ((inst1 & 0xff00) == 0xbd00)
414 nextpc =
self->ops->read_mem_uint (sp +
offset, 4, byte_order);
416 else if ((inst1 & 0xf000) == 0xd000)
418 unsigned long cond =
bits (inst1, 8, 11);
421 nextpc =
self->ops->syscall_next_pc (
self);
424 nextpc = pc_val + (
sbits (inst1, 0, 7) << 1);
426 else if ((inst1 & 0xf800) == 0xe000)
428 nextpc = pc_val + (
sbits (inst1, 0, 10) << 1);
432 unsigned short inst2;
433 inst2 =
self->ops->read_mem_uint (pc + 2, 2, byte_order_for_code);
439 if ((inst1 & 0xf800) == 0xf000 && (inst2 & 0x8000) == 0x8000)
443 if ((inst2 & 0x1000) != 0 || (inst2 & 0xd001) == 0xc000)
446 int j1, j2, imm1, imm2;
448 imm1 =
sbits (inst1, 0, 10);
449 imm2 =
bits (inst2, 0, 10);
450 j1 =
bit (inst2, 13);
451 j2 =
bit (inst2, 11);
453 offset = ((imm1 << 12) + (imm2 << 1));
454 offset ^= ((!j2) << 22) | ((!j1) << 23);
458 if (
bit (inst2, 12) == 0)
459 nextpc = nextpc & 0xfffffffc;
461 else if (inst1 == 0xf3de && (inst2 & 0xff00) == 0x3f00)
465 nextpc -= inst2 & 0x00ff;
467 else if ((inst2 & 0xd000) == 0x8000 && (inst1 & 0x0380) != 0x0380)
472 int sign, j1, j2, imm1, imm2;
474 sign =
sbits (inst1, 10, 10);
475 imm1 =
bits (inst1, 0, 5);
476 imm2 =
bits (inst2, 0, 10);
477 j1 =
bit (inst2, 13);
478 j2 =
bit (inst2, 11);
480 offset = (sign << 20) + (j2 << 19) + (j1 << 18);
481 offset += (imm1 << 12) + (imm2 << 1);
487 else if ((inst1 & 0xfe50) == 0xe810)
490 int rn,
offset, load_pc = 1;
492 rn =
bits (inst1, 0, 3);
493 if (
bit (inst1, 7) && !
bit (inst1, 8))
496 if (!
bit (inst2, 15))
500 else if (!
bit (inst1, 7) &&
bit (inst1, 8))
503 if (!
bit (inst2, 15))
507 else if (
bit (inst1, 7) &&
bit (inst1, 8))
512 else if (!
bit (inst1, 7) && !
bit (inst1, 8))
523 nextpc =
self->ops->read_mem_uint (addr +
offset, 4, byte_order);
526 else if ((inst1 & 0xffef) == 0xea4f && (inst2 & 0xfff0) == 0x0f00)
532 else if ((inst1 & 0xff70) == 0xf850 && (inst2 & 0xf000) == 0xf000)
538 rn =
bits (inst1, 0, 3);
544 base +=
bits (inst2, 0, 11);
546 base -=
bits (inst2, 0, 11);
548 else if (
bit (inst1, 7))
549 base +=
bits (inst2, 0, 11);
550 else if (
bit (inst2, 11))
555 base +=
bits (inst2, 0, 7);
557 base -=
bits (inst2, 0, 7);
560 else if ((inst2 & 0x0fc0) == 0x0000)
562 int shift =
bits (inst2, 4, 5), rm =
bits (inst2, 0, 3);
571 =
self->ops->read_mem_uint (base, 4, byte_order);
573 else if ((inst1 & 0xfff0) == 0xe8d0 && (inst2 & 0xfff0) == 0xf000)
578 tbl_reg =
bits (inst1, 0, 3);
585 length = 2 *
self->ops->read_mem_uint (table +
offset, 1, byte_order);
586 nextpc = pc_val + length;
588 else if ((inst1 & 0xfff0) == 0xe8d0 && (inst2 & 0xfff0) == 0xf010)
593 tbl_reg =
bits (inst1, 0, 3);
600 length = 2 *
self->ops->read_mem_uint (table +
offset, 2, byte_order);
601 nextpc = pc_val + length;
604 else if ((inst1 & 0xff00) == 0x4700)
606 if (
bits (inst1, 3, 6) == 0x0f)
611 else if ((inst1 & 0xff87) == 0x4687)
613 if (
bits (inst1, 3, 6) == 0x0f)
620 else if ((inst1 & 0xf500) == 0xb100)
623 int imm = (
bit (inst1, 9) << 6) + (
bits (inst1, 3, 7) << 1);
626 if (
bit (inst1, 11) &&
reg != 0)
627 nextpc = pc_val + imm;
628 else if (!
bit (inst1, 11) &&
reg == 0)
629 nextpc = pc_val + imm;
632 next_pcs.push_back (nextpc);
645 static std::vector<CORE_ADDR>
648 int byte_order =
self->byte_order;
649 int byte_order_for_code =
self->byte_order_for_code;
650 unsigned long pc_val;
651 unsigned long this_instr = 0;
656 std::vector<CORE_ADDR> next_pcs;
658 pc_val = (
unsigned long) pc;
659 this_instr =
self->ops->read_mem_uint (pc, 4, byte_order_for_code);
665 switch (
bits (this_instr, 24, 27))
672 nextpc |=
bit (this_instr, 24) << 1;
680 if (
bits (this_instr, 12, 15) == 15)
681 error (
_(
"Invalid update to pc in instruction"));
686 switch (
bits (this_instr, 24, 27))
693 unsigned long operand1, operand2, result = 0;
697 if (
bits (this_instr, 12, 15) != 15)
700 if (
bits (this_instr, 22, 25) == 0
701 &&
bits (this_instr, 4, 7) == 9)
702 error (
_(
"Invalid update to pc in instruction"));
705 if (
bits (this_instr, 4, 27) == 0x12fff1
706 ||
bits (this_instr, 4, 27) == 0x12fff3)
708 rn =
bits (this_instr, 0, 3);
713 next_pcs.push_back (nextpc);
719 rn =
bits (this_instr, 16, 19);
724 if (
bit (this_instr, 25))
726 unsigned long immval =
bits (this_instr, 0, 7);
727 unsigned long rotate = 2 *
bits (this_instr, 8, 11);
728 operand2 = ((immval >> rotate) | (immval << (32 - rotate)))
735 switch (
bits (this_instr, 21, 24))
738 result = operand1 & operand2;
742 result = operand1 ^ operand2;
746 result = operand1 - operand2;
750 result = operand2 - operand1;
754 result = operand1 + operand2;
758 result = operand1 + operand2 + c;
762 result = operand1 - operand2 + c;
766 result = operand2 - operand1 + c;
773 result = (
unsigned long) nextpc;
777 result = operand1 | operand2;
786 result = operand1 & ~operand2;
793 nextpc =
self->ops->addr_bits_remove (
self, result);
801 if (
bits (this_instr, 25, 27) == 0x3 &&
bit (this_instr, 4) == 1)
808 if (
bit (this_instr, 20))
811 if (
bits (this_instr, 12, 15) == 15)
817 if (
bit (this_instr, 22))
818 error (
_(
"Invalid update to pc in instruction"));
821 rn =
bits (this_instr, 16, 19);
826 if (
bit (this_instr, 24))
831 (
bit (this_instr, 25)
834 :
bits (this_instr, 0, 11));
836 if (
bit (this_instr, 23))
850 if (
bit (this_instr, 20))
853 if (
bit (this_instr, 15))
860 bits (this_instr, 16, 19));
862 if (
bit (this_instr, 23))
865 unsigned long reglist =
bits (this_instr, 0, 14);
867 if (
bit (this_instr, 24))
870 else if (
bit (this_instr, 24))
873 rn_val_offset = rn_val +
offset;
874 nextpc = (
CORE_ADDR) self->ops->read_mem_uint (rn_val_offset,
893 nextpc =
self->ops->syscall_next_pc (
self);
898 error (
_(
"Bad bit-field extraction"));
903 next_pcs.push_back (nextpc);
910 std::vector<CORE_ADDR>
913 std::vector<CORE_ADDR> next_pcs;
915 if (self->ops->is_thumb (
self))
918 if (next_pcs.empty ())
924 if (next_pcs.empty ())
928 if (self->ops->fixup != NULL)
931 pc_ref =
self->ops->fixup (
self, pc_ref);
ULONGEST regcache_raw_get_unsigned(struct regcache *regcache, int regnum)
regcache(gdbarch *gdbarch)
#define BranchDest(addr, instr)
static std::vector< CORE_ADDR > arm_get_next_pcs_raw(struct arm_get_next_pcs *self)
std::vector< CORE_ADDR > arm_get_next_pcs(struct arm_get_next_pcs *self)
#define bits(obj, st, fn)
int thumb_instruction_changes_pc(unsigned short inst)
static std::vector< CORE_ADDR > thumb_get_next_pcs_raw(struct arm_get_next_pcs *self)
#define sbits(obj, st, fn)
int thumb_advance_itstate(unsigned int itstate)
int thumb_insn_size(unsigned short inst1)
int arm_instruction_changes_pc(uint32_t this_instr)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
#define INT_REGISTER_SIZE
CORE_ADDR regcache_read_pc(struct regcache *regcache)
int bitcount(unsigned long val)
void arm_get_next_pcs_ctor(struct arm_get_next_pcs *self, struct arm_get_next_pcs_ops *ops, int byte_order, int byte_order_for_code, int has_thumb2_breakpoint, struct regcache *regcache)
static std::vector< CORE_ADDR > thumb_deal_with_atomic_sequence_raw(struct arm_get_next_pcs *self)
unsigned long long ULONGEST
int condition_true(unsigned long cond, unsigned long status_reg)
unsigned long shifted_reg_val(struct regcache *regcache, unsigned long inst, int carry, unsigned long pc_val, unsigned long status_reg)
static std::vector< CORE_ADDR > arm_deal_with_atomic_sequence_raw(struct arm_get_next_pcs *self)
int thumb2_instruction_changes_pc(unsigned short inst1, unsigned short inst2)
#define UNMAKE_THUMB_ADDR(addr)
void error(const char *fmt,...)
#define MAKE_THUMB_ADDR(addr)