[trace][intelpt] fix some test failures

Minor fixes needed and now `./bin/lldb-dotest -p TestTrace` passes
correctly.

- There was an incorrect iteration.
- Some error messages changed.
- The way repeat commands are handled changed a bit, so I had to create
a new --continue arg in "thread trace dump instructions" to handle this
correctly.

Differential Revision: https://reviews.llvm.org/D122023
This commit is contained in:
Walter Erquinigo 2022-03-18 09:22:27 -07:00
parent 217f267efe
commit b7d525ad38
6 changed files with 24 additions and 22 deletions

View File

@ -2032,7 +2032,7 @@ public:
unsigned i = 0;
for (llvm::StringRef plugin_name =
PluginManager::GetTraceExporterPluginNameAtIndex(i++);
PluginManager::GetTraceExporterPluginNameAtIndex(i);
!plugin_name.empty();
plugin_name = PluginManager::GetTraceExporterPluginNameAtIndex(i++)) {
if (ThreadTraceExportCommandCreator command_creator =
@ -2147,6 +2147,10 @@ public:
m_show_tsc = true;
break;
}
case 'C': {
m_continue = true;
break;
}
default:
llvm_unreachable("Unimplemented option");
}
@ -2159,6 +2163,7 @@ public:
m_raw = false;
m_forwards = false;
m_show_tsc = false;
m_continue = false;
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@ -2173,6 +2178,7 @@ public:
bool m_raw;
bool m_forwards;
bool m_show_tsc;
bool m_continue;
};
CommandObjectTraceDumpInstructions(CommandInterpreter &interpreter)
@ -2192,24 +2198,19 @@ public:
llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
uint32_t index) override {
current_command_args.GetCommandString(m_repeat_command);
m_create_repeat_command_just_invoked = true;
return m_repeat_command;
std::string cmd;
current_command_args.GetCommandString(cmd);
if (cmd.find("--continue") == std::string::npos)
cmd += " --continue";
return cmd;
}
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
if (!IsRepeatCommand())
if (!m_options.m_continue)
m_dumpers.clear();
bool status = CommandObjectIterateOverThreads::DoExecute(args, result);
m_create_repeat_command_just_invoked = false;
return status;
}
bool IsRepeatCommand() {
return !m_repeat_command.empty() && !m_create_repeat_command_just_invoked;
return CommandObjectIterateOverThreads::DoExecute(args, result);
}
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
@ -2249,10 +2250,6 @@ protected:
}
CommandOptions m_options;
// Repeat command helpers
std::string m_repeat_command;
bool m_create_repeat_command_just_invoked = false;
std::map<lldb::tid_t, std::unique_ptr<TraceInstructionDumper>> m_dumpers;
};

View File

@ -1116,6 +1116,12 @@ let Command = "thread trace dump instructions" in {
def thread_trace_dump_instructions_show_tsc : Option<"tsc", "t">,
Group<1>,
Desc<"For each instruction, print the corresponding timestamp counter if available.">;
def thread_trace_dump_instructions_continue: Option<"continue", "C">,
Group<1>,
Desc<"Continue dumping instructions right where the previous invocation of this "
"command was left, or from the beginning if this is the first invocation. The --skip "
"argument is discarded and the other arguments are preserved from the previous "
"invocation when possible.">;
}
let Command = "thread trace dump info" in {

View File

@ -18,7 +18,7 @@ class TestTraceDumpInfo(TraceIntelPTTestCaseBase):
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
self.expect("thread trace dump info",
substrs=["error: invalid process"],
substrs=["error: Command requires a current process."],
error=True)
# Now we check the output when there's a running target without a trace

View File

@ -19,7 +19,7 @@ class TestTraceDumpInstructions(TraceIntelPTTestCaseBase):
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
self.expect("thread trace dump instructions",
substrs=["error: invalid process"],
substrs=["error: Command requires a current process."],
error=True)
# Now we check the output when there's a running target without a trace

View File

@ -23,7 +23,7 @@ class TestTraceExport(TraceIntelPTTestCaseBase):
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
self.expect(f"thread trace export ctf --file {ctf_test_file}",
substrs=["error: invalid process"],
substrs=["error: Command requires a current process."],
error=True)
# Now we check the output when there's a running target without a trace
@ -172,4 +172,3 @@ class TestTraceExport(TraceIntelPTTestCaseBase):
data_index = index_of_first_layer_1_block
for i in range(len(expected_block_names)):
self.assertTrue(data[data_index + i]['name'] == expected_block_names[i])

View File

@ -18,7 +18,7 @@ class TestTraceSave(TraceIntelPTTestCaseBase):
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
self.expect("process trace save",
substrs=["error: invalid process"],
substrs=["error: Command requires a current process."],
error=True)
# Now we check the output when there's a running target without a trace