aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Core/Disassembler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lldb/source/Core/Disassembler.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Core/Disassembler.cpp80
1 files changed, 36 insertions, 44 deletions
diff --git a/contrib/llvm-project/lldb/source/Core/Disassembler.cpp b/contrib/llvm-project/lldb/source/Core/Disassembler.cpp
index cc354636987c..104e9100e388 100644
--- a/contrib/llvm-project/lldb/source/Core/Disassembler.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Disassembler.cpp
@@ -41,8 +41,8 @@
#include "lldb/lldb-private-enumerations.h"
#include "lldb/lldb-private-interfaces.h"
#include "lldb/lldb-private-types.h"
-#include "llvm/ADT/Triple.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/TargetParser/Triple.h"
#include <cstdint>
#include <cstring>
@@ -67,20 +67,16 @@ DisassemblerSP Disassembler::FindPlugin(const ArchSpec &arch,
create_callback =
PluginManager::GetDisassemblerCreateCallbackForPluginName(plugin_name);
if (create_callback) {
- DisassemblerSP disassembler_sp(create_callback(arch, flavor));
-
- if (disassembler_sp)
- return disassembler_sp;
+ if (auto disasm_sp = create_callback(arch, flavor))
+ return disasm_sp;
}
} else {
for (uint32_t idx = 0;
(create_callback = PluginManager::GetDisassemblerCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- DisassemblerSP disassembler_sp(create_callback(arch, flavor));
-
- if (disassembler_sp)
- return disassembler_sp;
+ if (auto disasm_sp = create_callback(arch, flavor))
+ return disasm_sp;
}
}
return DisassemblerSP();
@@ -243,7 +239,7 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine(
// Skip any line #0 entries - they are implementation details
if (line.line == 0)
- return false;
+ return true;
ThreadSP thread_sp = exe_ctx.GetThreadSP();
if (thread_sp) {
@@ -253,7 +249,7 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine(
if (target_sp) {
Status error;
OptionValueSP value_sp = target_sp->GetDebugger().GetPropertyValue(
- &exe_ctx, "target.process.thread.step-avoid-regexp", false, error);
+ &exe_ctx, "target.process.thread.step-avoid-regexp", error);
if (value_sp && value_sp->GetType() == OptionValue::eTypeRegex) {
OptionValueRegex *re = value_sp->GetAsRegex();
if (re) {
@@ -691,7 +687,7 @@ bool Instruction::HasDelaySlot() {
return false;
}
-OptionValueSP Instruction::ReadArray(FILE *in_file, Stream *out_stream,
+OptionValueSP Instruction::ReadArray(FILE *in_file, Stream &out_stream,
OptionValue::Type data_type) {
bool done = false;
char buffer[1024];
@@ -701,7 +697,7 @@ OptionValueSP Instruction::ReadArray(FILE *in_file, Stream *out_stream,
int idx = 0;
while (!done) {
if (!fgets(buffer, 1023, in_file)) {
- out_stream->Printf(
+ out_stream.Printf(
"Instruction::ReadArray: Error reading file (fgets).\n");
option_value_sp.reset();
return option_value_sp;
@@ -750,18 +746,18 @@ OptionValueSP Instruction::ReadArray(FILE *in_file, Stream *out_stream,
return option_value_sp;
}
-OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
+OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream &out_stream) {
bool done = false;
char buffer[1024];
auto option_value_sp = std::make_shared<OptionValueDictionary>();
- static ConstString encoding_key("data_encoding");
+ static constexpr llvm::StringLiteral encoding_key("data_encoding");
OptionValue::Type data_type = OptionValue::eTypeInvalid;
while (!done) {
// Read the next line in the file
if (!fgets(buffer, 1023, in_file)) {
- out_stream->Printf(
+ out_stream.Printf(
"Instruction::ReadDictionary: Error reading file (fgets).\n");
option_value_sp.reset();
return option_value_sp;
@@ -796,13 +792,12 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
key = matches[1].str();
value = matches[2].str();
} else {
- out_stream->Printf("Instruction::ReadDictionary: Failure executing "
- "regular expression.\n");
+ out_stream.Printf("Instruction::ReadDictionary: Failure executing "
+ "regular expression.\n");
option_value_sp.reset();
return option_value_sp;
}
- ConstString const_key(key.c_str());
// Check value to see if it's the start of an array or dictionary.
lldb::OptionValueSP value_sp;
@@ -838,15 +833,14 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
value_sp = std::make_shared<OptionValueString>(value.c_str(), "");
}
- if (const_key == encoding_key) {
+ if (key == encoding_key) {
// A 'data_encoding=..." is NOT a normal key-value pair; it is meta-data
- // indicating the
- // data type of an upcoming array (usually the next bit of data to be
- // read in).
- if (strcmp(value.c_str(), "uint32_t") == 0)
+ // indicating the data type of an upcoming array (usually the next bit
+ // of data to be read in).
+ if (llvm::StringRef(value) == "uint32_t")
data_type = OptionValue::eTypeUInt64;
} else
- option_value_sp->GetAsDictionary()->SetValueForKey(const_key, value_sp,
+ option_value_sp->GetAsDictionary()->SetValueForKey(key, value_sp,
false);
}
}
@@ -854,32 +848,29 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream *out_stream) {
return option_value_sp;
}
-bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) {
- if (!out_stream)
- return false;
-
+bool Instruction::TestEmulation(Stream &out_stream, const char *file_name) {
if (!file_name) {
- out_stream->Printf("Instruction::TestEmulation: Missing file_name.");
+ out_stream.Printf("Instruction::TestEmulation: Missing file_name.");
return false;
}
FILE *test_file = FileSystem::Instance().Fopen(file_name, "r");
if (!test_file) {
- out_stream->Printf(
+ out_stream.Printf(
"Instruction::TestEmulation: Attempt to open test file failed.");
return false;
}
char buffer[256];
if (!fgets(buffer, 255, test_file)) {
- out_stream->Printf(
+ out_stream.Printf(
"Instruction::TestEmulation: Error reading first line of test file.\n");
fclose(test_file);
return false;
}
if (strncmp(buffer, "InstructionEmulationState={", 27) != 0) {
- out_stream->Printf("Instructin::TestEmulation: Test file does not contain "
- "emulation state dictionary\n");
+ out_stream.Printf("Instructin::TestEmulation: Test file does not contain "
+ "emulation state dictionary\n");
fclose(test_file);
return false;
}
@@ -889,7 +880,7 @@ bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) {
OptionValueSP data_dictionary_sp(ReadDictionary(test_file, out_stream));
if (!data_dictionary_sp) {
- out_stream->Printf(
+ out_stream.Printf(
"Instruction::TestEmulation: Error reading Dictionary Object.\n");
fclose(test_file);
return false;
@@ -899,28 +890,29 @@ bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) {
OptionValueDictionary *data_dictionary =
data_dictionary_sp->GetAsDictionary();
- static ConstString description_key("assembly_string");
- static ConstString triple_key("triple");
+ static constexpr llvm::StringLiteral description_key("assembly_string");
+ static constexpr llvm::StringLiteral triple_key("triple");
OptionValueSP value_sp = data_dictionary->GetValueForKey(description_key);
if (!value_sp) {
- out_stream->Printf("Instruction::TestEmulation: Test file does not "
- "contain description string.\n");
+ out_stream.Printf("Instruction::TestEmulation: Test file does not "
+ "contain description string.\n");
return false;
}
- SetDescription(value_sp->GetStringValue());
+ SetDescription(value_sp->GetValueAs<llvm::StringRef>().value_or(""));
value_sp = data_dictionary->GetValueForKey(triple_key);
if (!value_sp) {
- out_stream->Printf(
+ out_stream.Printf(
"Instruction::TestEmulation: Test file does not contain triple.\n");
return false;
}
ArchSpec arch;
- arch.SetTriple(llvm::Triple(value_sp->GetStringValue()));
+ arch.SetTriple(
+ llvm::Triple(value_sp->GetValueAs<llvm::StringRef>().value_or("")));
bool success = false;
std::unique_ptr<EmulateInstruction> insn_emulator_up(
@@ -930,9 +922,9 @@ bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) {
insn_emulator_up->TestEmulation(out_stream, arch, data_dictionary);
if (success)
- out_stream->Printf("Emulation test succeeded.");
+ out_stream.Printf("Emulation test succeeded.");
else
- out_stream->Printf("Emulation test failed.");
+ out_stream.Printf("Emulation test failed.");
return success;
}