[Lldb-commits] [PATCH] D61565: Ignore generated @import statements in the expression evaluator to fix import-std-module tests on macOS

2019-05-05 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: aprantl, shafik.
teemperor added a project: C++ modules in LLDB.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The ClangModulesDeclVendor is currently interpreting all injected `@import` 
statements in our expression
wrapper as modules that the user has explicitly requested to be persistently 
loaded. As we inject
`@import` statements with our std module prototype, the ClangModulesDeclVendor 
will start compiling
and loading unrelated C++ modules because it thinks the user has requested that 
it should load them. As
the ClangModulesDeclVendor is lacking the setup to compile these modules (e.g. 
it lacks the include paths),
it will then actually just fail to compile them and cause the whole expression 
evaluation to fail. This causes
these tests to fail on systems that enable the ClangModulesDeclVendor (such as 
macOS).

This patch fixes this by preventing the ClangModulesDeclVendor from 
interpreting `@import` statements
in the wrapper source code. This is done by defining a macro directly before 
the actual user expression and
letting the preprocessor callbacks ignore import statements until we hit that 
macro.

This patch also enables most of the `import-std-module/` tests to make sure 
this patch is working as
intended. I didn't enable the sysroot test here as it still fails (due to 
another issue which will be a separate patch).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D61565

Files:
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/basic/TestImportStdModule.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/conflicts/TestStdModuleWithConflicts.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-basic/TestBasicDeque.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-basic/TestBasicForwardList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-basic/TestBasicList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-dbg-info-content/TestDbgInfoContentList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/no-std-module/TestMissingStdModule.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/queue/TestQueue.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContent.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr/TestSharedPtr.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/stack/TestStack.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr/TestUniquePtr.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-basic/TestBasicVector.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-bool/TestBoolVector.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-dbg-info-content/TestDbgInfoContentVector.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-of-vectors/TestVectorOfVectors.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtr.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/weak_ptr/TestWeakPtr.py
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
@@ -60,6 +60,11 @@
 lldb::LanguageType wrapping_language,
 size_t &start_loc, size_t &end_loc);
 
+  /// Returns the name of the macro that we placed directly before the
+  /// user expression in the source code. Used to signal the parser that it
+  /// is has started to parse the actual user expression.
+  static const char *GetExprStartMacroName() { return "__LLDB_EXPR_START"; }
+
 protected:
   ClangExpressionSourceCode(const char *name, const char *prefix, const char *body,

[Lldb-commits] [lldb] r359977 - [lldb] [lit] Fix more filename mismatches in Register tests

2019-05-05 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Sun May  5 05:06:22 2019
New Revision: 359977

URL: http://llvm.org/viewvc/llvm-project?rev=359977&view=rev
Log:
[lldb] [lit] Fix more filename mismatches in Register tests

Modified:
lldb/trunk/lit/Register/x86-gp-write.test
lldb/trunk/lit/Register/x86-ymm-write.test

Modified: lldb/trunk/lit/Register/x86-gp-write.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Register/x86-gp-write.test?rev=359977&r1=359976&r2=359977&view=diff
==
--- lldb/trunk/lit/Register/x86-gp-write.test (original)
+++ lldb/trunk/lit/Register/x86-gp-write.test Sun May  5 05:06:22 2019
@@ -1,6 +1,6 @@
 # XFAIL: system-windows
 # REQUIRES: native && target-x86
-# RUN: %clangxx -fomit-frame-pointer %p/Inputs/x86-64-gp-read.cpp -o %t
+# RUN: %clangxx -fomit-frame-pointer %p/Inputs/x86-gp-write.cpp -o %t
 # RUN: %lldb -b -s %s %t | FileCheck %s
 process launch
 

Modified: lldb/trunk/lit/Register/x86-ymm-write.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Register/x86-ymm-write.test?rev=359977&r1=359976&r2=359977&view=diff
==
--- lldb/trunk/lit/Register/x86-ymm-write.test (original)
+++ lldb/trunk/lit/Register/x86-ymm-write.test Sun May  5 05:06:22 2019
@@ -1,6 +1,6 @@
 # XFAIL: system-windows
 # REQUIRES: native && target-x86 && native-cpu-avx
-# RUN: %clangxx %p/Inputs/x86-ymm-read.cpp -o %t
+# RUN: %clangxx %p/Inputs/x86-ymm-write.cpp -o %t
 # RUN: %lldb -b -s %s %t | FileCheck %s
 process launch
 


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


[Lldb-commits] [lldb] r359978 - [lldb] [lit] Simplify general-purpose register tests

2019-05-05 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Sun May  5 05:06:32 2019
New Revision: 359978

URL: http://llvm.org/viewvc/llvm-project?rev=359978&view=rev
Log:
[lldb] [lit] Simplify general-purpose register tests

Use output constraints for specific general-purpose registers in order
to simplify the tests.  They save us from having to manually put
the values in correct registers, and reduce the number of registers
needed as a result.

Modified:
lldb/trunk/lit/Register/Inputs/x86-64-gp-read.cpp
lldb/trunk/lit/Register/Inputs/x86-64-gp-write.cpp
lldb/trunk/lit/Register/Inputs/x86-gp-read.cpp
lldb/trunk/lit/Register/Inputs/x86-gp-write.cpp

Modified: lldb/trunk/lit/Register/Inputs/x86-64-gp-read.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Register/Inputs/x86-64-gp-read.cpp?rev=359978&r1=359977&r2=359978&view=diff
==
--- lldb/trunk/lit/Register/Inputs/x86-64-gp-read.cpp (original)
+++ lldb/trunk/lit/Register/Inputs/x86-64-gp-read.cpp Sun May  5 05:06:32 2019
@@ -15,14 +15,8 @@ int main() {
 "movq%%rsp, %%r8\n\t"
 "movq%%rbp, %%r9\n\t"
 "\n\t"
-"movq%0, %%rax\n\t"
-"movq%1, %%rbx\n\t"
-"movq%2, %%rcx\n\t"
-"movq%3, %%rdx\n\t"
 "movq%4, %%rsp\n\t"
 "movq%5, %%rbp\n\t"
-"movq%6, %%rsi\n\t"
-"movq%7, %%rdi\n\t"
 "\n\t"
 "int3\n\t"
 "\n\t"
@@ -30,10 +24,9 @@ int main() {
 "movq%%r8, %%rsp\n\t"
 "movq%%r9, %%rbp"
 :
-: "i"(rax), "i"(rbx), "i"(rcx), "i"(rdx), "i"(rsp), "i"(rbp), "i"(rsi),
-  "i"(rdi)
-: "%rax", "%rbx", "%rcx", "%rdx", "%rsp", "%rbp", "%rsi", "%rdi", "%r8",
-  "%r9"
+: "a"(rax), "b"(rbx), "c"(rcx), "d"(rdx), "i"(rsp), "i"(rbp), "S"(rsi),
+  "D"(rdi)
+: "%r8", "%r9"
   );
 
   return 0;

Modified: lldb/trunk/lit/Register/Inputs/x86-64-gp-write.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Register/Inputs/x86-64-gp-write.cpp?rev=359978&r1=359977&r2=359978&view=diff
==
--- lldb/trunk/lit/Register/Inputs/x86-64-gp-write.cpp (original)
+++ lldb/trunk/lit/Register/Inputs/x86-64-gp-write.cpp Sun May  5 05:06:32 2019
@@ -9,8 +9,8 @@ int main() {
 
   asm volatile(
 // save rsp & rbp
-"movq%%rsp, %%mm0\n\t"
-"movq%%rbp, %%mm1\n\t"
+"movq%%rsp, %4\n\t"
+"movq%%rbp, %5\n\t"
 "\n\t"
 "movq%8, %%rax\n\t"
 "movq%8, %%rbx\n\t"
@@ -23,23 +23,13 @@ int main() {
 "\n\t"
 "int3\n\t"
 "\n\t"
-"movq%%rax, %0\n\t"
-"movq%%rbx, %1\n\t"
-"movq%%rcx, %2\n\t"
-"movq%%rdx, %3\n\t"
-"movq%%rsp, %4\n\t"
-"movq%%rbp, %5\n\t"
-"movq%%rsi, %6\n\t"
-"movq%%rdi, %7\n\t"
-"\n\t"
-// restore rsp & rbp
-"movq%%mm0, %%rsp\n\t"
-"movq%%mm1, %%rbp\n\t"
-: "=r"(rax), "=r"(rbx), "=r"(rcx), "=r"(rdx), "=r"(rsp), "=r"(rbp),
-  "=r"(rsi), "=r"(rdi)
+// swap saved & current rsp & rbp
+"xchgq%%rsp, %4\n\t"
+"xchgq%%rbp, %5\n\t"
+: "=a"(rax), "=b"(rbx), "=c"(rcx), "=d"(rdx), "=r"(rsp), "=r"(rbp),
+  "=S"(rsi), "=D"(rdi)
 : "g"(fill)
-: "%rax", "%rbx", "%rcx", "%rdx", "%rsp", "%rbp", "%rsi", "%rdi", "%mm0",
-  "%mm1"
+:
   );
 
   printf("rax = 0x%016" PRIx64 "\n", rax);

Modified: lldb/trunk/lit/Register/Inputs/x86-gp-read.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Register/Inputs/x86-gp-read.cpp?rev=359978&r1=359977&r2=359978&view=diff
==
--- lldb/trunk/lit/Register/Inputs/x86-gp-read.cpp (original)
+++ lldb/trunk/lit/Register/Inputs/x86-gp-read.cpp Sun May  5 05:06:32 2019
@@ -15,14 +15,8 @@ int main() {
 "movd%%esp, %%mm0\n\t"
 "movd%%ebp, %%mm1\n\t"
 "\n\t"
-"movl%0, %%eax\n\t"
-"movl%1, %%ebx\n\t"
-"movl%2, %%ecx\n\t"
-"movl%3, %%edx\n\t"
 "movl%4, %%esp\n\t"
 "movl%5, %%ebp\n\t"
-"movl%6, %%esi\n\t"
-"movl%7, %%edi\n\t"
 "\n\t"
 "int3\n\t"
 "\n\t"
@@ -30,10 +24,9 @@ int main() {
 "movd%%mm0, %%esp\n\t"
 "movd%%mm1, %%ebp\n\t"
 :
-: "i"(eax), "i"(ebx), "i"(ecx), "i"(edx), "i"(esp), "i"(ebp), "i"(esi),
-  "i"(edi)
-: "%eax", "%ebx", "%ecx", "%edx", "%esp", "%ebp", "%esi", "%edi", "%mm0",
-  "%mm1"
+: "a"(eax), "b"(ebx), "c"(ecx), "d"(edx), "i"(esp), "i"(ebp), "S"(esi),
+  "D"(edi)
+: "%mm0", "%mm1"
   );
 
   return 0;

Modified: lldb/trunk/lit/Register/Inputs/x86-gp-write.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Register/Inputs/x86-gp-write.cpp?rev=359978&r1=359977&r2=359978&view=diff
==
--- lldb/trunk/lit/Register/Inputs/x86-gp-write.cpp (original)
+++ lldb/trunk/lit/Register/Inputs/x86-gp-write.cpp

[Lldb-commits] [PATCH] D61543: Initialization: move InstructionEmulation to full initialization

2019-05-05 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

This looks much better, though I'd just change one tiny thing: in the macro 
"canonicalization" step, I'd define a custom macro, instead of reusing one of 
the system ones (`_M_ARM` and friends), as those are reserved identifiers and 
it's bad for your karma to define those.

It might also be nice to make the linking of the relevant plugins conditional 
in the cmake files, but judging by a quick search, there isn't a very straight 
forward way to do that (CMAKE_SYSTEM_PROCESSOR would be variable to look at, 
but it's values aren't very standardized).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D61543



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


[Lldb-commits] [lldb] r359992 - [test] Remove randomness

2019-05-05 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Sun May  5 11:54:16 2019
New Revision: 359992

URL: http://llvm.org/viewvc/llvm-project?rev=359992&view=rev
Log:
[test] Remove randomness

This particular test fails once every so many runs on GreenDragon. Given
that the randomness in the inferior isn't critical to the test, I
removed it in the hopes that it is the cause of the flakiness.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp?rev=359992&r1=359991&r2=359992&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp
 Sun May  5 11:54:16 2019
@@ -9,11 +9,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
-std::default_random_engine g_random_engine{std::random_device{}()};
-std::uniform_int_distribution<> g_distribution{0, 300};
 std::condition_variable g_condition_variable;
 std::mutex g_mutex;
 int g_count;
@@ -74,17 +71,15 @@ thread_func (uint32_t thread_index)
 uint32_t val;
 while (count++ < 15)
 {
-// random micro second sleep from zero to 3 seconds
-int usec = g_distribution(g_random_engine);
-printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, 
thread_index, usec);
-std::this_thread::sleep_for(std::chrono::microseconds{usec});
+printf ("%s (thread = %u) sleeping for 1 second...\n", __FUNCTION__, 
thread_index);
+std::this_thread::sleep_for(std::chrono::seconds(1));
 
 if (count < 7)
 val = access_pool ();
 else
 val = access_pool (true);
 
-printf ("%s (thread = %u) after usleep access_pool returns %d 
(count=%d)...\n", __FUNCTION__, thread_index, val, count);
+printf ("%s (thread = %u) after sleep access_pool returns %d 
(count=%d)...\n", __FUNCTION__, thread_index, val, count);
 }
 printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index);
 }


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


[Lldb-commits] [PATCH] D61577: [Driver] Change the way we deal with local lldbinit files.

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

Currently we have special handling for local lldbinit files in the driver. At 
the same time, we have an SB API named 
`SourceInitFileInCurrentWorkingDirectory` that does the same thing. This patch 
removes the special handling from the driver and uses the API instead. In 
addition to the obvious advantages of having one canonical way of doing things 
and removing code duplication, this change also means that the code path is the 
same for global and local lldb init files. This is important for another patch 
I have in the pipeline.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D61577

Files:
  lldb/lit/Driver/Inputs/.lldbinit
  lldb/lit/Driver/LocalLLDBInit.test
  lldb/lit/helper/toolchain.py
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/driver/Driver.h

Index: lldb/tools/driver/Driver.h
===
--- lldb/tools/driver/Driver.h
+++ lldb/tools/driver/Driver.h
@@ -47,24 +47,18 @@
 lldb::SBStream &strm);
 
   struct OptionData {
-void AddLocalLLDBInit();
 void AddInitialCommand(std::string command, CommandPlacement placement,
bool is_file, lldb::SBError &error);
 
 struct InitialCmdEntry {
   InitialCmdEntry(std::string contents, bool in_is_file,
-  bool is_cwd_lldbinit_file_read, bool in_quiet = false)
+  bool in_quiet = false)
   : contents(std::move(contents)), is_file(in_is_file),
-source_quietly(in_quiet),
-is_cwd_lldbinit_file_read(is_cwd_lldbinit_file_read) {}
+source_quietly(in_quiet) {}
 
   std::string contents;
   bool is_file;
   bool source_quietly;
-
-  /// Remember if this is reading the local lldbinit file so we can skip it
-  /// if not permitted.
-  bool is_cwd_lldbinit_file_read;
 };
 
 std::vector m_args;
Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -113,24 +113,6 @@
 
 Driver::~Driver() { g_driver = nullptr; }
 
-void Driver::OptionData::AddLocalLLDBInit() {
-  // If there is a local .lldbinit, add that to the list of things to be
-  // sourced, if the settings permit it.
-  SBFileSpec local_lldbinit(".lldbinit", true);
-  SBFileSpec homedir_dot_lldb = SBHostOS::GetUserHomeDirectory();
-  homedir_dot_lldb.AppendPathComponent(".lldbinit");
-
-  // Only read .lldbinit in the current working directory if it's not the same
-  // as the .lldbinit in the home directory (which is already being read in).
-  if (local_lldbinit.Exists() && strcmp(local_lldbinit.GetDirectory(),
-homedir_dot_lldb.GetDirectory()) != 0) {
-char path[PATH_MAX];
-local_lldbinit.GetPath(path, sizeof(path));
-InitialCmdEntry entry(path, true, true, true);
-m_after_file_commands.push_back(entry);
-  }
-}
-
 void Driver::OptionData::AddInitialCommand(std::string command,
CommandPlacement placement,
bool is_file, SBError &error) {
@@ -150,17 +132,17 @@
   if (is_file) {
 SBFileSpec file(command.c_str());
 if (file.Exists())
-  command_set->push_back(InitialCmdEntry(command, is_file, false));
+  command_set->push_back(InitialCmdEntry(command, is_file));
 else if (file.ResolveExecutableLocation()) {
   char final_path[PATH_MAX];
   file.GetPath(final_path, sizeof(final_path));
-  command_set->push_back(InitialCmdEntry(final_path, is_file, false));
+  command_set->push_back(InitialCmdEntry(final_path, is_file));
 } else
   error.SetErrorStringWithFormat(
   "file specified in --source (-s) option doesn't exist: '%s'",
   command.c_str());
   } else
-command_set->push_back(InitialCmdEntry(command, is_file, false));
+command_set->push_back(InitialCmdEntry(command, is_file));
 }
 
 void Driver::WriteCommandsForSourcing(CommandPlacement placement,
@@ -181,36 +163,6 @@
   for (const auto &command_entry : *command_set) {
 const char *command = command_entry.contents.c_str();
 if (command_entry.is_file) {
-  // If this command_entry is a file to be sourced, and it's the ./.lldbinit
-  // file (the .lldbinit
-  // file in the current working directory), only read it if
-  // target.load-cwd-lldbinit is 'true'.
-  if (command_entry.is_cwd_lldbinit_file_read) {
-SBStringList strlist = lldb::SBDebugger::GetInternalVariableValue(
-"target.load-cwd-lldbinit", m_debugger.GetInstanceName());
-if (strlist.GetSize() == 1 &&
-strcmp(strlist.GetStringAtIndex(0), "warn") == 0) {
-  FILE *output = m_debugger.GetOutputFil

[Lldb-commits] [PATCH] D61578: [Driver] Add command line option to allow loading local lldbinit file

2019-05-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: clayborg, labath, jingham.
Herald added a project: LLDB.
JDevlieghere added a parent revision: D61577: [Driver] Change the way we deal 
with local lldbinit files..

This patch adds a command line flag that allows lldb to load local lldbinit 
files.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D61578

Files:
  lldb/lit/Driver/LocalLLDBInit.test
  lldb/tools/driver/Driver.cpp
  lldb/tools/driver/Options.td


Index: lldb/tools/driver/Options.td
===
--- lldb/tools/driver/Options.td
+++ lldb/tools/driver/Options.td
@@ -95,6 +95,9 @@
   Alias,
   HelpText<"Alias for --no-lldbinit">,
   Group;
+def local_lldbinit: F<"local-lldbinit">,
+  HelpText<"Allow the debugger to load the local lldbinit files.">,
+  Group;
 
 def batch: F<"batch">,
   HelpText<"Tells the debugger to run the commands from -s, -S, -o & -O, and 
then quit.">,
Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -222,6 +222,11 @@
 m_debugger.SkipAppInitFiles(true);
   }
 
+  if (args.hasArg(OPT_local_lldbinit)) {
+lldb::SBDebugger::SetInternalVariable("target.load-cwd-lldbinit", "true",
+  m_debugger.GetInstanceName());
+  }
+
   if (args.hasArg(OPT_no_use_colors)) {
 m_debugger.SetUseColor(false);
   }
Index: lldb/lit/Driver/LocalLLDBInit.test
===
--- lldb/lit/Driver/LocalLLDBInit.test
+++ lldb/lit/Driver/LocalLLDBInit.test
@@ -1,9 +1,11 @@
 # RUN: mkdir -p %t.root
 # RUN: cp %S/Inputs/.lldbinit %t.root
 # RUN: cd %t.root
-# RUN: %lldb-init -o 'settings show frame-format' 2>&1 | FileCheck %s 
--check-prefix=INIT --check-prefix=CHECK
+# RUN: %lldb-init -o 'settings show frame-format' 2>&1 | FileCheck %s 
--check-prefix=WARNINIT --check-prefix=CHECK
+# RUN: %lldb-init -local-lldbinit -o 'settings show frame-format' 2>&1 | 
FileCheck %s --check-prefix=ALLOWINIT --check-prefix=NOINIT
 # RUN: %lldb -o 'settings show frame-format' 2>&1 | FileCheck %s 
--check-prefix=NOINIT --check-prefix=CHECK
 
-# INIT: There is a .lldbinit file in the current directory which is not being 
read.
+# WARNINIT: There is a .lldbinit file in the current directory which is not 
being read.
 # NOINIT-NOT: There is a .lldbinit file in the current directory which is not 
being read.
 # CHECK-NOT: bogus
+# ALLOWINIT: bogus


Index: lldb/tools/driver/Options.td
===
--- lldb/tools/driver/Options.td
+++ lldb/tools/driver/Options.td
@@ -95,6 +95,9 @@
   Alias,
   HelpText<"Alias for --no-lldbinit">,
   Group;
+def local_lldbinit: F<"local-lldbinit">,
+  HelpText<"Allow the debugger to load the local lldbinit files.">,
+  Group;
 
 def batch: F<"batch">,
   HelpText<"Tells the debugger to run the commands from -s, -S, -o & -O, and then quit.">,
Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -222,6 +222,11 @@
 m_debugger.SkipAppInitFiles(true);
   }
 
+  if (args.hasArg(OPT_local_lldbinit)) {
+lldb::SBDebugger::SetInternalVariable("target.load-cwd-lldbinit", "true",
+  m_debugger.GetInstanceName());
+  }
+
   if (args.hasArg(OPT_no_use_colors)) {
 m_debugger.SetUseColor(false);
   }
Index: lldb/lit/Driver/LocalLLDBInit.test
===
--- lldb/lit/Driver/LocalLLDBInit.test
+++ lldb/lit/Driver/LocalLLDBInit.test
@@ -1,9 +1,11 @@
 # RUN: mkdir -p %t.root
 # RUN: cp %S/Inputs/.lldbinit %t.root
 # RUN: cd %t.root
-# RUN: %lldb-init -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=INIT --check-prefix=CHECK
+# RUN: %lldb-init -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=WARNINIT --check-prefix=CHECK
+# RUN: %lldb-init -local-lldbinit -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=ALLOWINIT --check-prefix=NOINIT
 # RUN: %lldb -o 'settings show frame-format' 2>&1 | FileCheck %s --check-prefix=NOINIT --check-prefix=CHECK
 
-# INIT: There is a .lldbinit file in the current directory which is not being read.
+# WARNINIT: There is a .lldbinit file in the current directory which is not being read.
 # NOINIT-NOT: There is a .lldbinit file in the current directory which is not being read.
 # CHECK-NOT: bogus
+# ALLOWINIT: bogus
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D61579: Propagate command interpreter errors from lldlbinit

2019-05-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: clayborg, labath, jingham.
Herald added a subscriber: abidh.
Herald added a project: LLDB.
JDevlieghere added a parent revision: D61578: [Driver] Add command line option 
to allow loading local lldbinit file.

This patch ensures that we propagate errors coming from the lldbinit file 
trough the command/script interpreter. Before, if you did something like 
`command script import syntax_error.py`,  and the python file contained a 
syntax error, lldb wouldn't tell you about it. This changes with the current 
patch: errors are now propagated by default.

PS: Jim authored this change and I added testing.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D61579

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/lit/Driver/Inputs/.lldbinit
  lldb/lit/Driver/Inputs/syntax_error.py
  lldb/lit/Driver/LocalLLDBInit.test
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectBugreport.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2652,6 +2652,7 @@
 options.SetStopOnError(true);
 options.SetEchoCommands(false);
 options.SetPrintResults(true);
+options.SetPrintErrors(true);
 options.SetAddToHistory(false);
 
 // Force Async:
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2173,6 +2173,7 @@
 const bool saved_batch = SetBatchCommandMode(true);
 CommandInterpreterRunOptions options;
 options.SetSilent(true);
+options.SetPrintErrors(true);
 options.SetStopOnError(false);
 options.SetStopOnContinue(true);
 
@@ -2364,7 +2365,8 @@
   eHandleCommandFlagEchoCommand = (1u << 2),
   eHandleCommandFlagEchoCommentCommand = (1u << 3),
   eHandleCommandFlagPrintResult = (1u << 4),
-  eHandleCommandFlagStopOnCrash = (1u << 5)
+  eHandleCommandFlagPrintErrors = (1u << 5),
+  eHandleCommandFlagStopOnCrash = (1u << 6)
 };
 
 void CommandInterpreter::HandleCommandsFromFile(
@@ -2463,6 +2465,17 @@
 flags |= eHandleCommandFlagPrintResult;
   }
 
+  if (options.m_print_errors == eLazyBoolCalculate) {
+if (m_command_source_flags.empty()) {
+  // Print output by default
+  flags |= eHandleCommandFlagPrintErrors;
+} else if (m_command_source_flags.back() & eHandleCommandFlagPrintErrors) {
+  flags |= eHandleCommandFlagPrintErrors;
+}
+  } else if (options.m_print_errors == eLazyBoolYes) {
+flags |= eHandleCommandFlagPrintErrors;
+  }
+
   if (flags & eHandleCommandFlagPrintResult) {
 debugger.GetOutputFile()->Printf("Executing commands in '%s'.\n",
  cmd_file_path.c_str());
@@ -2790,7 +2803,9 @@
   HandleCommand(line.c_str(), eLazyBoolCalculate, result);
 
   // Now emit the command output text from the command we just executed
-  if (io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) {
+  if ((result.Succeeded() &&
+   io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
+  io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors)) {
 // Display any STDOUT/STDERR _prior_ to emitting the command result text
 GetProcessOutput();
 
@@ -2960,8 +2975,11 @@
 flags |= eHandleCommandFlagEchoCommentCommand;
   if (options->m_print_results != eLazyBoolNo)
 flags |= eHandleCommandFlagPrintResult;
+  if (options->m_print_errors != eLazyBoolNo)
+flags |= eHandleCommandFlagPrintErrors;
 } else {
-  flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult;
+  flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult |
+  eHandleCommandFlagPrintErrors;
 }
 
 m_command_io_handler_sp = std::make_shared(
Index: lldb/source/Commands/CommandObjectWatchpointCommand.cpp
===
--- lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -295,6 +295,7 @@
 options.SetStopOnError(data->stop_on_error);
 options.SetEchoCommands(false);
 options.SetPrintResults(true);
+options.SetPrintErrors(true);
 options.SetAddToHistory(false);
 
 debugger.GetCommandInterpreter().HandleCommands(commands, &exe_ctx,
Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Com

[Lldb-commits] [PATCH] D61292: Include inlined functions when figuring out a contiguous address range

2019-05-05 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

The test changes look fine to me. Thank you for doing that.




Comment at: lldb/unittests/Symbol/TestLineEntry.cpp:96-122
+llvm::Expected LineEntryTest::GetModule() {
+  if (m_module_sp)
+return m_module_sp;
+
+  std::string yaml = GetInputFilePath("inlined-functions.yaml");
+  llvm::SmallString<128> obj;
+

aadsm wrote:
> labath wrote:
> > aadsm wrote:
> > > jingham wrote:
> > > > It looks like this bit of business has been copied around in a bunch of 
> > > > other tests in the unittest framework.  Could we put this in a common 
> > > > place (like make a LLDBUnitTest : testing::Test class that does this?
> > > How about adding a new function to TestUtilities.cpp named 
> > > `ReadYAMLObject`?
> > A utility function sounds nice. (a test class would be fine too, but I'd 
> > name it a bit less generic, as not all of our unit tests are in business of 
> > running yaml2obj and creating modules).
> > 
> > The part I'm not so sure about is the location. Originally the idea was 
> > that we would have a special subfolder for test helpers related to each 
> > module under test, but then at some point that got changed into 
> > `TestingSupport` which sounds more generic (this evolution here is visible 
> > in the fact that the cmake target name in that folder is called 
> > `lldbUtilityHelpers`). If we put this function there then we'd have to pull 
> > in the Core module (and everything that goes with it). Though that isn't 
> > that bad on it's own, it is a bit unfortunate, as right now the `Utility` 
> > unit test executable is our best defense against unexpected dependencies 
> > creeping into the main module. After this, that executable would link in 
> > the whole world again, and we'd lose this defense.
> > 
> > Another possibility might be to just put the yaml2obj (which is the main 
> > source of mess here) part in that file, and leave the construction of the 
> > Module object to the users.
> Yeah, the way I did it locally was to create a function that only handles the 
> yaml2obj part. Some tests use the file for other things other than creating a 
> ModuleSpec.
> I also put the responsibility of creating and cleaning up the object file in 
> the caller. I was not sure how to handle the clean up of the temporary file 
> for all different cases. Here's how it looks like from the caller side.
> 
> ```
> llvm::SmallString<128> obj;
> if (auto ec = llvm::sys::fs::createTemporaryFile("source-%%", "obj", obj))
>   return llvm::errorCodeToError(ec);
> llvm::FileRemover obj_remover(obj);
> if (auto error = ReadYAMLObjectFile("inlined-functions.yaml", obj))
>   return llvm::Error(std::move(error));
> ```
> What do you think?
Yeah, that's fine. I can think of a couple of ways of simplifying that further, 
but that would require making some tweaks to the FileRemover class (the class 
only has a handful of uses in llvm, so it's not surprising it has some rough 
edges). However, this is already a pretty big improvement over the current 
state, so thank you for doing that.



Comment at: lldb/unittests/TestingSupport/TestUtilities.cpp:12
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"

What is this header used for? If need something to include to use 
`createStringError`, you should include `llvm/Support/Error.h`, as that's what 
defines it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61292



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


[Lldb-commits] [PATCH] D61483: [www] list command: lldb run

2019-05-05 Thread Konrad Kleine via Phabricator via lldb-commits
kkleine updated this revision to Diff 198223.
kkleine added a comment.

- [www] move `run ` command down for educational purposes
- Add documentation to docs/use/map.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61483

Files:
  lldb/docs/use/map.rst
  lldb/www/lldb-gdb.html


Index: lldb/www/lldb-gdb.html
===
--- lldb/www/lldb-gdb.html
+++ lldb/www/lldb-gdb.html
@@ -59,6 +59,7 @@
 
 
 (lldb) process launch -- 
+(lldb) run 
 (lldb) r 
 
 
Index: lldb/docs/use/map.rst
===
--- lldb/docs/use/map.rst
+++ lldb/docs/use/map.rst
@@ -51,6 +51,8 @@

   (lldb) process launch -- 
   
+  (lldb) run 
+  
   (lldb) r 

  


Index: lldb/www/lldb-gdb.html
===
--- lldb/www/lldb-gdb.html
+++ lldb/www/lldb-gdb.html
@@ -59,6 +59,7 @@
 
 
 (lldb) process launch -- 
+(lldb) run 
 (lldb) r 
 
 
Index: lldb/docs/use/map.rst
===
--- lldb/docs/use/map.rst
+++ lldb/docs/use/map.rst
@@ -51,6 +51,8 @@

   (lldb) process launch -- 
   
+  (lldb) run 
+  
   (lldb) r 

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


[Lldb-commits] [PATCH] D61483: [www] list command: lldb run

2019-05-05 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

In D61483#1489264 , @labath wrote:

> This is the old documentation. You should edit the new one in 
> `docs/use/map.rst`.


Oh, good to know. The new documentation is also updated. May I ask why we have 
two documentation and don't just throw away one of them? What are they both 
used for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61483



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