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