本文整理汇总了C++中Process::ReadPointerFromMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::ReadPointerFromMemory方法的具体用法?C++ Process::ReadPointerFromMemory怎么用?C++ Process::ReadPointerFromMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::ReadPointerFromMemory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exe_ctx
ObjCLanguageRuntime::ClassDescriptorSP
ObjCLanguageRuntime::GetClassDescriptor(ValueObject &valobj) {
ClassDescriptorSP objc_class_sp;
// if we get an invalid VO (which might still happen when playing around
// with pointers returned by the expression parser, don't consider this
// a valid ObjC object)
if (valobj.GetCompilerType().IsValid()) {
addr_t isa_pointer = valobj.GetPointerValue();
if (isa_pointer != LLDB_INVALID_ADDRESS) {
ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
if (process) {
Error error;
ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
if (isa != LLDB_INVALID_ADDRESS)
objc_class_sp = GetClassDescriptorFromISA(isa);
}
}
}
return objc_class_sp;
}
示例2: objc_module_sp
lldb::addr_t
AppleObjCRuntimeV1::GetISAHashTablePointer ()
{
if (m_isa_hash_table_ptr == LLDB_INVALID_ADDRESS)
{
ModuleSP objc_module_sp(GetObjCModule());
if (!objc_module_sp)
return LLDB_INVALID_ADDRESS;
static ConstString g_objc_debug_class_hash("_objc_debug_class_hash");
const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(g_objc_debug_class_hash, lldb::eSymbolTypeData);
if (symbol && symbol->ValueIsAddress())
{
Process *process = GetProcess();
if (process)
{
lldb::addr_t objc_debug_class_hash_addr = symbol->GetAddressRef().GetLoadAddress(&process->GetTarget());
if (objc_debug_class_hash_addr != LLDB_INVALID_ADDRESS)
{
Error error;
lldb::addr_t objc_debug_class_hash_ptr = process->ReadPointerFromMemory(objc_debug_class_hash_addr, error);
if (objc_debug_class_hash_ptr != 0 &&
objc_debug_class_hash_ptr != LLDB_INVALID_ADDRESS)
{
m_isa_hash_table_ptr = objc_debug_class_hash_ptr;
}
}
}
}
}
return m_isa_hash_table_ptr;
}
示例3: Dump
//.........这里部分代码省略.........
Dump(s, exe_scope, DumpStyleSectionNameOffset);
}
}
}
}
} else {
if (fallback_style != DumpStyleInvalid)
return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
return false;
}
break;
case DumpStyleDetailedSymbolContext:
if (IsSectionOffset()) {
ModuleSP module_sp(GetModule());
if (module_sp) {
SymbolContext sc;
module_sp->ResolveSymbolContextForAddress(
*this, eSymbolContextEverything | eSymbolContextVariable, sc);
if (sc.symbol) {
// If we have just a symbol make sure it is in the same section
// as our address. If it isn't, then we might have just found
// the last symbol that came before the address that we are
// looking up that has nothing to do with our address lookup.
if (sc.symbol->ValueIsAddress() &&
sc.symbol->GetAddressRef().GetSection() != GetSection())
sc.symbol = nullptr;
}
sc.GetDescription(s, eDescriptionLevelBrief, target);
if (sc.block) {
bool can_create = true;
bool get_parent_variables = true;
bool stop_if_block_is_inlined_function = false;
VariableList variable_list;
sc.block->AppendVariables(can_create, get_parent_variables,
stop_if_block_is_inlined_function,
[](Variable *) { return true; },
&variable_list);
const size_t num_variables = variable_list.GetSize();
for (size_t var_idx = 0; var_idx < num_variables; ++var_idx) {
Variable *var = variable_list.GetVariableAtIndex(var_idx).get();
if (var && var->LocationIsValidForAddress(*this)) {
s->Indent();
s->Printf(" Variable: id = {0x%8.8" PRIx64 "}, name = \"%s\"",
var->GetID(), var->GetName().GetCString());
Type *type = var->GetType();
if (type)
s->Printf(", type = \"%s\"", type->GetName().GetCString());
else
s->PutCString(", type = <unknown>");
s->PutCString(", location = ");
var->DumpLocationForAddress(s, *this);
s->PutCString(", decl = ");
var->GetDeclaration().DumpStopContext(s, false);
s->EOL();
}
}
}
}
} else {
if (fallback_style != DumpStyleInvalid)
return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
return false;
}
break;
case DumpStyleResolvedPointerDescription: {
Process *process = exe_ctx.GetProcessPtr();
if (process) {
addr_t load_addr = GetLoadAddress(target);
if (load_addr != LLDB_INVALID_ADDRESS) {
Error memory_error;
addr_t dereferenced_load_addr =
process->ReadPointerFromMemory(load_addr, memory_error);
if (dereferenced_load_addr != LLDB_INVALID_ADDRESS) {
Address dereferenced_addr;
if (dereferenced_addr.SetLoadAddress(dereferenced_load_addr,
target)) {
StreamString strm;
if (dereferenced_addr.Dump(&strm, exe_scope,
DumpStyleResolvedDescription,
DumpStyleInvalid, addr_size)) {
s->Address(dereferenced_load_addr, addr_size, " -> ", " ");
s->Write(strm.GetData(), strm.GetSize());
return true;
}
}
}
}
}
if (fallback_style != DumpStyleInvalid)
return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
return false;
} break;
}
return true;
}
示例4: GetDynamicTypeAndAddress
bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name, Address &dynamic_address,
Value::ValueType &value_type) {
// For Itanium, if the type has a vtable pointer in the object, it will be at
// offset 0
// in the object. That will point to the "address point" within the vtable
// (not the beginning of the
// vtable.) We can then look up the symbol containing this "address point"
// and that symbol's name
// demangled will contain the full class name.
// The second pointer above the "address point" is the "offset_to_top". We'll
// use that to get the
// start of the value object which holds the dynamic type.
//
class_type_or_name.Clear();
value_type = Value::ValueType::eValueTypeScalar;
// Only a pointer or reference type can have a different dynamic and static
// type:
if (CouldHaveDynamicValue(in_value)) {
// First job, pull out the address at 0 offset from the object.
AddressType address_type;
lldb::addr_t original_ptr = in_value.GetPointerValue(&address_type);
if (original_ptr == LLDB_INVALID_ADDRESS)
return false;
ExecutionContext exe_ctx(in_value.GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
if (process == nullptr)
return false;
Error error;
const lldb::addr_t vtable_address_point =
process->ReadPointerFromMemory(original_ptr, error);
if (!error.Success() || vtable_address_point == LLDB_INVALID_ADDRESS) {
return false;
}
class_type_or_name = GetTypeInfoFromVTableAddress(in_value, original_ptr,
vtable_address_point);
if (class_type_or_name) {
TypeSP type_sp = class_type_or_name.GetTypeSP();
// There can only be one type with a given name,
// so we've just found duplicate definitions, and this
// one will do as well as any other.
// We don't consider something to have a dynamic type if
// it is the same as the static type. So compare against
// the value we were handed.
if (type_sp) {
if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(),
type_sp->GetForwardCompilerType())) {
// The dynamic type we found was the same type,
// so we don't have a dynamic type here...
return false;
}
// The offset_to_top is two pointers above the vtable pointer.
const uint32_t addr_byte_size = process->GetAddressByteSize();
const lldb::addr_t offset_to_top_location =
vtable_address_point - 2 * addr_byte_size;
// Watch for underflow, offset_to_top_location should be less than
// vtable_address_point
if (offset_to_top_location >= vtable_address_point)
return false;
const int64_t offset_to_top = process->ReadSignedIntegerFromMemory(
offset_to_top_location, addr_byte_size, INT64_MIN, error);
if (offset_to_top == INT64_MIN)
return false;
// So the dynamic type is a value that starts at offset_to_top
// above the original address.
lldb::addr_t dynamic_addr = original_ptr + offset_to_top;
if (!process->GetTarget().GetSectionLoadList().ResolveLoadAddress(
dynamic_addr, dynamic_address)) {
dynamic_address.SetRawAddress(dynamic_addr);
}
return true;
}
}
}
return class_type_or_name.IsEmpty() == false;
}
示例5: member__f_
CPPLanguageRuntime::LibCppStdFunctionCallableInfo
CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
lldb::ValueObjectSP &valobj_sp) {
LibCppStdFunctionCallableInfo optional_info;
if (!valobj_sp)
return optional_info;
// Member __f_ has type __base*, the contents of which will hold:
// 1) a vtable entry which may hold type information needed to discover the
// lambda being called
// 2) possibly hold a pointer to the callable object
// e.g.
//
// (lldb) frame var -R f_display
// (std::__1::function<void (int)>) f_display = {
// __buf_ = {
// …
// }
// __f_ = 0x00007ffeefbffa00
// }
// (lldb) memory read -fA 0x00007ffeefbffa00
// 0x7ffeefbffa00: ... `vtable for std::__1::__function::__func<void (*) ...
// 0x7ffeefbffa08: ... `print_num(int) at std_function_cppreference_exam ...
//
// We will be handling five cases below, std::function is wrapping:
//
// 1) a lambda we know at compile time. We will obtain the name of the lambda
// from the first template pameter from __func's vtable. We will look up
// the lambda's operator()() and obtain the line table entry.
// 2) a lambda we know at runtime. A pointer to the lambdas __invoke method
// will be stored after the vtable. We will obtain the lambdas name from
// this entry and lookup operator()() and obtain the line table entry.
// 3) a callable object via operator()(). We will obtain the name of the
// object from the first template parameter from __func's vtable. We will
// look up the objectc operator()() and obtain the line table entry.
// 4) a member function. A pointer to the function will stored after the
// we will obtain the name from this pointer.
// 5) a free function. A pointer to the function will stored after the vtable
// we will obtain the name from this pointer.
ValueObjectSP member__f_(
valobj_sp->GetChildMemberWithName(ConstString("__f_"), true));
if (member__f_) {
ValueObjectSP sub_member__f_(
member__f_->GetChildMemberWithName(ConstString("__f_"), true));
if (sub_member__f_)
member__f_ = sub_member__f_;
}
lldb::addr_t member__f_pointer_value = member__f_->GetValueAsUnsigned(0);
optional_info.member__f_pointer_value = member__f_pointer_value;
ExecutionContext exe_ctx(valobj_sp->GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
if (process == nullptr)
return optional_info;
uint32_t address_size = process->GetAddressByteSize();
Status status;
// First item pointed to by __f_ should be the pointer to the vtable for
// a __base object.
lldb::addr_t vtable_address =
process->ReadPointerFromMemory(member__f_pointer_value, status);
if (status.Fail())
return optional_info;
lldb::addr_t address_after_vtable = member__f_pointer_value + address_size;
// As commened above we may not have a function pointer but if we do we will
// need it.
lldb::addr_t possible_function_address =
process->ReadPointerFromMemory(address_after_vtable, status);
if (status.Fail())
return optional_info;
Target &target = process->GetTarget();
if (target.GetSectionLoadList().IsEmpty())
return optional_info;
Address vtable_addr_resolved;
SymbolContext sc;
Symbol *symbol;
if (!target.GetSectionLoadList().ResolveLoadAddress(vtable_address,
vtable_addr_resolved))
return optional_info;
target.GetImages().ResolveSymbolContextForAddress(
vtable_addr_resolved, eSymbolContextEverything, sc);
symbol = sc.symbol;
if (symbol == nullptr)
return optional_info;
//.........这里部分代码省略.........