[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: teemperor, JDevlieghere.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch introduces a new interpreter setting
`interpreter.save-session-directory` so the user can specify a directory
where the session transcripts will be saved.

If not set, the session transcript are saved on a temporary file.

rdar://72902842

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105030

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- lldb/test/API/commands/session/save/TestSessionSave.py
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -1,7 +1,7 @@
 """
 Test the session save feature
 """
-
+import os
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -72,3 +72,20 @@
   lines = raw.splitlines()[:-1]
   for line in lines:
 self.assertIn(line, content)
+
+td = tempfile.TemporaryDirectory()
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('settings set interpreter.save-session-directory ' + td.name, res)
+self.assertTrue(res.Succeeded())
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('session save', res)
+self.assertTrue(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
+  content = file.read()
+  # Exclude last line, since session won't record it's own output
+  lines = raw.splitlines()[:-1]
+  for line in lines:
+self.assertIn(line, content)
Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,9 @@
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
+DefaultStringValue<"">,
+Desc<"A path where LLDB will save the session's transcripts.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -160,6 +160,16 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
+  const uint32_t idx = ePropertySaveSessionDirectory;
+  return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+}
+
+void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) {
+  const uint32_t idx = ePropertySaveSessionDirectory;
+  m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
+}
+
 bool CommandInterpreter::GetEchoCommands() const {
   const uint32_t idx = ePropertyEchoCommands;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -2925,9 +2935,15 @@
 std::string now = llvm::to_string(std::chrono::system_clock::now());
 std::replace(now.begin(), now.end(), ' ', '_');
 const std::string file_name = "lldb_session_" + now + ".log";
-FileSpec tmp = HostInfo::GetGlobalTempDir();
-tmp.AppendPathComponent(file_name);
-output_file = tmp.GetPath();
+
+FileSpec save_location = GetSaveSessionDirectory();
+
+if (!save_location)
+  save_location = HostInfo::GetGlobalTempDir();
+
+FileSystem::Instance().Resolve(save_location);
+save_location.AppendPathComponent(file_name);
+output_file = save_location.GetPath();
   }
 
   auto error_out = [&](llvm::StringRef error_message, std::string description) {
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -493,6 +493,9 @@
   bool GetSaveSessionOnQuit() const;
   void SetSaveSessionOnQuit(bool enable);
 
+  FileSpec GetSaveSessionDirectory() const;
+  void SetSaveSessionDirectory(llvm::StringRef path);
+
   bool GetEchoCommands() const;
   void SetEchoCommands(bool enable);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105034: [lldb/lua] Add scripted watchpoints for Lua

2021-06-28 Thread Siger Young via Phabricator via lldb-commits
siger-young created this revision.
siger-young added reviewers: tammela, JDevlieghere.
siger-young added a project: LLDB.
siger-young requested review of this revision.
Herald added a subscriber: lldb-commits.

Add support for Lua scripted watchpoints, with basic tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105034

Files:
  lldb/bindings/lua/lua-swigsafecast.swig
  lldb/bindings/lua/lua-wrapper.swig
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test
  lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp

Index: lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
===
--- lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
+++ lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
@@ -30,6 +30,11 @@
   return false;
 }
 
+extern "C" llvm::Expected LLDBSwigLuaWatchpointCallbackFunction(
+lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) {
+  return false;
+}
+
 #if _MSC_VER
 #pragma warning (pop)
 #endif
Index: lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test
===
--- lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test
+++ lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test
@@ -1,9 +1,15 @@
 # REQUIRES: lua
 # XFAIL: system-netbsd
-# RUN: echo "int main() { return 0; }" | %clang_host -x c - -o %t
+# RUN: echo "int main() { int val = 1; val++; return 0; }" | %clang_host -x c - -g -o %t
 # RUN: %lldb -s %s --script-language lua %t 2>&1 | FileCheck %s
 b main
 r
-watchpoint set expr 0x0
+watchpoint set variable val
 watchpoint command add -s lua
-# CHECK: error: This script interpreter does not support watchpoint callbacks
+print("val="..tostring(frame:FindVariable("val"):GetValue()))
+quit
+c
+# CHECK: val=1
+# CHECK: val=2
+# CHECK: val=nil
+# CHECK: Process {{[0-9]+}} exited
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_ScriptInterpreterLua_h_
 #define liblldb_ScriptInterpreterLua_h_
 
+#include "lldb/Breakpoint/WatchpointOptions.h"
 #include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Utility/Status.h"
@@ -61,6 +62,10 @@
  lldb::user_id_t break_id,
  lldb::user_id_t break_loc_id);
 
+  static bool WatchpointCallbackFunction(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t watch_id);
+
   // PluginInterface protocol
   lldb_private::ConstString GetPluginName() override;
 
@@ -75,9 +80,16 @@
   std::vector &bp_options_vec,
   CommandReturnObject &result) override;
 
+  void
+  CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options,
+  CommandReturnObject &result) override;
+
   Status SetBreakpointCommandCallback(BreakpointOptions *bp_options,
   const char *command_body_text) override;
 
+  void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
+const char *command_body_text) override;
+
   Status SetBreakpointCommandCallbackFunction(
   BreakpointOptions *bp_options, const char *function_name,
   StructuredData::ObjectSP extra_args_sp) override;
@@ -89,6 +101,10 @@
   Status RegisterBreakpointCallback(BreakpointOptions *bp_options,
 const char *command_body_text,
 StructuredData::ObjectSP extra_args_sp);
+
+  Status RegisterWatchpointCallback(WatchpointOptions *wp_options,
+const char *command_body_text,
+StructuredData::ObjectSP extra_args_sp);
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -58,7 +58,13 @@
 const char *instructions = nullptr;
 switch (m_active_io_handler) {
 case eIOHandlerNone:
+  break;
 case eIOHandlerWatchpoint:
+  instructions = "Enter your Lua command(s). Type 'quit' to end.\n"
+ "The commands are compiled as the body of the following "
+   

[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Interpreter/InterpreterProperties.td:18
+DefaultStringValue<"">,
+Desc<"A path where LLDB will save the session's transcripts.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", 
"Boolean">,

Given that `session save` already takes a file, I think it would make sense to 
call out here that this is particularly useful in combination with 
`save-session-on-quit`. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105030/new/

https://reviews.llvm.org/D105030

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/source/Interpreter/InterpreterProperties.td:18
+DefaultStringValue<"">,
+Desc<"A path where LLDB will save the session's transcripts.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", 
"Boolean">,

JDevlieghere wrote:
> Given that `session save` already takes a file, I think it would make sense 
> to call out here that this is particularly useful in combination with 
> `save-session-on-quit`. 
Just to clarify, `session save` can be used with no arguments, in which case, 
the transcript will either be saved to a temporary folder or at the location 
set in this property.

But I can definitely mention that it is very useful with `save-session-on-quit`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105030/new/

https://reviews.llvm.org/D105030

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 354916.
mib added a comment.

Address @JDevlieghere comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105030/new/

https://reviews.llvm.org/D105030

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- lldb/test/API/commands/session/save/TestSessionSave.py
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -1,7 +1,7 @@
 """
 Test the session save feature
 """
-
+import os
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -72,3 +72,20 @@
   lines = raw.splitlines()[:-1]
   for line in lines:
 self.assertIn(line, content)
+
+td = tempfile.TemporaryDirectory()
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('settings set interpreter.save-session-directory ' + td.name, res)
+self.assertTrue(res.Succeeded())
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('session save', res)
+self.assertTrue(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
+  content = file.read()
+  # Exclude last line, since session won't record it's own output
+  lines = raw.splitlines()[:-1]
+  for line in lines:
+self.assertIn(line, content)
Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,9 @@
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
+DefaultStringValue<"">,
+Desc<"A path where LLDB will save the session's transcripts. This setting is particularly useful when `save-session-on-quit` is enabled.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -160,6 +160,16 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
+  const uint32_t idx = ePropertySaveSessionDirectory;
+  return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+}
+
+void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) {
+  const uint32_t idx = ePropertySaveSessionDirectory;
+  m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
+}
+
 bool CommandInterpreter::GetEchoCommands() const {
   const uint32_t idx = ePropertyEchoCommands;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -2925,9 +2935,15 @@
 std::string now = llvm::to_string(std::chrono::system_clock::now());
 std::replace(now.begin(), now.end(), ' ', '_');
 const std::string file_name = "lldb_session_" + now + ".log";
-FileSpec tmp = HostInfo::GetGlobalTempDir();
-tmp.AppendPathComponent(file_name);
-output_file = tmp.GetPath();
+
+FileSpec save_location = GetSaveSessionDirectory();
+
+if (!save_location)
+  save_location = HostInfo::GetGlobalTempDir();
+
+FileSystem::Instance().Resolve(save_location);
+save_location.AppendPathComponent(file_name);
+output_file = save_location.GetPath();
   }
 
   auto error_out = [&](llvm::StringRef error_message, std::string description) {
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -493,6 +493,9 @@
   bool GetSaveSessionOnQuit() const;
   void SetSaveSessionOnQuit(bool enable);
 
+  FileSpec GetSaveSessionDirectory() const;
+  void SetSaveSessionDirectory(llvm::StringRef path);
+
   bool GetEchoCommands() const;
   void SetEchoCommands(bool enable);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, teemperor.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

Previously, when `interpreter.save-session-on-quit` was enabled, lldb
would save the session transcript only when running the `quit` command.

This patch changes that so the transcripts are saved when the debugger
object is destroyed if the setting is enabled.

rdar://72902650

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105038

Files:
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2974,6 +2974,7 @@
 return error_out("Unable to write to destination file",
  "Bytes written do not match transcript size.");
 
+  result.SetStatus(eReturnStatusSuccessContinuingResult);
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Host/Terminal.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionValue.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/OptionValueSInt64.h"
@@ -604,6 +605,17 @@
   if (!debugger_sp)
 return;
 
+  CommandInterpreter &cmd_interpreter = debugger_sp->GetCommandInterpreter();
+
+  if (cmd_interpreter.GetSaveSessionOnQuit()) {
+CommandReturnObject result(/*colors*/ true);
+cmd_interpreter.SaveTranscript(result);
+if (result.Succeeded())
+  debugger_sp->GetOutputStream() << result.GetOutputData() << '\n';
+else
+  debugger_sp->GetErrorStream() << result.GetErrorData() << '\n';
+  }
+
   debugger_sp->Clear();
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
Index: lldb/source/Commands/CommandObjectQuit.cpp
===
--- lldb/source/Commands/CommandObjectQuit.cpp
+++ lldb/source/Commands/CommandObjectQuit.cpp
@@ -101,8 +101,5 @@
   m_interpreter.BroadcastEvent(event_type);
   result.SetStatus(eReturnStatusQuit);
 
-  if (m_interpreter.GetSaveSessionOnQuit())
-m_interpreter.SaveTranscript(result);
-
   return true;
 }


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2974,6 +2974,7 @@
 return error_out("Unable to write to destination file",
  "Bytes written do not match transcript size.");
 
+  result.SetStatus(eReturnStatusSuccessContinuingResult);
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Host/Terminal.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionValue.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/OptionValueSInt64.h"
@@ -604,6 +605,17 @@
   if (!debugger_sp)
 return;
 
+  CommandInterpreter &cmd_interpreter = debugger_sp->GetCommandInterpreter();
+
+  if (cmd_interpreter.GetSaveSessionOnQuit()) {
+CommandReturnObject result(/*colors*/ true);
+cmd_interpreter.SaveTranscript(result);
+if (result.Succeeded())
+  debugger_sp->GetOutputStream() << result.GetOutputData() << '\n';
+else
+  debugger_sp->GetErrorStream() << result.GetErrorData() << '\n';
+  }
+
   debugger_sp->Clear();
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
Index: lldb/source/Commands/CommandObjectQuit.cpp
===
--- lldb/source/Commands/CommandObjectQuit.cpp
+++ lldb/source/Commands/CommandObjectQuit.cpp
@@ -101,8 +101,5 @@
   m_interpreter.BroadcastEvent(event_type);
   result.SetStatus(eReturnStatusQuit);
 
-  if (m_interpreter.GetSaveSessionOnQuit())
-m_interpreter.SaveTranscript(result);
-
   return true;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Maybe a test?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lldb/source/Interpreter/InterpreterProperties.td:18
+DefaultStringValue<"">,
+Desc<"A path where LLDB will save the session's transcripts. This setting 
is particularly useful when `save-session-on-quit` is enabled.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", 
"Boolean">,





Comment at: lldb/source/Interpreter/InterpreterProperties.td:18
+DefaultStringValue<"">,
+Desc<"A path where LLDB will save the session's transcripts.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", 
"Boolean">,

mib wrote:
> JDevlieghere wrote:
> > Given that `session save` already takes a file, I think it would make sense 
> > to call out here that this is particularly useful in combination with 
> > `save-session-on-quit`. 
> Just to clarify, `session save` can be used with no arguments, in which case, 
> the transcript will either be saved to a temporary folder or at the location 
> set in this property.
> 
> But I can definitely mention that it is very useful with 
> `save-session-on-quit`.
Sure, I just want to make it explicit that we're not just adding a second way 
to do the same thing (but that it's actually covering a use case we can't 
support today). 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105030/new/

https://reviews.llvm.org/D105030

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2977
 
+  result.SetStatus(eReturnStatusSuccessContinuingResult);
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",

Why `eReturnStatusSuccessContinuingResult` and not 
`eReturnStatusSuccessFinishNoResult`? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment.

I love the save-session feature. Just checking, has it already been 
release-noted on llvm.org (and for that matter Xcode)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105030/new/

https://reviews.llvm.org/D105030

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104406: Express PathMappingList::FindFile() in terms of PathMappingList.h::RemapPath() (NFC)

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM too


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104406/new/

https://reviews.llvm.org/D104406

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104405: Change PathMappingList::FindFile to return an optional result (NFC)

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM modulo formatting


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104405/new/

https://reviews.llvm.org/D104405

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D103349: [lldb] Don't print script output twice in HandleCommand

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test:1
+# RUN: %build %p/Inputs/dummy-target.c -o %t.out
+# RUN: %lldb %t.out -o 'b main' -o 'break command add 1 -o "script print(95000 
+ 126)"' -o 'r'

thakis wrote:
> Did you mean to put this file in 
> lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test or should it be in 
> lldb/test/Shell/Breakpoint/breakpoint-command.test (just one "lldb/")?
Yeah, this seems like a `patch` prefix mistake on my end. I'll move the file. 
Thanks! 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103349/new/

https://reviews.llvm.org/D103349

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a4aa705 - [lldb] Remove spurious lldb/lldb subdirectory

2021-06-28 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-06-28T10:41:03-07:00
New Revision: a4aa705d52e818cf526f5e41cce8e719befd97a6

URL: 
https://github.com/llvm/llvm-project/commit/a4aa705d52e818cf526f5e41cce8e719befd97a6
DIFF: 
https://github.com/llvm/llvm-project/commit/a4aa705d52e818cf526f5e41cce8e719befd97a6.diff

LOG: [lldb] Remove spurious lldb/lldb subdirectory

Remove the lldb/lldb subdirectory which I must have accidentally created
when applying a patch with the wrong prefix number.

Thank you Nico Weber for pointing this out!

Added: 


Modified: 


Removed: 
lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test



diff  --git a/lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test 
b/lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test
deleted file mode 100644
index 6104713cde5ae..0
--- a/lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test
+++ /dev/null
@@ -1,5 +0,0 @@
-# RUN: %build %p/Inputs/dummy-target.c -o %t.out
-# RUN: %lldb %t.out -o 'b main' -o 'break command add 1 -o "script print(95000 
+ 126)"' -o 'r'
-
-# CHECK: 95125
-# CHECK-NOT: 95126



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D103349: [lldb] Don't print script output twice in HandleCommand

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test:1
+# RUN: %build %p/Inputs/dummy-target.c -o %t.out
+# RUN: %lldb %t.out -o 'b main' -o 'break command add 1 -o "script print(95000 
+ 126)"' -o 'r'

JDevlieghere wrote:
> thakis wrote:
> > Did you mean to put this file in 
> > lldb/lldb/test/Shell/Breakpoint/breakpoint-command.test or should it be in 
> > lldb/test/Shell/Breakpoint/breakpoint-command.test (just one "lldb/")?
> Yeah, this seems like a `patch` prefix mistake on my end. I'll move the file. 
> Thanks! 
a4aa705d52e818cf526f5e41cce8e719befd97a6


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103349/new/

https://reviews.llvm.org/D103349

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 354950.
mib marked 3 inline comments as done.
mib added a comment.

Rephrase setting description


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105030/new/

https://reviews.llvm.org/D105030

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/InterpreterProperties.td
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- lldb/test/API/commands/session/save/TestSessionSave.py
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -1,7 +1,7 @@
 """
 Test the session save feature
 """
-
+import os
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -72,3 +72,20 @@
   lines = raw.splitlines()[:-1]
   for line in lines:
 self.assertIn(line, content)
+
+td = tempfile.TemporaryDirectory()
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('settings set interpreter.save-session-directory ' + td.name, res)
+self.assertTrue(res.Succeeded())
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand('session save', res)
+self.assertTrue(res.Succeeded())
+raw += self.raw_transcript_builder(cmd, res)
+
+with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
+  content = file.read()
+  # Exclude last line, since session won't record it's own output
+  lines = raw.splitlines()[:-1]
+  for line in lines:
+self.assertIn(line, content)
Index: lldb/source/Interpreter/InterpreterProperties.td
===
--- lldb/source/Interpreter/InterpreterProperties.td
+++ lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,9 @@
 Global,
 DefaultFalse,
 Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+  def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
+DefaultStringValue<"">,
+Desc<"A path where LLDB will save the session's transcripts. This is particularly useful when you can't set the session file, for example when using `save-session-on-quit`.">;
   def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
 Global,
 DefaultTrue,
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -160,6 +160,16 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
+FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
+  const uint32_t idx = ePropertySaveSessionDirectory;
+  return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+}
+
+void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) {
+  const uint32_t idx = ePropertySaveSessionDirectory;
+  m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
+}
+
 bool CommandInterpreter::GetEchoCommands() const {
   const uint32_t idx = ePropertyEchoCommands;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -2925,9 +2935,15 @@
 std::string now = llvm::to_string(std::chrono::system_clock::now());
 std::replace(now.begin(), now.end(), ' ', '_');
 const std::string file_name = "lldb_session_" + now + ".log";
-FileSpec tmp = HostInfo::GetGlobalTempDir();
-tmp.AppendPathComponent(file_name);
-output_file = tmp.GetPath();
+
+FileSpec save_location = GetSaveSessionDirectory();
+
+if (!save_location)
+  save_location = HostInfo::GetGlobalTempDir();
+
+FileSystem::Instance().Resolve(save_location);
+save_location.AppendPathComponent(file_name);
+output_file = save_location.GetPath();
   }
 
   auto error_out = [&](llvm::StringRef error_message, std::string description) {
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -493,6 +493,9 @@
   bool GetSaveSessionOnQuit() const;
   void SetSaveSessionOnQuit(bool enable);
 
+  FileSpec GetSaveSessionDirectory() const;
+  void SetSaveSessionDirectory(llvm::StringRef path);
+
   bool GetEchoCommands() const;
   void SetEchoCommands(bool enable);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105030: [lldb/Interpreter] Add setting to set session transcript save directory

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D105030#2844708 , @vsk wrote:

> I love the save-session feature. Just checking, has it already been 
> release-noted on llvm.org (and for that matter Xcode)?

Glad you like it @vsk ! I don't think it was on the release note (at lease for 
Xcode) ... may be it would be good to mention it 😊


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105030/new/

https://reviews.llvm.org/D105030

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 355541a - [lldb] Avoid using any shell when calling xcrun.

2021-06-28 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-06-28T19:53:52+02:00
New Revision: 355541a1b7a5011f8f4ebadc3e23b25c734f9d27

URL: 
https://github.com/llvm/llvm-project/commit/355541a1b7a5011f8f4ebadc3e23b25c734f9d27
DIFF: 
https://github.com/llvm/llvm-project/commit/355541a1b7a5011f8f4ebadc3e23b25c734f9d27.diff

LOG: [lldb] Avoid using any shell when calling xcrun.

When we run `xcrun` we don't have any user input in our command so relying on
the user's default shell doesn't make a lot of sense. If the user has set the
system shell to a something that isn't supported yet (dash, ash) then we would
run into the problem that we don't know how to escape our command string.

This patch just avoids using any shell at all as xcrun is always at the same
path.

Reviewed By: aprantl, JDevlieghere, kastiglione

Differential Revision: https://reviews.llvm.org/D104653

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index f822533f1b41a..a0706ec9ff6ae 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -383,17 +383,22 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 
   auto xcrun = [](const std::string &sdk,
   llvm::StringRef developer_dir = "") -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk;
-if (!developer_dir.empty())
-  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir.str() +
-  "\" " + xcrun_cmd;
+Args args;
+if (!developer_dir.empty()) {
+  args.AppendArgument("/usr/bin/env");
+  args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
+}
+args.AppendArgument("/usr/bin/xcrun");
+args.AppendArgument("--show-sdk-path");
+args.AppendArgument("--sdk");
+args.AppendArgument(sdk);
 
 int status = 0;
 int signo = 0;
 std::string output_str;
 lldb_private::Status error =
-Host::RunShellCommand(xcrun_cmd, FileSpec(), &status, &signo,
-  &output_str, std::chrono::seconds(15));
+Host::RunShellCommand(args, FileSpec(), &status, &signo, &output_str,
+  std::chrono::seconds(15));
 
 // Check that xcrun return something useful.
 if (status != 0 || output_str.empty())



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104653: [lldb] Avoid using any shell when calling xcrun.

2021-06-28 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG355541a1b7a5: [lldb] Avoid using any shell when calling 
xcrun. (authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104653/new/

https://reviews.llvm.org/D104653

Files:
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -383,17 +383,22 @@
 
   auto xcrun = [](const std::string &sdk,
   llvm::StringRef developer_dir = "") -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk;
-if (!developer_dir.empty())
-  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir.str() +
-  "\" " + xcrun_cmd;
+Args args;
+if (!developer_dir.empty()) {
+  args.AppendArgument("/usr/bin/env");
+  args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
+}
+args.AppendArgument("/usr/bin/xcrun");
+args.AppendArgument("--show-sdk-path");
+args.AppendArgument("--sdk");
+args.AppendArgument(sdk);
 
 int status = 0;
 int signo = 0;
 std::string output_str;
 lldb_private::Status error =
-Host::RunShellCommand(xcrun_cmd, FileSpec(), &status, &signo,
-  &output_str, std::chrono::seconds(15));
+Host::RunShellCommand(args, FileSpec(), &status, &signo, &output_str,
+  std::chrono::seconds(15));
 
 // Check that xcrun return something useful.
 if (status != 0 || output_str.empty())


Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -383,17 +383,22 @@
 
   auto xcrun = [](const std::string &sdk,
   llvm::StringRef developer_dir = "") -> std::string {
-std::string xcrun_cmd = "xcrun --show-sdk-path --sdk " + sdk;
-if (!developer_dir.empty())
-  xcrun_cmd = "/usr/bin/env DEVELOPER_DIR=\"" + developer_dir.str() +
-  "\" " + xcrun_cmd;
+Args args;
+if (!developer_dir.empty()) {
+  args.AppendArgument("/usr/bin/env");
+  args.AppendArgument("DEVELOPER_DIR=" + developer_dir.str());
+}
+args.AppendArgument("/usr/bin/xcrun");
+args.AppendArgument("--show-sdk-path");
+args.AppendArgument("--sdk");
+args.AppendArgument(sdk);
 
 int status = 0;
 int signo = 0;
 std::string output_str;
 lldb_private::Status error =
-Host::RunShellCommand(xcrun_cmd, FileSpec(), &status, &signo,
-  &output_str, std::chrono::seconds(15));
+Host::RunShellCommand(args, FileSpec(), &status, &signo, &output_str,
+  std::chrono::seconds(15));
 
 // Check that xcrun return something useful.
 if (status != 0 || output_str.empty())
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Core/Debugger.cpp:611
+  if (cmd_interpreter.GetSaveSessionOnQuit()) {
+CommandReturnObject result(/*colors*/ true);
+cmd_interpreter.SaveTranscript(result);

`/*colors=*/true`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 354962.
mib marked 2 inline comments as done.
mib added a comment.

Address @jingham, @JDevlieghere & @shafik comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

Files:
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- lldb/test/API/commands/session/save/TestSessionSave.py
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -2,6 +2,8 @@
 Test the session save feature
 """
 import os
+import tempfile
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -57,7 +59,6 @@
 self.assertFalse(res.Succeeded())
 raw += self.raw_transcript_builder(cmd, res)
 
-import tempfile
 tf = tempfile.NamedTemporaryFile()
 output_file = tf.name
 
@@ -89,3 +90,37 @@
   lines = raw.splitlines()[:-1]
   for line in lines:
 self.assertIn(line, content)
+
+@skipIfWindows
+@skipIfReproducer
+@no_debug_info_test
+def test_session_save_on_quit(self):
+raw = ""
+interpreter = self.dbg.GetCommandInterpreter()
+
+td = tempfile.TemporaryDirectory()
+
+settings = [
+  'settings set interpreter.echo-commands true',
+  'settings set interpreter.echo-comment-commands true',
+  'settings set interpreter.stop-command-source-on-error false',
+  'settings set interpreter.save-session-on-quit true',
+  'settings set interpreter.save-session-directory ' + td.name,
+]
+
+for setting in settings:
+  res = lldb.SBCommandReturnObject()
+  interpreter.HandleCommand(setting, res)
+  raw += self.raw_transcript_builder(setting, res)
+
+self.dbg.Destroy(self.dbg)
+
+with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
+  content = file.read()
+  # Exclude last line, since session won't record it's own output
+  lines = raw.splitlines()[:-1]
+  for line in lines:
+self.assertIn(line, content)
+
+
+
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2974,6 +2974,7 @@
 return error_out("Unable to write to destination file",
  "Bytes written do not match transcript size.");
 
+  result.SetStatus(eReturnStatusSuccessFinishNoResult);
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Host/Terminal.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionValue.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/OptionValueSInt64.h"
@@ -604,6 +605,17 @@
   if (!debugger_sp)
 return;
 
+  CommandInterpreter &cmd_interpreter = debugger_sp->GetCommandInterpreter();
+
+  if (cmd_interpreter.GetSaveSessionOnQuit()) {
+CommandReturnObject result(/*colors=*/true);
+cmd_interpreter.SaveTranscript(result);
+if (result.Succeeded())
+  debugger_sp->GetOutputStream() << result.GetOutputData() << '\n';
+else
+  debugger_sp->GetErrorStream() << result.GetErrorData() << '\n';
+  }
+
   debugger_sp->Clear();
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
Index: lldb/source/Commands/CommandObjectQuit.cpp
===
--- lldb/source/Commands/CommandObjectQuit.cpp
+++ lldb/source/Commands/CommandObjectQuit.cpp
@@ -101,8 +101,5 @@
   m_interpreter.BroadcastEvent(event_type);
   result.SetStatus(eReturnStatusQuit);
 
-  if (m_interpreter.GetSaveSessionOnQuit())
-m_interpreter.SaveTranscript(result);
-
   return true;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

One nit about the handling of colors.




Comment at: lldb/source/Core/Debugger.cpp:611
+  if (cmd_interpreter.GetSaveSessionOnQuit()) {
+CommandReturnObject result(/*colors=*/true);
+cmd_interpreter.SaveTranscript(result);

Maybe you should get the setting for colors here?  If I turn off colors with 
the use-colors setting, I would be surprised to find them in the session save 
file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

Shouldn't have also said accepted yet...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2dbe1c6 - [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via lldb-commits

Author: Melanie Blower
Date: 2021-06-28T15:09:53-04:00
New Revision: 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0

URL: 
https://github.com/llvm/llvm-project/commit/2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0
DIFF: 
https://github.com/llvm/llvm-project/commit/2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0.diff

LOG: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine 
to allow diagnostics on target-unsupported options

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D104729

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index d59bad30e7428..20f6afa76cbb3 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions &Opts);
+  virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions &CGOpts,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e73b4a3a40c74..4c2859e5eda7f 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(LangOptions &Opts) {
+void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 595132e2e70ba..fac786dbcf9e2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(LangOptions &Opts) {
-  TargetInfo::adjust(Opts);
+void AMDGPUTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
+  TargetInfo::adjust(Diags, Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index fe5c61c6ba2bb..244a6e0446905 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(LangOptions &Opts) override;
+  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 6860b5e5d02fa..d431dda970222 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl &Values) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(LangOptions &Opts) {
+void PPCTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Opts);
+  TargetInfo::adjust(Diags, Opts);
   if (LongDoubleFormat != &llvm::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? &llvm::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 554f2174fee00..18ee1194c759d 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -89,7 +89

[Lldb-commits] [PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2dbe1c675fe9: [clang][PATCH][nfc] Refactor 
TargetInfo::adjust to pass DiagnosticsEngine to… (authored by mibintc).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D104729?vs=354932&id=354981#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104729/new/

https://reviews.llvm.org/D104729

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -704,7 +704,7 @@
   if (!instance->hasTarget())
 return nullptr;
 
-  instance->getTarget().adjust(instance->getLangOpts());
+  instance->getTarget().adjust(*diagnostics_engine, instance->getLangOpts());
 
   if (!action->BeginSourceFile(*instance,
instance->getFrontendOpts().Inputs[0]))
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -658,7 +658,8 @@
   //
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  m_compiler->getTarget().adjust(m_compiler->getLangOpts());
+  m_compiler->getTarget().adjust(m_compiler->getDiagnostics(),
+		 m_compiler->getLangOpts());
 
   // 6. Set up the diagnostic buffer for reporting errors
 
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -110,7 +110,7 @@
"Initialization failed. "
"Target is missing");
 
-  Clang->getTarget().adjust(Clang->getLangOpts());
+  Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
   return std::move(Clang);
 }
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -142,7 +142,7 @@
   // Inform the target of the language options.
   // FIXME: We shouldn't need to do this, the target should be immutable once
   // created. This complexity should be lifted elsewhere.
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
 
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
@@ -457,7 +457,7 @@
   getSourceManager(), *HeaderInfo, *this,
   /*IdentifierInfoLookup=*/nullptr,
   /*OwnsHeaderSearch=*/true, TUKind);
-  getTarget().adjust(getLangOpts());
+  getTarget().adjust(getDiagnostics(), getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   if (PPOpts.DetailedRecord)
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -588,7 +588,7 @@
 //
 // FIXME: We shouldn't need to do this, the target should be immutable once
 // created. This complexity should be lifted elsewhere

[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 354988.
mib added a comment.

Address @jingham comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

Files:
  lldb/source/Commands/CommandObjectQuit.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/commands/session/save/TestSessionSave.py

Index: lldb/test/API/commands/session/save/TestSessionSave.py
===
--- lldb/test/API/commands/session/save/TestSessionSave.py
+++ lldb/test/API/commands/session/save/TestSessionSave.py
@@ -2,6 +2,8 @@
 Test the session save feature
 """
 import os
+import tempfile
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -57,7 +59,6 @@
 self.assertFalse(res.Succeeded())
 raw += self.raw_transcript_builder(cmd, res)
 
-import tempfile
 tf = tempfile.NamedTemporaryFile()
 output_file = tf.name
 
@@ -89,3 +90,37 @@
   lines = raw.splitlines()[:-1]
   for line in lines:
 self.assertIn(line, content)
+
+@skipIfWindows
+@skipIfReproducer
+@no_debug_info_test
+def test_session_save_on_quit(self):
+raw = ""
+interpreter = self.dbg.GetCommandInterpreter()
+
+td = tempfile.TemporaryDirectory()
+
+settings = [
+  'settings set interpreter.echo-commands true',
+  'settings set interpreter.echo-comment-commands true',
+  'settings set interpreter.stop-command-source-on-error false',
+  'settings set interpreter.save-session-on-quit true',
+  'settings set interpreter.save-session-directory ' + td.name,
+]
+
+for setting in settings:
+  res = lldb.SBCommandReturnObject()
+  interpreter.HandleCommand(setting, res)
+  raw += self.raw_transcript_builder(setting, res)
+
+self.dbg.Destroy(self.dbg)
+
+with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
+  content = file.read()
+  # Exclude last line, since session won't record it's own output
+  lines = raw.splitlines()[:-1]
+  for line in lines:
+self.assertIn(line, content)
+
+
+
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2974,6 +2974,7 @@
 return error_out("Unable to write to destination file",
  "Bytes written do not match transcript size.");
 
+  result.SetStatus(eReturnStatusSuccessFinishNoResult);
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
 
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Host/Terminal.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionValue.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/OptionValueSInt64.h"
@@ -604,6 +605,17 @@
   if (!debugger_sp)
 return;
 
+  CommandInterpreter &cmd_interpreter = debugger_sp->GetCommandInterpreter();
+
+  if (cmd_interpreter.GetSaveSessionOnQuit()) {
+CommandReturnObject result(debugger_sp->GetUseColor());
+cmd_interpreter.SaveTranscript(result);
+if (result.Succeeded())
+  debugger_sp->GetOutputStream() << result.GetOutputData() << '\n';
+else
+  debugger_sp->GetErrorStream() << result.GetErrorData() << '\n';
+  }
+
   debugger_sp->Clear();
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
Index: lldb/source/Commands/CommandObjectQuit.cpp
===
--- lldb/source/Commands/CommandObjectQuit.cpp
+++ lldb/source/Commands/CommandObjectQuit.cpp
@@ -101,8 +101,5 @@
   m_interpreter.BroadcastEvent(event_type);
   result.SetStatus(eReturnStatusQuit);
 
-  if (m_interpreter.GetSaveSessionOnQuit())
-m_interpreter.SaveTranscript(result);
-
   return true;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1d85d08 - Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options"

2021-06-28 Thread Melanie Blower via lldb-commits

Author: Melanie Blower
Date: 2021-06-28T15:47:21-04:00
New Revision: 1d85d0879a75b9556b10f55739437af8233c0b64

URL: 
https://github.com/llvm/llvm-project/commit/1d85d0879a75b9556b10f55739437af8233c0b64
DIFF: 
https://github.com/llvm/llvm-project/commit/1d85d0879a75b9556b10f55739437af8233c0b64.diff

LOG: Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass 
DiagnosticsEngine to allow diagnostics on target-unsupported options"

This reverts commit 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0.
More buildbot failures

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/WebAssembly.cpp
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/tools/clang-import-test/clang-import-test.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 20f6afa76cbb3..d59bad30e7428 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1162,7 +1162,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Apply changes to the target information with respect to certain
   /// language options which change the target configuration and adjust
   /// the language based on the target options where applicable.
-  virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
+  virtual void adjust(LangOptions &Opts);
 
   /// Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions &CGOpts,

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 4c2859e5eda7f..e73b4a3a40c74 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -346,7 +346,7 @@ bool TargetInfo::isTypeSigned(IntType T) {
 /// Apply changes to the target information with respect to certain
 /// language options which change the target configuration and adjust
 /// the language based on the target options where applicable.
-void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
+void TargetInfo::adjust(LangOptions &Opts) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index fac786dbcf9e2..595132e2e70ba 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -358,8 +358,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 }
 
-void AMDGPUTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
-  TargetInfo::adjust(Diags, Opts);
+void AMDGPUTargetInfo::adjust(LangOptions &Opts) {
+  TargetInfo::adjust(Opts);
   // ToDo: There are still a few places using default address space as private
   // address space in OpenCL, which needs to be cleaned up, then Opts.OpenCL
   // can be removed from the following line.

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 244a6e0446905..fe5c61c6ba2bb 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -93,7 +93,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public 
TargetInfo {
 
   void setAddressSpaceMap(bool DefaultIsPrivate);
 
-  void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
+  void adjust(LangOptions &Opts) override;
 
   uint64_t getPointerWidthV(unsigned AddrSpace) const override {
 if (isR600(getTriple()))

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index d431dda970222..6860b5e5d02fa 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -614,10 +614,10 @@ void 
PPCTargetInfo::fillValidCPUList(SmallVectorImpl &Values) const {
   Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
 }
 
-void PPCTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
+void PPCTargetInfo::adjust(LangOptions &Opts) {
   if (HasAltivec)
 Opts.AltiVec = 1;
-  TargetInfo::adjust(Diags, Opts);
+  TargetInfo::adjust(Opts);
   if (LongDoubleFormat != &llvm::APFloat::IEEEdouble())
 LongDoubleFormat = Opts.PPCIEEELongDouble
? &llvm::APFloat::IEEEquad()

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 18ee1194c759d..554f2174fee00 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@

[Lldb-commits] [PATCH] D104729: [clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to allow diagnostics on target-unsupported options

2021-06-28 Thread Melanie Blower via Phabricator via lldb-commits
mibintc reopened this revision.
mibintc added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

More buildbot failures


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104729/new/

https://reviews.llvm.org/D104729

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105060: [LLDB] dotest.py set selected_platform on remote connection

2021-06-28 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added a reviewer: JDevlieghere.
omjavaid requested review of this revision.

This patch fixes a bug in dotest.py where lldb.selected_platform was
being set to host platform even after a successful connection to a
remote platform via platform url. This patch fixes this behavior and
sets selected_platform to remote_platform after a successful connection.

  

This patch also removes target_platform variable from run_suite.


https://reviews.llvm.org/D105060

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -929,6 +929,7 @@
 err = lldb.remote_platform.ConnectRemote(platform_connect_options)
 if err.Success():
 print("Connected.")
+lldb.selected_platform = lldb.remote_platform
 else:
 print("error: failed to connect to remote platform using URL 
'%s': %s" % (
 configuration.lldb_platform_url, err))
@@ -958,9 +959,6 @@
 # Note that it's not dotest's job to clean this directory.
 lldbutil.mkdir_p(configuration.test_build_dir)
 
-from . import lldbplatformutil
-target_platform = lldbplatformutil.getPlatform()
-
 checkLibcxxSupport()
 checkLibstdcxxSupport()
 checkWatchpointSupport()


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -929,6 +929,7 @@
 err = lldb.remote_platform.ConnectRemote(platform_connect_options)
 if err.Success():
 print("Connected.")
+lldb.selected_platform = lldb.remote_platform
 else:
 print("error: failed to connect to remote platform using URL '%s': %s" % (
 configuration.lldb_platform_url, err))
@@ -958,9 +959,6 @@
 # Note that it's not dotest's job to clean this directory.
 lldbutil.mkdir_p(configuration.test_build_dir)
 
-from . import lldbplatformutil
-target_platform = lldbplatformutil.getPlatform()
-
 checkLibcxxSupport()
 checkLibstdcxxSupport()
 checkWatchpointSupport()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105060: [LLDB] dotest.py set selected_platform on remote connection

2021-06-28 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105060/new/

https://reviews.llvm.org/D105060

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1fa7023 - [LLDB] dotest.py set selected_platform on remote connection

2021-06-28 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2021-06-28T21:37:12Z
New Revision: 1fa70235856962fae723d97cb39b47da6eb9666e

URL: 
https://github.com/llvm/llvm-project/commit/1fa70235856962fae723d97cb39b47da6eb9666e
DIFF: 
https://github.com/llvm/llvm-project/commit/1fa70235856962fae723d97cb39b47da6eb9666e.diff

LOG: [LLDB] dotest.py set selected_platform on remote connection

This patch fixes a bug in dotest.py where lldb.selected_platform was
being set to host platform even after a successful connection to a
remote platform via platform url. This patch fixes this behavior and
sets selected_platform to remote_platform after a successful connection.

This patch also removes target_platform variable from run_suite.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D105060

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 3e832d91e288d..5c5583fb5706f 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -929,6 +929,7 @@ def run_suite():
 err = lldb.remote_platform.ConnectRemote(platform_connect_options)
 if err.Success():
 print("Connected.")
+lldb.selected_platform = lldb.remote_platform
 else:
 print("error: failed to connect to remote platform using URL 
'%s': %s" % (
 configuration.lldb_platform_url, err))
@@ -958,9 +959,6 @@ def run_suite():
 # Note that it's not dotest's job to clean this directory.
 lldbutil.mkdir_p(configuration.test_build_dir)
 
-from . import lldbplatformutil
-target_platform = lldbplatformutil.getPlatform()
-
 checkLibcxxSupport()
 checkLibstdcxxSupport()
 checkWatchpointSupport()



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105060: [LLDB] dotest.py set selected_platform on remote connection

2021-06-28 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1fa702358569: [LLDB] dotest.py set selected_platform on 
remote connection (authored by omjavaid).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105060/new/

https://reviews.llvm.org/D105060

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -929,6 +929,7 @@
 err = lldb.remote_platform.ConnectRemote(platform_connect_options)
 if err.Success():
 print("Connected.")
+lldb.selected_platform = lldb.remote_platform
 else:
 print("error: failed to connect to remote platform using URL 
'%s': %s" % (
 configuration.lldb_platform_url, err))
@@ -958,9 +959,6 @@
 # Note that it's not dotest's job to clean this directory.
 lldbutil.mkdir_p(configuration.test_build_dir)
 
-from . import lldbplatformutil
-target_platform = lldbplatformutil.getPlatform()
-
 checkLibcxxSupport()
 checkLibstdcxxSupport()
 checkWatchpointSupport()


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -929,6 +929,7 @@
 err = lldb.remote_platform.ConnectRemote(platform_connect_options)
 if err.Success():
 print("Connected.")
+lldb.selected_platform = lldb.remote_platform
 else:
 print("error: failed to connect to remote platform using URL '%s': %s" % (
 configuration.lldb_platform_url, err))
@@ -958,9 +959,6 @@
 # Note that it's not dotest's job to clean this directory.
 lldbutil.mkdir_p(configuration.test_build_dir)
 
-from . import lldbplatformutil
-target_platform = lldbplatformutil.getPlatform()
-
 checkLibcxxSupport()
 checkLibstdcxxSupport()
 checkWatchpointSupport()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D

2021-06-28 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Excellent


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105038/new/

https://reviews.llvm.org/D105038

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D103626: [lldb][AArch64] Remove non address bits from memory read arguments

2021-06-28 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid accepted this revision.
omjavaid added inline comments.
This revision is now accepted and ready to land.



Comment at: 
lldb/test/API/linux/aarch64/tagged_memory_read/TestAArch64LinuxTaggedMemoryRead.py:23
+def test_mte_regions(self):
+if not self.isAArch64PAuth():
+self.skipTest('Target must support pointer authentication.')

DavidSpickett wrote:
> omjavaid wrote:
> > This condition will always be true because we havent yet connected to 
> > remote platform.
> Runs fine for me using dotest:
> ```
> $ ./bin/lldb-dotest --platform-name remote-linux <...> -p 
> TestAArch64LinuxTaggedMemoryRead.py --arch aarch64
> ```
> 
> And this is how it's used elsewhere. Perhaps you're running the tests in a 
> different way?
This will be fixed by D105060


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103626/new/

https://reviews.llvm.org/D103626

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D102757: [lldb] Remove non address bits when looking up memory regions

2021-06-28 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

In D102757#2826611 , @DavidSpickett 
wrote:

> Do you think this needs a test with a core file as well?

I guess it wont be needed. Included test is fine to check whether we remove 
non-address bits or not. Rest functionality does not change for elf-core.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102757/new/

https://reviews.llvm.org/D102757

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104914: [lldb] Correct format of qMemTags type field

2021-06-28 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added inline comments.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:3477
+
+  if (raw_type == std::numeric_limits::max() ||
+  // Make sure the cast below would be valid

First condition looks redundant given that anything above 32 bit range is 
invalid and being tested in next condition?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104914/new/

https://reviews.llvm.org/D104914

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104488: Create synthetic symbol names on demand to improve memory consumption and startup times.

2021-06-28 Thread Greg Clayton via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd77ccfdc7218: Create synthetic symbol names on demand to 
improve memory consumption and… (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104488/new/

https://reviews.llvm.org/D104488

Files:
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/include/lldb/Symbol/Symbol.h
  lldb/include/lldb/Symbol/Symtab.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Symbol/ObjectFile.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -301,7 +301,7 @@
   // the trampoline symbols to be searchable by name we can remove this and
   // then possibly add a new bool to any of the Symtab functions that
   // lookup symbols by name to indicate if they want trampolines.
-  if (symbol->IsTrampoline())
+  if (symbol->IsTrampoline() || symbol->IsSynthetic())
 continue;
 
   // If the symbol's name string matched a Mangled::ManglingScheme, it is
@@ -628,6 +628,36 @@
   }
 }
 
+uint32_t Symtab::GetNameIndexes(ConstString symbol_name,
+std::vector &indexes) {
+  auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
+  const uint32_t count = name_to_index.GetValues(symbol_name, indexes);
+  if (count)
+return count;
+  // Synthetic symbol names are not added to the name indexes, but they start
+  // with a prefix and end with a the symbol UserID. This allows users to find
+  // these symbols without having to add them to the name indexes. These
+  // queries will not happen very often since the names don't mean anything, so
+  // performance is not paramount in this case.
+  llvm::StringRef name = symbol_name.GetStringRef();
+  // String the synthetic prefix if the name starts with it.
+  if (!name.consume_front(Symbol::GetSyntheticSymbolPrefix()))
+return 0; // Not a synthetic symbol name
+
+  // Extract the user ID from the symbol name
+  user_id_t uid = 0;
+  if (getAsUnsignedInteger(name, /*Radix=*/10, uid))
+return 0; // Failed to extract the user ID as an integer
+  Symbol *symbol = FindSymbolByID(uid);
+  if (symbol == nullptr)
+return 0;
+  const uint32_t symbol_idx = GetIndexForSymbol(symbol);
+  if (symbol_idx == UINT32_MAX)
+return 0;
+  indexes.push_back(symbol_idx);
+  return 1;
+}
+
 uint32_t Symtab::AppendSymbolIndexesWithName(ConstString symbol_name,
  std::vector &indexes) {
   std::lock_guard guard(m_mutex);
@@ -637,8 +667,7 @@
 if (!m_name_indexes_computed)
   InitNameIndexes();
 
-auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
-return name_to_index.GetValues(symbol_name, indexes);
+return GetNameIndexes(symbol_name, indexes);
   }
   return 0;
 }
@@ -655,10 +684,9 @@
 if (!m_name_indexes_computed)
   InitNameIndexes();
 
-auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
 std::vector all_name_indexes;
 const size_t name_match_count =
-name_to_index.GetValues(symbol_name, all_name_indexes);
+GetNameIndexes(symbol_name, all_name_indexes);
 for (size_t i = 0; i < name_match_count; ++i) {
   if (CheckSymbolAtIndex(all_name_indexes[i], symbol_debug_type,
  symbol_visibility))
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -56,8 +56,8 @@
   m_size_is_synthesized(false),
   m_size_is_valid(size_is_valid || range.GetByteSize() > 0),
   m_demangled_is_synthesized(false),
-  m_contains_linker_annotations(contains_linker_annotations), 
-  m_is_weak(false), m_type(type), m_mangled(mangled), m_addr_range(range), 
+  m_contains_linker_annotations(contains_linker_annotations),
+  m_is_weak(false), m_type(type), m_mangled(mangled), m_addr_range(range),
   m_flags(flags) {}
 
 Symbol::Symbol(const Symbol &rhs)
@@ -119,7 +119,7 @@
 }
 
 ConstString Symbol::GetDisplayName() const {
-  return m_mangled.GetDisplayDemangledName();
+  return GetMangled().GetDisplayDemangledName();
 }
 
 ConstString Symbol::GetReExportedSymbolName() const {
@@ -202,7 +202,7 @@
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = m_mangled.GetDemangledName();
+  ConstString demangled = GetMangled().GetDemangledName();
   if (demangled)
 s->Printf(", name=\"%s\"", demangled.AsCString());
   if (m_mangled.GetMangledName())
@@ -218,7 +218,7 

[Lldb-commits] [lldb] d77ccfd - Create synthetic symbol names on demand to improve memory consumption and startup times.

2021-06-28 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-06-28T18:04:51-07:00
New Revision: d77ccfdc72182cf7ca1bbf6b8b47e062766a9f1f

URL: 
https://github.com/llvm/llvm-project/commit/d77ccfdc72182cf7ca1bbf6b8b47e062766a9f1f
DIFF: 
https://github.com/llvm/llvm-project/commit/d77ccfdc72182cf7ca1bbf6b8b47e062766a9f1f.diff

LOG: Create synthetic symbol names on demand to improve memory consumption and 
startup times.

This fix was created after profiling the target creation of a large C/C++/ObjC 
application that contained almost 4,000,000 redacted symbol names. The symbol 
table parsing code was creating names for each of these synthetic symbols and 
adding them to the name indexes. The code was also adding the object file 
basename to the end of the symbol name which doesn't allow symbols from 
different shared libraries to share the names in the constant string pool.

Prior to this fix this was creating 180MB of "___lldb_unnamed_symbol" symbol 
names and was taking a long time to generate each name, add them to the string 
pool and then add each of these names to the name index.

This patch fixes the issue by:
- not adding a name to synthetic symbols at creation time, and allows name to 
be dynamically generated when accessed
- doesn't add synthetic symbol names to the name indexes, but catches this 
special case as name lookup time. Users won't typically set breakpoints or 
lookup these synthetic names, but support was added to do the lookup in case it 
does happen
- removes the object file baseanme from the generated names to allow the names 
to be shared in the constant string pool

Prior to this fix the startup times for a large application was:
12.5 seconds (cold file caches)
8.5 seconds (warm file caches)

After this fix:
9.7 seconds (cold file caches)
5.7 seconds (warm file caches)

The names of the symbols are auto generated by appending the symbol's UserID to 
the end of the "___lldb_unnamed_symbol" string and is only done when the name 
is requested from a synthetic symbol if it has no name.

Differential Revision: https://reviews.llvm.org/D104488

Added: 


Modified: 
lldb/include/lldb/Symbol/ObjectFile.h
lldb/include/lldb/Symbol/Symbol.h
lldb/include/lldb/Symbol/Symtab.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/source/Symbol/Symbol.cpp
lldb/source/Symbol/Symtab.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index 1e29cf53b78b3..dc83565c7db52 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -712,8 +712,6 @@ class ObjectFile : public 
std::enable_shared_from_this,
   /// false otherwise.
   bool SetModulesArchitecture(const ArchSpec &new_arch);
 
-  ConstString GetNextSyntheticSymbolName();
-
   static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size,
 uint64_t Offset);
 

diff  --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 3abe3114863de..be3e8abefa490 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -113,14 +113,20 @@ class Symbol : public SymbolContextScope {
   lldb::LanguageType GetLanguage() const {
 // TODO: See if there is a way to determine the language for a symbol
 // somehow, for now just return our best guess
-return m_mangled.GuessLanguage();
+return GetMangled().GuessLanguage();
   }
 
   void SetID(uint32_t uid) { m_uid = uid; }
 
-  Mangled &GetMangled() { return m_mangled; }
+  Mangled &GetMangled() {
+SynthesizeNameIfNeeded();
+return m_mangled;
+  }
 
-  const Mangled &GetMangled() const { return m_mangled; }
+  const Mangled &GetMangled() const {
+SynthesizeNameIfNeeded();
+return m_mangled;
+  }
 
   ConstString GetReExportedSymbolName() const;
 
@@ -166,9 +172,9 @@ class Symbol : public SymbolContextScope {
   bool IsTrampoline() const;
 
   bool IsIndirect() const;
-  
+
   bool IsWeak() const { return m_is_weak; }
-  
+
   void SetIsWeak (bool b) { m_is_weak = b; }
 
   bool GetByteSizeIsValid() const { return m_size_is_valid; }
@@ -223,6 +229,10 @@ class Symbol : public SymbolContextScope {
 
   bool ContainsFileAddress(lldb::addr_t file_addr) const;
 
+  static llvm::StringRef GetSyntheticSymbolPrefix() {
+return "___lldb_unnamed_symbol";
+  }
+
 protected:
   // This is the internal guts of ResolveReExportedSymbol, it assumes
   // reexport_name is not null, and that module_spec is valid.  We track the
@@ -233,6 +243,8 @@ class Symbol : public SymbolContextScope {
   lldb_private::ModuleSpec &module_spec,
   lldb_private::ModuleList &seen_modules) const;
 
+  void SynthesizeNameIfNeeded() const;
+
   uint32_t m_uid =
   UINT32_MAX;   // User ID (usually the origi

[Lldb-commits] [lldb] 323bcbd - Fix buildbot failure after https://reviews.llvm.org/D104488.

2021-06-28 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-06-28T18:12:05-07:00
New Revision: 323bcbdba0e6ffa206a4575ce90e5056e8e77c09

URL: 
https://github.com/llvm/llvm-project/commit/323bcbdba0e6ffa206a4575ce90e5056e8e77c09
DIFF: 
https://github.com/llvm/llvm-project/commit/323bcbdba0e6ffa206a4575ce90e5056e8e77c09.diff

LOG: Fix buildbot failure after https://reviews.llvm.org/D104488.

Added: 


Modified: 
lldb/source/Symbol/Symtab.cpp

Removed: 




diff  --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index d859d8e25129..89e75c28cb9b 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -645,7 +645,7 @@ uint32_t Symtab::GetNameIndexes(ConstString symbol_name,
 return 0; // Not a synthetic symbol name
 
   // Extract the user ID from the symbol name
-  user_id_t uid = 0;
+  unsigned long long uid = 0;
   if (getAsUnsignedInteger(name, /*Radix=*/10, uid))
 return 0; // Failed to extract the user ID as an integer
   Symbol *symbol = FindSymbolByID(uid);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 42c05ed - Fix failing tests after https://reviews.llvm.org/D104488.

2021-06-28 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-06-28T19:59:24-07:00
New Revision: 42c05ed8beb264ccae0b471ca67ad3d7a6aeaa0c

URL: 
https://github.com/llvm/llvm-project/commit/42c05ed8beb264ccae0b471ca67ad3d7a6aeaa0c
DIFF: 
https://github.com/llvm/llvm-project/commit/42c05ed8beb264ccae0b471ca67ad3d7a6aeaa0c.diff

LOG: Fix failing tests after https://reviews.llvm.org/D104488.

Synthetic names no longer have the shared library name appended to the end.

Added: 


Modified: 
lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml
lldb/test/Shell/SymbolFile/Breakpad/symtab.test

Removed: 




diff  --git a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml 
b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml
index 6178a45de1b59..0dcc9fb76bd4f 100644
--- a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml
+++ b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml
@@ -3,8 +3,8 @@
 
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address
   Size   Flags  Name
 # CHECK: [0]  1 SourceFile  0x 
   0x 0x0004 -
-# CHECK: [1]  2  SX Code0x00201180 
   0x0010 0x ___lldb_unnamed_symbol1$${{.*}}
-# CHECK: [2]  3  SX Code0x00201190 
   0x0006 0x ___lldb_unnamed_symbol2$${{.*}}
+# CHECK: [1]  2  SX Code0x00201180 
   0x0010 0x ___lldb_unnamed_symbol{{[0-9]*}}
+# CHECK: [2]  3  SX Code0x00201190 
   0x0006 0x ___lldb_unnamed_symbol{{[0-9]*}}
 
 --- !ELF
 FileHeader:

diff  --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test 
b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test
index 1eb03fa43deb0..788dafe248d50 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test
@@ -5,7 +5,7 @@
 # CHECK-LABEL: (lldb) image dump symtab symtab.out
 # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address
   Size   Flags  Name
-# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}$$symtab.out
+# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}
 # CHECK: [1]  0   X Code0x004000b0 
   0x000c 0x f1_func
 # CHECK: [2]  0   X Code0x004000a0 
   0x000d 0x func_only
 # CHECK: [3]  0   X Code0x004000c0 
   0x0010 0x f2



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits