blob: 482ecec1ce699fbd88188f1963d78289ed6ba8e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
//===-- SBAddress.cpp -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBProcess.h"
#include "lldb/Core/Address.h"
using namespace lldb;
SBAddress::SBAddress () :
m_lldb_object_ap ()
{
}
SBAddress::SBAddress (const lldb_private::Address *lldb_object_ptr) :
m_lldb_object_ap ()
{
if (lldb_object_ptr)
m_lldb_object_ap.reset (new lldb_private::Address(*lldb_object_ptr));
}
SBAddress::SBAddress (const SBAddress &rhs) :
m_lldb_object_ap ()
{
if (rhs.IsValid())
m_lldb_object_ap.reset (new lldb_private::Address(*rhs.m_lldb_object_ap.get()));
}
SBAddress::~SBAddress ()
{
}
const SBAddress &
SBAddress::operator = (const SBAddress &rhs)
{
if (this != &rhs)
{
if (rhs.IsValid())
m_lldb_object_ap.reset (new lldb_private::Address(*rhs.m_lldb_object_ap.get()));
}
return *this;
}
bool
SBAddress::IsValid () const
{
return m_lldb_object_ap.get() != NULL && m_lldb_object_ap->IsValid();
}
void
SBAddress::SetAddress (const lldb_private::Address *lldb_object_ptr)
{
if (lldb_object_ptr)
{
if (m_lldb_object_ap.get())
*m_lldb_object_ap = *lldb_object_ptr;
else
m_lldb_object_ap.reset (new lldb_private::Address(*lldb_object_ptr));
return;
}
if (m_lldb_object_ap.get())
m_lldb_object_ap->Clear();
}
lldb::addr_t
SBAddress::GetFileAddress () const
{
if (m_lldb_object_ap.get())
return m_lldb_object_ap->GetFileAddress();
else
return LLDB_INVALID_ADDRESS;
}
lldb::addr_t
SBAddress::GetLoadAddress (const SBProcess &process) const
{
if (m_lldb_object_ap.get())
return m_lldb_object_ap->GetLoadAddress(process.get());
else
return LLDB_INVALID_ADDRESS;
}
bool
SBAddress::OffsetAddress (addr_t offset)
{
if (m_lldb_object_ap.get())
{
addr_t addr_offset = m_lldb_object_ap->GetOffset();
if (addr_offset != LLDB_INVALID_ADDRESS)
{
m_lldb_object_ap->SetOffset(addr_offset + offset);
return true;
}
}
return false;
}
const lldb_private::Address *
SBAddress::operator->() const
{
return m_lldb_object_ap.get();
}
const lldb_private::Address &
SBAddress::operator*() const
{
return *m_lldb_object_ap;
}
|