Skip to content

Commit 70d9ce3

Browse files
committed
cleaner SBInstructionList::GetDescription
1 parent cb03788 commit 70d9ce3

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lldb/include/lldb/API/SBInstructionList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class LLDB_API SBInstructionList {
6868

6969
void SetDisassembler(const lldb::DisassemblerSP &opaque_sp);
7070
bool GetDescription(lldb_private::Stream &description,
71-
lldb::SBExecutionContext *exe_ctx = nullptr);
71+
lldb_private::ExecutionContext *exe_ctx = nullptr);
7272

7373
private:
7474
lldb::DisassemblerSP m_opaque_sp;

lldb/source/API/SBInstructionList.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "lldb/Target/ExecutionContext.h"
2020
#include "lldb/Utility/Instrumentation.h"
2121
#include "lldb/Utility/Stream.h"
22-
#include <memory>
2322

2423
using namespace lldb;
2524
using namespace lldb_private;
@@ -144,11 +143,12 @@ bool SBInstructionList::GetDescription(lldb::SBStream &stream) {
144143
bool SBInstructionList::GetDescription(lldb::SBStream &stream,
145144
lldb::SBExecutionContext &exe_ctx) {
146145
LLDB_INSTRUMENT_VA(this, stream);
147-
return GetDescription(stream.ref(), &exe_ctx);
146+
ExecutionContext exe_ctx_wrapper(exe_ctx.get());
147+
return GetDescription(stream.ref(), &exe_ctx_wrapper);
148148
}
149149

150-
bool SBInstructionList::GetDescription(Stream &sref,
151-
lldb::SBExecutionContext *exe_ctx) {
150+
bool SBInstructionList::GetDescription(
151+
Stream &sref, lldb_private::ExecutionContext *exe_ctx) {
152152

153153
if (m_opaque_sp) {
154154
size_t num_instructions = GetSize();
@@ -162,11 +162,6 @@ bool SBInstructionList::GetDescription(Stream &sref,
162162
SymbolContext sc;
163163
SymbolContext prev_sc;
164164

165-
std::shared_ptr<ExecutionContext> exe_ctx_ptr;
166-
if (nullptr != exe_ctx) {
167-
exe_ctx_ptr = std::make_shared<ExecutionContext>(exe_ctx->get());
168-
}
169-
170165
// Expected address of the next instruction. Used to print an empty line
171166
// for non-contiguous blocks of insns.
172167
std::optional<Address> next_addr;
@@ -187,8 +182,8 @@ bool SBInstructionList::GetDescription(Stream &sref,
187182
if (next_addr && *next_addr != addr)
188183
sref.EOL();
189184
inst->Dump(&sref, max_opcode_byte_size, true, false,
190-
/*show_control_flow_kind=*/false, exe_ctx_ptr.get(), &sc,
191-
&prev_sc, &format, 0);
185+
/*show_control_flow_kind=*/false, exe_ctx, &sc, &prev_sc,
186+
&format, 0);
192187
sref.EOL();
193188
next_addr = addr;
194189
next_addr->Slide(inst->GetOpcode().GetByteSize());

0 commit comments

Comments
 (0)