LLDB  mainline
CXXFunctionPointer.cpp
Go to the documentation of this file.
1 //===-- CXXFunctionPointer.cpp-----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "lldb/Core/ValueObject.h"
13 #include "lldb/Target/Target.h"
14 #include "lldb/Utility/Stream.h"
15 
16 #include <string>
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 using namespace lldb_private::formatters;
21 
23  ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
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  switch (func_ptr_address_type) {
31  case eAddressTypeFile:
32  case eAddressTypeHost:
33  break;
34 
35  case eAddressTypeLoad: {
36  ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
37 
38  Address so_addr;
39  Target *target = exe_ctx.GetTargetPtr();
40  if (target && !target->GetSectionLoadList().IsEmpty()) {
41  if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address,
42  so_addr)) {
43  so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(),
44  Address::DumpStyleResolvedDescription,
45  Address::DumpStyleSectionNameOffset);
46  }
47  }
48  } break;
49  }
50  }
51  if (sstr.GetSize() > 0) {
52  stream.Printf("(%s)", sstr.GetData());
53  return true;
54  } else
55  return false;
56 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Address is an address as found in an object or symbol file.
void Dump(Stream *s, lldb::DescriptionLevel description_level)
Dump a description of this object to a Stream.
Definition: Target.cpp:148
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const char * GetData() const
Definition: StreamString.h:43
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
Address is an address in the process that is running this code.
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1012
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
const ExecutionContextRef & GetExecutionContextRef() const
Definition: ValueObject.h:353
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
A section + offset based address class.
Definition: Address.h:80
uint64_t addr_t
Definition: lldb-types.h:83
Definition: SBAddress.h:15
bool CXXFunctionPointerSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Address is an address as in the current target inferior process.