blob: 6b8a5898114bb7f608d08d24393e9324e6893e2a [file] [log] [blame]
Enrico Granata419d7912015-09-04 00:33:51 +00001//===-- 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
Enrico Granatac6bbb8b2015-09-04 21:22:54 +000010#include "lldb/DataFormatters/CXXFunctionPointer.h"
11
Enrico Granata419d7912015-09-04 00:33:51 +000012#include "lldb/Target/SectionLoadList.h"
13#include "lldb/Target/Target.h"
14
15#include <string>
16
17using namespace lldb;
18using namespace lldb_private;
19using namespace lldb_private::formatters;
20
21bool
22lldb_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}