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 "lldb/DataFormatters/CXXFunctionPointer.h" 11 12 #include "lldb/Target/SectionLoadList.h" 13 #include "lldb/Target/Target.h" 14 15 #include <string> 16 17 using namespace lldb; 18 using namespace lldb_private; 19 using namespace lldb_private::formatters; 20 21 bool 22 lldb_private::formatters::CXXFunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) 23 { 24 std::string destination; 25 StreamString sstr; 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 { 30 switch (func_ptr_address_type) 31 { 32 case eAddressTypeInvalid: 33 case eAddressTypeFile: 34 case eAddressTypeHost: 35 break; 36 37 case eAddressTypeLoad: 38 { 39 ExecutionContext exe_ctx (valobj.GetExecutionContextRef()); 40 41 Address so_addr; 42 Target *target = exe_ctx.GetTargetPtr(); 43 if (target && target->GetSectionLoadList().IsEmpty() == false) 44 { 45 if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address, so_addr)) 46 { 47 so_addr.Dump (&sstr, 48 exe_ctx.GetBestExecutionContextScope(), 49 Address::DumpStyleResolvedDescription, 50 Address::DumpStyleSectionNameOffset); 51 } 52 } 53 } 54 break; 55 } 56 } 57 if (sstr.GetSize() > 0) 58 { 59 stream.Printf("(%s)", sstr.GetData()); 60 return true; 61 } 62 else 63 return false; 64 } 65