本文整理汇总了C++中Process::ReadCStringFromMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::ReadCStringFromMemory方法的具体用法?C++ Process::ReadCStringFromMemory怎么用?C++ Process::ReadCStringFromMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::ReadCStringFromMemory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
//.........这里部分代码省略.........
// If it is not a pointer, see if we can make it into a pointer.
ClangASTContext *ast_context = target->GetScratchClangASTContext();
CompilerType opaque_type = ast_context->GetBasicType(eBasicTypeObjCID);
if (!opaque_type)
opaque_type = ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
//value.SetContext(Value::eContextTypeClangType, opaque_type_ptr);
value.SetCompilerType (opaque_type);
}
ValueList arg_value_list;
arg_value_list.PushValue(value);
// This is the return value:
ClangASTContext *ast_context = target->GetScratchClangASTContext();
CompilerType return_compiler_type = ast_context->GetCStringType(true);
Value ret;
// ret.SetContext(Value::eContextTypeClangType, return_compiler_type);
ret.SetCompilerType (return_compiler_type);
if (exe_ctx.GetFramePtr() == NULL)
{
Thread *thread = exe_ctx.GetThreadPtr();
if (thread == NULL)
{
exe_ctx.SetThreadSP(process->GetThreadList().GetSelectedThread());
thread = exe_ctx.GetThreadPtr();
}
if (thread)
{
exe_ctx.SetFrameSP(thread->GetSelectedFrame());
}
}
// Now we're ready to call the function:
StreamString error_stream;
lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
if (!m_print_object_caller_up)
{
Error error;
m_print_object_caller_up.reset(exe_scope->CalculateTarget()->GetFunctionCallerForLanguage (eLanguageTypeObjC,
return_compiler_type,
*function_address,
arg_value_list,
"objc-object-description",
error));
if (error.Fail())
{
m_print_object_caller_up.reset();
strm.Printf("Could not get function runner to call print for debugger function: %s.", error.AsCString());
return false;
}
m_print_object_caller_up->InsertFunction(exe_ctx, wrapper_struct_addr, error_stream);
}
else
{
m_print_object_caller_up->WriteFunctionArguments(exe_ctx,
wrapper_struct_addr,
arg_value_list,
error_stream);
}
EvaluateExpressionOptions options;
options.SetUnwindOnError(true);
options.SetTryAllThreads(true);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
options.SetTimeoutUsec(PO_FUNCTION_TIMEOUT_USEC);
options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
ExpressionResults results = m_print_object_caller_up->ExecuteFunction (exe_ctx,
&wrapper_struct_addr,
options,
error_stream,
ret);
if (results != eExpressionCompleted)
{
strm.Printf("Error evaluating Print Object function: %d.\n", results);
return false;
}
addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
char buf[512];
size_t cstr_len = 0;
size_t full_buffer_len = sizeof (buf) - 1;
size_t curr_len = full_buffer_len;
while (curr_len == full_buffer_len)
{
Error error;
curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf), error);
strm.Write (buf, curr_len);
cstr_len += curr_len;
}
return cstr_len > 0;
}
示例2: func
//.........这里部分代码省略.........
// We need other parts of the exe_ctx, but the processes have to match.
assert (m_process == process);
// Get the function address for the print function.
const Address *function_address = GetPrintForDebuggerAddr();
if (!function_address)
return false;
Target *target = exe_ctx.GetTargetPtr();
ClangASTType clang_type = value.GetClangType();
if (clang_type)
{
if (!clang_type.IsObjCObjectPointerType())
{
strm.Printf ("Value doesn't point to an ObjC object.\n");
return false;
}
}
else
{
// If it is not a pointer, see if we can make it into a pointer.
ClangASTContext *ast_context = target->GetScratchClangASTContext();
ClangASTType opaque_type = ast_context->GetBasicType(eBasicTypeObjCID);
if (!opaque_type)
opaque_type = ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
//value.SetContext(Value::eContextTypeClangType, opaque_type_ptr);
value.SetClangType (opaque_type);
}
ValueList arg_value_list;
arg_value_list.PushValue(value);
// This is the return value:
ClangASTContext *ast_context = target->GetScratchClangASTContext();
ClangASTType return_clang_type = ast_context->GetCStringType(true);
Value ret;
// ret.SetContext(Value::eContextTypeClangType, return_clang_type);
ret.SetClangType (return_clang_type);
if (exe_ctx.GetFramePtr() == NULL)
{
Thread *thread = exe_ctx.GetThreadPtr();
if (thread == NULL)
{
exe_ctx.SetThreadSP(process->GetThreadList().GetSelectedThread());
thread = exe_ctx.GetThreadPtr();
}
if (thread)
{
exe_ctx.SetFrameSP(thread->GetSelectedFrame());
}
}
// Now we're ready to call the function:
ClangFunction func (*exe_ctx.GetBestExecutionContextScope(),
return_clang_type,
*function_address,
arg_value_list);
StreamString error_stream;
lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream);
const bool unwind_on_error = true;
const bool try_all_threads = true;
const bool stop_others = true;
const bool ignore_breakpoints = true;
ExecutionResults results = func.ExecuteFunction (exe_ctx,
&wrapper_struct_addr,
error_stream,
stop_others,
PO_FUNCTION_TIMEOUT_USEC /* 15 secs timeout */,
try_all_threads,
unwind_on_error,
ignore_breakpoints,
ret);
if (results != eExecutionCompleted)
{
strm.Printf("Error evaluating Print Object function: %d.\n", results);
return false;
}
addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
char buf[512];
size_t cstr_len = 0;
size_t full_buffer_len = sizeof (buf) - 1;
size_t curr_len = full_buffer_len;
while (curr_len == full_buffer_len)
{
Error error;
curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf), error);
strm.Write (buf, curr_len);
cstr_len += curr_len;
}
return cstr_len > 0;
}
示例3: func
bool
AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionContextScope *exe_scope)
{
if (!m_read_objc_library)
return false;
ExecutionContext exe_ctx;
exe_scope->CalculateExecutionContext(exe_ctx);
Process *process = exe_ctx.GetProcessPtr();
if (!process)
return false;
// We need other parts of the exe_ctx, but the processes have to match.
assert (m_process == process);
// Get the function address for the print function.
const Address *function_address = GetPrintForDebuggerAddr();
if (!function_address)
return false;
Target *target = exe_ctx.GetTargetPtr();
if (value.GetClangType())
{
clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType());
if (!value_type->isObjCObjectPointerType())
{
strm.Printf ("Value doesn't point to an ObjC object.\n");
return false;
}
}
else
{
// If it is not a pointer, see if we can make it into a pointer.
ClangASTContext *ast_context = target->GetScratchClangASTContext();
void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id();
if (opaque_type_ptr == NULL)
opaque_type_ptr = ast_context->GetVoidPtrType(false);
value.SetContext(Value::eContextTypeClangType, opaque_type_ptr);
}
ValueList arg_value_list;
arg_value_list.PushValue(value);
// This is the return value:
ClangASTContext *ast_context = target->GetScratchClangASTContext();
void *return_qualtype = ast_context->GetCStringType(true);
Value ret;
ret.SetContext(Value::eContextTypeClangType, return_qualtype);
// Now we're ready to call the function:
ClangFunction func (*exe_ctx.GetBestExecutionContextScope(),
ast_context,
return_qualtype,
*function_address,
arg_value_list);
StreamString error_stream;
lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream);
bool unwind_on_error = true;
bool try_all_threads = true;
bool stop_others = true;
ExecutionResults results = func.ExecuteFunction (exe_ctx,
&wrapper_struct_addr,
error_stream,
stop_others,
1000000,
try_all_threads,
unwind_on_error,
ret);
if (results != eExecutionCompleted)
{
strm.Printf("Error evaluating Print Object function: %d.\n", results);
return false;
}
addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
char buf[512];
size_t cstr_len = 0;
size_t full_buffer_len = sizeof (buf) - 1;
size_t curr_len = full_buffer_len;
while (curr_len == full_buffer_len)
{
Error error;
curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf), error);
strm.Write (buf, curr_len);
cstr_len += curr_len;
}
return cstr_len > 0;
}