1515#include " lldb/Core/Module.h"
1616#include " lldb/Host/StreamFile.h"
1717#include " lldb/Symbol/SymbolContext.h"
18+ #include " lldb/Target/ExecutionContext.h"
1819#include " lldb/Utility/Instrumentation.h"
1920#include " lldb/Utility/Stream.h"
21+ #include < memory>
2022
2123using namespace lldb ;
2224using namespace lldb_private ;
@@ -114,31 +116,37 @@ void SBInstructionList::Print(FILE *out) {
114116 if (out == nullptr )
115117 return ;
116118 StreamFile stream (out, false );
117- GetDescription (stream);
119+ GetDescription (stream, nullptr );
118120}
119121
120122void SBInstructionList::Print (SBFile out) {
121123 LLDB_INSTRUMENT_VA (this , out);
122124 if (!out.IsValid ())
123125 return ;
124126 StreamFile stream (out.m_opaque_sp );
125- GetDescription (stream);
127+ GetDescription (stream, nullptr );
126128}
127129
128130void SBInstructionList::Print (FileSP out_sp) {
129131 LLDB_INSTRUMENT_VA (this , out_sp);
130132 if (!out_sp || !out_sp->IsValid ())
131133 return ;
132134 StreamFile stream (out_sp);
133- GetDescription (stream);
135+ GetDescription (stream, nullptr );
134136}
135137
136138bool SBInstructionList::GetDescription (lldb::SBStream &stream) {
137139 LLDB_INSTRUMENT_VA (this , stream);
138- return GetDescription (stream.ref ());
140+ return GetDescription (stream.ref (), nullptr );
139141}
140142
141- bool SBInstructionList::GetDescription (Stream &sref) {
143+ bool SBInstructionList::GetDescription (lldb::SBStream &stream,
144+ lldb::SBFrame &frame) {
145+ LLDB_INSTRUMENT_VA (this , stream);
146+ return GetDescription (stream.ref (), &frame);
147+ }
148+
149+ bool SBInstructionList::GetDescription (Stream &sref, lldb::SBFrame *frame) {
142150
143151 if (m_opaque_sp) {
144152 size_t num_instructions = GetSize ();
@@ -148,10 +156,15 @@ bool SBInstructionList::GetDescription(Stream &sref) {
148156 const uint32_t max_opcode_byte_size =
149157 m_opaque_sp->GetInstructionList ().GetMaxOpcocdeByteSize ();
150158 FormatEntity::Entry format;
151- FormatEntity::Parse (" ${addr}: " , format);
159+ FormatEntity::Parse (" ${addr-file-or-load }: " , format);
152160 SymbolContext sc;
153161 SymbolContext prev_sc;
154162
163+ std::shared_ptr<ExecutionContext> exec_ctx;
164+ if (nullptr != frame) {
165+ exec_ctx = std::make_shared<ExecutionContext>(frame->GetFrameSP ());
166+ }
167+
155168 // Expected address of the next instruction. Used to print an empty line
156169 // for non-contiguous blocks of insns.
157170 std::optional<Address> next_addr;
@@ -172,8 +185,8 @@ bool SBInstructionList::GetDescription(Stream &sref) {
172185 if (next_addr && *next_addr != addr)
173186 sref.EOL ();
174187 inst->Dump (&sref, max_opcode_byte_size, true , false ,
175- /* show_control_flow_kind=*/ false , nullptr , &sc, &prev_sc ,
176- &format, 0 );
188+ /* show_control_flow_kind=*/ false , exec_ctx. get () , &sc,
189+ &prev_sc, & format, 0 );
177190 sref.EOL ();
178191 next_addr = addr;
179192 next_addr->Slide (inst->GetOpcode ().GetByteSize ());
0 commit comments