1 //===-- CXXFunctionPointer.cpp-----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/DataFormatters/CXXFunctionPointer.h"
12 #include "lldb/Core/Stream.h"
13 #include "lldb/Core/ValueObject.h"
14 #include "lldb/Target/SectionLoadList.h"
15 #include "lldb/Target/Target.h"
20 using namespace lldb_private;
21 using namespace lldb_private::formatters;
23 bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
24 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
25 std::string destination;
27 AddressType func_ptr_address_type = eAddressTypeInvalid;
28 addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);
29 if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS) {
30 switch (func_ptr_address_type) {
31 case eAddressTypeInvalid:
32 case eAddressTypeFile:
33 case eAddressTypeHost:
36 case eAddressTypeLoad: {
37 ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
40 Target *target = exe_ctx.GetTargetPtr();
41 if (target && target->GetSectionLoadList().IsEmpty() == false) {
42 if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address,
44 so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(),
45 Address::DumpStyleResolvedDescription,
46 Address::DumpStyleSectionNameOffset);
52 if (sstr.GetSize() > 0) {
53 stream.Printf("(%s)", sstr.GetData());