本文整理汇总了C++中Scalar::SetValueFromCString方法的典型用法代码示例。如果您正苦于以下问题:C++ Scalar::SetValueFromCString方法的具体用法?C++ Scalar::SetValueFromCString怎么用?C++ Scalar::SetValueFromCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalar
的用法示例。
在下文中一共展示了Scalar::SetValueFromCString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exe_ctx
virtual bool
Execute
(
Args& command,
CommandReturnObject &result
)
{
DataExtractor reg_data;
ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
RegisterContext *reg_context = exe_ctx.GetRegisterContext ();
if (reg_context)
{
if (command.GetArgumentCount() != 2)
{
result.AppendError ("register write takes exactly 2 arguments: <reg-name> <value>");
result.SetStatus (eReturnStatusFailed);
}
else
{
const char *reg_name = command.GetArgumentAtIndex(0);
const char *value_str = command.GetArgumentAtIndex(1);
const RegisterInfo *reg_info = reg_context->GetRegisterInfoByName(reg_name);
if (reg_info)
{
Scalar scalar;
Error error(scalar.SetValueFromCString (value_str, reg_info->encoding, reg_info->byte_size));
if (error.Success())
{
if (reg_context->WriteRegisterValue(reg_info->kinds[eRegisterKindLLDB], scalar))
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
return true;
}
}
else
{
result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n",
reg_name,
value_str,
error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
result.AppendErrorWithFormat ("Register not found for '%s'.\n", reg_name);
result.SetStatus (eReturnStatusFailed);
}
}
}
else
{
result.AppendError ("no current frame");
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例2: Succeeded
TEST(ScalarTest, SetValueFromCString) {
Scalar a;
EXPECT_THAT_ERROR(
a.SetValueFromCString("1234567890123", lldb::eEncodingUint, 8).ToError(),
Succeeded());
EXPECT_EQ(1234567890123ull, a);
EXPECT_THAT_ERROR(
a.SetValueFromCString("-1234567890123", lldb::eEncodingSint, 8).ToError(),
Succeeded());
EXPECT_EQ(-1234567890123ll, a);
EXPECT_THAT_ERROR(
a.SetValueFromCString("asdf", lldb::eEncodingSint, 8).ToError(),
Failed());
EXPECT_THAT_ERROR(
a.SetValueFromCString("asdf", lldb::eEncodingUint, 8).ToError(),
Failed());
EXPECT_THAT_ERROR(
a.SetValueFromCString("1234567890123", lldb::eEncodingUint, 4).ToError(),
Failed());
EXPECT_THAT_ERROR(a.SetValueFromCString("123456789012345678901234567890",
lldb::eEncodingUint, 8)
.ToError(),
Failed());
EXPECT_THAT_ERROR(
a.SetValueFromCString("-123", lldb::eEncodingUint, 8).ToError(),
Failed());
}