2016-11-26 13:23:44 +08:00
|
|
|
//===-- CXXFunctionPointer.cpp-----------------------------------*- C++ -*-===//
|
2015-09-04 08:33:51 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-09-05 05:22:54 +08:00
|
|
|
#include "lldb/DataFormatters/CXXFunctionPointer.h"
|
|
|
|
|
2015-10-20 12:50:09 +08:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
2015-09-04 08:33:51 +08:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2015-09-04 08:33:51 +08:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::formatters;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
|
|
|
|
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
|
|
|
|
std::string destination;
|
|
|
|
StreamString sstr;
|
|
|
|
AddressType func_ptr_address_type = eAddressTypeInvalid;
|
|
|
|
addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);
|
|
|
|
if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS) {
|
|
|
|
switch (func_ptr_address_type) {
|
|
|
|
case eAddressTypeInvalid:
|
|
|
|
case eAddressTypeFile:
|
|
|
|
case eAddressTypeHost:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eAddressTypeLoad: {
|
|
|
|
ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
|
|
|
|
|
|
|
|
Address so_addr;
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2018-12-15 08:15:33 +08:00
|
|
|
if (target && !target->GetSectionLoadList().IsEmpty()) {
|
2016-09-07 04:57:50 +08:00
|
|
|
if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address,
|
|
|
|
so_addr)) {
|
|
|
|
so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(),
|
|
|
|
Address::DumpStyleResolvedDescription,
|
|
|
|
Address::DumpStyleSectionNameOffset);
|
2015-09-04 08:33:51 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} break;
|
2015-09-04 08:33:51 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
if (sstr.GetSize() > 0) {
|
|
|
|
stream.Printf("(%s)", sstr.GetData());
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
2015-09-04 08:33:51 +08:00
|
|
|
}
|