diff options
author | royitaqi <royitaqi@users.noreply.github.com> | 2024-06-03 13:52:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 13:52:03 -0700 |
commit | c2d061da7e17e61d4a0efad261e5280793c1b7ce (patch) | |
tree | 1d569a2d7ff416b699b93ab55b71db7492b27089 /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | b61d7ec16bf5c740346e87b8b03315e38fe31725 (diff) | |
download | llvm-c2d061da7e17e61d4a0efad261e5280793c1b7ce.zip llvm-c2d061da7e17e61d4a0efad261e5280793c1b7ce.tar.gz llvm-c2d061da7e17e61d4a0efad261e5280793c1b7ce.tar.bz2 |
Re-merge `A few updates around "transcript"` (#92843) (#94067)
Problematic PR: https://github.com/llvm/llvm-project/pull/92843
Reverted by: https://github.com/llvm/llvm-project/pull/94088
The first PR added a test which fails in Linux builds (see the last few
comments there).
This PR contains all the changes in the first PR, plus the fix to the
said test.
---------
Co-authored-by: Roy Shi <royshi@meta.com>
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 6a61882d..acd6294c 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include <chrono> #include <cstdlib> #include <limits> #include <memory> @@ -1909,6 +1910,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line, transcript_item = std::make_shared<StructuredData::Dictionary>(); transcript_item->AddStringItem("command", command_line); + transcript_item->AddIntegerItem( + "timestampInEpochSeconds", + std::chrono::duration_cast<std::chrono::seconds>( + std::chrono::system_clock::now().time_since_epoch()) + .count()); m_transcript.AddItem(transcript_item); } @@ -2056,6 +2062,14 @@ bool CommandInterpreter::HandleCommand(const char *command_line, log, "HandleCommand, command line after removing command name(s): '%s'", remainder.c_str()); + // To test whether or not transcript should be saved, `transcript_item` is + // used instead of `GetSaveTrasncript()`. This is because the latter will + // fail when the command is "settings set interpreter.save-transcript true". + if (transcript_item) { + transcript_item->AddStringItem("commandName", cmd_obj->GetCommandName()); + transcript_item->AddStringItem("commandArguments", remainder); + } + ElapsedTime elapsed(execute_time); cmd_obj->Execute(remainder.c_str(), result); } @@ -2072,7 +2086,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line, transcript_item->AddStringItem("output", result.GetOutputData()); transcript_item->AddStringItem("error", result.GetErrorData()); - transcript_item->AddFloatItem("seconds", execute_time.get().count()); + transcript_item->AddFloatItem("durationInSeconds", + execute_time.get().count()); } return result.Succeeded(); |