uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) { ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { Scalar scalar; if (value_sp->ResolveValue (scalar)) return scalar.ULongLong(fail_value); } return fail_value; }
uint64_t SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value) { error.Clear(); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { Scalar scalar; if (value_sp->ResolveValue (scalar)) return scalar.ULongLong(fail_value); else error.SetErrorString("could not resolve value"); } else error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString()); return fail_value; }
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; }
bool RegisterContextMach_x86_64::WriteRegisterValue (uint32_t reg, const Scalar &value) { int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg); if (set == -1) return false; if (ReadRegisterSet(set, false) != KERN_SUCCESS) return false; switch (reg) { case gpr_rax: case gpr_rbx: case gpr_rcx: case gpr_rdx: case gpr_rdi: case gpr_rsi: case gpr_rbp: case gpr_rsp: case gpr_r8: case gpr_r9: case gpr_r10: case gpr_r11: case gpr_r12: case gpr_r13: case gpr_r14: case gpr_r15: case gpr_rip: case gpr_rflags: case gpr_cs: case gpr_fs: case gpr_gs: (&gpr.rax)[reg - gpr_rax] = value.ULongLong(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: case fpu_xmm8: case fpu_xmm9: case fpu_xmm10: case fpu_xmm11: case fpu_xmm12: case fpu_xmm13: case fpu_xmm14: case fpu_xmm15: // 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; }