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