1 //===-- CXXFormatterFunctions.cpp---------------------------------*- C++ 2 //-*-===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is distributed under the University of Illinois Open Source 7 // License. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 #include "lldb/DataFormatters/CXXFunctionPointer.h" 12 13 #include "lldb/Core/Stream.h" 14 #include "lldb/Core/ValueObject.h" 15 #include "lldb/Target/SectionLoadList.h" 16 #include "lldb/Target/Target.h" 17 18 #include <string> 19 20 using namespace lldb; 21 using namespace lldb_private; 22 using namespace lldb_private::formatters; 23 24 bool lldb_private::formatters::CXXFunctionPointerSummaryProvider( 25 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { 26 std::string destination; 27 StreamString sstr; 28 AddressType func_ptr_address_type = eAddressTypeInvalid; 29 addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type); 30 if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS) { 31 switch (func_ptr_address_type) { 32 case eAddressTypeInvalid: 33 case eAddressTypeFile: 34 case eAddressTypeHost: 35 break; 36 37 case eAddressTypeLoad: { 38 ExecutionContext exe_ctx(valobj.GetExecutionContextRef()); 39 40 Address so_addr; 41 Target *target = exe_ctx.GetTargetPtr(); 42 if (target && target->GetSectionLoadList().IsEmpty() == false) { 43 if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address, 44 so_addr)) { 45 so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(), 46 Address::DumpStyleResolvedDescription, 47 Address::DumpStyleSectionNameOffset); 48 } 49 } 50 } break; 51 } 52 } 53 if (sstr.GetSize() > 0) { 54 stream.Printf("(%s)", sstr.GetData()); 55 return true; 56 } else 57 return false; 58 } 59