bool RegisterContextMach_i386::WriteRegisterValue (uint32_t reg, const Scalar &value) { int set = GetSetForNativeRegNum (reg); if (set == -1) return false; if (ReadRegisterSet(set, false) != KERN_SUCCESS) return false; switch (reg) { case gpr_eax: case gpr_ebx: case gpr_ecx: case gpr_edx: case gpr_edi: case gpr_esi: case gpr_ebp: case gpr_esp: case gpr_ss: case gpr_eflags: case gpr_eip: case gpr_cs: case gpr_ds: case gpr_es: case gpr_fs: case gpr_gs: (&gpr.eax)[reg - gpr_eax] = value.UInt(0); break; case fpu_fcw: fpu.fcw = value.UInt(0); break; case fpu_fsw: fpu.fsw = value.UInt(0); break; case fpu_ftw: fpu.ftw = value.UInt(0); break; case fpu_fop: fpu.fop = value.UInt(0); break; case fpu_ip: fpu.ip = value.UInt(0); break; case fpu_cs: fpu.cs = value.UInt(0); break; case fpu_dp: fpu.dp = value.UInt(0); break; case fpu_ds: fpu.ds = value.UInt(0); break; case fpu_mxcsr: fpu.mxcsr = value.UInt(0); break; case fpu_mxcsrmask: fpu.mxcsrmask = value.UInt(0); break; case fpu_stmm0: case fpu_stmm1: case fpu_stmm2: case fpu_stmm3: case fpu_stmm4: case fpu_stmm5: case fpu_stmm6: case fpu_stmm7: // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() // must be used for these registers //::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, reg_value.value.vector.uint8, 10); return false; case fpu_xmm0: case fpu_xmm1: case fpu_xmm2: case fpu_xmm3: case fpu_xmm4: case fpu_xmm5: case fpu_xmm6: case fpu_xmm7: // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes() // must be used for these registers //::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, reg_value.value.vector.uint8, 16); return false; case exc_trapno: exc.trapno = value.UInt(0); break; case exc_err: exc.err = value.UInt(0); break; case exc_faultvaddr: exc.faultvaddr = value.UInt(0); break; default: return false; } return WriteRegisterSet(set) == KERN_SUCCESS; }
bool CompilerType::SetValueFromScalar (const Scalar &value, Stream &strm) { if (!IsValid()) return false; // Aggregate types don't have scalar values if (!IsAggregateType ()) { strm.GetFlags().Set(Stream::eBinary); uint64_t count = 0; lldb::Encoding encoding = GetEncoding (count); if (encoding == lldb::eEncodingInvalid || count != 1) return false; const uint64_t bit_width = GetBitSize(nullptr); // This function doesn't currently handle non-byte aligned assignments if ((bit_width % 8) != 0) return false; const uint64_t byte_size = (bit_width + 7 ) / 8; switch (encoding) { case lldb::eEncodingInvalid: break; case lldb::eEncodingVector: break; case lldb::eEncodingUint: switch (byte_size) { case 1: strm.PutHex8(value.UInt()); return true; case 2: strm.PutHex16(value.UInt()); return true; case 4: strm.PutHex32(value.UInt()); return true; case 8: strm.PutHex64(value.ULongLong()); return true; default: break; } break; case lldb::eEncodingSint: switch (byte_size) { case 1: strm.PutHex8(value.SInt()); return true; case 2: strm.PutHex16(value.SInt()); return true; case 4: strm.PutHex32(value.SInt()); return true; case 8: strm.PutHex64(value.SLongLong()); return true; default: break; } break; case lldb::eEncodingIEEE754: if (byte_size <= sizeof(long double)) { if (byte_size == sizeof(float)) { strm.PutFloat(value.Float()); return true; } else if (byte_size == sizeof(double)) { strm.PutDouble(value.Double()); return true; } else if (byte_size == sizeof(long double)) { strm.PutDouble(value.LongDouble()); return true; } } break; } } return false; }