[Lldb-commits] [PATCH] D100503: [lldb] [client] Implement follow-fork-mode

2021-09-02 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski accepted this revision.
krytarowski added a comment.
This revision is now accepted and ready to land.

Looks good


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

https://reviews.llvm.org/D100503

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


[Lldb-commits] [lldb] e387c8c - [lldb server] Tidy up LLDB server return codes and associated tests

2021-09-02 Thread Raphael Isemann via lldb-commits

Author: Sebastian Schwartz
Date: 2021-09-02T11:16:37+02:00
New Revision: e387c8c413e2127bc93950fb6d786290237b4a9f

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

LOG: [lldb server] Tidy up LLDB server return codes and associated tests

This diff modifies the LLDB server return codes to more accurately reflect usage
error paths. Specifically we always propagate the return codes from the main
entrypoints into GDB remote LLDB server, and platform LLDB server. This way, the
top-level caller of LLDB server will be able to correctly check whether the
executable exited with or without an error.

We additionally modify and extend the associated shell unit tests to expect
nonzero return codes on error conditions.

Test Plan:
LLDB tests pass:

```
ninja check-lldb
```

Reviewed By: teemperor

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

Added: 


Modified: 
lldb/test/Shell/lldb-server/TestErrorMessages.test
lldb/test/Shell/lldb-server/TestGdbserverPort.test
lldb/tools/lldb-server/lldb-platform.cpp
lldb/tools/lldb-server/lldb-server.cpp

Removed: 




diff  --git a/lldb/test/Shell/lldb-server/TestErrorMessages.test 
b/lldb/test/Shell/lldb-server/TestErrorMessages.test
index b9689fb1e4673..799c65904f6b7 100644
--- a/lldb/test/Shell/lldb-server/TestErrorMessages.test
+++ b/lldb/test/Shell/lldb-server/TestErrorMessages.test
@@ -1,14 +1,26 @@
-RUN: %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
+RUN: not %lldb-server gdbserver --fd 2>&1 | FileCheck 
--check-prefixes=FD1,GDB_REMOTE_ALL %s
 FD1: error: --fd: missing argument
 
-RUN: %lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,ALL %s
+RUN: not %lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,GDB_REMOTE_ALL %s
 FD2: error: invalid '--fd' argument
 
-RUN: %lldb-server gdbserver --bogus 2>&1 | FileCheck 
--check-prefixes=BOGUS,ALL %s
+RUN: not %lldb-server gdbserver --bogus 2>&1 | FileCheck 
--check-prefixes=BOGUS,GDB_REMOTE_ALL %s
 BOGUS: error: unknown argument '--bogus'
 
-RUN: %lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
+RUN: not %lldb-server gdbserver 2>&1 | FileCheck 
--check-prefixes=CONN,GDB_REMOTE_ALL %s
 CONN: error: no connection arguments
 
-ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
+RUN: %lldb-server platform 2>&1 | FileCheck --check-prefixes=LLDB_PLATFORM_ALL 
%s
+
+RUN: %lldb-server platform --fd 2>&1 | FileCheck 
--check-prefixes=FD3,LLDB_PLATFORM_ALL %s
+FD3: lldb-server: unrecognized option `--fd'
+
+RUN: not %lldb-server platform --min-gdbserver-port 42 --max-gdbserver-port 43 
2>&1 | FileCheck --check-prefixes=PORT1,LLDB_PLATFORM_ALL %s
+PORT1: error: port number 42 is not in the valid user port range of 1024 - 
49152 
+
+RUN: %lldb-server version 2>&1 | FileCheck --check-prefixes=VERSION %s
+VERSION: lldb version
+
+GDB_REMOTE_ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
+LLDB_PLATFORM_ALL: lldb-server platform [--log-file log-file-name] 
[--log-channels log-channel-list] [--port-file port-file-path] --server 
--listen port 
 

diff  --git a/lldb/test/Shell/lldb-server/TestGdbserverPort.test 
b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
index 04facfec831ca..a3dd1af44f356 100644
--- a/lldb/test/Shell/lldb-server/TestGdbserverPort.test
+++ b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
@@ -1,4 +1,4 @@
 # Windows does not build lldb-server.
 # UNSUPPORTED: system-windows
-# RUN: %platformserver --server --listen :1234 --min-gdbserver-port 1234 
--max-gdbserver-port 1234 2>&1 | FileCheck %s
+# RUN: not %platformserver --server --listen :1234 --min-gdbserver-port 1234 
--max-gdbserver-port 1234 2>&1 | FileCheck %s
 # CHECK: error: --min-gdbserver-port (1234) is not lower than 
--max-gdbserver-port (1234)

diff  --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index d4b54362bb468..3cf8613786eca 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -92,7 +92,6 @@ static void display_usage(const char *progname, const char 
*subcommand) {
   "log-channel-list] [--port-file port-file-path] --server "
   "--listen port\n",
   progname, subcommand);
-  exit(0);
 }
 
 static Status save_socket_id_to_file(const std::string &socket_id,
@@ -165,7 +164,6 @@ int main_platform(int argc, char *argv[]) {
   FileSpec socket_file;
   bool show_usage = false;
   int option_error = 0;
-  int socket_error = -1;
 
   std::string 
short_options(OptionParser::GetShortOptionString(g_long_options));
 
@@ -249,7 +247,7 @@ int main_platform(int argc, char *argv[]) {
   }
 
   if (!LLDBServerUtilities::SetupLogging(log_file, log_channels,

[Lldb-commits] [PATCH] D108351: [lldb server] Tidy up LLDB server return codes and associated tests

2021-09-02 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe387c8c413e2: [lldb server] Tidy up LLDB server return codes 
and associated tests (authored by saschwartz, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108351

Files:
  lldb/test/Shell/lldb-server/TestErrorMessages.test
  lldb/test/Shell/lldb-server/TestGdbserverPort.test
  lldb/tools/lldb-server/lldb-platform.cpp
  lldb/tools/lldb-server/lldb-server.cpp

Index: lldb/tools/lldb-server/lldb-server.cpp
===
--- lldb/tools/lldb-server/lldb-server.cpp
+++ lldb/tools/lldb-server/lldb-server.cpp
@@ -11,6 +11,7 @@
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/ManagedStatic.h"
@@ -52,29 +53,30 @@
   llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);
   llvm::PrettyStackTraceProgram X(argc, argv);
 
-  int option_error = 0;
   const char *progname = argv[0];
   if (argc < 2) {
 display_usage(progname);
-exit(option_error);
+return 1;
   }
 
   switch (argv[1][0]) {
-  case 'g':
+  case 'g': {
 llgs::initialize();
-main_gdbserver(argc, argv);
-llgs::terminate_debugger();
-break;
-  case 'p':
+auto deinit = llvm::make_scope_exit([]() { llgs::terminate_debugger(); });
+return main_gdbserver(argc, argv);
+  }
+  case 'p': {
 llgs::initialize();
-main_platform(argc, argv);
-llgs::terminate_debugger();
-break;
-  case 'v':
+auto deinit = llvm::make_scope_exit([]() { llgs::terminate_debugger(); });
+return main_platform(argc, argv);
+  }
+  case 'v': {
 fprintf(stderr, "%s\n", lldb_private::GetVersion());
-break;
-  default:
+return 0;
+  }
+  default: {
 display_usage(progname);
-exit(option_error);
+return 1;
+  }
   }
 }
Index: lldb/tools/lldb-server/lldb-platform.cpp
===
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -92,7 +92,6 @@
   "log-channel-list] [--port-file port-file-path] --server "
   "--listen port\n",
   progname, subcommand);
-  exit(0);
 }
 
 static Status save_socket_id_to_file(const std::string &socket_id,
@@ -165,7 +164,6 @@
   FileSpec socket_file;
   bool show_usage = false;
   int option_error = 0;
-  int socket_error = -1;
 
   std::string short_options(OptionParser::GetShortOptionString(g_long_options));
 
@@ -249,7 +247,7 @@
   }
 
   if (!LLDBServerUtilities::SetupLogging(log_file, log_channels, 0))
-return -1;
+return 1;
 
   // Make a port map for a port range that was specified.
   if (min_gdbserver_port && min_gdbserver_port < max_gdbserver_port) {
@@ -269,7 +267,7 @@
 
   if (show_usage || option_error) {
 display_usage(progname, subcommand);
-exit(option_error);
+return option_error;
   }
 
   // Skip any options we consumed with getopt_long_only.
@@ -288,13 +286,13 @@
   listen_host_port, children_inherit_listen_socket, error));
   if (error.Fail()) {
 fprintf(stderr, "failed to create acceptor: %s", error.AsCString());
-exit(socket_error);
+return 1;
   }
 
   error = acceptor_up->Listen(backlog);
   if (error.Fail()) {
 printf("failed to listen: %s\n", error.AsCString());
-exit(socket_error);
+return 1;
   }
   if (socket_file) {
 error =
@@ -322,7 +320,7 @@
 error = acceptor_up->Accept(children_inherit_accept_socket, conn);
 if (error.Fail()) {
   WithColor::error() << error.AsCString() << '\n';
-  exit(socket_error);
+  return 1;
 }
 printf("Connection established.\n");
 if (g_server) {
Index: lldb/test/Shell/lldb-server/TestGdbserverPort.test
===
--- lldb/test/Shell/lldb-server/TestGdbserverPort.test
+++ lldb/test/Shell/lldb-server/TestGdbserverPort.test
@@ -1,4 +1,4 @@
 # Windows does not build lldb-server.
 # UNSUPPORTED: system-windows
-# RUN: %platformserver --server --listen :1234 --min-gdbserver-port 1234 --max-gdbserver-port 1234 2>&1 | FileCheck %s
+# RUN: not %platformserver --server --listen :1234 --min-gdbserver-port 1234 --max-gdbserver-port 1234 2>&1 | FileCheck %s
 # CHECK: error: --min-gdbserver-port (1234) is not lower than --max-gdbserver-port (1234)
Index: lldb/test/Shell/lldb-server/TestErrorMessages.test
===
--- lldb/test/Shell/lldb-server/TestErrorMessages.test
+++ lldb/test/Shell/lldb-server/TestErrorMessages.test
@@ -1,14 +1,26 @@
-RUN: %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
+RUN: not %lldb-server gdbserv

[Lldb-commits] [PATCH] D108953: [lldb/Plugins] Add memory region support in ScriptedProcess

2021-09-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 370216.
mib added a comment.

Add test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108953

Files:
  lldb/bindings/interface/SBMemoryRegionInfo.i
  lldb/bindings/interface/SBMemoryRegionInfoList.i
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_process/main.stack-dump
  lldb/examples/python/scripted_process/my_scripted_process.py
  lldb/include/lldb/API/SBMemoryRegionInfo.h
  lldb/include/lldb/API/SBMemoryRegionInfoList.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/source/API/SBMemoryRegionInfo.cpp
  lldb/source/API/SBMemoryRegionInfoList.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
  lldb/test/API/functionalities/scripted_process/main.c
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -166,6 +166,10 @@
   return nullptr;
 }
 
+extern "C" void *LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(void *data) {
+  return nullptr;
+}
+
 extern lldb::ValueObjectSP
 LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data) {
   return nullptr;
Index: lldb/test/API/functionalities/scripted_process/main.c
===
--- lldb/test/API/functionalities/scripted_process/main.c
+++ lldb/test/API/functionalities/scripted_process/main.c
@@ -1,5 +1,8 @@
-#include 
-
-int main() {
-  return 0; // break here
+int bar(int i) {
+  int j = i * i;
+  return j; // break here
 }
+
+int foo(int i) { return bar(i); }
+
+int main() { return foo(42); }
Index: lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
@@ -0,0 +1,90 @@
+import os,struct, signal
+
+from typing import Any, Dict
+
+import lldb
+from lldb.plugins.scripted_process import ScriptedProcess
+from lldb.plugins.scripted_process import ScriptedThread
+
+class DummyScriptedProcess(ScriptedProcess):
+def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
+super().__init__(target, args)
+
+def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
+return self.memory_regions[0]
+
+def get_thread_with_id(self, tid: int):
+return {}
+
+def get_registers_for_thread(self, tid: int):
+return {}
+
+def read_memory_at_address(self, addr: int, size: int) -> lldb.SBData:
+data = lldb.SBData().CreateDataFromCString(
+self.target.GetByteOrder(),
+self.target.GetCodeByteSize(),
+"Hello, world!")
+return data
+
+def get_loaded_images(self):
+return self.loaded_images
+
+def get_process_id(self) -> int:
+return 42
+
+def should_stop(self) -> bool:
+return True
+
+def is_alive(self) -> bool:
+return True
+
+def get_scripted_thread_plugin(self):
+return DummyScriptedThread.__module__ + "." + DummyScriptedThread.__name__
+
+
+class DummyScriptedThread(ScriptedThread):
+def __init__(self, target):
+super().__init__(target)
+
+def get_thread_id(self) -> int:
+return 0x19
+
+def get_name(self) -> str:
+return DummyScriptedThread.__name__ + ".thread-1"
+
+def get_state(self) -> int:
+return lldb.eStateStopped
+
+def get_stop_reason(self) -> Dict[str, Any]:
+return { "type": lldb.eStopReasonSignal, "data": {
+"signal": signal.SIGINT
+} }
+
+def get_stackframes(self):
+class ScriptedStackFrame:
+def __init__(idx, cfa, pc, symbol_ctx):
+self.idx = idx
+self.cfa = cfa
+self.pc = pc
+self.symbol_ctx = symbol_ctx
+
+
+symbol_ctx = lldb.SBSymbolContext()
+frame_zero = ScriptedStackFrame(0, 0x42424242, 0x500, symbol_ctx)
+self.frames.append(frame_zero)
+
+return self.frame_zero[0:0]
+
+def get_register_context(self) -> str:
+return struct.pack(
+'21Q', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17

[Lldb-commits] [lldb] 4a2a947 - [lldb] [client] Implement follow-fork-mode

2021-09-02 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-09-02T12:16:58+02:00
New Revision: 4a2a947317bf702178bf1af34dffd0d280d49970

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

LOG: [lldb] [client] Implement follow-fork-mode

Implement a new target.process.follow-fork-mode setting to control
LLDB's behavior on fork.  If set to 'parent', the forked child is
detached and parent continues being traced.  If set to 'child',
the parent is detached and child becomes traced instead.

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

Added: 
lldb/test/Shell/Subprocess/clone-follow-child-softbp.test
lldb/test/Shell/Subprocess/clone-follow-child-wp.test
lldb/test/Shell/Subprocess/clone-follow-child.test
lldb/test/Shell/Subprocess/fork-follow-child-softbp.test
lldb/test/Shell/Subprocess/fork-follow-child-wp.test
lldb/test/Shell/Subprocess/fork-follow-child.test
lldb/test/Shell/Subprocess/vfork-follow-child-softbp.test
lldb/test/Shell/Subprocess/vfork-follow-child-wp.test
lldb/test/Shell/Subprocess/vfork-follow-child.test

Modified: 
lldb/include/lldb/Target/Process.h
lldb/include/lldb/lldb-private-enumerations.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Target/Process.cpp
lldb/source/Target/TargetProperties.td
lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index b1f1d908c3581..a11c8cbf87ec9 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -99,6 +99,7 @@ class ProcessProperties : public Properties {
   bool GetOSPluginReportsAllThreads() const;
   void SetOSPluginReportsAllThreads(bool does_report);
   bool GetSteppingRunsAllThreads() const;
+  FollowForkMode GetFollowForkMode() const;
 
 protected:
   Process *m_process; // Can be nullptr for global ProcessProperties

diff  --git a/lldb/include/lldb/lldb-private-enumerations.h 
b/lldb/include/lldb/lldb-private-enumerations.h
index 7009d1b4fba78..9bbb889359b12 100644
--- a/lldb/include/lldb/lldb-private-enumerations.h
+++ b/lldb/include/lldb/lldb-private-enumerations.h
@@ -172,6 +172,12 @@ enum MemoryModuleLoadLevel {
   eMemoryModuleLoadLevelComplete, // Load sections and all symbols
 };
 
+// Behavior on fork/vfork
+enum FollowForkMode {
+  eFollowParent, // Follow parent process
+  eFollowChild,  // Follow child process
+};
+
 // Result enums for when reading multiple lines from IOHandlers
 enum class LineStatus {
   Success, // The line that was just edited if good and should be added to the

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 0ec972ec37d03..71177a0811b07 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5498,6 +5498,31 @@ void 
ProcessGDBRemote::DidForkSwitchSoftwareBreakpoints(bool enable) {
   });
 }
 
+void ProcessGDBRemote::DidForkSwitchHardwareTraps(bool enable) {
+  if (m_gdb_comm.SupportsGDBStoppointPacket(eBreakpointHardware)) {
+GetBreakpointSiteList().ForEach([this, enable](BreakpointSite *bp_site) {
+  if (bp_site->IsEnabled() &&
+  bp_site->GetType() == BreakpointSite::eHardware) {
+m_gdb_comm.SendGDBStoppointTypePacket(
+eBreakpointHardware, enable, bp_site->GetLoadAddress(),
+GetSoftwareBreakpointTrapOpcode(bp_site), GetInterruptTimeout());
+  }
+});
+  }
+
+  WatchpointList &wps = GetTarget().GetWatchpointList();
+  size_t wp_count = wps.GetSize();
+  for (size_t i = 0; i < wp_count; ++i) {
+WatchpointSP wp = wps.GetByIndex(i);
+if (wp->IsEnabled()) {
+  GDBStoppointType type = GetGDBStoppointType(wp.get());
+  m_gdb_comm.SendGDBStoppointTypePacket(type, enable, wp->GetLoadAddress(),
+wp->GetByteSize(),
+GetInterruptTimeout());
+}
+  }
+}
+
 void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
 
@@ -5506,30 +5531,58 @@ void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, 
lldb::tid_t child_tid) {
   // anyway.
   lldb::tid_t parent_tid = m_thread_ids.front();
 
-  if (m_gdb_comm.SupportsGDBStoppointPacket(eBreakpointSoftware)) {
-// Switch to the new process to clear breakpoints there.
-if (!m_gdb_comm.SetCurrentThread(child_tid, child_pid)) {
-  LLDB_LOG(log, "ProcessGDBRemote::DidFork() unable to set pid/tid");
-  return;
-}
+  lldb::pid_t follow_pid, deta

[Lldb-commits] [PATCH] D100503: [lldb] [client] Implement follow-fork-mode

2021-09-02 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a2a947317bf: [lldb] [client] Implement follow-fork-mode 
(authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D100503?vs=369949&id=370217#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100503

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/lldb-private-enumerations.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/Process.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/Shell/Subprocess/clone-follow-child-softbp.test
  lldb/test/Shell/Subprocess/clone-follow-child-wp.test
  lldb/test/Shell/Subprocess/clone-follow-child.test
  lldb/test/Shell/Subprocess/fork-follow-child-softbp.test
  lldb/test/Shell/Subprocess/fork-follow-child-wp.test
  lldb/test/Shell/Subprocess/fork-follow-child.test
  lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
  lldb/test/Shell/Subprocess/vfork-follow-child-softbp.test
  lldb/test/Shell/Subprocess/vfork-follow-child-wp.test
  lldb/test/Shell/Subprocess/vfork-follow-child.test

Index: lldb/test/Shell/Subprocess/vfork-follow-child.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/vfork-follow-child.test
@@ -0,0 +1,9 @@
+# REQUIRES: native
+# UNSUPPORTED: system-windows
+# RUN: %clangxx_host %p/Inputs/fork.cpp -DTEST_FORK=vfork -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+settings set target.process.follow-fork-mode child
+b parent_func
+process launch
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/vfork-follow-child-wp.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/vfork-follow-child-wp.test
@@ -0,0 +1,11 @@
+# REQUIRES: native && dbregs-set
+# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-darwin
+# RUN: %clangxx_host -g %p/Inputs/fork.cpp -DTEST_FORK=vfork -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+settings set target.process.follow-fork-mode child
+process launch -s
+watchpoint set variable -w write g_val
+# CHECK: Watchpoint created:
+continue
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/vfork-follow-child-softbp.test
===
--- lldb/test/Shell/Subprocess/vfork-follow-child-softbp.test
+++ lldb/test/Shell/Subprocess/vfork-follow-child-softbp.test
@@ -1,13 +1,10 @@
 # REQUIRES: native
-# UNSUPPORTED: system-darwin
 # UNSUPPORTED: system-windows
-# RUN: %clangxx_host %p/Inputs/fork.cpp -DTEST_FORK=fork -o %t
+# RUN: %clangxx_host %p/Inputs/fork.cpp -DTEST_FORK=vfork -o %t
 # RUN: %lldb -b -s %s %t | FileCheck %s
-b parent_func
+settings set target.process.follow-fork-mode child
 b child_func
+b parent_func
 process launch
-# CHECK-NOT: function run in parent
-# CHECK: stop reason = breakpoint
-continue
 # CHECK: function run in parent
 # CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/fork-follow-child.test
===
--- lldb/test/Shell/Subprocess/fork-follow-child.test
+++ lldb/test/Shell/Subprocess/fork-follow-child.test
@@ -1,13 +1,9 @@
 # REQUIRES: native
-# UNSUPPORTED: system-darwin
 # UNSUPPORTED: system-windows
 # RUN: %clangxx_host %p/Inputs/fork.cpp -DTEST_FORK=fork -o %t
 # RUN: %lldb -b -s %s %t | FileCheck %s
+settings set target.process.follow-fork-mode child
 b parent_func
-b child_func
 process launch
-# CHECK-NOT: function run in parent
-# CHECK: stop reason = breakpoint
-continue
 # CHECK: function run in parent
 # CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/fork-follow-child-wp.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/fork-follow-child-wp.test
@@ -0,0 +1,14 @@
+# REQUIRES: native && dbregs-set
+# UNSUPPORTED: system-windows
+# RUN: %clangxx_host -g %p/Inputs/fork.cpp -DTEST_FORK=fork -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+settings set target.process.follow-fork-mode child
+process launch -s
+watchpoint set variable -w write g_val
+# CHECK: Watchpoint created:
+continue
+# CHECK: stop reason = watchpoint
+continue
+# CHECK: stop reason = watchpoint
+continue
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
===
--- lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
+++ lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
@@ -8,6 +8,7 @@
 process launch
 # CHECK-NOT: function run in parent
 # CHECK: stop reason = breakpoint
+# CHECK-NEXT: parent_func
 continue
 # CHECK: function run in parent
 # CHECK: ch

[Lldb-commits] [PATCH] D108351: [lldb server] Tidy up LLDB server return codes and associated tests

2021-09-02 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

The new test is failing on all Linux buildbots such as:
lldb-x86_64-fedora = https://lab.llvm.org/staging/#/builders/16
lldb-x86_64-debian = https://lab.llvm.org/buildbot/#/builders/68
https://lab.llvm.org/buildbot/#/builders?tags=lldb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108351

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


[Lldb-commits] [lldb] bbcb4d6 - Revert "[lldb server] Tidy up LLDB server return codes and associated tests"

2021-09-02 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-09-02T15:27:39+02:00
New Revision: bbcb4d6bc0db612698ab8938ce209029cd8551e0

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

LOG: Revert "[lldb server] Tidy up LLDB server return codes and associated 
tests"

This reverts commit e387c8c413e2127bc93950fb6d786290237b4a9f. The
TestErrorMessages.test is failing on the Linux bots.

Added: 


Modified: 
lldb/test/Shell/lldb-server/TestErrorMessages.test
lldb/test/Shell/lldb-server/TestGdbserverPort.test
lldb/tools/lldb-server/lldb-platform.cpp
lldb/tools/lldb-server/lldb-server.cpp

Removed: 




diff  --git a/lldb/test/Shell/lldb-server/TestErrorMessages.test 
b/lldb/test/Shell/lldb-server/TestErrorMessages.test
index 799c65904f6b7..b9689fb1e4673 100644
--- a/lldb/test/Shell/lldb-server/TestErrorMessages.test
+++ b/lldb/test/Shell/lldb-server/TestErrorMessages.test
@@ -1,26 +1,14 @@
-RUN: not %lldb-server gdbserver --fd 2>&1 | FileCheck 
--check-prefixes=FD1,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
 FD1: error: --fd: missing argument
 
-RUN: not %lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver --fd three 2>&1 | FileCheck 
--check-prefixes=FD2,ALL %s
 FD2: error: invalid '--fd' argument
 
-RUN: not %lldb-server gdbserver --bogus 2>&1 | FileCheck 
--check-prefixes=BOGUS,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver --bogus 2>&1 | FileCheck 
--check-prefixes=BOGUS,ALL %s
 BOGUS: error: unknown argument '--bogus'
 
-RUN: not %lldb-server gdbserver 2>&1 | FileCheck 
--check-prefixes=CONN,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
 CONN: error: no connection arguments
 
-RUN: %lldb-server platform 2>&1 | FileCheck --check-prefixes=LLDB_PLATFORM_ALL 
%s
-
-RUN: %lldb-server platform --fd 2>&1 | FileCheck 
--check-prefixes=FD3,LLDB_PLATFORM_ALL %s
-FD3: lldb-server: unrecognized option `--fd'
-
-RUN: not %lldb-server platform --min-gdbserver-port 42 --max-gdbserver-port 43 
2>&1 | FileCheck --check-prefixes=PORT1,LLDB_PLATFORM_ALL %s
-PORT1: error: port number 42 is not in the valid user port range of 1024 - 
49152 
-
-RUN: %lldb-server version 2>&1 | FileCheck --check-prefixes=VERSION %s
-VERSION: lldb version
-
-GDB_REMOTE_ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
-LLDB_PLATFORM_ALL: lldb-server platform [--log-file log-file-name] 
[--log-channels log-channel-list] [--port-file port-file-path] --server 
--listen port 
+ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
 

diff  --git a/lldb/test/Shell/lldb-server/TestGdbserverPort.test 
b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
index a3dd1af44f356..04facfec831ca 100644
--- a/lldb/test/Shell/lldb-server/TestGdbserverPort.test
+++ b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
@@ -1,4 +1,4 @@
 # Windows does not build lldb-server.
 # UNSUPPORTED: system-windows
-# RUN: not %platformserver --server --listen :1234 --min-gdbserver-port 1234 
--max-gdbserver-port 1234 2>&1 | FileCheck %s
+# RUN: %platformserver --server --listen :1234 --min-gdbserver-port 1234 
--max-gdbserver-port 1234 2>&1 | FileCheck %s
 # CHECK: error: --min-gdbserver-port (1234) is not lower than 
--max-gdbserver-port (1234)

diff  --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 3cf8613786eca..d4b54362bb468 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -92,6 +92,7 @@ static void display_usage(const char *progname, const char 
*subcommand) {
   "log-channel-list] [--port-file port-file-path] --server "
   "--listen port\n",
   progname, subcommand);
+  exit(0);
 }
 
 static Status save_socket_id_to_file(const std::string &socket_id,
@@ -164,6 +165,7 @@ int main_platform(int argc, char *argv[]) {
   FileSpec socket_file;
   bool show_usage = false;
   int option_error = 0;
+  int socket_error = -1;
 
   std::string 
short_options(OptionParser::GetShortOptionString(g_long_options));
 
@@ -247,7 +249,7 @@ int main_platform(int argc, char *argv[]) {
   }
 
   if (!LLDBServerUtilities::SetupLogging(log_file, log_channels, 0))
-return 1;
+return -1;
 
   // Make a port map for a port range that was specified.
   if (min_gdbserver_port && min_gdbserver_port < max_gdbserver_port) {
@@ -267,7 +269,7 @@ int main_platform(int argc, char *argv[]) {
 
   if (show_usage || option_error) {
 display_usage(progname, subcommand);
-return option_error;
+exit(option_error);
   }
 
   // Skip any options we consumed with getopt_long_only.
@@ -286,13 +288,13 @@ int main_platform(int argc, char *ar

[Lldb-commits] [PATCH] D108351: [lldb server] Tidy up LLDB server return codes and associated tests

2021-09-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor reopened this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Thanks, reverted the commit.

@saschwartz Can you take a look at the failure?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108351

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


[Lldb-commits] [PATCH] D107521: [lldb/Plugins] Introduce Scripted Interface Factory

2021-09-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib marked 3 inline comments as done.
mib added inline comments.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp:80
 
-  return static_cast(*should_stop);
-}
-
-Status ScriptedProcessPythonInterface::Stop() {
-  return GetStatusFromMethod("stop");
-}
-
-Status ScriptedProcessPythonInterface::GetStatusFromMethod(
-llvm::StringRef method_name) {
-  Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
- Locker::FreeLock);
-
-  if (!m_object_instance_sp)
-return Status("Python object ill-formed.");
-
-  if (!m_object_instance_sp)
-return Status("Cannot convert Python object to StructuredData::Generic.");
-  PythonObject implementor(PyRefType::Borrowed,
-   (PyObject *)m_object_instance_sp->GetValue());
-
-  if (!implementor.IsAllocated())
-return Status("Python implementor not allocated.");
-
-  PythonObject pmeth(
-  PyRefType::Owned,
-  PyObject_GetAttrString(implementor.get(), method_name.str().c_str()));
-
-  if (PyErr_Occurred())
-PyErr_Clear();
-
-  if (!pmeth.IsAllocated())
-return Status("Python method not allocated.");
-
-  if (PyCallable_Check(pmeth.get()) == 0) {
-if (PyErr_Occurred())
-  PyErr_Clear();
-return Status("Python method not callable.");
-  }
-
-  if (PyErr_Occurred())
-PyErr_Clear();
-
-  PythonObject py_return(PyRefType::Owned,
- PyObject_CallMethod(implementor.get(),
- method_name.str().c_str(),
- nullptr));
-
-  if (PyErr_Occurred()) {
-PyErr_Print();
-PyErr_Clear();
-return Status("Python method could not be called.");
-  }
-
-  if (PyObject *py_ret_ptr = py_return.get()) {
-lldb::SBError *sb_error =
-(lldb::SBError *)LLDBSWIGPython_CastPyObjectToSBError(py_ret_ptr);
-
-if (!sb_error)
-  return Status("Couldn't cast lldb::SBError to lldb::Status.");
-
-Status status = m_interpreter.GetStatusFromSBError(*sb_error);
-
-if (status.Fail())
-  return Status("error: %s", status.AsCString());
-
-return status;
+  if (!obj || !obj->IsValid() || error.Fail()) {
+return error_with_message(llvm::Twine("Null or invalid object (" +

JDevlieghere wrote:
> jingham wrote:
> > It seems like we also do this bit every time we do Dispatch.  Maybe 
> > Dispatch could check the outgoing obj & obj->IsValid and if they aren't 
> > then it can put an appropriate message in the "error" object.  Then you 
> > would just have to check error.Fail().
> > 
> > That would also simplify the logging.   You could always dump the error's 
> > GetCString to your error_with_message.  Right now, you don't log the 
> > error's GetCString in the case where the object is valid, but error.Fail is 
> > true, which might end up dropping some useful info.
> I had a similar observation but I was thinking that Dispatch should return an 
> `Expected`. That way you can be more specific in 
> your error message too and differentiate between the object being null, 
> invalid or another error.
TBH, I don't see the added value of using `Expected` because I'll still need 
to check the expected object `!expected` which is the same as doing `!obj`. 

Also, regarding @jingham's suggestion, since `Dispatch`'s return type is 
templated, it is not guaranteed to have an `operator bool()` method (same with 
`IsValid()`) that's why the check is done after calling `Dispatch`, on a case 
by case basis.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h:111
+
+if (sizeof...(Args) > 0) {
+  FormatArgs(format_buffer, args...);

JDevlieghere wrote:
> FormatArgs has an overload for the no-args case so I don't think you need 
> this? 
I need it since `PyObject_CallMethod` expects a nullptr for the format string 
when the param pack is empty, not an empty string.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107521

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


[Lldb-commits] [PATCH] D107521: [lldb/Plugins] Introduce Scripted Interface Factory

2021-09-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 370258.
mib marked an inline comment as done.
mib added a comment.

Tighten to PythonInterpreter Lock.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107521

Files:
  lldb/bindings/interface/SBMemoryRegionInfo.i
  lldb/bindings/interface/SBMemoryRegionInfoList.i
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_process/main.stack-dump
  lldb/examples/python/scripted_process/my_scripted_process.py
  lldb/include/lldb/API/SBMemoryRegionInfo.h
  lldb/include/lldb/API/SBMemoryRegionInfoList.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Interpreter/ScriptedInterface.h
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/source/API/SBMemoryRegionInfo.cpp
  lldb/source/API/SBMemoryRegionInfoList.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
  lldb/test/API/functionalities/scripted_process/main.c
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
@@ -0,0 +1,38 @@
+//===-- ScriptedPythonInterface.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h"
+#include "lldb/lldb-enumerations.h"
+
+#if LLDB_ENABLE_PYTHON
+
+// LLDB Python header must be included first
+#include "lldb-python.h"
+
+#include "SWIGPythonBridge.h"
+#include "ScriptInterpreterPythonImpl.h"
+#include "ScriptedPythonInterface.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+ScriptedPythonInterface::ScriptedPythonInterface(
+ScriptInterpreterPythonImpl &interpreter)
+: ScriptedInterface(), m_interpreter(interpreter) {}
+
+Status
+ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) {
+  Status error;
+  Dispatch(method_name, error);
+
+  return error;
+}
+
+#endif
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -13,17 +13,18 @@
 
 #if LLDB_ENABLE_PYTHON
 
+#include "ScriptedPythonInterface.h"
 #include "lldb/Interpreter/ScriptedProcessInterface.h"
 
 namespace lldb_private {
-class ScriptInterpreterPythonImpl;
-class ScriptedProcessPythonInterface : public ScriptedProcessInterface {
+class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
+   public ScriptedPythonInterface {
 public:
-  ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter)
-  : ScriptedProcessInterface(), m_interpreter(interpreter) {}
+  ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter);
 
   StructuredData::GenericSP
-  CreatePluginObject(const llvm::StringRef class_name, lldb::TargetSP target_sp,
+  CreatePluginObject(const llvm::StringRef class_name,
+ ExecutionContext &exe_ctx,
  StructuredData::DictionarySP args_sp) override;
 
   Status Launch() override;
@@ -49,16 +50,6 @@
   lldb::pid_t GetProcessID() override;
 
   bool IsAlive() override;
-
-protected:
-  llvm::Optional
-  GetGenericInteger(llvm::StringRef method_name);
-  Status GetStatusFromMethod(llvm::StringRef method_name);
-
-private:
-  // The lifetime is managed by the ScriptInterpreter
-  ScriptInterpreterPythonImpl &m_interpreter;
-  StructuredData::GenericSP m_object_instance_sp;
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

[Lldb-commits] [PATCH] D108351: [lldb server] Tidy up LLDB server return codes and associated tests

2021-09-02 Thread Sebastian Schwartz via Phabricator via lldb-commits
saschwartz added a comment.

Yes, will take a look. I had `check-lldb` pass for the new tests locally 
previously - I'll rebase and rerun and see what happens.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108351

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


[Lldb-commits] [PATCH] D107585: [lldb/Plugins] Add support for ScriptedThread in ScriptedProcess

2021-09-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 370261.
mib added a comment.

Tighten PythonInterpreter Lock.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107585

Files:
  lldb/bindings/interface/SBMemoryRegionInfo.i
  lldb/bindings/interface/SBMemoryRegionInfoList.i
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_process/main.stack-dump
  lldb/examples/python/scripted_process/my_scripted_process.py
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/API/SBMemoryRegionInfo.h
  lldb/include/lldb/API/SBMemoryRegionInfoList.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/API/SBMemoryRegionInfo.cpp
  lldb/source/API/SBMemoryRegionInfoList.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/Process/scripted/CMakeLists.txt
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.h
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py
  lldb/test/API/functionalities/scripted_process/main.c
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
@@ -0,0 +1,49 @@
+//===-- ScriptedThreadPythonInterface.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H
+
+#include "lldb/Host/Config.h"
+
+#if LLDB_ENABLE_PYTHON
+
+#include "ScriptedPythonInterface.h"
+#include "lldb/Interpreter/ScriptedProcessInterface.h"
+
+namespace lldb_private {
+class ScriptedThreadPythonInterface : public ScriptedThreadInterface,
+  public ScriptedPythonInterface {
+public:
+  ScriptedThreadPythonInterface(ScriptInterpreterPythonImpl &interpreter);
+
+  StructuredData::GenericSP
+  CreatePluginObject(const llvm::StringRef class_name,
+ ExecutionContext &exe_ctx,
+ StructuredData::DictionarySP args_sp) override;
+
+  lldb::tid_t GetThreadID() override;
+
+  llvm::Optional GetName() override;
+
+  lldb::StateType GetState() override;
+
+  llvm::Optional GetQueue() override;
+
+  StructuredData::DictionarySP GetStopReason() override;
+
+  StructuredData::ArraySP GetStackFrames() override;
+
+  StructuredData::DictionarySP GetRegisterInfo() override;
+
+  llvm::Optional GetRegisterContext() override;
+};
+} // namespace lldb_private
+
+#endif // LLDB_ENABLE_PYTHON
+#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSTHREADINTERFACE_H
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
@@ -0,0 +1,205 @@
+//===-- ScriptedThreadPythonInterface.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Host/Config.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h"
+#include "lldb/lldb-enumerations.h"
+
+#if LLDB_ENABLE_PYTHON
+
+// LLDB Python header must be included first
+#include "lldb-python.h"
+
+#include "SWIGPythonBridge.h"
+#include "ScriptInterpreterPythonImpl.h"
+#include "ScriptedThreadPythonInterface.h"
+
+using namespace lldb;
+usin

[Lldb-commits] [lldb] 7f544f7 - Try to unbreak lldb build after 973519826edb76

2021-09-02 Thread Nico Weber via lldb-commits

Author: Nico Weber
Date: 2021-09-02T11:32:28-04:00
New Revision: 7f544f7658357045bde67c2f897a088558310f16

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

LOG: Try to unbreak lldb build after 973519826edb76

Added: 


Modified: 
lldb/include/lldb/Utility/Environment.h
lldb/source/Utility/Environment.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Environment.h 
b/lldb/include/lldb/Utility/Environment.h
index e2af2eb2463d7..24cbee246f83f 100644
--- a/lldb/include/lldb/Utility/Environment.h
+++ b/lldb/include/lldb/Utility/Environment.h
@@ -73,7 +73,7 @@ class Environment : private llvm::StringMap {
 return insert(std::make_pair(Split.first, std::string(Split.second)));
   }
 
-  void insert(const_iterator first, const_iterator last);
+  void insert(iterator first, iterator last);
 
   Envp getEnvp() const { return Envp(*this); }
 

diff  --git a/lldb/source/Utility/Environment.cpp 
b/lldb/source/Utility/Environment.cpp
index 5666c2c12ffdf..419e0745671a2 100644
--- a/lldb/source/Utility/Environment.cpp
+++ b/lldb/source/Utility/Environment.cpp
@@ -41,7 +41,7 @@ Environment::Environment(const char *const *Env) {
 insert(*Env++);
 }
 
-void Environment::insert(const_iterator first, const_iterator last) {
+void Environment::insert(iterator first, iterator last) {
   while (first != last) {
 try_emplace(first->first(), first->second);
 ++first;



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


[Lldb-commits] [PATCH] D107585: [lldb/Plugins] Add support for ScriptedThread in ScriptedProcess

2021-09-02 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Can you explain why we need the memory region? When we're using an SB class 
from the ScriptedProcess plugin, we need to be very careful to avoid 
introducing cyclic dependencies. The memory region seems like a pretty "dumb" 
class (i.e. it's basically just a few ivars with getters and setters) so it's 
probably fine, but we should have a comment explaining why it's fine.




Comment at: lldb/include/lldb/API/SBMemoryRegionInfo.h:133
 
-  lldb::MemoryRegionInfoUP m_opaque_up;
+  lldb::MemoryRegionInfoSP m_opaque_sp;
 };

Why is this necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107585

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


[Lldb-commits] [PATCH] D107585: [lldb/Plugins] Add support for ScriptedThread in ScriptedProcess

2021-09-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 370300.
mib added a comment.

Remove code related to `D108953`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107585

Files:
  lldb/bindings/python/python-wrapper.swig
  lldb/examples/python/scripted_process/my_scripted_process.py
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Plugins/Process/scripted/CMakeLists.txt
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/source/Plugins/Process/scripted/ScriptedThread.h
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
  lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -223,6 +223,12 @@
   return nullptr;
 }
 
+extern "C" void *LLDBSwigPythonCreateScriptedThread(
+const char *python_class_name, const char *session_dictionary_name,
+const lldb::TargetSP &target_sp, std::string &error_string) {
+  return nullptr;
+}
+
 extern "C" void *
 LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name,
  const char *session_dictionary_name) {
Index: lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
===
--- lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -72,6 +72,28 @@
 self.assertTrue(error.Success(), "Failed to read memory from scripted process.")
 self.assertEqual(hello_world, memory_read)
 
+self.assertEqual(process.GetNumThreads(), 1)
+
+thread = process.GetSelectedThread()
+self.assertTrue(thread, "Invalid thread.")
+self.assertEqual(thread.GetThreadID(), 0x19)
+self.assertEqual(thread.GetName(), "MyScriptedThread.thread-1")
+self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
+
+self.assertGreater(thread.GetNumFrames(), 0)
+
+frame = thread.GetFrameAtIndex(0)
+register_set = frame.registers # Returns an SBValueList.
+for regs in register_set:
+if 'GPR' in regs.name:
+registers  = regs
+break
+
+self.assertTrue(registers, "Invalid General Purpose Registers Set")
+self.assertEqual(registers.GetNumChildren(), 21)
+for idx, reg in enumerate(registers, start=1):
+self.assertEqual(idx, int(reg.value, 16))
+
 def test_launch_scripted_process_cli(self):
 """Test that we can launch an lldb scripted process from the command
 line, check its process ID and read string from memory."""
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
===
--- /dev/null
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h
@@ -0,0 +1,49 @@
+//===-- ScriptedThreadPythonInterface.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H
+#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H
+
+#include "lldb/Host/Config.h"
+
+#if LLDB_ENABLE_PYTHON
+
+#include "ScriptedPythonInterface.h"
+#include "lldb/Interpreter/ScriptedProcessInterface.h"
+
+namespace lldb_private {
+class ScriptedThreadPythonInterface : public ScriptedThreadInterface,
+  public ScriptedPythonInterface {
+public:
+  ScriptedThreadPythonInterface(ScriptInterpreterPythonImpl &interpreter);
+
+  StructuredData::GenericSP
+  CreatePluginObject(const llvm::StringRef class_name,
+ 

[Lldb-commits] [PATCH] D107585: [lldb/Plugins] Add support for ScriptedThread in ScriptedProcess

2021-09-02 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D107585#2979988 , @JDevlieghere 
wrote:

> Can you explain why we need the memory region? When we're using an SB class 
> from the ScriptedProcess plugin, we need to be very careful to avoid 
> introducing cyclic dependencies. The memory region seems like a pretty "dumb" 
> class (i.e. it's basically just a few ivars with getters and setters) so it's 
> probably fine, but we should have a comment explaining why it's fine.

I mistakenly merge the changes for this patch and D108953 
 on my previous diff ... Since your question 
is concerning that other patch, I'll follow-up there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107585

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


[Lldb-commits] [lldb] ebbf7f9 - Fix lldb after D108614

2021-09-02 Thread Arthur Eubanks via lldb-commits

Author: Arthur Eubanks
Date: 2021-09-02T12:58:41-07:00
New Revision: ebbf7f90b5529460bf5cc9dde3f35aa3ee6a6093

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

LOG: Fix lldb after D108614

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
index f51190e0c82cd..edfadc94debea 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -240,9 +240,9 @@ bool fixupRSAllocationStructByValCalls(llvm::Module 
&module) {
 for (unsigned I = call_attribs.index_begin(); I != 
call_attribs.index_end();
  I++) {
   // if this argument is passed by val
-  if (call_attribs.hasAttribute(I, llvm::Attribute::ByVal)) {
+  if (call_attribs.hasAttributeAtIndex(I, llvm::Attribute::ByVal)) {
 // strip away the byval attribute
-call_inst->removeAttribute(I, llvm::Attribute::ByVal);
+call_inst->removeAttributeAtIndex(I, llvm::Attribute::ByVal);
 changed = true;
   }
 }



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


[Lldb-commits] [PATCH] D108061: [lldb] Add support for shared library load when executable called through ld.

2021-09-02 Thread Rumeet Dhindsa via Phabricator via lldb-commits
rdhindsa added a comment.

Thank you for suggestion to try! 
After adding the assertions in memory region info trick, 3 testcases from only 
one test failed because of assertion : 
lldb/test/API/functionalities/load_unload/TestLoadUnload.py

test_lldb_process_load_and_unload_commands
test_load_unload
test_step_over_load

File path found for these test cases corresponds to the respective a.out files: 
 
lldb-test-build.noindex/functionalities/load_unload/TestLoadUnload.test_lldb_process_load_and_unload_commands/a.out
lldb-test-build.noindex/functionalities/load_unload/TestLoadUnload.test_load_unload/a.out
 
lldb-test-build.noindex/functionalities/load_unload/TestLoadUnload.test_step_over_load/a.out

So this test seems to be working as expected with the patch. It passes if I 
remove the assertions. However, I didn't find any other test failing due to 
assertions. Even the multithreaded test passes with assertions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108061

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


[Lldb-commits] [PATCH] D100503: [lldb] [client] Implement follow-fork-mode

2021-09-02 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

The new tests here fall for me on macOS:

  [4303/4304] Running lldb shell test suite
  llvm-lit: 
/Users/thakis/src/llvm-project/lldb/test/Shell/helper/toolchain.py:126: note: 
using SDKROOT: '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'
  llvm-lit: 
/Users/thakis/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: 
using clang: /Users/thakis/src/llvm-build-project/bin/clang
  llvm-lit: 
/Users/thakis/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: 
using ld.lld: /Users/thakis/src/llvm-build-project/bin/ld.lld
  llvm-lit: 
/Users/thakis/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: 
using lld-link: /Users/thakis/src/llvm-build-project/bin/lld-link
  llvm-lit: 
/Users/thakis/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: 
using ld64.lld: /Users/thakis/src/llvm-build-project/bin/ld64.lld
  llvm-lit: 
/Users/thakis/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: 
using wasm-ld: /Users/thakis/src/llvm-build-project/bin/wasm-ld
  llvm-lit: /Users/thakis/src/llvm-project/lldb/test/Shell/lit.cfg.py:98: 
warning: Could not set a default per-test timeout. Requires the Python psutil 
module but it could not be found. Try installing it via pip or via your 
operating system's package manager.
  FAIL: lldb-shell :: Subprocess/fork-follow-child.test (433 of 437)
   TEST 'lldb-shell :: Subprocess/fork-follow-child.test' 
FAILED 
  Script:
  --
  : 'RUN: at line 3';   /Users/thakis/src/llvm-build-project/bin/clang 
--driver-mode=g++ --target=specify-a-target-or-use-a-_host-substitution 
--target=x86_64-apple-darwin19.6.0 -isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk 
-fmodules-cache-path=/Users/thakis/src/llvm-build-project/lldb-test-build.noindex/module-cache-clang/lldb-shell
 /Users/thakis/src/llvm-project/lldb/test/Shell/Subprocess/Inputs/fork.cpp 
-DTEST_FORK=fork -o 
/Users/thakis/src/llvm-build-project/tools/lldb/test/Shell/Subprocess/Output/fork-follow-child.test.tmp
  : 'RUN: at line 4';   /Users/thakis/src/llvm-build-project/bin/lldb 
--no-lldbinit -S 
/Users/thakis/src/llvm-build-project/tools/lldb/test/Shell/lit-lldb-init -b -s 
/Users/thakis/src/llvm-project/lldb/test/Shell/Subprocess/fork-follow-child.test
 
/Users/thakis/src/llvm-build-project/tools/lldb/test/Shell/Subprocess/Output/fork-follow-child.test.tmp
 | /Users/thakis/src/llvm-build-project/bin/FileCheck 
/Users/thakis/src/llvm-project/lldb/test/Shell/Subprocess/fork-follow-child.test
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  clang-13: warning: argument unused during compilation: 
'-fmodules-cache-path=/Users/thakis/src/llvm-build-project/lldb-test-build.noindex/module-cache-clang/lldb-shell'
 [-Wunused-command-line-argument]
  
/Users/thakis/src/llvm-project/lldb/test/Shell/Subprocess/fork-follow-child.test:9:10:
 error: CHECK: expected string not found in input
  # CHECK: child exited: 0
   ^
  :26:69: note: scanning from here
   0x13cee <+14>: leaq 0x21b(%rip), %rdi ; "function run in parent\n"
  ^
  :27:115: note: possible intended match here
  Process 39485 launched: 
'/Users/thakis/src/llvm-build-project/tools/lldb/test/Shell/Subprocess/Output/fork-follow-child.test.tmp'
 (x86_64)

^
  
  Input file: 
  Check file: 
/Users/thakis/src/llvm-project/lldb/test/Shell/Subprocess/fork-follow-child.test
  
  -dump-input=help explains the following input dump.
  
  Input was:
  <<
 .
 .
 .
21:  frame #0: 0x00013ce0 
fork-follow-child.test.tmp`parent_func()
22: fork-follow-child.test.tmp`parent_func:
23: -> 0x13ce0 <+0>: pushq %rbp
24:  0x13ce1 <+1>: movq %rsp, %rbp
25:  0x13ce4 <+4>: movl $0x1, 0x434a(%rip) ; _dyld_private + 4
26:  0x13cee <+14>: leaq 0x21b(%rip), %rdi ; "function run in 
parent\n"
  check:9'0 
X~~~ error: no match found
27: Process 39485 launched: 
'/Users/thakis/src/llvm-build-project/tools/lldb/test/Shell/Subprocess/Output/fork-follow-child.test.tmp'
 (x86_64)
  check:9'0 
~~~
  check:9'1 
  ? 
possible intended match
  >>
  
  --
  
  
  FAIL: lldb-shell :: Subprocess/vfork-follow-child.test (434 of 437)
   TEST 'lldb-shell :: Subprocess/vfork-follow-child.test' 
FAILED 
  Script:
  --
  : 'RUN: at line 3'