24 #include <asm/ptrace.h> 31 #define PPC_FIELD(value, from, len) \ 32 (((value) >> (32 - (from) - (len))) & ((1 << (len)) - 1)) 33 #define PPC_SEXT(v, bs) \ 34 ((((CORE_ADDR) (v) & (((CORE_ADDR) 1 << (bs)) - 1)) \ 35 ^ ((CORE_ADDR) 1 << ((bs) - 1))) \ 36 - ((CORE_ADDR) 1 << ((bs) - 1))) 37 #define PPC_OP6(insn) PPC_FIELD (insn, 0, 6) 38 #define PPC_BO(insn) PPC_FIELD (insn, 6, 5) 39 #define PPC_LI(insn) (PPC_SEXT (PPC_FIELD (insn, 6, 24), 24) << 2) 40 #define PPC_BD(insn) (PPC_SEXT (PPC_FIELD (insn, 16, 14), 14) << 2) 45 #define ppc_num_regs 73 51 {PT_R0 * 8, PT_R1 * 8, PT_R2 * 8, PT_R3 * 8,
52 PT_R4 * 8, PT_R5 * 8, PT_R6 * 8, PT_R7 * 8,
53 PT_R8 * 8, PT_R9 * 8, PT_R10 * 8, PT_R11 * 8,
54 PT_R12 * 8, PT_R13 * 8, PT_R14 * 8, PT_R15 * 8,
55 PT_R16 * 8, PT_R17 * 8, PT_R18 * 8, PT_R19 * 8,
56 PT_R20 * 8, PT_R21 * 8, PT_R22 * 8, PT_R23 * 8,
57 PT_R24 * 8, PT_R25 * 8, PT_R26 * 8, PT_R27 * 8,
58 PT_R28 * 8, PT_R29 * 8, PT_R30 * 8, PT_R31 * 8,
59 PT_FPR0*8, PT_FPR0*8 + 8, PT_FPR0*8+16, PT_FPR0*8+24,
60 PT_FPR0*8+32, PT_FPR0*8+40, PT_FPR0*8+48, PT_FPR0*8+56,
61 PT_FPR0*8+64, PT_FPR0*8+72, PT_FPR0*8+80, PT_FPR0*8+88,
62 PT_FPR0*8+96, PT_FPR0*8+104, PT_FPR0*8+112, PT_FPR0*8+120,
63 PT_FPR0*8+128, PT_FPR0*8+136, PT_FPR0*8+144, PT_FPR0*8+152,
64 PT_FPR0*8+160, PT_FPR0*8+168, PT_FPR0*8+176, PT_FPR0*8+184,
65 PT_FPR0*8+192, PT_FPR0*8+200, PT_FPR0*8+208, PT_FPR0*8+216,
66 PT_FPR0*8+224, PT_FPR0*8+232, PT_FPR0*8+240, PT_FPR0*8+248,
67 PT_NIP * 8, PT_MSR * 8, PT_CCR * 8, PT_LNK * 8,
68 PT_CTR * 8, PT_XER * 8, PT_FPR0*8 + 256,
73 {PT_R0 * 4, PT_R1 * 4, PT_R2 * 4, PT_R3 * 4,
74 PT_R4 * 4, PT_R5 * 4, PT_R6 * 4, PT_R7 * 4,
75 PT_R8 * 4, PT_R9 * 4, PT_R10 * 4, PT_R11 * 4,
76 PT_R12 * 4, PT_R13 * 4, PT_R14 * 4, PT_R15 * 4,
77 PT_R16 * 4, PT_R17 * 4, PT_R18 * 4, PT_R19 * 4,
78 PT_R20 * 4, PT_R21 * 4, PT_R22 * 4, PT_R23 * 4,
79 PT_R24 * 4, PT_R25 * 4, PT_R26 * 4, PT_R27 * 4,
80 PT_R28 * 4, PT_R29 * 4, PT_R30 * 4, PT_R31 * 4,
81 PT_FPR0*4, PT_FPR0*4 + 8, PT_FPR0*4+16, PT_FPR0*4+24,
82 PT_FPR0*4+32, PT_FPR0*4+40, PT_FPR0*4+48, PT_FPR0*4+56,
83 PT_FPR0*4+64, PT_FPR0*4+72, PT_FPR0*4+80, PT_FPR0*4+88,
84 PT_FPR0*4+96, PT_FPR0*4+104, PT_FPR0*4+112, PT_FPR0*4+120,
85 PT_FPR0*4+128, PT_FPR0*4+136, PT_FPR0*4+144, PT_FPR0*4+152,
86 PT_FPR0*4+160, PT_FPR0*4+168, PT_FPR0*4+176, PT_FPR0*4+184,
87 PT_FPR0*4+192, PT_FPR0*4+200, PT_FPR0*4+208, PT_FPR0*4+216,
88 PT_FPR0*4+224, PT_FPR0*4+232, PT_FPR0*4+240, PT_FPR0*4+248,
89 PT_NIP * 4, PT_MSR * 4, PT_CCR * 4, PT_LNK * 4,
90 PT_CTR * 4, PT_XER * 4, PT_FPSCR * 4,
95 {PT_R0 * 4, PT_R1 * 4, PT_R2 * 4, PT_R3 * 4,
96 PT_R4 * 4, PT_R5 * 4, PT_R6 * 4, PT_R7 * 4,
97 PT_R8 * 4, PT_R9 * 4, PT_R10 * 4, PT_R11 * 4,
98 PT_R12 * 4, PT_R13 * 4, PT_R14 * 4, PT_R15 * 4,
99 PT_R16 * 4, PT_R17 * 4, PT_R18 * 4, PT_R19 * 4,
100 PT_R20 * 4, PT_R21 * 4, PT_R22 * 4, PT_R23 * 4,
101 PT_R24 * 4, PT_R25 * 4, PT_R26 * 4, PT_R27 * 4,
102 PT_R28 * 4, PT_R29 * 4, PT_R30 * 4, PT_R31 * 4,
111 PT_NIP * 4, PT_MSR * 4, PT_CCR * 4, PT_LNK * 4,
112 PT_CTR * 4, PT_XER * 4, -1,
122 #ifndef __powerpc64__ 146 memset (buf, 0,
sizeof (
long));
148 if (__BYTE_ORDER == __LITTLE_ENDIAN)
153 else if (__BYTE_ORDER == __BIG_ENDIAN)
160 if (size <
sizeof (
long))
171 int regno,
const char *buf)
173 if (__BYTE_ORDER == __LITTLE_ENDIAN)
178 else if (__BYTE_ORDER == __BIG_ENDIAN)
185 if (size <
sizeof (
long))
195 #define INSTR_SC 0x44000002 196 #define NR_spu_run 0x0116 210 unsigned int pc, r0, r3, r4;
222 unsigned long pc, r0, r3, r4;
235 (
unsigned char *) &curr_insn, 4) != 0)
282 unsigned int newpc = pc;
287 unsigned int newpc = pc;
292 unsigned long newpc = pc;
303 unsigned char *data = (
unsigned char *)
alloca (2 * wordsize);
310 unsigned int *data_p = (
unsigned int *)data;
311 if (data_p[0] == type)
319 unsigned long *data_p = (
unsigned long *)data;
320 if (data_p[0] == type)
334 #ifndef __powerpc64__ 343 #define ppc_breakpoint_len 4 362 sprintf (mem_annex,
"%d/mem", (
int)((where >> 32) & 0x7fffffff));
364 NULL, where & 0xffffffff, 4);
450 for (i = 0; i < 32; i++)
453 for (i = 64; i < 70; i++)
456 for (i = 71; i < 73; i++)
460 #define SIZEOF_VSXREGS 32*8 466 char *regset = (
char *) buf;
472 for (i = 0; i < 32; i++)
480 const char *regset = (
const char *) buf;
486 for (i = 0; i < 32; i++)
490 #define SIZEOF_VRREGS 33*16+4 496 char *regset = (
char *) buf;
502 for (i = 0; i < 32; i++)
513 const char *regset = (
const char *) buf;
519 for (i = 0; i < 32; i++)
543 for (i = 0; i < 32; i++)
560 for (i = 0; i < 32; i++)
627 tdesc = tdesc_powerpc_64l;
635 if (ppc64_64bit_inferior_p (msr))
639 tdesc = tdesc_powerpc_cell64l;
650 tdesc = tdesc_powerpc_isa205_vsx64l;
652 tdesc = tdesc_powerpc_vsx64l;
657 tdesc = tdesc_powerpc_isa205_altivec64l;
659 tdesc = tdesc_powerpc_altivec64l;
691 #ifndef __powerpc64__ 751 #define EF_PPC64_ABI 3 758 is_elfv2_inferior (
void)
763 const int def_res = 1;
765 const int def_res = 0;
777 if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG))
780 return (ehdr.e_flags & EF_PPC64_ABI) == 2;
792 gen_ds_form (uint32_t *buf,
int opcd,
int rst,
int ra,
int ds,
int xo)
801 insn = (rst << 21) | (ra << 16) | (ds & 0xfffc) | (xo & 0
x3);
802 *buf = (opcd << 26) | insn;
808 #define GEN_STD(buf, rs, ra, offset) gen_ds_form (buf, 62, rs, ra, offset, 0) 809 #define GEN_STDU(buf, rs, ra, offset) gen_ds_form (buf, 62, rs, ra, offset, 1) 810 #define GEN_LD(buf, rt, ra, offset) gen_ds_form (buf, 58, rt, ra, offset, 0) 811 #define GEN_LDU(buf, rt, ra, offset) gen_ds_form (buf, 58, rt, ra, offset, 1) 819 gen_d_form (uint32_t *buf,
int opcd,
int rst,
int ra,
int si)
827 insn = (rst << 21) | (ra << 16) | (si & 0xffff);
828 *buf = (opcd << 26) | insn;
834 #define GEN_ADDI(buf, rt, ra, si) gen_d_form (buf, 14, rt, ra, si) 835 #define GEN_ADDIS(buf, rt, ra, si) gen_d_form (buf, 15, rt, ra, si) 836 #define GEN_LI(buf, rt, si) GEN_ADDI (buf, rt, 0, si) 837 #define GEN_LIS(buf, rt, si) GEN_ADDIS (buf, rt, 0, si) 838 #define GEN_ORI(buf, rt, ra, si) gen_d_form (buf, 24, rt, ra, si) 839 #define GEN_ORIS(buf, rt, ra, si) gen_d_form (buf, 25, rt, ra, si) 840 #define GEN_LWZ(buf, rt, ra, si) gen_d_form (buf, 32, rt, ra, si) 841 #define GEN_STW(buf, rt, ra, si) gen_d_form (buf, 36, rt, ra, si) 842 #define GEN_STWU(buf, rt, ra, si) gen_d_form (buf, 37, rt, ra, si) 854 unsigned int n = ((ri & 0x1f) << 5) | ((ri >> 5) & 0x1f);
860 insn = (rst << 21) | (n << 11) | (xo << 1);
861 *buf = (opcd << 26) | insn;
867 #define GEN_MFSPR(buf, rt, spr) gen_xfx_form (buf, 31, rt, spr, 339) 868 #define GEN_MTSPR(buf, rt, spr) gen_xfx_form (buf, 31, rt, spr, 467) 869 #define GEN_MFCR(buf, rt) gen_xfx_form (buf, 31, rt, 0, 19) 870 #define GEN_MTCR(buf, rt) gen_xfx_form (buf, 31, rt, 0x3cf, 144) 871 #define GEN_SYNC(buf, L, E) gen_xfx_form (buf, 31, L & 0x3, \ 873 #define GEN_LWSYNC(buf) GEN_SYNC (buf, 1, 0) 882 gen_x_form (uint32_t *buf,
int opcd,
int rst,
int ra,
int rb,
int xo,
int rc)
893 insn = (rst << 21) | (ra << 16) | (rb << 11) | (xo << 1) | rc;
894 *buf = (opcd << 26) | insn;
900 #define GEN_OR(buf, ra, rs, rb) gen_x_form (buf, 31, rs, ra, rb, 444, 0) 901 #define GEN_MR(buf, ra, rs) GEN_OR (buf, ra, rs, rs) 902 #define GEN_LWARX(buf, rt, ra, rb) gen_x_form (buf, 31, rt, ra, rb, 20, 0) 903 #define GEN_STWCX(buf, rs, ra, rb) gen_x_form (buf, 31, rs, ra, rb, 150, 1) 905 #define GEN_CMPW(buf, ra, rb) gen_x_form (buf, 31, 28, ra, rb, 0, 0) 914 gen_md_form (uint32_t *buf,
int opcd,
int rs,
int ra,
int sh,
int mb,
918 unsigned int n = ((mb & 0x1f) << 1) | ((mb >> 5) & 0
x1);
919 unsigned int sh0_4 = sh & 0x1f;
920 unsigned int sh5 = (sh >> 5) & 1;
930 insn = (rs << 21) | (ra << 16) | (sh0_4 << 11) | (n << 5)
931 | (sh5 << 1) | (xo << 2) | (rc & 1);
932 *buf = (opcd << 26) | insn;
938 #define GEN_RLDICL(buf, ra, rs ,sh, mb) \ 939 gen_md_form (buf, 30, rs, ra, sh, mb, 0, 0) 940 #define GEN_RLDICR(buf, ra, rs ,sh, mb) \ 941 gen_md_form (buf, 30, rs, ra, sh, mb, 1, 0) 955 insn = (li & 0x3fffffc) | (aa & 1) | (lk & 1);
956 *buf = (opcd << 26) | insn;
962 #define GEN_B(buf, li) gen_i_form (buf, 18, li, 0, 0) 963 #define GEN_BL(buf, li) gen_i_form (buf, 18, li, 0, 1) 980 insn = (bo << 21) | (bi << 16) | (bd & 0xfffc) | (aa & 1) | (lk & 1);
981 *buf = (opcd << 26) | insn;
987 #define GEN_BNE(buf, bd) gen_b_form (buf, 16, 0x4, (7 << 2) | 2, bd, 0 ,0) 994 #define GEN_LOAD(buf, rt, ra, si, is_64) (is_64 ? \ 995 GEN_LD (buf, rt, ra, si) : \ 996 GEN_LWZ (buf, rt, ra, si)) 997 #define GEN_STORE(buf, rt, ra, si, is_64) (is_64 ? \ 998 GEN_STD (buf, rt, ra, si) : \ 999 GEN_STW (buf, rt, ra, si)) 1001 #define GEN_LOAD(buf, rt, ra, si, is_64) GEN_LWZ (buf, rt, ra, si) 1002 #define GEN_STORE(buf, rt, ra, si, is_64) GEN_STW (buf, rt, ra, si) 1009 gen_limm (uint32_t *buf,
int reg, uint64_t imm,
int is_64)
1013 if ((imm + 32768) < 65536)
1016 p +=
GEN_LI (p, reg, imm);
1018 else if ((imm >> 32) == 0)
1023 p +=
GEN_LIS (p, reg, (imm >> 16) & 0xffff);
1024 if ((imm & 0xffff) != 0)
1025 p +=
GEN_ORI (p, reg, reg, imm & 0xffff);
1027 if (imm & (1u << 31) && is_64)
1038 p +=
GEN_LIS (p, reg, ((imm >> 48) & 0xffff));
1039 if (((imm >> 32) & 0xffff) != 0)
1040 p +=
GEN_ORI (p, reg, reg, ((imm >> 32) & 0xffff));
1042 if (((imm >> 16) & 0xffff) != 0)
1043 p +=
GEN_ORIS (p, reg, reg, ((imm >> 16) & 0xffff));
1044 if ((imm & 0xffff) != 0)
1045 p +=
GEN_ORI (p, reg, reg, (imm & 0xffff));
1060 const int r_lock = 6;
1061 const int r_old = 7;
1062 const int r_tmp = 8;
1072 p +=
gen_limm (p, r_lock, lock, is_64);
1073 p +=
gen_limm (p, r_old, old_value, is_64);
1096 p +=
GEN_LOAD (p, 11, 12, 16, is_64);
1097 p +=
GEN_LOAD (p, 2, 12, 8, is_64);
1098 p +=
GEN_LOAD (p, 12, 12, 0, is_64);
1119 if (op6 == 18 && (insn & 2) == 0)
1123 newrel = (oldloc - *to) + rel;
1126 if (newrel >= (1 << 25) || newrel < -(1 << 25))
1129 insn = (insn & ~0x3fffffc) | (newrel & 0x3fffffc);
1131 else if (op6 == 16 && (insn & 2) == 0)
1173 newrel = (oldloc - *to) + rel;
1175 if (newrel < (1 << 15) && newrel >= -(1 << 15))
1176 insn = (insn & ~0xfffc) | (newrel & 0xfffc);
1177 else if ((
PPC_BO (insn) & 0x14) == 0
x4 || (
PPC_BO (insn) & 0x14) == 0x10)
1182 if (newrel >= (1 << 25) || newrel < -(1 << 25))
1187 else if ((
PPC_BO (insn) & 0x14) == 0x10)
1191 insn = (insn & ~0xfffc) | 0x8;
1196 insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
1202 else if ((
PPC_BO (insn) & 0x14) == 0)
1204 uint32_t bdnz_insn = (16 << 26) | (0x10 << 21) | 12;
1205 uint32_t bf_insn = (16 << 26) | (0
x4 << 21) | 8;
1210 if (newrel >= (1 << 25) || newrel < -(1 << 25))
1214 bf_insn |= (insn & 0x1f0000);
1217 bdnz_insn |= (insn ^ (1 << 22)) & (1 << 22);
1218 bf_insn |= (insn ^ (1 << 24)) & (1 << 24);
1226 insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
1235 if (newrel >= (1 << 25) || newrel < -(1 << 25))
1239 insn = (18 << 26) | (0x3fffffc & newrel) | (insn & 0x3);
1262 unsigned char *jjump_pad_insn,
1272 const CORE_ADDR entryaddr = *jump_entry;
1273 int rsz, min_frame, frame_size, tp_reg;
1274 #ifdef __powerpc64__ 1277 int is_opd = is_64 && !is_elfv2_inferior ();
1279 int is_64 = 0, is_opd = 0;
1282 #ifdef __powerpc64__ 1288 frame_size = (40 * rsz) + min_frame;
1296 frame_size = (40 * rsz) + min_frame;
1298 #ifdef __powerpc64__ 1335 p +=
GEN_STDU (p, 1, 1, -frame_size);
1337 p +=
GEN_STWU (p, 1, 1, -frame_size);
1341 for (j = 2; j < 32; j++)
1342 p +=
GEN_STORE (p, j, 1, min_frame + j * rsz, is_64);
1343 p +=
GEN_STORE (p, 0, 1, min_frame + 0 * rsz, is_64);
1346 p +=
GEN_ADDI (p, 0, 1, frame_size);
1347 p +=
GEN_STORE (p, 0, 1, min_frame + 1 * rsz, is_64);
1354 p +=
GEN_STORE (p, 3, 1, min_frame + 32 * rsz, is_64);
1355 p +=
GEN_STORE (p, 4, 1, min_frame + 33 * rsz, is_64);
1356 p +=
GEN_STORE (p, 5, 1, min_frame + 34 * rsz, is_64);
1357 p +=
GEN_STORE (p, 6, 1, min_frame + 35 * rsz, is_64);
1360 p +=
gen_limm (p, 3, tpaddr, is_64);
1361 p +=
GEN_STORE (p, 3, 1, min_frame + 36 * rsz, is_64);
1366 p +=
GEN_ADDI (p, 4, 1, min_frame);
1368 p +=
gen_limm (p, 3, tpoint, is_64);
1371 p +=
GEN_STORE (p, 3, 1, min_frame + 37 * rsz, is_64);
1372 p +=
GEN_STORE (p, tp_reg, 1, min_frame + 38 * rsz, is_64);
1381 p +=
gen_call (p, collector, is_64, is_opd);
1384 p +=
gen_limm (p, 3, lockaddr, is_64);
1390 p +=
GEN_LOAD (p, 3, 1, min_frame + 32 * rsz, is_64);
1391 p +=
GEN_LOAD (p, 4, 1, min_frame + 33 * rsz, is_64);
1392 p +=
GEN_LOAD (p, 5, 1, min_frame + 34 * rsz, is_64);
1393 p +=
GEN_LOAD (p, 6, 1, min_frame + 35 * rsz, is_64);
1400 for (j = 2; j < 32; j++)
1401 p +=
GEN_LOAD (p, j, 1, min_frame + j * rsz, is_64);
1402 p +=
GEN_LOAD (p, 0, 1, min_frame + 0 * rsz, is_64);
1404 p +=
GEN_ADDI (p, 1, 1, frame_size);
1410 *adjusted_insn_addr = buildaddr + (p - buf) * 4;
1411 *adjusted_insn_addr_end = *adjusted_insn_addr;
1416 if ((*adjusted_insn_addr_end - *adjusted_insn_addr == 0)
1417 || (*adjusted_insn_addr_end - *adjusted_insn_addr > 12))
1419 sprintf (err,
"E.Unexpected instruction length = %d" 1420 "when relocate instruction.",
1421 (
int) (*adjusted_insn_addr_end - *adjusted_insn_addr));
1425 buildaddr = *adjusted_insn_addr_end;
1428 offset = (tpaddr + 4) - buildaddr;
1431 sprintf (err,
"E.Jump back from jump pad too far from tracepoint " 1432 "(offset 0x%x > 26-bit).",
offset);
1438 *jump_entry = buildaddr + (p - buf) * 4;
1444 offset = entryaddr - tpaddr;
1447 sprintf (err,
"E.Jump back from jump pad too far from tracepoint " 1448 "(offset 0x%x > 26-bit).",
offset);
1453 *jjump_pad_insn_size = 4;
1472 n = n *
sizeof (uint32_t);
1477 #define __EMIT_ASM(NAME, INSNS) \ 1480 extern uint32_t start_bcax_ ## NAME []; \ 1481 extern uint32_t end_bcax_ ## NAME []; \ 1482 emit_insns (start_bcax_ ## NAME, \ 1483 end_bcax_ ## NAME - start_bcax_ ## NAME); \ 1484 __asm__ (".section .text.__ppcbcax\n\t" \ 1485 "start_bcax_" #NAME ":\n\t" \ 1487 "end_bcax_" #NAME ":\n\t" \ 1491 #define _EMIT_ASM(NAME, INSNS) __EMIT_ASM (NAME, INSNS) 1492 #define EMIT_ASM(INSNS) _EMIT_ASM (__LINE__, INSNS) 1540 #if __BYTE_ORDER == __LITTLE_ENDIAN 1541 #define TOP_FIRST "4" 1542 #define TOP_SECOND "3" 1543 #define TMP_FIRST "6" 1544 #define TMP_SECOND "5" 1546 #define TOP_FIRST "3" 1547 #define TOP_SECOND "4" 1548 #define TMP_FIRST "5" 1549 #define TMP_SECOND "6" 1563 "stw 31, 96-4(1) \n" 1564 "stw 30, 96-8(1) \n" 1565 "stw 4, 96-12(1) \n" 1566 "stw 3, 96-16(1) \n" 1617 "subfe 3, 3, 5 \n");
1819 "crand 6*4+0, 6*4+0, 7*4+2\n" 1821 "cror 7*4+0, 7*4+0, 6*4+0\n" 1823 "rlwinm 4, 4, 29, 31, 31 \n" 1838 "crand 6*4+0, 6*4+0, 7*4+2\n" 1840 "cror 7*4+0, 7*4+0, 6*4+0\n" 1842 "rlwinm 4, 4, 29, 31, 31 \n" 1867 if (__BYTE_ORDER == __LITTLE_ENDIAN)
1885 p +=
gen_limm (p, 3, num >> 32 & 0xffffffff, 0);
1886 p +=
gen_limm (p, 4, num & 0xffffffff, 0);
1889 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
1907 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
1909 if (__BYTE_ORDER == __LITTLE_ENDIAN)
1939 " addi 5, 30, -(8 + 8) \n" 1942 " stwu 31, -64(1) \n" 1943 "1:addi 30, 30, -8 \n");
1977 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
1991 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2005 p +=
gen_limm (p, 3, (uint32_t) arg1, 0);
2009 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2011 if (__BYTE_ORDER == __LITTLE_ENDIAN)
2035 if (__BYTE_ORDER == __LITTLE_ENDIAN)
2045 p +=
gen_limm (p, 3, (uint32_t) arg1, 0);
2053 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2144 "crand 6*4+0, 6*4+0, 7*4+2\n" 2146 "cror 7*4+0, 7*4+0, 6*4+0\n" 2167 "crandc 6*4+0, 7*4+2, 6*4+1\n" 2169 "cror 7*4+0, 7*4+0, 6*4+0\n" 2190 "crand 6*4+0, 6*4+1, 7*4+2\n" 2192 "cror 7*4+0, 7*4+1, 6*4+0\n" 2213 "crandc 6*4+0, 7*4+2, 6*4+0\n" 2215 "cror 7*4+0, 7*4+1, 6*4+0\n" 2235 long rel = to - from;
2240 opcd = (insn >> 26) & 0x3f;
2246 || (rel >= (1 << 15) || rel < -(1 << 15)))
2248 insn = (insn & ~0xfffc) | (rel & 0xfffc);
2252 || (rel >= (1 << 25) || rel < -(1 << 25)))
2254 insn = (insn & ~0x3fffffc) | (rel & 0x3fffffc);
2307 #ifdef __powerpc64__ 2354 ppc64v1_emit_prologue (
void)
2363 memcpy (buf, &opd,
sizeof buf);
2376 "stdu 1, -208(1) \n" 2378 "addi 30, 1, 168 \n" 2386 ppc64v2_emit_prologue (
void)
2399 "stdu 1, -208(1) \n" 2401 "addi 30, 1, 168 \n" 2409 ppc64_emit_epilogue (
void)
2430 ppc64_emit_add (
void)
2439 ppc64_emit_sub (
void)
2448 ppc64_emit_mul (
void)
2451 "mulld 3, 4, 3 \n");
2457 ppc64_emit_lsh (
void)
2467 ppc64_emit_rsh_signed (
void)
2477 ppc64_emit_rsh_unsigned (
void)
2486 ppc64_emit_ext (
int arg)
2507 ppc64_emit_zero_ext (
int arg)
2529 ppc64_emit_log_not (
void)
2538 ppc64_emit_bit_and (
void)
2547 ppc64_emit_bit_or (
void)
2556 ppc64_emit_bit_xor (
void)
2566 ppc64_emit_bit_not (
void)
2574 ppc64_emit_equal (
void)
2586 ppc64_emit_less_signed (
void)
2591 "rlwinm 3, 3, 29, 31, 31 \n");
2598 ppc64_emit_less_unsigned (
void)
2603 "rlwinm 3, 3, 29, 31, 31 \n");
2610 ppc64_emit_ref (
int size)
2632 ppc64_emit_const (
LONGEST num)
2640 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2647 ppc64v1_emit_reg (
int reg)
2653 p +=
GEN_LD (p, 3, 31, -32);
2657 p +=
GEN_LD (p, 2, 1, 40);
2660 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2666 ppc64v2_emit_reg (
int reg)
2672 p +=
GEN_LD (p, 3, 31, -32);
2676 p +=
GEN_LD (p, 2, 1, 24);
2679 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2685 ppc64_emit_pop (
void)
2696 ppc64_emit_stack_flush (
void)
2702 " addi 4, 30, -(112 + 8) \n" 2705 " stdu 31, -64(1) \n" 2706 "1:addi 30, 30, -8 \n");
2712 ppc64_emit_swap (
void)
2729 p +=
GEN_LD (p, 2, 1, 40);
2732 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2745 p +=
GEN_LD (p, 2, 1, 24);
2748 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2756 ppc64v1_emit_int_call_1 (
CORE_ADDR fn,
int arg1)
2765 p +=
GEN_LD (p, 2, 1, 40);
2768 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2774 ppc64v2_emit_int_call_1 (
CORE_ADDR fn,
int arg1)
2783 p +=
GEN_LD (p, 2, 1, 24);
2786 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2795 ppc64v1_emit_void_call_2 (
CORE_ADDR fn,
int arg1)
2808 p +=
GEN_LD (p, 2, 1, 40);
2811 p +=
GEN_LD (p, 3, 30, 0);
2814 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2820 ppc64v2_emit_void_call_2 (
CORE_ADDR fn,
int arg1)
2833 p +=
GEN_LD (p, 2, 1, 24);
2836 p +=
GEN_LD (p, 3, 30, 0);
2839 gdb_assert ((p - buf) <= (
sizeof (buf) /
sizeof (*buf)));
2845 ppc64_emit_if_goto (
int *offset_p,
int *size_p)
2860 ppc64_emit_eq_goto (
int *offset_p,
int *size_p)
2876 ppc64_emit_ne_goto (
int *offset_p,
int *size_p)
2892 ppc64_emit_lt_goto (
int *offset_p,
int *size_p)
2908 ppc64_emit_le_goto (
int *offset_p,
int *size_p)
2924 ppc64_emit_gt_goto (
int *offset_p,
int *size_p)
2940 ppc64_emit_ge_goto (
int *offset_p,
int *size_p)
2955 static struct emit_ops ppc64v1_emit_ops_impl =
2957 ppc64v1_emit_prologue,
2958 ppc64_emit_epilogue,
2963 ppc64_emit_rsh_signed,
2964 ppc64_emit_rsh_unsigned,
2972 ppc64_emit_less_signed,
2973 ppc64_emit_less_unsigned,
2982 ppc64_emit_stack_flush,
2983 ppc64_emit_zero_ext,
2986 ppc64v1_emit_int_call_1,
2987 ppc64v1_emit_void_call_2,
2998 static struct emit_ops ppc64v2_emit_ops_impl =
3000 ppc64v2_emit_prologue,
3001 ppc64_emit_epilogue,
3006 ppc64_emit_rsh_signed,
3007 ppc64_emit_rsh_unsigned,
3015 ppc64_emit_less_signed,
3016 ppc64_emit_less_unsigned,
3025 ppc64_emit_stack_flush,
3026 ppc64_emit_zero_ext,
3029 ppc64v2_emit_int_call_1,
3030 ppc64v2_emit_void_call_2,
3046 #ifdef __powerpc64__ 3051 if (is_elfv2_inferior ())
3052 return &ppc64v2_emit_ops_impl;
3054 return &ppc64v1_emit_ops_impl;
3068 #ifdef __powerpc64__ 3069 if (tdesc == tdesc_powerpc_64l)
3071 if (tdesc == tdesc_powerpc_altivec64l)
3073 if (tdesc == tdesc_powerpc_cell64l)
3075 if (tdesc == tdesc_powerpc_vsx64l)
3077 if (tdesc == tdesc_powerpc_isa205_64l)
3079 if (tdesc == tdesc_powerpc_isa205_altivec64l)
3081 if (tdesc == tdesc_powerpc_isa205_vsx64l)
3159 init_registers_powerpc_64l ();
3160 init_registers_powerpc_altivec64l ();
3161 init_registers_powerpc_cell64l ();
3162 init_registers_powerpc_vsx64l ();
3163 init_registers_powerpc_isa205_64l ();
3164 init_registers_powerpc_isa205_altivec64l ();
3165 init_registers_powerpc_isa205_vsx64l ();
#define GEN_STORE(buf, rt, ra, si, is_64)
const struct target_desc * tdesc
static void ppc_emit_goto(int *offset_p, int *size_p)
struct thread_info * current_thread
void collect_register(struct regcache *regcache, int n, void *buf)
#define GEN_ORIS(buf, rt, ra, si)
static void ppc_emit_lt_goto(int *offset_p, int *size_p)
static struct regsets_info ppc_regsets_info
static void ppc_emit_le_goto(int *offset_p, int *size_p)
static void ppc_store_vsxregset(struct regcache *regcache, const void *buf)
static int gen_b_form(uint32_t *buf, int opcd, int bo, int bi, int bd, int aa, int lk)
struct regcache * new_register_cache(const struct target_desc *tdesc)
void supply_register_by_name(struct regcache *regcache, const char *name, const void *buf)
const struct target_desc * tdesc_powerpc_vsx32l
static int ppc_cannot_fetch_register(int regno)
static void ppc_collect_ptrace_register(struct regcache *regcache, int regno, char *buf)
static void ppc_emit_mul(void)
const struct target_desc * tdesc_powerpc_isa205_altivec32l
static void ppc_emit_bit_not(void)
static int gen_i_form(uint32_t *buf, int opcd, int li, int aa, int lk)
static void ppc_relocate_instruction(CORE_ADDR *to, CORE_ADDR oldloc)
struct lwp_info * find_lwp_pid(ptid_t ptid)
static void ppc_emit_stack_adjust(int n)
static struct regset_info ppc_regsets[]
static void ppc_fill_evrregset(struct regcache *regcache, void *buf)
static int ppc_get_ipa_tdesc_idx(void)
static int ppc_breakpoint_at(CORE_ADDR where)
void * memset(T *s, int c, size_t n)=delete
static int parse_spufs_run(struct regcache *regcache, int *fd, CORE_ADDR *addr)
static void ppc_emit_const(LONGEST num)
static void ppc_emit_bit_or(void)
static void ppc_emit_ne_goto(int *offset_p, int *size_p)
#define GEN_STD(buf, rs, ra, offset)
#define GEN_RLDICR(buf, ra, rs,sh, mb)
#define GEN_LWZ(buf, rt, ra, si)
static struct emit_ops * ppc_emit_ops(void)
static void ppc_emit_ext(int arg)
#define PTRACE_GETEVRREGS
static void ppc_emit_epilogue(void)
const struct target_desc * tdesc_powerpc_32l
static void ppc_emit_pop(void)
#define GEN_STWU(buf, rt, ra, si)
#define GEN_MTSPR(buf, rt, spr)
static int gen_d_form(uint32_t *buf, int opcd, int rst, int ra, int si)
struct target_ops * the_target
void init_registers_powerpc_e500l(void)
const struct target_desc * tdesc
const struct target_desc * tdesc_powerpc_isa205_32l
void init_registers_powerpc_cell32l(void)
static const gdb_byte * ppc_sw_breakpoint_from_kind(int kind, int *size)
static void ppc_store_evrregset(struct regcache *regcache, const void *buf)
static void ppc_emit_equal(void)
#define PPC_FEATURE_HAS_DFP
#define GEN_LOAD(buf, rt, ra, si, is_64)
static void ppc_emit_gt_goto(int *offset_p, int *size_p)
static void ppc_emit_bit_xor(void)
#define ppc_breakpoint_len
static const struct aarch64_register x4
void collect_register_by_name(struct regcache *regcache, const char *name, void *buf)
#define GEN_RLDICL(buf, ra, rs,sh, mb)
static void ppc_fill_vrregset(struct regcache *regcache, void *buf)
static void ppc_emit_stack_flush(void)
#define PTRACE_SETEVRREGS
int(* write_memory)(CORE_ADDR memaddr, const unsigned char *myaddr, int len)
static void ppc_emit_lsh(void)
void init_registers_powerpc_isa205_32l(void)
static void ppc_emit_ref(int size)
static int ppc_supports_tracepoints(void)
static int gen_x_form(uint32_t *buf, int opcd, int rst, int ra, int rb, int xo, int rc)
#define GEN_STW(buf, rt, ra, si)
CORE_ADDR current_insn_ptr
static int ppc_cannot_store_register(int regno)
static void ppc_fill_vsxregset(struct regcache *regcache, void *buf)
const struct target_desc * tdesc_powerpc_e500l
static void ppc_emit_int_call_1(CORE_ADDR fn, int arg1)
static int gen_atomic_xchg(uint32_t *buf, CORE_ADDR lock, int old_value, int r_new, int is_64)
static void ppc_emit_sub(void)
int read_inferior_memory(CORE_ADDR memaddr, unsigned char *myaddr, int len)
static int ppc_supports_hardware_single_step(void)
static void ppc_emit_void_call_2(CORE_ADDR fn, int arg1)
static void ppc_emit_reg(int reg)
static void ppc_emit_log_not(void)
static void ppc_supply_ptrace_register(struct regcache *regcache, int regno, const char *buf)
ptid_t pid_to_ptid(int pid)
#define GEN_ORI(buf, rt, ra, si)
static int gen_call(uint32_t *buf, CORE_ADDR fn, int is_64, int is_opd)
#define GEN_LI(buf, rt, si)
static int ppc_supports_z_point_type(char z_type)
void init_registers_powerpc_32l(void)
#define PPC_FEATURE_HAS_ALTIVEC
static int ppc_insert_point(enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp)
#define get_lwp_thread(lwp)
int register_size(const struct target_desc *tdesc, int n)
static int ppc_get_thread_area(int lwpid, CORE_ADDR *addr)
static void ppc_emit_ge_goto(int *offset_p, int *size_p)
#define GEN_ADDI(buf, rt, ra, si)
struct process_info * current_process(void)
const struct target_desc * tdesc_powerpc_isa205_vsx32l
static void ppc_emit_swap(void)
static void ppc_emit_call(CORE_ADDR fn)
static CORE_ADDR ppc_get_pc(struct regcache *regcache)
static struct emit_ops ppc_emit_ops_impl
#define GEN_MR(buf, ra, rs)
void init_registers_powerpc_vsx32l(void)
void init_registers_powerpc_isa205_vsx32l(void)
static int ppc_install_fast_tracepoint_jump_pad(CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector, CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry, CORE_ADDR *trampoline, ULONGEST *trampoline_size, unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size, CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end, char *err)
int write_inferior_memory(CORE_ADDR memaddr, const unsigned char *myaddr, int len)
struct linux_target_ops the_low_target
static int ppc_regmap_adjusted
static const struct aarch64_register x3
static int gen_md_form(uint32_t *buf, int opcd, int rs, int ra, int sh, int mb, int xo, int rc)
int(* qxfer_spu)(const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, int len)
static void ppc_emit_less_unsigned(void)
#define GEN_MFCR(buf, rt)
static int gen_limm(uint32_t *buf, int reg, uint64_t imm, int is_64)
static void ppc_emit_less_signed(void)
int find_regno(const struct target_desc *tdesc, const char *name)
#define GEN_LD(buf, rt, ra, offset)
#define GEN_LIS(buf, rt, si)
static int gen_xfx_form(uint32_t *buf, int opcd, int rst, int ri, int xo)
static void ppc_emit_rsh_unsigned(void)
#define PPC_FEATURE_HAS_SPE
void init_registers_powerpc_altivec32l(void)
static void ppc_emit_eq_goto(int *offset_p, int *size_p)
#define fetch_inferior_registers(regcache, regno)
static void ppc_emit_bit_and(void)
CORE_ADDR get_raw_reg_func_addr(void)
int(* read_auxv)(CORE_ADDR offset, unsigned char *myaddr, unsigned int len)
static struct usrregs_info ppc_usrregs_info
static void emit_insns(uint32_t *buf, int n)
#define PTRACE_GETVSXREGS
#define GEN_STWCX(buf, rs, ra, rb)
int(* read_memory)(CORE_ADDR memaddr, unsigned char *myaddr, int len)
#define GEN_MFSPR(buf, rt, spr)
struct regcache * get_thread_regcache(struct thread_info *thread, int fetch)
#define Z_PACKET_ACCESS_WP
static void ppc_arch_setup(void)
static int ppc_regmap_e500[]
void perror_with_name(const char *string)
void init_registers_powerpc_isa205_altivec32l(void)
int insert_memory_breakpoint(struct raw_breakpoint *bp)
void free_register_cache(struct regcache *regcache)
static const struct aarch64_register x1
static int ppc_get_min_fast_tracepoint_insn_len(void)
unsigned long long ULONGEST
static void ppc_write_goto_address(CORE_ADDR from, CORE_ADDR to, int size)
#define GEN_MTCR(buf, rt)
static void ppc_emit_rsh_signed(void)
static const unsigned int ppc_breakpoint
static int ppc_get_auxv(unsigned long type, unsigned long *valp)
void initialize_low_arch(void)
static int ppc_remove_point(enum raw_bkpt_type type, CORE_ADDR addr, int size, struct raw_breakpoint *bp)
const struct target_desc * tdesc_powerpc_altivec32l
#define PTRACE_SETVSXREGS
static void ppc_emit_add(void)
static struct regs_info regs_info
#define GEN_CMPW(buf, ra, rb)
void supply_register(struct regcache *regcache, int n, const void *buf)
const struct target_desc * tdesc_powerpc_cell32l
int remove_memory_breakpoint(struct raw_breakpoint *bp)
static void ppc_emit_prologue(void)
static unsigned long ppc_hwcap
static const struct regs_info * ppc_regs_info(void)
static void ppc_set_pc(struct regcache *regcache, CORE_ADDR pc)
static void ppc_store_vrregset(struct regcache *regcache, const void *buf)
static void ppc_emit_if_goto(int *offset_p, int *size_p)
#define PPC_FEATURE_HAS_VSX
static void ppc_fill_gregset(struct regcache *regcache, void *buf)
#define GEN_STDU(buf, rs, ra, offset)
#define GEN_LWARX(buf, rt, ra, rb)
#define Z_PACKET_WRITE_WP
static void ppc_emit_zero_ext(int arg)