From c2d061da7e17e61d4a0efad261e5280793c1b7ce Mon Sep 17 00:00:00 2001 From: royitaqi Date: Mon, 3 Jun 2024 13:52:03 -0700 Subject: 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 --- lldb/source/Interpreter/CommandInterpreter.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp') 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 #include #include #include @@ -1909,6 +1910,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line, transcript_item = std::make_shared(); transcript_item->AddStringItem("command", command_line); + transcript_item->AddIntegerItem( + "timestampInEpochSeconds", + std::chrono::duration_cast( + 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(); -- cgit v1.1