Skip to content

Commit 6d3872f

Browse files
committed
[lldb] use the default instruction flavour if none is provided
this is already done in the other overloaded function `SBTarget::ReadInstructions::(SBAddress, SBAddress, const char *)` It completes it to be more in line wither other `ReadInstruction/GetInstructions` api
1 parent cb7d68a commit 6d3872f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lldb/source/API/SBTarget.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,17 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
20392039
const size_t bytes_read =
20402040
target_sp->ReadMemory(*addr_ptr, data.GetBytes(), data.GetByteSize(),
20412041
error, force_live_memory, &load_addr);
2042+
20422043
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
2044+
if (!flavor_string || flavor_string[0] == '\0') {
2045+
// FIXME - we don't have the mechanism in place to do per-architecture
2046+
// settings. But since we know that for now we only support flavors on
2047+
// x86 & x86_64,
2048+
const llvm::Triple::ArchType arch =
2049+
target_sp->GetArchitecture().GetTriple().getArch();
2050+
if (arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)
2051+
flavor_string = target_sp->GetDisassemblyFlavor();
2052+
}
20432053
sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
20442054
target_sp->GetArchitecture(), nullptr, flavor_string,
20452055
target_sp->GetDisassemblyCPU(), target_sp->GetDisassemblyFeatures(),
@@ -2098,7 +2108,16 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
20982108
if (base_addr.get())
20992109
addr = *base_addr.get();
21002110

2101-
const bool data_from_file = true;
2111+
constexpr bool data_from_file = true;
2112+
if (!flavor_string || flavor_string[0] == '\0') {
2113+
// FIXME - we don't have the mechanism in place to do per-architecture
2114+
// settings. But since we know that for now we only support flavors on
2115+
// x86 & x86_64,
2116+
const llvm::Triple::ArchType arch =
2117+
target_sp->GetArchitecture().GetTriple().getArch();
2118+
if (arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)
2119+
flavor_string = target_sp->GetDisassemblyFlavor();
2120+
}
21022121

21032122
sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
21042123
target_sp->GetArchitecture(), nullptr, flavor_string,

0 commit comments

Comments
 (0)