1 //===-- CXXFunctionPointer.cpp-----------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/DataFormatters/CXXFunctionPointer.h"
11 #include "lldb/Core/ValueObject.h"
12 #include "lldb/Target/SectionLoadList.h"
13 #include "lldb/Target/Target.h"
14 #include "lldb/Utility/Stream.h"
19 using namespace lldb_private;
20 using namespace lldb_private::formatters;
22 bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
23 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
24 std::string destination;
26 AddressType func_ptr_address_type = eAddressTypeInvalid;
27 addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);
28 if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS) {
29 switch (func_ptr_address_type) {
30 case eAddressTypeInvalid:
31 case eAddressTypeFile:
32 case eAddressTypeHost:
35 case eAddressTypeLoad: {
36 ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
39 Target *target = exe_ctx.GetTargetPtr();
40 if (target && !target->GetSectionLoadList().IsEmpty()) {
41 if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address,
43 so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(),
44 Address::DumpStyleResolvedDescription,
45 Address::DumpStyleSectionNameOffset);
51 if (sstr.GetSize() > 0) {
52 stream.Printf("(%s)", sstr.GetData());