[Lldb-commits] [lldb] 68cb7d8 - [lldb/Commands] Honor the scripting language passed (2/2)

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T22:32:13-08:00
New Revision: 68cb7d85423c19a61c5d6afbc8e004a345a28856

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

LOG: [lldb/Commands] Honor the scripting language passed (2/2)

This ensures that watchpoint command honors the scripting language
passed with `-s`. Currently the argument ignores the actual language and
only uses it to differentiate between lldb and script commands.

Added: 


Modified: 
lldb/source/Commands/CommandObjectWatchpointCommand.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp 
b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index 237c4e28638c..4cc74e77ed4d 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -36,6 +36,11 @@ static constexpr OptionEnumValueElement 
g_script_option_enumeration[] = {
 "python",
 "Commands are in the Python language.",
 },
+{
+eScriptLanguageLua,
+"lua",
+"Commands are in the Python language.",
+},
 {
 eSortOrderByName,
 "default-script",
@@ -331,8 +336,16 @@ are no syntax errors may indicate that a function was 
declared but never called.
 option_arg, GetDefinitions()[option_idx].enum_values,
 eScriptLanguageNone, error);
 
-m_use_script_language = (m_script_language == eScriptLanguagePython ||
- m_script_language == eScriptLanguageDefault);
+switch (m_script_language) {
+case eScriptLanguagePython:
+case eScriptLanguageLua:
+  m_use_script_language = true;
+  break;
+case eScriptLanguageNone:
+case eScriptLanguageUnknown:
+  m_use_script_language = false;
+  break;
+}
 break;
 
   case 'e': {
@@ -347,7 +360,6 @@ are no syntax errors may indicate that a function was 
declared but never called.
 
   case 'F':
 m_use_one_liner = false;
-m_use_script_language = true;
 m_function_name.assign(option_arg);
 break;
 
@@ -398,12 +410,11 @@ are no syntax errors may indicate that a function was 
declared but never called.
   return false;
 }
 
-if (!m_options.m_use_script_language &&
-!m_options.m_function_name.empty()) {
-  result.AppendError("need to enable scripting to have a function run as a 
"
- "watchpoint command");
-  result.SetStatus(eReturnStatusFailed);
-  return false;
+if (!m_options.m_function_name.empty()) {
+  if (!m_options.m_use_script_language) {
+m_options.m_script_language = GetDebugger().GetScriptLanguage();
+m_options.m_use_script_language = true;
+  }
 }
 
 std::vector valid_wp_ids;
@@ -433,9 +444,11 @@ are no syntax errors may indicate that a function was 
declared but never called.
 // to set or collect command callback.  Otherwise, call the methods
 // associated with this object.
 if (m_options.m_use_script_language) {
+  ScriptInterpreter *script_interp = 
GetDebugger().GetScriptInterpreter(
+  /*can_create=*/true, m_options.m_script_language);
   // Special handling for one-liner specified inline.
   if (m_options.m_use_one_liner) {
-GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
+script_interp->SetWatchpointCommandCallback(
 wp_options, m_options.m_one_liner.c_str());
   }
   // Special handling for using a Python function by name instead of
@@ -445,12 +458,11 @@ are no syntax errors may indicate that a function was 
declared but never called.
   else if (!m_options.m_function_name.empty()) {
 std::string oneliner(m_options.m_function_name);
 oneliner += "(frame, wp, internal_dict)";
-GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
+script_interp->SetWatchpointCommandCallback(
 wp_options, oneliner.c_str());
   } else {
-GetDebugger()
-.GetScriptInterpreter()
-->CollectDataForWatchpointCommandCallback(wp_options, result);
+script_interp->CollectDataForWatchpointCommandCallback(wp_options,
+   result);
   }
 } else {
   // Special handling for one-liner specified inline.



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


[Lldb-commits] [lldb] ba0eb7b - [lldb/ScriptInterpreter] Fix stale/bogus error messages

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T22:33:02-08:00
New Revision: ba0eb7b66fd9dac7bf4883f70b65bded03a4b97a

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

LOG: [lldb/ScriptInterpreter] Fix stale/bogus error messages

Fix the nonsensical error messages for when breakpoint and watchpoint
callbacks are not supported.

Added: 
lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_callback.test
lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test

Modified: 
lldb/source/Interpreter/ScriptInterpreter.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/ScriptInterpreter.cpp 
b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 552661ef80ee..0ef859061ab1 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -32,14 +32,14 @@ void 
ScriptInterpreter::CollectDataForBreakpointCommandCallback(
 CommandReturnObject ) {
   result.SetStatus(eReturnStatusFailed);
   result.AppendError(
-  "ScriptInterpreter::GetScriptCommands(StringList &) is not 
implemented.");
+  "This script interpreter does not support breakpoint callbacks.");
 }
 
 void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
 WatchpointOptions *bp_options, CommandReturnObject ) {
   result.SetStatus(eReturnStatusFailed);
   result.AppendError(
-  "ScriptInterpreter::GetScriptCommands(StringList &) is not 
implemented.");
+  "This script interpreter does not support watchpoint callbacks.");
 }
 
 std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) 
{

diff  --git a/lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_callback.test 
b/lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_callback.test
new file mode 100644
index ..4dbf286a693e
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_callback.test
@@ -0,0 +1,5 @@
+# REQUIRES: lua
+# RUN: %lldb -s %s --script-language lua 2>&1 | FileCheck %s
+b main
+breakpoint command add -s lua
+# CHECK: error: This script interpreter does not support breakpoint callbacks

diff  --git a/lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test 
b/lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test
new file mode 100644
index ..c0bddbc1fdf5
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/Lua/watchpoint_callback.test
@@ -0,0 +1,8 @@
+# REQUIRES: lua
+# RUN: echo "int main() { return 0; }" | %clang_host -x c - -o %t
+# RUN: %lldb -s %s --script-language lua %t 2>&1 | FileCheck %s
+b main
+r
+watchpoint set expr 0x0
+watchpoint command add -s lua
+# CHECK: error: This script interpreter does not support watchpoint callbacks



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


[Lldb-commits] [lldb] acdda13 - [lldb/Lua] Add missing boiler plate to ScriptInterpreter.

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T21:54:44-08:00
New Revision: acdda1344a0e1b45bd3ba7feb0e8cd398bee0179

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

LOG: [lldb/Lua] Add missing boiler plate to ScriptInterpreter.

 - Fix enum entry order.
 - Fix missing enum case in CommandObjectBreakpointCommand.
 - Add Lua entry to swtich in LanguageToString and simplify the code.

Added: 


Modified: 
lldb/include/lldb/lldb-enumerations.h
lldb/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp

Removed: 




diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 5640a16c8f44..dd3d9cc7da50 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -211,11 +211,11 @@ enum DescriptionLevel {
 
 /// Script interpreter types.
 enum ScriptLanguage {
-  eScriptLanguageNone,
+  eScriptLanguageNone = 0,
   eScriptLanguagePython,
   eScriptLanguageLua,
-  eScriptLanguageDefault = eScriptLanguagePython,
-  eScriptLanguageUnknown
+  eScriptLanguageUnknown,
+  eScriptLanguageDefault = eScriptLanguagePython
 };
 
 /// Register numbering types.

diff  --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp 
b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index d62fe519eca5..551d0ac0081a 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -307,6 +307,7 @@ are no syntax errors may indicate that a function was 
declared but never called.
   m_use_script_language = true;
   break;
 case eScriptLanguageNone:
+case eScriptLanguageUnknown:
   m_use_script_language = false;
   break;
 }

diff  --git a/lldb/source/Interpreter/ScriptInterpreter.cpp 
b/lldb/source/Interpreter/ScriptInterpreter.cpp
index fd47aed6dcf6..552661ef80ee 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -43,21 +43,16 @@ void 
ScriptInterpreter::CollectDataForWatchpointCommandCallback(
 }
 
 std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) 
{
-  std::string return_value;
-
   switch (language) {
   case eScriptLanguageNone:
-return_value = "None";
-break;
+return "None";
   case eScriptLanguagePython:
-return_value = "Python";
-break;
+return "Python";
+  case eScriptLanguageLua:
+return "Lua";
   case eScriptLanguageUnknown:
-return_value = "Unknown";
-break;
+return "Unknown";
   }
-
-  return return_value;
 }
 
 lldb::ScriptLanguage
@@ -66,6 +61,8 @@ ScriptInterpreter::StringToLanguage(const llvm::StringRef 
) {
 return eScriptLanguageNone;
   if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
 return eScriptLanguagePython;
+  if (language.equals_lower(LanguageToString(eScriptLanguageLua)))
+return eScriptLanguageLua;
   return eScriptLanguageUnknown;
 }
 
@@ -82,13 +79,12 @@ Status ScriptInterpreter::SetBreakpointCommandCallback(
 }
 
 Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(
-std::vector _options_vec,
-const char *function_name,
+std::vector _options_vec, const char 
*function_name,
 StructuredData::ObjectSP extra_args_sp) {
   Status error;
   for (BreakpointOptions *bp_options : bp_options_vec) {
-error = SetBreakpointCommandCallbackFunction(bp_options, function_name, 
- extra_args_sp);
+error = SetBreakpointCommandCallbackFunction(bp_options, function_name,
+ extra_args_sp);
 if (!error.Success())
   return error;
   }



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


[Lldb-commits] [lldb] 1ff01cf - [lldb/Commands] Use the default scripting langauge for BP functions

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T18:12:37-08:00
New Revision: 1ff01cfe3ea51f873ff91ed66e1b8157583c6aa1

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

LOG: [lldb/Commands] Use the default scripting langauge for BP functions

When a function is used as a breakpoint command, use to the debugger's
default scripting language, unless a language is explicitly specified.

Added: 


Modified: 
lldb/source/Commands/CommandObjectBreakpointCommand.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp 
b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 73153cf6329d..d62fe519eca5 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -375,7 +375,10 @@ are no syntax errors may indicate that a function was 
declared but never called.
 
 if (!m_func_options.GetName().empty()) {
   m_options.m_use_one_liner = false;
-  m_options.m_use_script_language = true;
+  if (!m_options.m_use_script_language) {
+m_options.m_script_language = GetDebugger().GetScriptLanguage();
+m_options.m_use_script_language = true;
+  }
 }
 
 BreakpointIDList valid_bp_ids;



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


[Lldb-commits] [lldb] bbf70c0 - [lldb/Core] Support asking the debugger for a specific script interpreter

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T17:11:12-08:00
New Revision: bbf70c046789f4403a9c02fc5558708ef19073cf

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

LOG: [lldb/Core] Support asking the debugger for a specific script interpreter

Rather than holding on to one script interpreter, it should be possible
to request a script interpreter for a specific scripting language. The
GetScriptInterpreter method now takes an optional scripting language
argument.

(NFC)

Added: 


Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/source/Core/Debugger.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index b2f696c22834..a8048427c8f1 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -151,7 +151,9 @@ class Debugger : public 
std::enable_shared_from_this,
 return *m_command_interpreter_up;
   }
 
-  ScriptInterpreter *GetScriptInterpreter(bool can_create = true);
+  ScriptInterpreter *
+  GetScriptInterpreter(bool can_create = true,
+   llvm::Optional language = {});
 
   lldb::ListenerSP GetListener() { return m_listener_sp; }
 
@@ -396,8 +398,9 @@ class Debugger : public 
std::enable_shared_from_this,
   // source file cache.
   std::unique_ptr m_command_interpreter_up;
 
-  lldb::ScriptInterpreterSP m_script_interpreter_sp;
   std::recursive_mutex m_script_interpreter_mutex;
+  std::array
+  m_script_interpreters;
 
   IOHandlerStack m_input_reader_stack;
   llvm::StringMap> m_log_streams;

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 18397d00dcaa..c4619776c11c 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -708,8 +708,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, 
void *baton)
   m_source_manager_up(), m_source_file_cache(),
   m_command_interpreter_up(
   std::make_unique(*this, false)),
-  m_script_interpreter_sp(), m_input_reader_stack(), m_instance_name(),
-  m_loaded_plugins(), m_event_handler_thread(), m_io_handler_thread(),
+  m_input_reader_stack(), m_instance_name(), m_loaded_plugins(),
+  m_event_handler_thread(), m_io_handler_thread(),
   m_sync_broadcaster(nullptr, "lldb.debugger.sync"),
   m_forward_listener_sp(), m_clear_once() {
   char instance_cstr[256];
@@ -1198,17 +1198,21 @@ bool Debugger::EnableLog(llvm::StringRef channel,
error_stream);
 }
 
-ScriptInterpreter *Debugger::GetScriptInterpreter(bool can_create) {
+ScriptInterpreter *
+Debugger::GetScriptInterpreter(bool can_create,
+   llvm::Optional language) {
   std::lock_guard locker(m_script_interpreter_mutex);
+  lldb::ScriptLanguage script_language =
+  language ? *language : GetScriptLanguage();
 
-  if (!m_script_interpreter_sp) {
+  if (!m_script_interpreters[script_language]) {
 if (!can_create)
   return nullptr;
-m_script_interpreter_sp = PluginManager::GetScriptInterpreterForLanguage(
-GetScriptLanguage(), *this);
+m_script_interpreters[script_language] =
+PluginManager::GetScriptInterpreterForLanguage(script_language, *this);
   }
 
-  return m_script_interpreter_sp.get();
+  return m_script_interpreters[script_language].get();
 }
 
 SourceManager ::GetSourceManager() {



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


[Lldb-commits] [lldb] 8983d69 - [lldb/Commands] Fix bogus enum entry and add Lua (NFC)

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T17:21:32-08:00
New Revision: 8983d69144d14d6477c377bb91e9c7224e32f753

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

LOG: [lldb/Commands] Fix bogus enum entry and add Lua (NFC)

Fixes a bogus enum value for the scripting language options, adds an
entry for Lua and refactored the code to use an exhaustive switch.

Added: 


Modified: 
lldb/source/Commands/CommandObjectBreakpointCommand.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp 
b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 5151181a622f..0cc46a96489f 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -38,7 +38,12 @@ static constexpr OptionEnumValueElement 
g_script_option_enumeration[] = {
 "Commands are in the Python language.",
 },
 {
-eSortOrderByName,
+eScriptLanguageLua,
+"lua",
+"Commands are in the Lua language.",
+},
+{
+eScriptLanguageDefault,
 "default-script",
 "Commands are in the default scripting language.",
 },
@@ -297,12 +302,14 @@ are no syntax errors may indicate that a function was 
declared but never called.
 option_arg,
 g_breakpoint_command_add_options[option_idx].enum_values,
 eScriptLanguageNone, error);
-
-if (m_script_language == eScriptLanguagePython ||
-m_script_language == eScriptLanguageDefault) {
+switch (m_script_language) {
+case eScriptLanguagePython:
+case eScriptLanguageLua:
   m_use_script_language = true;
-} else {
+  break;
+case eScriptLanguageNone:
   m_use_script_language = false;
+  break;
 }
 break;
 



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


[Lldb-commits] [PATCH] D71801: [lldb/Lua] Make lldb.debugger et al available to Lua

2019-12-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 235033.
JDevlieghere added a comment.

Test


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

https://reviews.llvm.org/D71801

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/test/Shell/ScriptInterpreter/Lua/convenience_variables.test

Index: lldb/test/Shell/ScriptInterpreter/Lua/convenience_variables.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/convenience_variables.test
@@ -0,0 +1,17 @@
+# REQUIRES: lua
+#
+# This tests that the convenience variables are not nil. Given that there is no
+# target we only expect the debugger to be valid.
+#
+# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
+script
+print(string.format("lldb.debugger is valid: %s", lldb.debugger:IsValid()))
+print(string.format("lldb.target is valid: %s", lldb.target:IsValid()))
+print(string.format("lldb.process is valid: %s", lldb.process:IsValid()))
+print(string.format("lldb.thread is valid: %s", lldb.thread:IsValid()))
+print(string.format("lldb.frame is valid: %s", lldb.frame:IsValid()))
+# CHECK: debugger is valid: true
+# CHECK: target is valid: false
+# CHECK: process is valid: false
+# CHECK: thread is valid: false
+# CHECK: frame is valid: false
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -27,7 +27,14 @@
   : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
   ">>> ", "..> ", true, debugger.GetUseColor(), 0,
   *this, nullptr),
-m_script_interpreter(script_interpreter) {}
+m_script_interpreter(script_interpreter) {
+llvm::cantFail(
+m_script_interpreter.GetLua().EnterSession(debugger.GetID()));
+  }
+
+  ~IOHandlerLuaInterpreter() {
+llvm::cantFail(m_script_interpreter.GetLua().LeaveSession());
+  }
 
   void IOHandlerInputComplete(IOHandler _handler,
   std::string ) override {
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_Lua_h_
 #define liblldb_Lua_h_
 
+#include "lldb/lldb-types.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
@@ -35,11 +36,15 @@
 luaL_openlibs(m_lua_state);
   }
 
+  llvm::Error EnterSession(lldb::user_id_t debugger_id);
+  llvm::Error LeaveSession();
+
   llvm::Error Run(llvm::StringRef buffer);
 
 private:
   std::mutex m_mutex;
   lua_State *m_lua_state;
+  bool m_session_is_active = false;
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -10,6 +10,7 @@
 #include "llvm/Support/FormatVariadic.h"
 
 using namespace lldb_private;
+using namespace lldb;
 
 llvm::Error Lua::Run(llvm::StringRef buffer) {
   std::lock_guard lock(m_mutex);
@@ -26,3 +27,27 @@
   lua_pop(m_lua_state, 1);
   return e;
 }
+
+llvm::Error Lua::EnterSession(user_id_t debugger_id) {
+  if (m_session_is_active)
+return llvm::Error::success();
+
+  m_session_is_active = true;
+  std::string buffer = llvm::formatv(
+  "lldb.debugger = lldb.SBDebugger.FindDebuggerWithID({0})", debugger_id);
+  buffer.append("; lldb.target = lldb.debugger:GetSelectedTarget()");
+  buffer.append("; lldb.process = lldb.target:GetProcess()");
+  buffer.append("; lldb.thread = lldb.process:GetSelectedThread()");
+  buffer.append("; lldb.frame = lldb.thread:GetSelectedFrame ()");
+  return Run(buffer);
+}
+
+llvm::Error Lua::LeaveSession() {
+  m_session_is_active = false;
+  std::string buffer = "lldb.debugger = nil";
+  buffer.append("; lldb.target = nil");
+  buffer.append("; lldb.process = nil");
+  buffer.append("; lldb.thread = nil");
+  buffer.append("; lldb.frame = nil");
+  return Run(buffer);
+}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71801: [lldb/Lua] Make lldb.debugger et al available to Lua

2019-12-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: LLDB, labath.
Herald added a project: LLDB.

The Python script interpreter makes the current debugger, target, process, 
thread and frame available to interactive scripting sessions through 
convenience variables. This patch does the same for Lua.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71801

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -27,7 +27,14 @@
   : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
   ">>> ", "..> ", true, debugger.GetUseColor(), 0,
   *this, nullptr),
-m_script_interpreter(script_interpreter) {}
+m_script_interpreter(script_interpreter) {
+llvm::cantFail(
+m_script_interpreter.GetLua().EnterSession(debugger.GetID()));
+  }
+
+  ~IOHandlerLuaInterpreter() {
+llvm::cantFail(m_script_interpreter.GetLua().LeaveSession());
+  }
 
   void IOHandlerInputComplete(IOHandler _handler,
   std::string ) override {
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_Lua_h_
 #define liblldb_Lua_h_
 
+#include "lldb/lldb-types.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
@@ -35,11 +36,15 @@
 luaL_openlibs(m_lua_state);
   }
 
+  llvm::Error EnterSession(lldb::user_id_t debugger_id);
+  llvm::Error LeaveSession();
+
   llvm::Error Run(llvm::StringRef buffer);
 
 private:
   std::mutex m_mutex;
   lua_State *m_lua_state;
+  bool m_session_is_active = false;
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -10,6 +10,7 @@
 #include "llvm/Support/FormatVariadic.h"
 
 using namespace lldb_private;
+using namespace lldb;
 
 llvm::Error Lua::Run(llvm::StringRef buffer) {
   std::lock_guard lock(m_mutex);
@@ -26,3 +27,27 @@
   lua_pop(m_lua_state, 1);
   return e;
 }
+
+llvm::Error Lua::EnterSession(user_id_t debugger_id) {
+  if (m_session_is_active)
+return llvm::Error::success();
+
+  m_session_is_active = true;
+  std::string buffer = llvm::formatv(
+  "lldb.debugger = lldb.SBDebugger.FindDebuggerWithID({0})", debugger_id);
+  buffer.append("; lldb.target = lldb.debugger:GetSelectedTarget()");
+  buffer.append("; lldb.process = lldb.target:GetProcess()");
+  buffer.append("; lldb.thread = lldb.process:GetSelectedThread()");
+  buffer.append("; lldb.frame = lldb.thread:GetSelectedFrame ()");
+  return Run(buffer);
+}
+
+llvm::Error Lua::LeaveSession() {
+  m_session_is_active = false;
+  std::string buffer = "lldb.debugger = nil";
+  buffer.append("; lldb.target = nil");
+  buffer.append("; lldb.process = nil");
+  buffer.append("; lldb.thread = nil");
+  buffer.append("; lldb.frame = nil");
+  return Run(buffer);
+}


Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -27,7 +27,14 @@
   : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
   ">>> ", "..> ", true, debugger.GetUseColor(), 0,
   *this, nullptr),
-m_script_interpreter(script_interpreter) {}
+m_script_interpreter(script_interpreter) {
+llvm::cantFail(
+m_script_interpreter.GetLua().EnterSession(debugger.GetID()));
+  }
+
+  ~IOHandlerLuaInterpreter() {
+llvm::cantFail(m_script_interpreter.GetLua().LeaveSession());
+  }
 
   void IOHandlerInputComplete(IOHandler _handler,
   std::string ) override {
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_Lua_h_
 #define liblldb_Lua_h_
 
+#include "lldb/lldb-types.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
@@ -35,11 +36,15 @@
 luaL_openlibs(m_lua_state);
   }
 
+  llvm::Error EnterSession(lldb::user_id_t debugger_id);
+  

[Lldb-commits] [PATCH] D71800: [CMake] Add $ORIGIN/../../../../lib to rpath if BUILD_SHARED_LIBS AND UNIX

2019-12-21 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: lldb/source/API/CMakeLists.txt:124
+  set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" 
"\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+  set_target_properties(liblldb PROPERTIES INSTALL_RPATH "${_install_rpath}")
+endif()

The extra_libdir logic is copied from `llvm/cmake/modules/AddLLVM.cmake` 
`llvm_setup_rpath`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71800



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


[Lldb-commits] [PATCH] D71800: [CMake] Add $ORIGIN/../../../../lib to rpath if BUILD_SHARED_LIBS AND UNIX

2019-12-21 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay created this revision.
MaskRay added reviewers: clayborg, JDevlieghere, jingham, labath.
Herald added subscribers: lldb-commits, kristof.beyls, mgorny.
Herald added a project: LLDB.

For -DBUILD_SHARED_LIBS=On builds, lib/liblldb.so depends on lib/*.so .
lib/python2.7/dist-packages/lldb/_lldb.so is a symlink to
lib/liblldb.so, which needs an additional rpath
`$ORIGIN/../../../../lib` to load. This fixes an import error from
lib/python2.7/dist-packages/lldb/__init__.py

  from . import _lldb
  ImportError: libLLVMAArch64CodeGen.so.10git: cannot open shared object file: 
No such file or directory


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71800

Files:
  lldb/source/API/CMakeLists.txt


Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -111,6 +111,19 @@
   ${option_install_prefix}
 )
 
+# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so .
+# Add an additional rpath \$ORIGIN/../../../../lib so that _lldb.so can be
+# loaded from Python.
+if(LLDB_ENABLE_PYTHON AND BUILD_SHARED_LIBS AND UNIX)
+  if(LLVM_INSTALL_PREFIX AND NOT (LLVM_INSTALL_PREFIX STREQUAL 
CMAKE_INSTALL_PREFIX))
+set(extra_libdir ${LLVM_LIBRARY_DIR})
+  elseif(LLVM_BUILD_LIBRARY_DIR)
+set(extra_libdir ${LLVM_LIBRARY_DIR})
+  endif()
+  set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" 
"\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+  set_target_properties(liblldb PROPERTIES INSTALL_RPATH "${_install_rpath}")
+endif()
+
 if (MSVC)
   set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
 endif()


Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -111,6 +111,19 @@
   ${option_install_prefix}
 )
 
+# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so .
+# Add an additional rpath \$ORIGIN/../../../../lib so that _lldb.so can be
+# loaded from Python.
+if(LLDB_ENABLE_PYTHON AND BUILD_SHARED_LIBS AND UNIX)
+  if(LLVM_INSTALL_PREFIX AND NOT (LLVM_INSTALL_PREFIX STREQUAL CMAKE_INSTALL_PREFIX))
+set(extra_libdir ${LLVM_LIBRARY_DIR})
+  elseif(LLVM_BUILD_LIBRARY_DIR)
+set(extra_libdir ${LLVM_LIBRARY_DIR})
+  endif()
+  set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+  set_target_properties(liblldb PROPERTIES INSTALL_RPATH "${_install_rpath}")
+endif()
+
 if (MSVC)
   set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4164be7 - [Lldb/Lua] Persist Lua state across script interpreter calls.

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T15:00:35-08:00
New Revision: 4164be7206d740b77b5a7b4b2f859ed122d08c10

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

LOG: [Lldb/Lua] Persist Lua state across script interpreter calls.

Don't create a new lua state on every operation. Share a single state
across the lifetime of the script interpreter. Add simple locking to
prevent two threads from modifying the state concurrently.

Added: 
lldb/test/Shell/ScriptInterpreter/Lua/persistent_state.test

Modified: 
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

Removed: 




diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
index a908ef086735..dc64139fa4e5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -12,6 +12,7 @@
 using namespace lldb_private;
 
 llvm::Error Lua::Run(llvm::StringRef buffer) {
+  std::lock_guard lock(m_mutex);
   int error =
   luaL_loadbuffer(m_lua_state, buffer.data(), buffer.size(), "buffer") ||
   lua_pcall(m_lua_state, 0, 0, 0);

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
index 073e7e22e7d6..ed1d159590ac 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -14,6 +14,8 @@
 
 #include "lua.hpp"
 
+#include 
+
 namespace lldb_private {
 
 extern "C" {
@@ -36,6 +38,7 @@ class Lua {
   llvm::Error Run(llvm::StringRef buffer);
 
 private:
+  std::mutex m_mutex;
   lua_State *m_lua_state;
 };
 

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
index b3f1689909fd..d5423b78b8c4 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -22,33 +22,34 @@ using namespace lldb_private;
 class IOHandlerLuaInterpreter : public IOHandlerDelegate,
 public IOHandlerEditline {
 public:
-  IOHandlerLuaInterpreter(Debugger )
+  IOHandlerLuaInterpreter(Debugger ,
+  ScriptInterpreterLua _interpreter)
   : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
   ">>> ", "..> ", true, debugger.GetUseColor(), 0,
   *this, nullptr),
-m_lua() {}
+m_script_interpreter(script_interpreter) {}
 
   void IOHandlerInputComplete(IOHandler _handler,
   std::string ) override {
-if (llvm::Error error = m_lua.Run(data)) {
+if (llvm::Error error = m_script_interpreter.GetLua().Run(data)) {
   *GetOutputStreamFileSP() << llvm::toString(std::move(error));
 }
   }
 
 private:
-  Lua m_lua;
+  ScriptInterpreterLua _script_interpreter;
 };
 
 ScriptInterpreterLua::ScriptInterpreterLua(Debugger )
-: ScriptInterpreter(debugger, eScriptLanguageLua) {}
+: ScriptInterpreter(debugger, eScriptLanguageLua),
+  m_lua(std::make_unique()) {}
 
 ScriptInterpreterLua::~ScriptInterpreterLua() {}
 
 bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
   CommandReturnObject *result,
   const ExecuteScriptOptions ) 
{
-  Lua l;
-  if (llvm::Error e = l.Run(command)) {
+  if (llvm::Error e = m_lua->Run(command)) {
 result->AppendErrorWithFormatv(
 "lua failed attempting to evaluate '{0}': {1}\n", command,
 llvm::toString(std::move(e)));
@@ -72,7 +73,7 @@ void ScriptInterpreterLua::ExecuteInterpreterLoop() {
   if (!debugger.GetInputFile().IsValid())
 return;
 
-  IOHandlerSP io_handler_sp(new IOHandlerLuaInterpreter(debugger));
+  IOHandlerSP io_handler_sp(new IOHandlerLuaInterpreter(debugger, *this));
   debugger.PushIOHandler(io_handler_sp);
 }
 
@@ -107,3 +108,5 @@ lldb_private::ConstString 
ScriptInterpreterLua::GetPluginName() {
 }
 
 uint32_t ScriptInterpreterLua::GetPluginVersion() { return 1; }
+
+Lua ::GetLua() { return *m_lua; }

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h 
b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
index 7f69a73f5882..b34c7d0e8217 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -12,7 +12,7 @@
 #include "lldb/Interpreter/ScriptInterpreter.h"
 
 namespace 

[Lldb-commits] [lldb] ceb433a - [lldb] Fix windows build after getASTContext() change

2019-12-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-21T23:27:27+01:00
New Revision: ceb433ad162bac35888303d29d34dc2609974d92

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

LOG: [lldb] Fix windows build after getASTContext() change

Added: 


Modified: 
lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Removed: 




diff  --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp 
b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index e8a8690c1ff1..c0163f647268 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -437,10 +437,9 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
   llvm::dyn_cast_or_null(_ast_ctx_or_err.get());
   EXPECT_NE(nullptr, clang_ast_ctx);
 
-  auto ast_ctx = clang_ast_ctx->getASTContext();
-  EXPECT_NE(nullptr, ast_ctx);
+  clang::ASTContext _ctx = clang_ast_ctx->getASTContext();
 
-  auto tu = ast_ctx->getTranslationUnitDecl();
+  auto tu = ast_ctx.getTranslationUnitDecl();
   EXPECT_NE(nullptr, tu);
 
   symfile->ParseDeclsForContext(CompilerDeclContext(



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


[Lldb-commits] [PATCH] D71235: [lldb/Lua] Generate Lua Bindings and Make Them Available to the Script Interpreter

2019-12-21 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf03e17c5701: [Lldb/Lua] Generate Lua Bindings (authored by 
JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D71235?vs=234799=235024#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71235

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/lldb_lua.swig
  lldb/source/API/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  lldb/test/Shell/ScriptInterpreter/Lua/bindings.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
@@ -11,6 +11,8 @@
 
 using namespace lldb_private;
 
+extern "C" int luaopen_lldb(lua_State *L) { return 0; }
+
 TEST(LuaTest, RunValid) {
   Lua lua;
   llvm::Error error = lua.Run("foo = 1");
Index: lldb/test/Shell/ScriptInterpreter/Lua/bindings.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/bindings.test
@@ -0,0 +1,6 @@
+# REQUIRES: lua
+# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
+script
+debugger = lldb.SBDebugger.Create()
+print(string.format("debugger is valid: %s", debugger:IsValid()))
+# CHECK: debugger is valid: true
Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -16,11 +16,16 @@
 
 namespace lldb_private {
 
+extern "C" {
+int luaopen_lldb(lua_State *L);
+}
+
 class Lua {
 public:
   Lua() : m_lua_state(luaL_newstate()) {
 assert(m_lua_state);
 luaL_openlibs(m_lua_state);
+luaopen_lldb(m_lua_state);
   }
 
   ~Lua() {
Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(Lua REQUIRED)
+
 add_lldb_library(lldbPluginScriptInterpreterLua PLUGIN
   Lua.cpp
   ScriptInterpreterLua.cpp
Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -9,6 +9,11 @@
   set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp)
 endif()
 
+if(LLDB_ENABLE_LUA)
+  get_target_property(lldb_scripts_dir swig_wrapper_lua BINARY_DIR)
+  set(lldb_lua_wrapper ${lldb_scripts_dir}/LLDBWrapLua.cpp)
+endif()
+
 if(LLDB_BUILD_FRAMEWORK)
   set(option_install_prefix INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR})
   set(option_framework FRAMEWORK)
@@ -85,6 +90,7 @@
   SBUnixSignals.cpp
   SystemInitializerFull.cpp
   ${lldb_python_wrapper}
+  ${lldb_lua_wrapper}
 
   LINK_LIBS
 lldbBase
@@ -130,6 +136,19 @@
   endif ()
 endif()
 
+if(lldb_lua_wrapper)
+  add_dependencies(liblldb swig_wrapper_lua)
+  target_include_directories(liblldb PRIVATE ${LUA_INCLUDE_DIR})
+
+  if (MSVC)
+set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+  else()
+set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
+  endif()
+
+  set_source_files_properties(${lldb_lua_wrapper} PROPERTIES GENERATED ON)
+endif()
+
 set_target_properties(liblldb
   PROPERTIES
   VERSION ${LLDB_VERSION}
Index: lldb/scripts/lldb_lua.swig
===
--- /dev/null
+++ lldb/scripts/lldb_lua.swig
@@ -0,0 +1,18 @@
+/*
+   lldb.swig
+
+   This is the input file for SWIG, to create the appropriate C++ wrappers and
+   functions for various scripting languages, to enable them to call the
+   liblldb Script Bridge functions.
+*/
+
+%module lldb
+
+%include "./headers.swig"
+
+%{
+using namespace lldb_private;
+using namespace lldb;
+%}
+
+%include "./interfaces.swig"
Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -27,31 +27,58 @@
   set(DARWIN_EXTRAS "")
 endif()
 
-add_custom_command(
-  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
-  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
-  DEPENDS ${SWIG_SOURCES}
-  DEPENDS ${SWIG_INTERFACES}
-  DEPENDS ${SWIG_HEADERS}
-  COMMAND ${SWIG_EXECUTABLE} 
-  -c++
-  -shadow
-  -python
-  -features autodoc
-  -threads
-  -I${LLDB_SOURCE_DIR}/include
-  -I${CMAKE_CURRENT_SOURCE_DIR}
-  -D__STDC_LIMIT_MACROS
-  -D__STDC_CONSTANT_MACROS
-  ${DARWIN_EXTRAS}
-  -outdir 

[Lldb-commits] [lldb] bf03e17 - [Lldb/Lua] Generate Lua Bindings

2019-12-21 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-21T11:28:41-08:00
New Revision: bf03e17c570171c7a52117fe63ace89d58f328d5

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

LOG: [Lldb/Lua] Generate Lua Bindings

This patch uses SWIG to generate the Lua bindings for the SB API. It
covers most of the API, but some methods require a type map similar to
Python.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html

Differential revision: https://reviews.llvm.org/D71235

Added: 
lldb/scripts/lldb_lua.swig
lldb/test/Shell/ScriptInterpreter/Lua/bindings.test

Modified: 
lldb/CMakeLists.txt
lldb/scripts/CMakeLists.txt
lldb/source/API/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 3747c9896525..39e12b251623 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -50,10 +50,10 @@ if (LLDB_ENABLE_PYTHON)
   file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} 
LLDB_PYTHON_DEFAULT_RELATIVE_PATH)
   set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH}
 CACHE STRING "Path where Python modules are installed, relative to install 
prefix")
-
-  add_subdirectory(scripts)
 endif ()
 
+add_subdirectory(scripts)
+
 # We need the headers generated by instrinsics_gen before we can compile
 # any source file in LLDB as the imported Clang modules might include
 # some of these generated headers. This approach is copied from Clang's main

diff  --git a/lldb/scripts/CMakeLists.txt b/lldb/scripts/CMakeLists.txt
index 5b86956f2a9e..8fa4e5f78916 100644
--- a/lldb/scripts/CMakeLists.txt
+++ b/lldb/scripts/CMakeLists.txt
@@ -27,31 +27,58 @@ else()
   set(DARWIN_EXTRAS "")
 endif()
 
-add_custom_command(
-  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
-  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
-  DEPENDS ${SWIG_SOURCES}
-  DEPENDS ${SWIG_INTERFACES}
-  DEPENDS ${SWIG_HEADERS}
-  COMMAND ${SWIG_EXECUTABLE} 
-  -c++
-  -shadow
-  -python
-  -features autodoc
-  -threads
-  -I${LLDB_SOURCE_DIR}/include
-  -I${CMAKE_CURRENT_SOURCE_DIR}
-  -D__STDC_LIMIT_MACROS
-  -D__STDC_CONSTANT_MACROS
-  ${DARWIN_EXTRAS}
-  -outdir ${CMAKE_CURRENT_BINARY_DIR}
-  -o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
-  ${LLDB_SOURCE_DIR}/scripts/lldb.swig
-  VERBATIM
-  COMMENT "Builds LLDB Python wrapper")
-
-add_custom_target(swig_wrapper ALL DEPENDS
-  ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
-  ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
+set(SWIG_COMMON_FLAGS
+  -c++
+  -features autodoc
+  -I${LLDB_SOURCE_DIR}/include
+  -I${CMAKE_CURRENT_SOURCE_DIR}
+  -D__STDC_LIMIT_MACROS
+  -D__STDC_CONSTANT_MACROS
+  ${DARWIN_EXTRAS}
+  -outdir ${CMAKE_CURRENT_BINARY_DIR}
 )
 
+
+if (LLDB_ENABLE_PYTHON)
+  add_custom_command(
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
+DEPENDS ${SWIG_SOURCES}
+DEPENDS ${SWIG_INTERFACES}
+DEPENDS ${SWIG_HEADERS}
+COMMAND ${SWIG_EXECUTABLE}
+${SWIG_COMMON_FLAGS}
+-c++
+-shadow
+-python
+-threads
+-o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
+${LLDB_SOURCE_DIR}/scripts/lldb.swig
+VERBATIM
+COMMENT "Builds LLDB Python wrapper")
+
+  add_custom_target(swig_wrapper ALL DEPENDS
+${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
+${CMAKE_CURRENT_BINARY_DIR}/lldb.py
+  )
+endif()
+
+if (LLDB_ENABLE_LUA)
+  add_custom_command(
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapLua.cpp
+DEPENDS ${SWIG_SOURCES}
+DEPENDS ${SWIG_INTERFACES}
+DEPENDS ${SWIG_HEADERS}
+COMMAND ${SWIG_EXECUTABLE}
+${SWIG_COMMON_FLAGS}
+-lua
+-w503
+-o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapLua.cpp
+${LLDB_SOURCE_DIR}/scripts/lldb_lua.swig
+VERBATIM
+COMMENT "Builds LLDB Lua wrapper")
+
+  add_custom_target(swig_wrapper_lua ALL DEPENDS
+${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapLua.cpp
+  )
+endif()

diff  --git a/lldb/scripts/lldb_lua.swig b/lldb/scripts/lldb_lua.swig
new file mode 100644
index ..85edefff76f2
--- /dev/null
+++ b/lldb/scripts/lldb_lua.swig
@@ -0,0 +1,18 @@
+/*
+   lldb.swig
+
+   This is the input file for SWIG, to create the appropriate C++ wrappers and
+   functions for various scripting languages, to enable them to call the
+   liblldb Script Bridge functions.
+*/
+
+%module lldb
+
+%include "./headers.swig"
+
+%{
+using namespace lldb_private;
+using namespace lldb;
+%}
+
+%include "./interfaces.swig"

diff  --git a/lldb/source/API/CMakeLists.txt 

[Lldb-commits] [PATCH] D71789: [lldb] Refactor thread-step-out-ret-addr-check test to use .data instead of stack variable

2019-12-21 Thread Mark Mossberg via Phabricator via lldb-commits
mossberg abandoned this revision.
mossberg added a comment.

Thanks all for testing this! I had no idea it was this hard to get a 
non-executable section :)

Superseded by D71784 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71789



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


[Lldb-commits] [lldb] 49b206f - [lldb][NFC] Remove all ASTContext getter wrappers from ClangASTContext

2019-12-21 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-21T15:41:18+01:00
New Revision: 49b206f95806f35ff8f9a715185355fc2a159760

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

LOG: [lldb][NFC] Remove all ASTContext getter wrappers from ClangASTContext

Their naming is misleading as they only return the
ClangASTContext-owned variables. For ClangASTContext instances constructed
for a given clang::ASTContext they silently generated duplicated instances
(e.g., a second IdentifierTable) that were essentially unusable.

This removes all these getters as they are anyway not very useful in comparison
to just calling the clang::ASTContext getters. The initialization
code has been moved to the CreateASTContext initialization method so that all
code for making our own clang::ASTContext is in one place.

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Symbol/ClangASTContext.cpp
lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
b/lldb/include/lldb/Symbol/ClangASTContext.h
index 6cebd6f3b62a..e5dc77504afb 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -102,22 +102,6 @@ class ClangASTContext : public TypeSystem {
 
   clang::ASTContext *getASTContext();
 
-  clang::Builtin::Context *getBuiltinContext();
-
-  clang::IdentifierTable *getIdentifierTable();
-
-  clang::LangOptions *getLanguageOptions();
-
-  clang::SelectorTable *getSelectorTable();
-
-  clang::FileManager *getFileManager();
-
-  clang::SourceManager *getSourceManager();
-
-  clang::DiagnosticsEngine *getDiagnosticsEngine();
-
-  clang::DiagnosticConsumer *getDiagnosticConsumer();
-
   clang::MangleContext *getMangleContext();
 
   std::shared_ptr ();

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index e326d239cb55..e044a4d33b42 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -56,12 +56,10 @@ ClangASTSource::ClangASTSource(const lldb::TargetSP ,
   m_ast_importer_sp = importer;
 }
 
-void ClangASTSource::InstallASTContext(ClangASTContext _ast_context,
-   clang::FileManager _manager,
-   bool is_shared_context) {
+void ClangASTSource::InstallASTContext(ClangASTContext _ast_context) {
   m_ast_context = clang_ast_context.getASTContext();
   m_clang_ast_context = _ast_context;
-  m_file_manager = _manager;
+  m_file_manager = _ast_context->getSourceManager().getFileManager();
   m_ast_importer_sp->InstallMapCompleter(m_ast_context, *this);
 }
 

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index e0442aeca326..609b182ed61a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -60,9 +60,7 @@ class ClangASTSource : public ClangExternalASTSourceCommon,
   }
   void MaterializeVisibleDecls(const clang::DeclContext *DC) { return; }
 
-  void InstallASTContext(ClangASTContext _context,
- clang::FileManager _manager,
- bool is_shared_context = false);
+  void InstallASTContext(ClangASTContext _context);
 
   //
   // APIs for ExternalASTSource

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 15b242a8b87e..ebd2d5c1644b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -997,7 +997,7 @@ ClangExpressionParser::ParseInternal(DiagnosticManager 
_manager,
 } else {
   ast_context.setExternalSource(ast_source);
 }
-decl_map->InstallASTContext(*m_ast_context, m_compiler->getFileManager());
+decl_map->InstallASTContext(*m_ast_context);
   }
 
   // Check that the ASTReader is properly attached to ASTContext and Sema.

diff  --git a/lldb/source/Symbol/ClangASTContext.cpp 
b/lldb/source/Symbol/ClangASTContext.cpp
index 2e66b9a06c64..65b95089b931 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -571,9 +571,7 @@ lldb::TypeSystemSP 

[Lldb-commits] [lldb] 2947da9 - [lldb] disable thread-step-out-ret-addr-check on windows

2019-12-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-21T14:20:47+01:00
New Revision: 2947da9ff7d1a1c1d0356ac51405e6576d8fbf64

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

LOG: [lldb] disable thread-step-out-ret-addr-check on windows

I'm unable to get this test working there.

Added: 


Modified: 
lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index 36e106970201..e748b4e5c73c 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -2,6 +2,7 @@
 # points to non-executable memory.
 
 # REQUIRES: target-x86_64
+# UNSUPPORTED: system-windows
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s



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


[Lldb-commits] [PATCH] D71797: Fix thread-step-out-ret-addr-check.test PT_GNU_STACK compilation on Windows

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

This has been already fixed by @labath: 
https://github.com/llvm/llvm-project/commit/ce3ce9f46404688cc2d95f794799c8f834630905


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71797



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


[Lldb-commits] [PATCH] D71797: Fix thread-step-out-ret-addr-check.test PT_GNU_STACK compilation on Windows

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I already fixed the compilation error in rGce3ce9f 
, but it 
does not seem to be enough.. I guess the test will need to be re-disabled on 
windows. (My vague knowledge of windows tells me that the `nonstandard_stub` 
symbol might not make it into the final executable.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71797



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


[Lldb-commits] [lldb] e192cc1 - [lldb] One more attempt to fix thread-step-out-ret-addr-check on windows

2019-12-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-21T13:33:42+01:00
New Revision: e192cc1f1bf120712f7c78fcd51645db8918d083

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

LOG: [lldb] One more attempt to fix thread-step-out-ret-addr-check on windows

Added: 


Modified: 
lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s

Removed: 




diff  --git a/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s 
b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
index 2fb4935b38bb..dd4453c64b88 100644
--- a/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -10,6 +10,7 @@ asm_main:
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
+.globl nonstandard_stub
 nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi



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


[Lldb-commits] [PATCH] D71797: Fix thread-step-out-ret-addr-check.test PT_GNU_STACK compilation on Windows

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: stella.stamenova, mossberg, labath.
jankratochvil added a project: LLDB.
Herald added a subscriber: krytarowski.
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s:22
 
-#ifdef __linux__
 .section .note.GNU-stack,"",@progbits

That was apparently a comment now.  And OSX does not mind this section.



D71784  broke Windows: 
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/11924/steps/test/logs/stdio

  
E:\build_slave\lldb-x64-windows-ninja\llvm-project\lldb\test\Shell\Unwind/Inputs/thread-step-out-ret-addr-check.s:23:27:
 error: unexpected token in directive
  .section .note.GNU-stack,"",@progbits
^

Is this patch OK? I am not sure about the backquotes, `grep` etc. how it can 
work on Windows. The only other idea I have is to use Python test for it. Or 
give up on the stack and create some non-executable data section like D71789 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71797

Files:
  lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
  lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -3,7 +3,8 @@
 
 # REQUIRES: target-x86_64
 
-# RUN: %clang_host %p/Inputs/call-asm.c 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
+# RUN: llvm-mc -filetype=asm `%clang_host -print-target-triple|grep -qi linux 
&& echo --defsym LINUX=0` %p/Inputs/thread-step-out-ret-addr-check.s > %t.s
+# RUN: %clang_host %p/Inputs/call-asm.c %t.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
 
 breakpoint set -n nonstandard_stub
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -19,6 +19,6 @@
 add $0x10, %rsp
 ret
 
-#ifdef __linux__
+.ifdef LINUX
 .section .note.GNU-stack,"",@progbits
-#endif
+.endif


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -3,7 +3,8 @@
 
 # REQUIRES: target-x86_64
 
-# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/thread-step-out-ret-addr-check.s -o %t
+# RUN: llvm-mc -filetype=asm `%clang_host -print-target-triple|grep -qi linux && echo --defsym LINUX=0` %p/Inputs/thread-step-out-ret-addr-check.s > %t.s
+# RUN: %clang_host %p/Inputs/call-asm.c %t.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
 
 breakpoint set -n nonstandard_stub
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -19,6 +19,6 @@
 add $0x10, %rsp
 ret
 
-#ifdef __linux__
+.ifdef LINUX
 .section .note.GNU-stack,"",@progbits
-#endif
+.endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71797: Fix thread-step-out-ret-addr-check.test PT_GNU_STACK compilation on Windows

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s:22
 
-#ifdef __linux__
 .section .note.GNU-stack,"",@progbits

That was apparently a comment now.  And OSX does not mind this section.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71797



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


[Lldb-commits] [lldb] ce3ce9f - [lldb] Force the preprocessor to run in thread-step-out-ret-addr-check.test

2019-12-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-21T12:25:02+01:00
New Revision: ce3ce9f46404688cc2d95f794799c8f834630905

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

LOG: [lldb] Force the preprocessor to run in thread-step-out-ret-addr-check.test

It does not seem to run automatically on windows.

Added: 


Modified: 
lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index ec73bd808c24..36e106970201 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -3,7 +3,7 @@
 
 # REQUIRES: target-x86_64
 
-# RUN: %clang_host %p/Inputs/call-asm.c 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
+# RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
 
 breakpoint set -n nonstandard_stub



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


[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 2 inline comments as done.
jankratochvil added inline comments.



Comment at: lldb/source/Expression/IRMemoryMap.cpp:577-586
   if (lldb_private::Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
 LLDB_LOGF(log,
   "IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64
   ", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
-  (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
-  (uint64_t)allocation.m_process_start,
+  (uint64_t)process_address, (uint64_t)(uintptr_t)bytes,
+  (uint64_t)size, (uint64_t)allocation.m_process_start,

labath wrote:
> This could be something 
> `LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS), "({0:x}, {1:x}, 
> {2:x}) went to [{3:x}, {4:x})", process_address, bytes, 
> allocation.m_process_start, allocation.m_process_start + allocation.m_size)`
I haven't changed the log function, that could be a different patch, that goes 
too far IMO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71498



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


[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 234935.
jankratochvil marked an inline comment as done.
Herald added a subscriber: emaste.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71498

Files:
  lldb/source/Core/PluginManager.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Expression/IRMemoryMap.cpp
  lldb/source/Host/common/HostInfoBase.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/source/Plugins/Process/POSIX/CrashReason.cpp

Index: lldb/source/Plugins/Process/POSIX/CrashReason.cpp
===
--- lldb/source/Plugins/Process/POSIX/CrashReason.cpp
+++ lldb/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -136,15 +136,15 @@
 #if defined(si_lower) && defined(si_upper)
   if (reason == CrashReason::eBoundViolation) {
 str = "signal SIGSEGV";
-AppendBounds(str, reinterpret_cast(info.si_lower),
- reinterpret_cast(info.si_upper),
- reinterpret_cast(info.si_addr));
+AppendBounds(str, reinterpret_cast(info.si_lower),
+ reinterpret_cast(info.si_upper),
+ reinterpret_cast(info.si_addr));
 return str;
   }
 #endif
 
   return GetCrashReasonString(reason,
-  reinterpret_cast(info.si_addr));
+  reinterpret_cast(info.si_addr));
 }
 
 std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
Index: lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -355,7 +355,7 @@
 
   ConstantInt *new_constant_int =
   ConstantInt::get(llvm::Type::getInt64Ty(m_module->getContext()),
-   reinterpret_cast(result_decl), false);
+   reinterpret_cast(result_decl), false);
 
   llvm::Metadata *values[2];
   values[0] = ConstantAsMetadata::get(new_result_global);
Index: lldb/source/Host/common/HostInfoBase.cpp
===
--- lldb/source/Host/common/HostInfoBase.cpp
+++ lldb/source/Host/common/HostInfoBase.cpp
@@ -246,8 +246,8 @@
   // On other posix systems, we will get .../lib(64|32)?/liblldb.so.
 
   FileSpec lldb_file_spec(Host::GetModuleFileSpecForHostAddress(
-  reinterpret_cast(reinterpret_cast(
-  HostInfoBase::ComputeSharedLibraryDirectory;
+  reinterpret_cast(
+  HostInfoBase::ComputeSharedLibraryDirectory)));
 
   // This is necessary because when running the testsuite the shlib might be a
   // symbolic link inside the Python resource dir.
Index: lldb/source/Expression/IRMemoryMap.cpp
===
--- lldb/source/Expression/IRMemoryMap.cpp
+++ lldb/source/Expression/IRMemoryMap.cpp
@@ -328,9 +328,9 @@
   case eAllocationPolicyMirror:
 process_sp = m_process_wp.lock();
 LLDB_LOGF(log,
-  "IRMemoryMap::%s process_sp=0x%" PRIx64
+  "IRMemoryMap::%s process_sp=0x%" PRIxPTR
   ", process_sp->CanJIT()=%s, process_sp->IsAlive()=%s",
-  __FUNCTION__, (lldb::addr_t)process_sp.get(),
+  __FUNCTION__, reinterpret_cast(process_sp.get()),
   process_sp && process_sp->CanJIT() ? "true" : "false",
   process_sp && process_sp->IsAlive() ? "true" : "false");
 if (process_sp && process_sp->CanJIT() && process_sp->IsAlive()) {
@@ -577,9 +577,9 @@
   if (lldb_private::Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
 LLDB_LOGF(log,
-  "IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64
+  "IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIxPTR
   ", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
-  (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
+  (uint64_t)process_address, reinterpret_cast(bytes), (uint64_t)size,
   (uint64_t)allocation.m_process_start,
   (uint64_t)allocation.m_process_start +
   (uint64_t)allocation.m_size);
@@ -708,9 +708,9 @@
   if (lldb_private::Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
 LLDB_LOGF(log,
-  "IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIx64
+  "IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIxPTR
   ", 0x%" PRId64 ") came from [0x%" PRIx64 "..0x%" PRIx64 ")",
-  (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
+  (uint64_t)process_address, reinterpret_cast(bytes), (uint64_t)size,
   (uint64_t)allocation.m_process_start,
   (uint64_t)allocation.m_process_start +
   

[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 6 inline comments as done.
jankratochvil added inline comments.



Comment at: lldb/source/Core/PluginManager.cpp:89
 template  static FPtrTy CastToFPtr(void *VPtr) {
-  return reinterpret_cast(reinterpret_cast(VPtr));
+  return reinterpret_cast(VPtr);
 }

The source is a `void *` and destination is `bool (*PluginInitCallback)()` so 
there is no intermediate integer cast needed: [[ 
https://stackoverflow.com/a/2613393/2995591 | Casting pointer to object to void 
* in C++ ]]
It was caught by D71707 as `intptr_t` is dangerous.




Comment at: lldb/source/Expression/IRExecutionUnit.cpp:351-352
+m_jitted_functions.push_back(
+JittedFunction(function.getName().str().c_str(), external,
+   (lldb::addr_t)(uintptr_t)fun_ptr));
   }

clayborg wrote:
> This can probably just be:
> 
> ```
>  JittedFunction(function.getName().str().c_str(), external, 
> (uintptr_t)fun_ptr));
> ```
> since this is a function call and "fun_ptr" will be correctly converted to a 
> lldb::addr_t
Used `reinterpret_cast` instead of a C cast:
```
warning: C-style casts are discouraged; use 
static_cast/const_cast/reinterpret_cast [google-readability-casting]
```




Comment at: lldb/source/Host/common/HostInfoBase.cpp:250
+  reinterpret_cast(
+  HostInfoBase::ComputeSharedLibraryDirectory)));
 

The source is a `static bool ComputeSharedLibraryDirectory(FileSpec 
_spec);` and destination is `void *` so there is no intermediate integer 
cast needed: [[ https://stackoverflow.com/a/2613393/2995591 | Casting pointer 
to object to void * in C++ ]]
It was caught by D71707 as `intptr_t` is dangerous.




Comment at: lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp:358
   ConstantInt::get(llvm::Type::getInt64Ty(m_module->getContext()),
-   reinterpret_cast(result_decl), false);
+   reinterpret_cast(result_decl), false);
 

The source is a `clang::NamedDecl *result_decl` and destination is `uint64_t V`.




Comment at: lldb/source/Plugins/Process/POSIX/CrashReason.cpp:141
+ reinterpret_cast(info.si_upper),
+ reinterpret_cast(info.si_addr));
 return str;

Destination is always `lldb::addr_t`.




Comment at: lldb/source/Plugins/Process/POSIX/CrashReason.cpp:147
   return GetCrashReasonString(reason,
-  reinterpret_cast(info.si_addr));
+  reinterpret_cast(info.si_addr));
 }

Destination is `lldb::addr_t`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71498



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


[Lldb-commits] [PATCH] D71722: Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot

2019-12-21 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG44b4b833ad76: Rename DW_AT_LLVM_isysroot to 
DW_AT_LLVM_sysroot (authored by aprantl).
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71722

Files:
  clang/test/Modules/debug-info-moduleimport.m
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Assembler/dimodule.ll
  llvm/test/CodeGen/X86/load-combine-dbg.ll
  llvm/test/DebugInfo/X86/DIModule.ll
  llvm/test/DebugInfo/X86/DIModuleContext.ll
  llvm/test/DebugInfo/X86/clang-module.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -2059,7 +2059,7 @@
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(ConfigMacro, N->getConfigurationMacros());
   EXPECT_EQ(Includes, N->getIncludePath());
-  EXPECT_EQ(Sysroot, N->getISysRoot());
+  EXPECT_EQ(Sysroot, N->getSysRoot());
   EXPECT_EQ(N, DIModule::get(Context, Scope, Name,
  ConfigMacro, Includes, Sysroot));
   EXPECT_NE(N, DIModule::get(Context, getFile(), Name,
Index: llvm/test/DebugInfo/X86/clang-module.ll
===
--- llvm/test/DebugInfo/X86/clang-module.ll
+++ llvm/test/DebugInfo/X86/clang-module.ll
@@ -24,7 +24,7 @@
 !1 = !DIFile(filename: "modules.m", directory: "/")
 !3 = !{!4}
 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, line: 122)
-!5 = !DIModule(scope: null, name: "Foo", includePath: ".", isysroot: "/")
+!5 = !DIModule(scope: null, name: "Foo", includePath: ".", sysroot: "/")
 !6 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !7, producer: "clang version 5.0.0 (trunk 308357) (llvm/trunk 308379)", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "/Foo.pcm", emissionKind: FullDebug, dwoId: 1234)
 !7 = !DIFile(filename: "Foo", directory: ".")
 !15 = !{i32 2, !"Dwarf Version", i32 4}
Index: llvm/test/DebugInfo/X86/DIModuleContext.ll
===
--- llvm/test/DebugInfo/X86/DIModuleContext.ll
+++ llvm/test/DebugInfo/X86/DIModuleContext.ll
@@ -25,7 +25,7 @@
 !5 = !{!0}
 !6 = !{!7}
 !7 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !8, file: !3, line: 11)
-!8 = !DIModule(scope: null, name: "Module", includePath: ".", isysroot: "/")
+!8 = !DIModule(scope: null, name: "Module", includePath: ".", sysroot: "/")
 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, align: 64)
 !10 = !DICompositeType(tag: DW_TAG_structure_type, name: "s", scope: !8, file: !3, line: 1, flags: DIFlagFwdDecl)
 !11 = !{i32 2, !"Dwarf Version", i32 2}
Index: llvm/test/DebugInfo/X86/DIModule.ll
===
--- llvm/test/DebugInfo/X86/DIModule.ll
+++ llvm/test/DebugInfo/X86/DIModule.ll
@@ -6,7 +6,7 @@
 ; CHECK-NEXT: DW_AT_name {{.*}}"DebugModule"
 ; CHECK-NEXT: DW_AT_LLVM_config_macros {{.*}}"-DMODULES=0"
 ; CHECK-NEXT: DW_AT_LLVM_include_path {{.*}}"/llvm/tools/clang/test/Modules/Inputs"
-; CHECK-NEXT: DW_AT_LLVM_isysroot {{.*}}"/"
+; CHECK-NEXT: DW_AT_LLVM_sysroot {{.*}}"/"
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx"
@@ -20,7 +20,7 @@
 !2 = !{}
 !3 = !{!4}
 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, file: !1, line: 5)
-!5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", isysroot: "/")
+!5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", sysroot: "/")
 !6 = !{i32 2, !"Dwarf Version", i32 4}
 !7 = !{i32 2, !"Debug Info Version", i32 3}
 !8 = !{!"LLVM version 3.7.0"}
Index: llvm/test/CodeGen/X86/load-combine-dbg.ll
===
--- llvm/test/CodeGen/X86/load-combine-dbg.ll
+++ llvm/test/CodeGen/X86/load-combine-dbg.ll
@@ -25,7 +25,7 @@
 
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !3, isOptimized: false, emissionKind: FullDebug)
-!2 = !DIModule(scope: null, name: "test", includePath: "", isysroot: "/")
+!2 = !DIModule(scope: null, name: "test", 

[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
jankratochvil marked an inline comment as done.
Closed by commit rGdf6879ec0227: [lldb] Fix ARM32 inferior calls (authored by 
jankratochvil).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71498

Files:
  lldb/source/Core/PluginManager.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Expression/IRMemoryMap.cpp
  lldb/source/Host/common/HostInfoBase.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/source/Plugins/Process/POSIX/CrashReason.cpp

Index: lldb/source/Plugins/Process/POSIX/CrashReason.cpp
===
--- lldb/source/Plugins/Process/POSIX/CrashReason.cpp
+++ lldb/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -136,15 +136,15 @@
 #if defined(si_lower) && defined(si_upper)
   if (reason == CrashReason::eBoundViolation) {
 str = "signal SIGSEGV";
-AppendBounds(str, reinterpret_cast(info.si_lower),
- reinterpret_cast(info.si_upper),
- reinterpret_cast(info.si_addr));
+AppendBounds(str, reinterpret_cast(info.si_lower),
+ reinterpret_cast(info.si_upper),
+ reinterpret_cast(info.si_addr));
 return str;
   }
 #endif
 
   return GetCrashReasonString(reason,
-  reinterpret_cast(info.si_addr));
+  reinterpret_cast(info.si_addr));
 }
 
 std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
Index: lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -355,7 +355,7 @@
 
   ConstantInt *new_constant_int =
   ConstantInt::get(llvm::Type::getInt64Ty(m_module->getContext()),
-   reinterpret_cast(result_decl), false);
+   reinterpret_cast(result_decl), false);
 
   llvm::Metadata *values[2];
   values[0] = ConstantAsMetadata::get(new_result_global);
Index: lldb/source/Host/common/HostInfoBase.cpp
===
--- lldb/source/Host/common/HostInfoBase.cpp
+++ lldb/source/Host/common/HostInfoBase.cpp
@@ -246,8 +246,8 @@
   // On other posix systems, we will get .../lib(64|32)?/liblldb.so.
 
   FileSpec lldb_file_spec(Host::GetModuleFileSpecForHostAddress(
-  reinterpret_cast(reinterpret_cast(
-  HostInfoBase::ComputeSharedLibraryDirectory;
+  reinterpret_cast(
+  HostInfoBase::ComputeSharedLibraryDirectory)));
 
   // This is necessary because when running the testsuite the shlib might be a
   // symbolic link inside the Python resource dir.
Index: lldb/source/Expression/IRMemoryMap.cpp
===
--- lldb/source/Expression/IRMemoryMap.cpp
+++ lldb/source/Expression/IRMemoryMap.cpp
@@ -328,9 +328,9 @@
   case eAllocationPolicyMirror:
 process_sp = m_process_wp.lock();
 LLDB_LOGF(log,
-  "IRMemoryMap::%s process_sp=0x%" PRIx64
+  "IRMemoryMap::%s process_sp=0x%" PRIxPTR
   ", process_sp->CanJIT()=%s, process_sp->IsAlive()=%s",
-  __FUNCTION__, (lldb::addr_t)process_sp.get(),
+  __FUNCTION__, reinterpret_cast(process_sp.get()),
   process_sp && process_sp->CanJIT() ? "true" : "false",
   process_sp && process_sp->IsAlive() ? "true" : "false");
 if (process_sp && process_sp->CanJIT() && process_sp->IsAlive()) {
@@ -577,9 +577,9 @@
   if (lldb_private::Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
 LLDB_LOGF(log,
-  "IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64
+  "IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIxPTR
   ", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
-  (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
+  (uint64_t)process_address, reinterpret_cast(bytes), (uint64_t)size,
   (uint64_t)allocation.m_process_start,
   (uint64_t)allocation.m_process_start +
   (uint64_t)allocation.m_size);
@@ -708,9 +708,9 @@
   if (lldb_private::Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
 LLDB_LOGF(log,
-  "IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIx64
+  "IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIxPTR
   ", 0x%" PRId64 ") came from [0x%" PRIx64 "..0x%" PRIx64 ")",
-  (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
+  (uint64_t)process_address, reinterpret_cast(bytes), (uint64_t)size,
   (uint64_t)allocation.m_process_start,

[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 2 inline comments as done.
jankratochvil added inline comments.



Comment at: lldb/source/Host/common/HostInfoBase.cpp:250
+  reinterpret_cast(
+  HostInfoBase::ComputeSharedLibraryDirectory)));
 

labath wrote:
> jankratochvil wrote:
> > The source is a `static bool ComputeSharedLibraryDirectory(FileSpec 
> > _spec);` and destination is `void *` so there is no intermediate 
> > integer cast needed: [[ https://stackoverflow.com/a/2613393/2995591 | 
> > Casting pointer to object to void * in C++ ]]
> > It was caught by D71707 as `intptr_t` is dangerous.
> > 
> I seem to recall some compilers complaining (though still accepting) about 
> code which casts function pointers to void*, with this being the only 
> available workaround. However, I can't reproduce this now, so I guess this 
> could be fine..
I had to study it myself now as I also remembered something like that. It is 
valid complaint for plain C: https://stackoverflow.com/a/12359083/2995591
But it does not apply ("conditionally") for C++: 
https://stackoverflow.com/a/12360610/2995591
And it is valid for C++ of: clang-8.0.0-3.fc30.x86_64 && gcc-9.2.1-1.fc30.x86_64
So I would think for C++ it is OK now without the (u)intptr_ intermediate cast.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71498



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


[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D71498#1785458 , @labath wrote:

> In other places you're replacing a reinterpret_cast with two c casts.


`reinterpret_cast` and a `(c cast)` have the same behavior and as `c cast` is 
shorter I did prefer it.  But I see `clang-tidy` prefers `reinterpret_cast`:

  warning: C-style casts are discouraged; use 
static_cast/const_cast/reinterpret_cast [google-readability-casting]



> In these cases the second cast is not really needed, as uintptr_t->addr_t 
> should convert automatically.

Yes.

> Then our rule can be "always convert a pointer to uintptr_t". I don't know if 
> there's a clang-tidy check for that, but it sounds like that could be 
> something which could be checked/enforced there...

Yes, I have now written such clang-tidy extension as D71707 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71498



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


[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Thanks for tracking these down!




Comment at: lldb/source/Expression/IRMemoryMap.cpp:577-586
   if (lldb_private::Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
 LLDB_LOGF(log,
   "IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64
   ", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
-  (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
-  (uint64_t)allocation.m_process_start,
+  (uint64_t)process_address, (uint64_t)(uintptr_t)bytes,
+  (uint64_t)size, (uint64_t)allocation.m_process_start,

jankratochvil wrote:
> labath wrote:
> > This could be something 
> > `LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS), "({0:x}, 
> > {1:x}, {2:x}) went to [{3:x}, {4:x})", process_address, bytes, 
> > allocation.m_process_start, allocation.m_process_start + allocation.m_size)`
> I haven't changed the log function, that could be a different patch, that 
> goes too far IMO.
PRIxPTR is fine too, though I wouldn't really consider changing the log method 
as "going too far". I tend to do that for all non-trivial modifications to log 
statements that I make...



Comment at: lldb/source/Host/common/HostInfoBase.cpp:250
+  reinterpret_cast(
+  HostInfoBase::ComputeSharedLibraryDirectory)));
 

jankratochvil wrote:
> The source is a `static bool ComputeSharedLibraryDirectory(FileSpec 
> _spec);` and destination is `void *` so there is no intermediate integer 
> cast needed: [[ https://stackoverflow.com/a/2613393/2995591 | Casting pointer 
> to object to void * in C++ ]]
> It was caught by D71707 as `intptr_t` is dangerous.
> 
I seem to recall some compilers complaining (though still accepting) about code 
which casts function pointers to void*, with this being the only available 
workaround. However, I can't reproduce this now, so I guess this could be fine..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71498



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


[Lldb-commits] [PATCH] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4706a60e8a07: [lldb] [testsuite] Fix Linux fail: 
Unwind/thread-step-out-ret-addr-check.test (authored by jankratochvil).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71784

Files:
  lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
  lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -1,7 +1,7 @@
 # Test that `thread step-out` fails when the "return address"
 # points to non-executable memory.
 
-# REQUIRES: target-x86_64, system-darwin
+# REQUIRES: target-x86_64
 
 # RUN: %clang_host %p/Inputs/call-asm.c 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -4,13 +4,13 @@
 sub $0x8, %rsp
 movq $0, (%rsp)
 push %rsp
-jmp _nonstandard_stub
+jmp nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
-_nonstandard_stub:
+nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi
 add $1, %rsi
@@ -18,3 +18,7 @@
 
 add $0x10, %rsp
 ret
+
+#ifdef __linux__
+.section .note.GNU-stack,"",@progbits
+#endif


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -1,7 +1,7 @@
 # Test that `thread step-out` fails when the "return address"
 # points to non-executable memory.
 
-# REQUIRES: target-x86_64, system-darwin
+# REQUIRES: target-x86_64
 
 # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -4,13 +4,13 @@
 sub $0x8, %rsp
 movq $0, (%rsp)
 push %rsp
-jmp _nonstandard_stub
+jmp nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
-_nonstandard_stub:
+nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi
 add $1, %rsi
@@ -18,3 +18,7 @@
 
 add $0x10, %rsp
 ret
+
+#ifdef __linux__
+.section .note.GNU-stack,"",@progbits
+#endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1805d1f - [lldb] Fix -Wstringop-truncation in PythonReadline.cpp

2019-12-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-21T11:35:26+01:00
New Revision: 1805d1f87d7835b237f85bfb0595d1f411ebf1bf

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

LOG: [lldb] Fix -Wstringop-truncation in PythonReadline.cpp

The size is known and the truncation is deliberate -- use memcpy instead
of strncpy.

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
index 674ec9b6140a..5f6429f5cd0e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
@@ -67,7 +67,7 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt)
   char *ret = (char *)PyMem_Malloc(n + 2);
 #endif
   if (ret) {
-strncpy(ret, line, n);
+memcpy(ret, line, n);
 free(line);
 ret[n] = '\n';
 ret[n + 1] = '\0';



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


[Lldb-commits] [lldb] 4706a60 - [lldb] [testsuite] Fix Linux fail: Unwind/thread-step-out-ret-addr-check.test

2019-12-21 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2019-12-21T11:27:54+01:00
New Revision: 4706a60e8a071f0c6a686c45ed08c7bab0bb8446

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

LOG: [lldb] [testsuite] Fix Linux fail: 
Unwind/thread-step-out-ret-addr-check.test

D71372 introduced: `Unwind/thread-step-out-ret-addr-check.test` failing on
Fedora 30 Linux x86_64.
  [lldb] Add additional validation on return address in 'thread step-out'
  https://reviews.llvm.org/D71372

One problem is the underscored `_nonstandard_stub` in the `.s` file but not in
the LLDB command:
  (lldb) breakpoint set -n nonstandard_stub
  Breakpoint 1: no locations (pending).
  WARNING:  Unable to resolve breakpoint to any actual locations.
  (lldb) process launch
  Process 21919 exited with status = 0 (0x)
  Process 21919 launched: 
'/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/test/Unwind/Output/thread-step-out-ret-addr-check.test.tmp'
 (x86_64)
  (lldb) thread step-out
  error: invalid thread
  (lldb) _

Another problem is that Fedora Linux has executable stack by default and all
programs indicate non-executable stack by `PT_GNU_STACK`, after fixing the
underscore I was getting:
  (lldb) thread step-out
  Process 22294 exited with status = 0 (0x)
  (lldb) _

A different approach was tried as:
  [lldb] Refactor thread-step-out-ret-addr-check test to use .data instead of 
stack variable
  https://reviews.llvm.org/D71789

Differential revision: https://reviews.llvm.org/D71784

Added: 


Modified: 
lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s 
b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
index d18ea24fba4d..2fb4935b38bb 100644
--- a/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -4,13 +4,13 @@ asm_main:
 sub $0x8, %rsp
 movq $0, (%rsp)
 push %rsp
-jmp _nonstandard_stub
+jmp nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
-_nonstandard_stub:
+nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi
 add $1, %rsi
@@ -18,3 +18,7 @@ _nonstandard_stub:
 
 add $0x10, %rsp
 ret
+
+#ifdef __linux__
+.section .note.GNU-stack,"",@progbits
+#endif

diff  --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index 53436cd55af1..ec73bd808c24 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -1,7 +1,7 @@
 # Test that `thread step-out` fails when the "return address"
 # points to non-executable memory.
 
-# REQUIRES: target-x86_64, system-darwin
+# REQUIRES: target-x86_64
 
 # RUN: %clang_host %p/Inputs/call-asm.c 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s



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


[Lldb-commits] [PATCH] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I didn't check this patch exactly, but I tried something very similar 
investigating this patch yesterday, so I think this should be fine. You should 
be able to see any darwin failures here: 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71784



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


[Lldb-commits] [PATCH] D71235: [lldb/Lua] Generate Lua Bindings and Make Them Available to the Script Interpreter

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

This looks fine. Things will start to get interesting once you start wanting to 
access the current session from inside the lua script (not just creating a new 
one),,


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

https://reviews.llvm.org/D71235



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


[Lldb-commits] [PATCH] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Thanks for the review but is it tested on Darwin? I do not have any.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71784



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


[Lldb-commits] [PATCH] D71770: [lldb] Don't process symlinks deep inside DWARFUnit

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D71770#1793334 , @aprantl wrote:

> Does the mean these mappings will show up in the settings command?


No, these won't show up in the target.source-map setting because this is 
setting the "per-module" mapping list, and not the global target map. I don't 
thing we actually have a mechanism to display the per-module maps...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71770



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


[Lldb-commits] [PATCH] D71789: [lldb] Refactor thread-step-out-ret-addr-check test to use .data instead of stack variable

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil requested changes to this revision.
jankratochvil added a comment.
This revision now requires changes to proceed.

My testing matches the @labath's one. I have updated D71784 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71789



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


[Lldb-commits] [PATCH] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 235009.
jankratochvil added a comment.
Herald added a subscriber: krytarowski.

Addressed the review and D71789  and enabled 
it for Linux again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71784

Files:
  lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
  lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -1,7 +1,7 @@
 # Test that `thread step-out` fails when the "return address"
 # points to non-executable memory.
 
-# REQUIRES: target-x86_64, system-darwin
+# REQUIRES: target-x86_64
 
 # RUN: %clang_host %p/Inputs/call-asm.c 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -4,13 +4,13 @@
 sub $0x8, %rsp
 movq $0, (%rsp)
 push %rsp
-jmp _nonstandard_stub
+jmp nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
-_nonstandard_stub:
+nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi
 add $1, %rsi
@@ -18,3 +18,7 @@
 
 add $0x10, %rsp
 ret
+
+#ifdef __linux__
+.section .note.GNU-stack,"",@progbits
+#endif


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -1,7 +1,7 @@
 # Test that `thread step-out` fails when the "return address"
 # points to non-executable memory.
 
-# REQUIRES: target-x86_64, system-darwin
+# REQUIRES: target-x86_64
 
 # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -4,13 +4,13 @@
 sub $0x8, %rsp
 movq $0, (%rsp)
 push %rsp
-jmp _nonstandard_stub
+jmp nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
-_nonstandard_stub:
+nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi
 add $1, %rsi
@@ -18,3 +18,7 @@
 
 add $0x10, %rsp
 ret
+
+#ifdef __linux__
+.section .note.GNU-stack,"",@progbits
+#endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

As I said on the other patch, this is probably a simpler approach (assuming we 
can't find a way to make the data section non-executable in a generic way). 
You'll need to add an `#ifdef` for the section directive though...




Comment at: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s:13
 # memory check.
+nonstandard_stub:
 _nonstandard_stub:

mossberg wrote:
> Maybe we can just remove the underscore version, and simply use 
> `nonstandard_stub` if it will work everywhere?
Yes, I'm pretty sure that would work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71784



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


[Lldb-commits] [PATCH] D71789: [lldb] Refactor thread-step-out-ret-addr-check test to use .data instead of stack variable

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added subscribers: MaskRay, krytarowski.
labath added a comment.

I don't really understand what's going on, but it seems that the lack of the 
`.note.GNU-stack` section causes the data section to be executable too (at 
least on my machine, anyway). Which means that using the data address will not 
help. :( I'm cc'ing some people who know more about dynamic linkers to see if 
anyone can explain this behavior...

One sure way to get a non-executable memory address would be to allocate 
something on the heap (in the C file), but I think @jankratochvil's approach of 
adding the .note.GNU-stack is simpler, and so far it seems that it works 
everywhere. The section directive will trip up the non-linux assemblers though, 
so it needs to be `#ifdef __linux__` (afaict `#ifdefs` work just fine in asm 
files when invoking the processing through clang)...




Comment at: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s:18
 
 add $0x10, %rsp
 ret

This should be 0x08, or you'll should push one more value to stack in asm_main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71789



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


[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

A bunch more comments from me. :)

A higher level question I have is whether there's something suitable within 
llvm for parsing wasm object files that could be reused. I know this can be 
tricky with files loaded from memory etc., so it's fine if it isn't possible to 
do that, but I am wondering if you have considered this option...




Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:35-38
+  llvm::StringRef magic(reinterpret_cast(data_sp->GetBytes()), 
4);
+  if (magic != llvm::StringRef(llvm::wasm::WasmMagic,
+   sizeof(llvm::wasm::WasmMagic) / sizeof(char)))
+return false;

`if (llvm::identify_magic(toStringRef(data_sp->GetData())) != 
llvm::file_magic::wasm_object)` maybe ?



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:40
+
+  const uint32_t *version = reinterpret_cast(
+  data_sp->GetBytes() + sizeof(llvm::wasm::WasmMagic));

labath wrote:
> This looks like it will cause problems on big endian hosts..
One way to get around that would be to use something like 
`llvm::support::read32le`.



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:46-63
+llvm::Optional GetVaruint7(DataExtractor _header_data,
+lldb::offset_t *offset_ptr) {
+  lldb::offset_t initial_offset = *offset_ptr;
+  uint64_t value = section_header_data.GetULEB128(offset_ptr);
+  if (*offset_ptr == initial_offset || value > 127)
+return llvm::None;
+  return static_cast(value);

Maybe merge these and make the maximum width a function argument?



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:192
+
+ConstString sect_name(reinterpret_cast(name_bytes),
+  *name_len);

I'd just use StringRef here -- there's no advantage in ConstStringifying this...



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:215
+  *url_len);
+  GetModule()->SetSymbolFileFileSpec(FileSpec(symbols_url));
+

This seems odd -- I don't think any of our object file plugins work this way. 
It's normally the symbol vendor who fiddles with the symbol file spec.

This is kind of similar to the gnu_debuglink section, and the way that works in 
elf is that the object file exposes this via a separate method, which the 
symbol vendor can then query and do the appropriate thing.

Maybe you could just drop this part and we can get back to it with the symbol 
vendor patch?



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:217-225
+  uint32_t section_length =
+  *payload_len - *name_len - name_len_uleb_size - url_len_uleb_size;
+  offset += section_length;
+} else {
+  uint32_t section_length = *payload_len - *name_len - name_len_uleb_size;
+  m_sect_infos.push_back(section_info{*offset_ptr + offset, section_length,
+  *section_id, sect_name});

I wouldn't be afraid of presenting `external_debug_info` as an actual section, 
if that's how it's treated byt the object file format. And it looks like that 
could simplify this code a bit...



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:342-343
+section_type,  // Section type.
+sect_info.offset & 0x, // VM address.
+sect_info.size, // VM size in bytes of this section.
+sect_info.offset &

Are the debug info sections actually loaded into memory for wasm? Should these 
be zero (that's what they are for elf)?



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:382
+
+  DecodeSections(load_address);
+

This is strange.. I wouldn't expect that the section decoding logic should 
depend on the actual address that the object is loaded in memory. Can you 
explain the reasoning here?



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:395
+if (target.GetSectionLoadList().SetSectionLoadAddress(
+section_sp, load_address | section_sp->GetFileOffset())) {
+  ++num_loaded_sections;

Normally I would expect to see `->GetFileAddress()` here, as that's the thing 
which says how the sections are laid out in memory. The way you create these 
sections, the two values are the same, but it still seems more correct to call 
GetFileAddress()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71575



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

[Lldb-commits] [PATCH] D63540: Fix lookup of symbols with the same address range but different binding

2019-12-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thank you very much Omair. This is very useful information, and it does explain 
a few thing (while raising other questions). The thing that would help now is 
seeing the difference in the symbols and their properties in the area around 
the mmap function. Comparing the output of "image dump symtab lib.so" before 
and after the change could provide interesting clues.

Another thing which I'd be interested in seeing is the gdb-remote packet log. 
From the existing logs, it's clear that the mmap call does not complete due to 
a signal. However, observing how lldb actually sets up the call could tell us a 
lot about what went wrong (my current bet is on confusing the arm/thumb 
instruction set).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63540



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