[Lldb-commits] [PATCH] D81810: LLDB step-instruction gets stuck on jump to self

2020-06-16 Thread Sebastian Österlund via Phabricator via lldb-commits
sirmc added a comment.

Yes, I wasn't sure what the exact semantics were for step-inst for LLDB. I 
think the issue is not mainly the mimicking of GDB behavior, but rather that it 
is inconvenient for some use-cases.

To give some context on why I propose this change: the current behavior is 
pretty cumbersome when doing automated testing with LLDB of unknown/ generated 
programs. For example making use of the Python API, AFAIK, there is no 
interface where you can run a bounded number of instructions if 
`lldb.SBThread.StepInstruction` is not guaranteed to return (the current hack 
around it would be run this in a separate thread with a timeout).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81810



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


[Lldb-commits] [lldb] e4a8459 - [lldb/Test] Create dir if it doesn't yet exist in getReproducerArtifact

2020-06-16 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-16T09:46:48-07:00
New Revision: e4a84590e8ab21077bf47c50fdfeaaa99f617bee

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

LOG: [lldb/Test] Create dir if it doesn't yet exist in getReproducerArtifact

The type test use this method to store the golden output. This currently
fails if the reproducer directory hasn't yet been created.

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 7190be6be9b3..c5373479e48f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -696,6 +696,7 @@ def getSourcePath(self, name):
 return os.path.join(self.getSourceDir(), name)
 
 def getReproducerArtifact(self, name):
+lldbutil.mkdir_p(self.getReproducerDir())
 return os.path.join(self.getReproducerDir(), name)
 
 @classmethod



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


[Lldb-commits] [PATCH] D81810: LLDB step-instruction gets stuck on jump to self

2020-06-16 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D81810#2095902 , @sirmc wrote:

> Yes, I wasn't sure what the exact semantics were for step-inst for LLDB. I 
> think the issue is not mainly the mimicking of GDB behavior, but rather that 
> it is inconvenient for some use-cases.
>
> To give some context on why I propose this change: the current behavior is 
> pretty cumbersome when doing automated testing with LLDB of unknown/ 
> generated programs. For example making use of the Python API, AFAIK, there is 
> no interface where you can run a bounded number of instructions if 
> `lldb.SBThread.StepInstruction` is not guaranteed to return (the current hack 
> around it would be run this in a separate thread with a timeout).


This seems entirely reasonable.  It would be good to get a test case so 
somebody doesn't inadvertently change the behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81810



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


[Lldb-commits] [PATCH] D81898: [lldb/Python] Fix the infinitely looping prompt bug

2020-06-16 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, but some documentation would be nice.




Comment at: lldb/source/Interpreter/embedded_interpreter.py:77
+line = sys.stdin.readline()
+if not line:
+raise EOFError

`# Empty line from readline indicates EOF`



Comment at: lldb/test/Shell/ScriptInterpreter/Python/eof.test:3
+
+CHECK: >>>
+CHECK-NOT: >>>

I think this should have a comment that ">>>" is the python interpreter prompt 
and why we check for it.


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

https://reviews.llvm.org/D81898



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


[Lldb-commits] [lldb] 4dd3dfe - [lldb/Python] Fix the infinitely looping Python prompt bug

2020-06-16 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-16T11:05:19-07:00
New Revision: 4dd3dfe8e3266459d855008af78d611071ff99e2

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

LOG: [lldb/Python] Fix the infinitely looping Python prompt bug

Executing commands below will get you bombarded by a wall of Python
command prompts (>>> ).

$ echo 'foo' | ./bin/lldb -o script
$ cat /tmp/script
script
print("foo")
$ lldb --source /tmp/script

The issue is that our custom input reader doesn't handle EOF. According
to the Python documentation, file.readline always includes a trailing
newline character unless the file ends with an incomplete line. An empty
string signals EOF. This patch raises an EOFError when that happens.

[1] https://docs.python.org/2/library/stdtypes.html#file.readline

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

Added: 
lldb/test/Shell/ScriptInterpreter/Python/eof.test

Modified: 
lldb/source/Interpreter/embedded_interpreter.py

Removed: 




diff  --git a/lldb/source/Interpreter/embedded_interpreter.py 
b/lldb/source/Interpreter/embedded_interpreter.py
index 8a1195d83c6f..9312dbfaca4e 100644
--- a/lldb/source/Interpreter/embedded_interpreter.py
+++ b/lldb/source/Interpreter/embedded_interpreter.py
@@ -73,7 +73,12 @@ def get_terminal_size(fd):
 def readfunc_stdio(prompt):
 sys.stdout.write(prompt)
 sys.stdout.flush()
-return sys.stdin.readline().rstrip()
+line = sys.stdin.readline()
+# Readline always includes a trailing newline character unless the file
+# ends with an incomplete line. An empty line indicates EOF.
+if not line:
+raise EOFError
+return line.rstrip()
 
 
 def run_python_interpreter(local_dict):

diff  --git a/lldb/test/Shell/ScriptInterpreter/Python/eof.test 
b/lldb/test/Shell/ScriptInterpreter/Python/eof.test
new file mode 100644
index ..d777f24591ea
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/Python/eof.test
@@ -0,0 +1,6 @@
+RUN: echo 'foo' | %lldb -o script | FileCheck %s
+
+# Check that the python interpreter detects the OF and the prompt is printed
+# exactly once.
+CHECK: >>>
+CHECK-NOT: >>>



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


[Lldb-commits] [PATCH] D81898: [lldb/Python] Fix the infinitely looping prompt bug

2020-06-16 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dd3dfe8e326: [lldb/Python] Fix the infinitely looping 
Python prompt bug (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D81898?vs=270924&id=271147#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81898

Files:
  lldb/source/Interpreter/embedded_interpreter.py
  lldb/test/Shell/ScriptInterpreter/Python/eof.test


Index: lldb/test/Shell/ScriptInterpreter/Python/eof.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/eof.test
@@ -0,0 +1,6 @@
+RUN: echo 'foo' | %lldb -o script | FileCheck %s
+
+# Check that the python interpreter detects the OF and the prompt is printed
+# exactly once.
+CHECK: >>>
+CHECK-NOT: >>>
Index: lldb/source/Interpreter/embedded_interpreter.py
===
--- lldb/source/Interpreter/embedded_interpreter.py
+++ lldb/source/Interpreter/embedded_interpreter.py
@@ -73,7 +73,12 @@
 def readfunc_stdio(prompt):
 sys.stdout.write(prompt)
 sys.stdout.flush()
-return sys.stdin.readline().rstrip()
+line = sys.stdin.readline()
+# Readline always includes a trailing newline character unless the file
+# ends with an incomplete line. An empty line indicates EOF.
+if not line:
+raise EOFError
+return line.rstrip()
 
 
 def run_python_interpreter(local_dict):


Index: lldb/test/Shell/ScriptInterpreter/Python/eof.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/eof.test
@@ -0,0 +1,6 @@
+RUN: echo 'foo' | %lldb -o script | FileCheck %s
+
+# Check that the python interpreter detects the OF and the prompt is printed
+# exactly once.
+CHECK: >>>
+CHECK-NOT: >>>
Index: lldb/source/Interpreter/embedded_interpreter.py
===
--- lldb/source/Interpreter/embedded_interpreter.py
+++ lldb/source/Interpreter/embedded_interpreter.py
@@ -73,7 +73,12 @@
 def readfunc_stdio(prompt):
 sys.stdout.write(prompt)
 sys.stdout.flush()
-return sys.stdin.readline().rstrip()
+line = sys.stdin.readline()
+# Readline always includes a trailing newline character unless the file
+# ends with an incomplete line. An empty line indicates EOF.
+if not line:
+raise EOFError
+return line.rstrip()
 
 
 def run_python_interpreter(local_dict):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81200: [vscode] set default values for terminateDebuggee for the disconnect request

2020-06-16 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

@labath , does this look better now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81200



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


[Lldb-commits] [lldb] c0f1dcf - [lldb/Test] Pass the lldb_tool_dir when setting the lldb-repro substitutions

2020-06-16 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-16T13:56:16-07:00
New Revision: c0f1dcf31ee853c33e214d54f12658cf852bf288

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

LOG: [lldb/Test] Pass the lldb_tool_dir when setting the lldb-repro 
substitutions

Otherwise LIT can't find the lldb-repro script in standalone builds.

Added: 


Modified: 
lldb/test/Shell/helper/toolchain.py

Removed: 




diff  --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index 99e04b2b6e35..64a0c6671516 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -72,8 +72,7 @@ def use_lldb_substitutions(config):
 _disallow(config, 'debugserver')
 _disallow(config, 'platformserver')
 
-llvm_config.add_tool_substitutions(primary_tools,
-   [config.lldb_tools_dir])
+llvm_config.add_tool_substitutions(primary_tools, [config.lldb_tools_dir])
 
 def _use_msvc_substitutions(config):
 # If running from a Visual Studio Command prompt (e.g. vcvars), this will
@@ -169,4 +168,4 @@ def use_lldb_repro_substitutions(config, mode):
 command=FindTool('lldb-repro'),
 extra_args=[mode, '-S', lldb_init]),
 ]
-llvm_config.add_tool_substitutions(substitutions)
+llvm_config.add_tool_substitutions(substitutions, [config.lldb_tools_dir])



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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-06-16 Thread Shu Anzai via Phabricator via lldb-commits
gedatsu217 updated this revision to Diff 271146.
gedatsu217 added a comment.

Implementation all ascii characters for TypedCharacter.
Making m_use_autosuggestion in Editline.cpp. (I did not know a way to pass the 
bool value of IOHandlerEditline to Editline constructor, so I made a function, 
Editline::UseAutosuggestion, in Editline class. If the autosuggestion is valid, 
this function is called from IOHandlerEditline constructor. Is this 
implementation good?)

> You can test it by just doing settings set show-autosuggestion true (which 
> should activate this) and settings set show-autosuggestion true (which should 
> deactivate this). It's fine if LLDB requires a restart to do activate this 
> setting (that's to my knowledge a limitation of the current way the 
> IOHandlers work).

"restart" means that excuting "quit" in LLDB and executing "bin/lldb" again in 
Terminal?  I made m_use_autosuggestion in Editline.cpp and it goes well when 
show-autosuggestion is DefaultTrue. However, when show-autosuggestion is 
DefaultFalse and executing "settings set show-autosuggestion true", 
autosuggestion does not work well. Do you know what causes it?

In addition,

> There's no way to confirm the autosuggestion. In fish you can use right-arrow 
> or a key to move to the end of the line (END, CTRL-E).

If you press CTRL-F, you probably confirm the autosuggestion.

> The interaction between the autocompletion and autosuggestion is rather 
> confusing. Fish solves this by showing the autocompletion under the current 
> line. I don't we need to take it that far, but at least the the situation 
> described below should work.

I added some codes in TabCommand in Editline.cpp so that autosuggestion still 
show up after the completion when there is a possible completion.


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

https://reviews.llvm.org/D81001

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Host/common/Editline.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp

Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1866,6 +1866,21 @@
   HandleCompletionMatches(request);
 }
 
+llvm::Optional
+CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line,
+std::string &result) {
+  const size_t s = m_command_history.GetSize();
+  for (size_t i = 0; i < s; ++i) {
+llvm::StringRef entry = m_command_history.GetStringAtIndex(i);
+if (entry.startswith(line)) {
+  llvm::StringRef res = entry.substr(line.size());
+  result = res.str();
+  return result;
+}
+  }
+  return llvm::None;
+}
+
 CommandInterpreter::~CommandInterpreter() {}
 
 void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) {
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Host/Editline.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/CompletionRequest.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBAssert.h"
@@ -1004,6 +1005,17 @@
   to_add = to_add.substr(request.GetCursorArgumentPrefix().size());
   if (request.GetParsedArg().IsQuoted())
 to_add.push_back(request.GetParsedArg().GetQuoteChar());
+  if (m_use_autosuggestion) {
+int length = (int)(to_add.length());
+if ((int)(m_current_autosuggestion.length()) > length &&
+to_add == m_current_autosuggestion.substr(0, length)) {
+  to_add.push_back(' ');
+  el_insertstr(m_editline, to_add.c_str());
+  m_current_autosuggestion =
+  m_current_autosuggestion.substr(length + 1);
+  return CC_REFRESH;
+}
+  }
   to_add.push_back(' ');
   el_insertstr(m_editline, to_add.c_str());
   break;
@@ -1020,6 +1032,7 @@
   break;
 }
 }
+m_current_autosuggestion = "";
 return CC_REDISPLAY;
   }
 
@@ -1040,6 +1053,36 @@
   return CC_REDISPLAY;
 }
 
+unsigned char Editline::ApplyCompleteCommand(int ch) {
+  el_insertstr(m_editline, m_current_autosuggestion.c_str());
+  m_current_autosuggestion = "";
+  return CC_REDISPLAY;
+}
+
+unsigned char Editline::TypedCharacter(int ch) {
+  std::string typed = std::string(1, ch);
+  el_insertstr(m_editline, typed.c_str());
+  const LineInfo *line_info = el_line(m_editline);
+  llvm::StringRef line(line_info->buffer,
+   line_info->lastchar - line_

[Lldb-commits] [PATCH] D81200: [vscode] set default values for terminateDebuggee for the disconnect request

2020-06-16 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 271224.
wallace edited the summary of this revision.
wallace added a comment.

remove unwanted changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81200

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/disconnect/Makefile
  lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
  lldb/test/API/tools/lldb-vscode/disconnect/main.cpp
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -514,6 +514,7 @@
 //   }]
 // }
 void request_attach(const llvm::json::Object &request) {
+  g_vsc.is_attach = true;
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
@@ -769,7 +770,9 @@
   FillResponse(request, response);
   auto arguments = request.getObject("arguments");
 
-  bool terminateDebuggee = GetBoolean(arguments, "terminateDebuggee", false);
+  bool defaultTerminateDebuggee = g_vsc.is_attach ? false : true;
+  bool terminateDebuggee =
+  GetBoolean(arguments, "terminateDebuggee", defaultTerminateDebuggee);
   lldb::SBProcess process = g_vsc.target.GetProcess();
   auto state = process.GetState();
 
@@ -788,10 +791,9 @@
   case lldb::eStateStopped:
   case lldb::eStateRunning:
 g_vsc.debugger.SetAsync(false);
-if (terminateDebuggee)
-  process.Kill();
-else
-  process.Detach();
+lldb::SBError error = terminateDebuggee ? process.Kill() : process.Detach();
+if (!error.Success())
+  response.try_emplace("error", error.GetCString());
 g_vsc.debugger.SetAsync(true);
 break;
   }
@@ -1357,6 +1359,7 @@
 //   }]
 // }
 void request_launch(const llvm::json::Object &request) {
+  g_vsc.is_attach = false;
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
Index: lldb/tools/lldb-vscode/VSCode.h
===
--- lldb/tools/lldb-vscode/VSCode.h
+++ lldb/tools/lldb-vscode/VSCode.h
@@ -89,6 +89,7 @@
   lldb::tid_t focus_tid;
   bool sent_terminated_event;
   bool stop_at_entry;
+  bool is_attach;
   // Keep track of the last stop thread index IDs as threads won't go away
   // unless we send a "thread" event to indicate the thread exited.
   llvm::DenseSet thread_ids;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -38,7 +38,7 @@
{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
{"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
-  stop_at_entry(false) {
+  stop_at_entry(false), is_attach(false) {
   const char *log_file_path = getenv("LLDBVSCODE_LOG");
 #if defined(_WIN32)
 // Windows opens stdout and stdin in text mode which converts \n to 13,10
Index: lldb/test/API/tools/lldb-vscode/disconnect/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/disconnect/main.cpp
@@ -0,0 +1,33 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+volatile bool wait_for_attach = true;
+
+void handle_attach(char *sync_file_path) {
+  lldb_enable_attach();
+
+  {
+// Create a file to signal that this process has started up.
+std::ofstream sync_file;
+sync_file.open(sync_file_path);
+  }
+
+  while (wait_for_attach)
+std::this_thread::sleep_for(std::chrono::milliseconds(10));
+}
+
+int main(int argc, char **args) {
+  if (argc == 2)
+handle_attach(args[1]);
+
+  // We let the binary live a little bit to see if it executed after detaching
+  // from // breakpoint
+
+  // Create a file to signal that this process has started up.
+  std::ofstream out_file; // breakpoint
+  out_file.open(std::string(args[0]) + ".side_effect");
+  return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
@@ -0,0 +1,82 @@
+"""
+Test lldb-vscode disconnect request
+"""
+
+
+import unittest2
+import vscode
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbvscode_testcase
+import subprocess
+import time
+import os
+
+
+class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase):
+
+mydir = TestBase.compute_mydir(__file__)
+source = 'main.cpp'
+
+def disconnect_and_assert_no_output_printed(self):
+ 

[Lldb-commits] [lldb] c151230 - [lldb/Test] Cleanup TestJITLoaderGDB and make it compatible with reproducers

2020-06-16 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-16T15:46:14-07:00
New Revision: c151230533e07b8fb3dd20b9a83ba0d79677f54c

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

LOG: [lldb/Test] Cleanup TestJITLoaderGDB and make it compatible with 
reproducers

Added: 


Modified: 
lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py

Removed: 




diff  --git a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py 
b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
index 4bd4150185cf..3a89947d3051 100644
--- a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
+++ b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
@@ -8,7 +8,6 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
-file_index = 0
 
 class JITLoaderGDBTestCase(TestBase):
 
@@ -27,25 +26,18 @@ def test_bogus_values(self):
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
-# launch the process, do not stop at entry point.
+# Launch the process, do not stop at entry point.
 process = target.LaunchSimple(
 None, None, self.get_process_working_directory())
 self.assertTrue(process, PROCESS_IS_VALID)
 
 # The inferior will now pass bogus values over the interface. Make sure
 # we don't crash.
-
 self.assertEqual(process.GetState(), lldb.eStateExited)
 self.assertEqual(process.GetExitStatus(), 0)
 
 def gen_log_file(self):
-global file_index
-++file_index
-logfile = os.path.join(
-self.getBuildDir(),
-"jitintgdb-" + self.getArchitecture() + "-" +
-str(file_index) + ".txt")
-
+logfile = 
self.getBuildArtifact("jitintgdb-{}.txt".format(self.getArchitecture()))
 def cleanup():
 if os.path.exists(logfile):
 os.unlink(logfile)
@@ -70,7 +62,7 @@ def cleanup():
 self.runCmd("settings set plugin.jit-loader.gdb.enable default")
 self.addTearDownHook(cleanup)
 
-# launch the process
+# Launch the process.
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 process = target.LaunchSimple(
@@ -80,11 +72,10 @@ def cleanup():
 self.assertEqual(process.GetState(), lldb.eStateExited)
 self.assertEqual(process.GetExitStatus(), 0)
 
-logcontent = ""
-if os.path.exists(logfile):
+if not configuration.is_reproducer():
+self.assertTrue(os.path.exists(logfile))
 logcontent = open(logfile).read()
-self.assertIn(
-"SetJITBreakpoint setting JIT breakpoint", logcontent)
+self.assertIn("SetJITBreakpoint setting JIT breakpoint", 
logcontent)
 
 @skipIfWindows # This test fails on Windows during C code build
 def test_jit_int_off(self):
@@ -100,7 +91,7 @@ def cleanup():
 self.runCmd("settings set plugin.jit-loader.gdb.enable default")
 self.addTearDownHook(cleanup)
 
-# launch the process
+# Launch the process.
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 process = target.LaunchSimple(
@@ -110,9 +101,7 @@ def cleanup():
 self.assertEqual(process.GetState(), lldb.eStateExited)
 self.assertEqual(process.GetExitStatus(), 0)
 
-if os.path.exists(logfile):
+if not configuration.is_reproducer():
+self.assertTrue(os.path.exists(logfile))
 logcontent = open(logfile).read()
-self.assertNotIn(
-  "SetJITBreakpoint setting JIT breakpoint", logcontent)
-else:
-self.assertTrue(false)
+self.assertNotIn("SetJITBreakpoint setting JIT breakpoint", 
logcontent)



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


[Lldb-commits] [PATCH] D81978: Redo of Add terminateCommands to lldb-vscode protocol

2020-06-16 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
wallace added reviewers: clayborg, aadsm, kusmour, labath.
wallace added a project: LLDB.
wallace edited the summary of this revision.
wallace added a parent revision: D81200: [vscode] set default values for 
terminateDebuggee for the disconnect request.

This redoes https://reviews.llvm.org/D79726 and fixes two things.

- The logic that determines whether to automatically disconnect during the tear 
down is not very dumb compared to the original implementation. Each test will 
determine whether to do that or not.
- The terminate commands and terminate event were being sent after the 
disconnect response was sent to the IDE. That was not good, as VSCode stops the 
debug session as soon as it receives a disconnect response. Now, the terminate 
event and terminateEvents are being executed before the disconnect response is 
sent. This ensures that any connection between the IDE and lldb-vscode is alive 
while the terminate commands are executed. Besides, it also allows displaying 
the output of the terminate commands on the debug console, as it's still alive.

F12179083: Screen Shot 2020-06-16 at 3.52.33 PM.png 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81978

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
  lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
  lldb/tools/lldb-vscode/README.md
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -174,6 +174,7 @@
 void SendTerminatedEvent() {
   if (!g_vsc.sent_terminated_event) {
 g_vsc.sent_terminated_event = true;
+g_vsc.RunTerminateCommands();
 // Send a "terminated" event
 llvm::json::Object event(CreateEventObject("terminated"));
 g_vsc.SendJSON(llvm::json::Value(std::move(event)));
@@ -530,6 +531,7 @@
   g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands");
   g_vsc.stop_commands = GetStrings(arguments, "stopCommands");
   g_vsc.exit_commands = GetStrings(arguments, "exitCommands");
+  g_vsc.terminate_commands = GetStrings(arguments, "terminateCommands");
   auto attachCommands = GetStrings(arguments, "attachCommands");
   llvm::StringRef core_file = GetString(arguments, "coreFile");
   g_vsc.stop_at_entry =
@@ -775,7 +777,6 @@
   GetBoolean(arguments, "terminateDebuggee", defaultTerminateDebuggee);
   lldb::SBProcess process = g_vsc.target.GetProcess();
   auto state = process.GetState();
-
   switch (state) {
   case lldb::eStateInvalid:
   case lldb::eStateUnloaded:
@@ -797,8 +798,8 @@
 g_vsc.debugger.SetAsync(true);
 break;
   }
-  g_vsc.SendJSON(llvm::json::Value(std::move(response)));
   SendTerminatedEvent();
+  g_vsc.SendJSON(llvm::json::Value(std::move(response)));
   if (g_vsc.event_thread.joinable()) {
 g_vsc.broadcaster.BroadcastEventByType(eBroadcastBitStopEventThread);
 g_vsc.event_thread.join();
@@ -1368,6 +1369,7 @@
   g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands");
   g_vsc.stop_commands = GetStrings(arguments, "stopCommands");
   g_vsc.exit_commands = GetStrings(arguments, "exitCommands");
+  g_vsc.terminate_commands = GetStrings(arguments, "terminateCommands");
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot");
Index: lldb/tools/lldb-vscode/VSCode.h
===
--- lldb/tools/lldb-vscode/VSCode.h
+++ lldb/tools/lldb-vscode/VSCode.h
@@ -86,6 +86,7 @@
   std::vector pre_run_commands;
   std::vector exit_commands;
   std::vector stop_commands;
+  std::vector terminate_commands;
   lldb::tid_t focus_tid;
   bool sent_terminated_event;
   bool stop_at_entry;
@@ -133,6 +134,7 @@
   void RunPreRunCommands();
   void RunStopCommands();
   void RunExitCommands();
+  void RunTerminateCommands();
 
   /// Create a new SBTarget object from the given request arguments.
   /// \param[in] arguments
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -309,6 +309,10 @@
   RunLLDBCommands("Running exitCommands:", exit_commands);
 }
 
+void VSCode::RunTerminateCommands() {
+  RunLLDBCommands("Running terminateCommands:", terminate_commands);
+}
+
 lldb::SBTarget VSCode::CreateTargetFromArguments(
 const llvm::json::Object &arguments,
 lldb::SBError &error) {
Index: lldb/tools/lldb-vscode/README.md
===

[Lldb-commits] [PATCH] D81980: Repair support for launching iphone/tv/watch simulator binaries through platform

2020-06-16 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: friss, jasonmolenda, jingham.

and delete a bunch (but not all) redundant code. If you compare the remaining 
implementations of Platform*Simulator.cpp, there is still an obvious leftover 
cleanup task.

Specifically, this patch

- removes SDK initialization from dotest (there is equivalent but more complete 
code in Makefile.rules)
- make Platform*Simulator inherit the generic implementation of 
PlatformAppleSimulator (more can be done here)
- simplify the platform logic in Makefile.rules
- replace the custom SDK finding logic in Platform*Simulator with XcodeSDK
- adds a test for each supported simulator


https://reviews.llvm.org/D81980

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
  lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
  
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/test/API/macosx/simulator/Makefile
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
  lldb/test/API/macosx/simulator/hello.c

Index: lldb/test/API/macosx/simulator/hello.c
===
--- /dev/null
+++ lldb/test/API/macosx/simulator/hello.c
@@ -0,0 +1,5 @@
+void puts(char *);
+int main(int argc, char **argv) {
+  puts("break here\n");
+  return 0;
+}
Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===
--- /dev/null
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -0,0 +1,46 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+import json
+import unittest2
+
+
+class TestSimulatorPlatformLaunching(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def run_with(self, arch, platform, os, env):
+self.build(dictionary={'TRIPLE': arch+'-apple-'+os+'-'+env, 'ARCH': arch})
+lldbutil.run_to_source_breakpoint(self, "break here",
+  lldb.SBFileSpec("hello.c"))
+self.expect('image list -b -t',
+patterns=['a\.out '+arch+'-apple-'+os+'.*-'+env])
+
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+@apple_simulator_test('iphonesimulator')
+def test_ios(self):
+"""Test running an iOS simulator binary"""
+self.run_with(arch=self.getArchitecture(),
+  os='ios', env='simulator',
+  platform='iphonesimulator')
+
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+@apple_simulator_test('appletvsimulator')
+def test_tvos(self):
+"""Test running an tvOS simulator binary"""
+self.run_with(arch=self.getArchitecture(),
+  os='tvos', env='simulator',
+  platform='appletvsimulator')
+
+@skipUnlessDarwin
+@skipIfDarwinEmbedded
+@apple_simulator_test('watchsimulator')
+def test_watchos(self):
+"""Test running a 32-bit watchOS simulator binary"""
+self.run_with(arch='i386',
+  os='watchos', env='simulator',
+  platform='watchsimulator')
Index: lldb/test/API/macosx/simulator/Makefile
===
--- /dev/null
+++ lldb/test/API/macosx/simulator/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := hello.c
+
+include Makefile.rules
Index: lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
===
--- lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
+++ lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
@@ -1,5 +1,4 @@
-//===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp ---*- C++
-//-*-===//
+//===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -51,10 +50,12 @@
 - (NSUInteger)state;
 - (BOOL)shutdownWithError:(NSError **)error;
 - (NSUUID *)UDID;
-- (pid_t)spawnWithPath:(NSString *)path
-   options:(NSDictionary *)options
-terminationHandler:(void (^)(int status))terminationHandler
- e

[Lldb-commits] [PATCH] D81978: Redo of Add terminateCommands to lldb-vscode protocol

2020-06-16 Thread António Afonso via Phabricator via lldb-commits
aadsm accepted this revision.
aadsm added a comment.
This revision is now accepted and ready to land.

Thank you for this! <3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81978



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