Skip to content

Commit b7d525a

Browse files
author
Walter Erquinigo
committed
[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
1 parent 217f267 commit b7d525a

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

lldb/source/Commands/CommandObjectThread.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ class CommandObjectTraceExport : public CommandObjectMultiword {
20322032

20332033
unsigned i = 0;
20342034
for (llvm::StringRef plugin_name =
2035-
PluginManager::GetTraceExporterPluginNameAtIndex(i++);
2035+
PluginManager::GetTraceExporterPluginNameAtIndex(i);
20362036
!plugin_name.empty();
20372037
plugin_name = PluginManager::GetTraceExporterPluginNameAtIndex(i++)) {
20382038
if (ThreadTraceExportCommandCreator command_creator =
@@ -2147,6 +2147,10 @@ class CommandObjectTraceDumpInstructions
21472147
m_show_tsc = true;
21482148
break;
21492149
}
2150+
case 'C': {
2151+
m_continue = true;
2152+
break;
2153+
}
21502154
default:
21512155
llvm_unreachable("Unimplemented option");
21522156
}
@@ -2159,6 +2163,7 @@ class CommandObjectTraceDumpInstructions
21592163
m_raw = false;
21602164
m_forwards = false;
21612165
m_show_tsc = false;
2166+
m_continue = false;
21622167
}
21632168

21642169
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -2173,6 +2178,7 @@ class CommandObjectTraceDumpInstructions
21732178
bool m_raw;
21742179
bool m_forwards;
21752180
bool m_show_tsc;
2181+
bool m_continue;
21762182
};
21772183

21782184
CommandObjectTraceDumpInstructions(CommandInterpreter &interpreter)
@@ -2192,24 +2198,19 @@ class CommandObjectTraceDumpInstructions
21922198

21932199
llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
21942200
uint32_t index) override {
2195-
current_command_args.GetCommandString(m_repeat_command);
2196-
m_create_repeat_command_just_invoked = true;
2197-
return m_repeat_command;
2201+
std::string cmd;
2202+
current_command_args.GetCommandString(cmd);
2203+
if (cmd.find("--continue") == std::string::npos)
2204+
cmd += " --continue";
2205+
return cmd;
21982206
}
21992207

22002208
protected:
22012209
bool DoExecute(Args &args, CommandReturnObject &result) override {
2202-
if (!IsRepeatCommand())
2210+
if (!m_options.m_continue)
22032211
m_dumpers.clear();
22042212

2205-
bool status = CommandObjectIterateOverThreads::DoExecute(args, result);
2206-
2207-
m_create_repeat_command_just_invoked = false;
2208-
return status;
2209-
}
2210-
2211-
bool IsRepeatCommand() {
2212-
return !m_repeat_command.empty() && !m_create_repeat_command_just_invoked;
2213+
return CommandObjectIterateOverThreads::DoExecute(args, result);
22132214
}
22142215

22152216
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
@@ -2249,10 +2250,6 @@ class CommandObjectTraceDumpInstructions
22492250
}
22502251

22512252
CommandOptions m_options;
2252-
2253-
// Repeat command helpers
2254-
std::string m_repeat_command;
2255-
bool m_create_repeat_command_just_invoked = false;
22562253
std::map<lldb::tid_t, std::unique_ptr<TraceInstructionDumper>> m_dumpers;
22572254
};
22582255

lldb/source/Commands/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,12 @@ let Command = "thread trace dump instructions" in {
11161116
def thread_trace_dump_instructions_show_tsc : Option<"tsc", "t">,
11171117
Group<1>,
11181118
Desc<"For each instruction, print the corresponding timestamp counter if available.">;
1119+
def thread_trace_dump_instructions_continue: Option<"continue", "C">,
1120+
Group<1>,
1121+
Desc<"Continue dumping instructions right where the previous invocation of this "
1122+
"command was left, or from the beginning if this is the first invocation. The --skip "
1123+
"argument is discarded and the other arguments are preserved from the previous "
1124+
"invocation when possible.">;
11191125
}
11201126

11211127
let Command = "thread trace dump info" in {

lldb/test/API/commands/trace/TestTraceDumpInfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def testErrorMessages(self):
1818
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
1919

2020
self.expect("thread trace dump info",
21-
substrs=["error: invalid process"],
21+
substrs=["error: Command requires a current process."],
2222
error=True)
2323

2424
# Now we check the output when there's a running target without a trace

lldb/test/API/commands/trace/TestTraceDumpInstructions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def testErrorMessages(self):
1919
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
2020

2121
self.expect("thread trace dump instructions",
22-
substrs=["error: invalid process"],
22+
substrs=["error: Command requires a current process."],
2323
error=True)
2424

2525
# Now we check the output when there's a running target without a trace

lldb/test/API/commands/trace/TestTraceExport.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def testErrorMessages(self):
2323
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
2424

2525
self.expect(f"thread trace export ctf --file {ctf_test_file}",
26-
substrs=["error: invalid process"],
26+
substrs=["error: Command requires a current process."],
2727
error=True)
2828

2929
# Now we check the output when there's a running target without a trace
@@ -172,4 +172,3 @@ def testHtrBasicSuperBlockPassSequenceCheck(self):
172172
data_index = index_of_first_layer_1_block
173173
for i in range(len(expected_block_names)):
174174
self.assertTrue(data[data_index + i]['name'] == expected_block_names[i])
175-

lldb/test/API/commands/trace/TestTraceSave.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def testErrorMessages(self):
1818
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
1919

2020
self.expect("process trace save",
21-
substrs=["error: invalid process"],
21+
substrs=["error: Command requires a current process."],
2222
error=True)
2323

2424
# Now we check the output when there's a running target without a trace

0 commit comments

Comments
 (0)