Skip to content

Commit 7d256c0

Browse files
committed
Adding const modifier to SBAddress methods
1 parent d6a2ca3 commit 7d256c0

File tree

9 files changed

+31
-28
lines changed

9 files changed

+31
-28
lines changed

lldb/include/lldb/API/SBAddress.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class LLDB_API SBAddress {
5656
// will only return valid values if the address has been resolved to a code
5757
// or data address using "void SBAddress::SetLoadAddress(...)" or
5858
// "lldb::SBAddress SBTarget::ResolveLoadAddress (...)".
59-
lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope);
59+
lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const;
6060

6161
// The following functions grab individual objects for a given address and
6262
// are less efficient if you want more than one symbol related objects. Use
@@ -69,21 +69,21 @@ class LLDB_API SBAddress {
6969
// One or more bits from the SymbolContextItem enumerations can be logically
7070
// OR'ed together to more efficiently retrieve multiple symbol objects.
7171

72-
lldb::SBSection GetSection();
72+
lldb::SBSection GetSection() const;
7373

74-
lldb::addr_t GetOffset();
74+
lldb::addr_t GetOffset() const;
7575

76-
lldb::SBModule GetModule();
76+
lldb::SBModule GetModule() const;
7777

78-
lldb::SBCompileUnit GetCompileUnit();
78+
lldb::SBCompileUnit GetCompileUnit() const;
7979

80-
lldb::SBFunction GetFunction();
80+
lldb::SBFunction GetFunction() const;
8181

82-
lldb::SBBlock GetBlock();
82+
lldb::SBBlock GetBlock() const;
8383

84-
lldb::SBSymbol GetSymbol();
84+
lldb::SBSymbol GetSymbol() const;
8585

86-
lldb::SBLineEntry GetLineEntry();
86+
lldb::SBLineEntry GetLineEntry() const;
8787

8888
protected:
8989
friend class SBAddressRange;

lldb/include/lldb/API/SBTarget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ class LLDB_API SBTarget {
585585
lldb::addr_t vm_addr);
586586

587587
SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr,
588-
uint32_t resolve_scope);
588+
uint32_t resolve_scope) const;
589589

590590
/// Read target memory. If a target process is running then memory
591591
/// is read from here. Otherwise the memory is read from the object

lldb/source/API/SBAddress.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool SBAddress::OffsetAddress(addr_t offset) {
149149
return false;
150150
}
151151

152-
lldb::SBSection SBAddress::GetSection() {
152+
lldb::SBSection SBAddress::GetSection() const {
153153
LLDB_INSTRUMENT_VA(this);
154154

155155
lldb::SBSection sb_section;
@@ -158,7 +158,7 @@ lldb::SBSection SBAddress::GetSection() {
158158
return sb_section;
159159
}
160160

161-
lldb::addr_t SBAddress::GetOffset() {
161+
lldb::addr_t SBAddress::GetOffset() const {
162162
LLDB_INSTRUMENT_VA(this);
163163

164164
if (m_opaque_up->IsValid())
@@ -200,7 +200,7 @@ bool SBAddress::GetDescription(SBStream &description) {
200200
return true;
201201
}
202202

203-
SBModule SBAddress::GetModule() {
203+
SBModule SBAddress::GetModule() const {
204204
LLDB_INSTRUMENT_VA(this);
205205

206206
SBModule sb_module;
@@ -209,7 +209,7 @@ SBModule SBAddress::GetModule() {
209209
return sb_module;
210210
}
211211

212-
SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) {
212+
SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) const {
213213
LLDB_INSTRUMENT_VA(this, resolve_scope);
214214

215215
SBSymbolContext sb_sc;
@@ -219,7 +219,7 @@ SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) {
219219
return sb_sc;
220220
}
221221

222-
SBCompileUnit SBAddress::GetCompileUnit() {
222+
SBCompileUnit SBAddress::GetCompileUnit() const {
223223
LLDB_INSTRUMENT_VA(this);
224224

225225
SBCompileUnit sb_comp_unit;
@@ -228,7 +228,7 @@ SBCompileUnit SBAddress::GetCompileUnit() {
228228
return sb_comp_unit;
229229
}
230230

231-
SBFunction SBAddress::GetFunction() {
231+
SBFunction SBAddress::GetFunction() const {
232232
LLDB_INSTRUMENT_VA(this);
233233

234234
SBFunction sb_function;
@@ -237,7 +237,7 @@ SBFunction SBAddress::GetFunction() {
237237
return sb_function;
238238
}
239239

240-
SBBlock SBAddress::GetBlock() {
240+
SBBlock SBAddress::GetBlock() const {
241241
LLDB_INSTRUMENT_VA(this);
242242

243243
SBBlock sb_block;
@@ -246,7 +246,7 @@ SBBlock SBAddress::GetBlock() {
246246
return sb_block;
247247
}
248248

249-
SBSymbol SBAddress::GetSymbol() {
249+
SBSymbol SBAddress::GetSymbol() const {
250250
LLDB_INSTRUMENT_VA(this);
251251

252252
SBSymbol sb_symbol;
@@ -255,7 +255,7 @@ SBSymbol SBAddress::GetSymbol() {
255255
return sb_symbol;
256256
}
257257

258-
SBLineEntry SBAddress::GetLineEntry() {
258+
SBLineEntry SBAddress::GetLineEntry() const {
259259
LLDB_INSTRUMENT_VA(this);
260260

261261
SBLineEntry sb_line_entry;

lldb/source/API/SBTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id,
633633

634634
SBSymbolContext
635635
SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
636-
uint32_t resolve_scope) {
636+
uint32_t resolve_scope) const {
637637
LLDB_INSTRUMENT_VA(this, addr, resolve_scope);
638638

639639
SBSymbolContext sb_sc;

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "DAP.h"
1111
#include "ExceptionBreakpoint.h"
1212
#include "LLDBUtils.h"
13+
#include "Protocol/ProtocolTypes.h"
1314
#include "ProtocolUtils.h"
1415
#include "lldb/API/SBAddress.h"
1516
#include "lldb/API/SBCompileUnit.h"
@@ -581,8 +582,8 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame,
581582

582583
EmplaceSafeString(object, "name", frame_name);
583584

584-
auto target = frame.GetThread().GetProcess().GetTarget();
585-
auto source = CreateSource(frame.GetPCAddress(), target);
585+
protocol::Source source = CreateSource(
586+
frame.GetPCAddress(), frame.GetThread().GetProcess().GetTarget());
586587
if (!IsAssemblySource(source)) {
587588
// This is a normal source with a valid line entry.
588589
auto line_entry = frame.GetLineEntry();

lldb/tools/lldb-dap/LLDBUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ std::string GetSBFileSpecPath(const lldb::SBFileSpec &file_spec) {
252252
return path;
253253
}
254254

255-
lldb::SBLineEntry GetLineEntryForAddress(lldb::SBTarget &target,
255+
lldb::SBLineEntry GetLineEntryForAddress(const lldb::SBTarget &target,
256256
const lldb::SBAddress &address) {
257257
lldb::SBSymbolContext sc = target.ResolveSymbolContextForAddress(
258258
address, lldb::eSymbolContextLineEntry);

lldb/tools/lldb-dap/LLDBUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ std::string GetSBFileSpecPath(const lldb::SBFileSpec &file_spec);
182182
///
183183
/// \return
184184
/// The line entry for the given address.
185-
lldb::SBLineEntry GetLineEntryForAddress(lldb::SBTarget &target,
185+
lldb::SBLineEntry GetLineEntryForAddress(const lldb::SBTarget &target,
186186
const lldb::SBAddress &address);
187187

188188
/// Helper for sending telemetry to lldb server, if client-telemetry is enabled.

lldb/tools/lldb-dap/ProtocolUtils.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace lldb_dap {
1616

1717
static bool ShouldDisplayAssemblySource(
18-
lldb::SBAddress address,
18+
const lldb::SBAddress &address,
1919
lldb::StopDisassemblyType stop_disassembly_display) {
2020
if (stop_disassembly_display == lldb::eStopDisassemblyTypeNever)
2121
return false;
@@ -40,7 +40,7 @@ static bool ShouldDisplayAssemblySource(
4040
}
4141

4242
static protocol::Source CreateAssemblySource(const lldb::SBTarget &target,
43-
lldb::SBAddress address) {
43+
const lldb::SBAddress &address) {
4444
protocol::Source source;
4545

4646
auto symbol = address.GetSymbol();
@@ -87,7 +87,8 @@ protocol::Source CreateSource(const lldb::SBFileSpec &file) {
8787
return source;
8888
}
8989

90-
protocol::Source CreateSource(lldb::SBAddress address, lldb::SBTarget &target) {
90+
protocol::Source CreateSource(const lldb::SBAddress &address,
91+
const lldb::SBTarget &target) {
9192
lldb::SBDebugger debugger = target.GetDebugger();
9293
lldb::StopDisassemblyType stop_disassembly_display =
9394
GetStopDisassemblyDisplay(debugger);

lldb/tools/lldb-dap/ProtocolUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ protocol::Source CreateSource(const lldb::SBFileSpec &file);
4040
/// \return
4141
/// A "Source" JSON object that follows the formal JSON
4242
/// definition outlined by Microsoft.
43-
protocol::Source CreateSource(lldb::SBAddress address, lldb::SBTarget &target);
43+
protocol::Source CreateSource(const lldb::SBAddress &address,
44+
const lldb::SBTarget &target);
4445

4546
/// Checks if the given source is for assembly code.
4647
bool IsAssemblySource(const protocol::Source &source);

0 commit comments

Comments
 (0)