summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/functionalities/command_script
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/command_script')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/.categories1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py142
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py73
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/main.c15
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/Makefile3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py31
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/main.cpp70
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/mysto.py23
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/py_import12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/command_script/welcome.py46
24 files changed, 495 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/.categories b/packages/Python/lldbsuite/test/functionalities/command_script/.categories
new file mode 100644
index 0000000..3a3f4df
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/.categories
@@ -0,0 +1 @@
+cmdline
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/Makefile b/packages/Python/lldbsuite/test/functionalities/command_script/Makefile
new file mode 100644
index 0000000..8a7102e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
new file mode 100644
index 0000000..542ee7a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
@@ -0,0 +1,142 @@
+"""
+Test lldb Python commands.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class CmdPythonTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test (self):
+ self.build ()
+ self.pycmd_tests ()
+
+ def pycmd_tests (self):
+ self.runCmd("command source py_import")
+
+ # Verify command that specifies eCommandRequiresTarget returns failure
+ # without a target.
+ self.expect('targetname',
+ substrs = ['a.out'], matching=False, error=True)
+
+ exe = os.path.join (os.getcwd(), "a.out")
+ self.expect("file " + exe,
+ patterns = [ "Current executable set to .*a.out" ])
+
+ self.expect('targetname',
+ substrs = ['a.out'], matching=True, error=False)
+
+ # This is the function to remove the custom commands in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('command script delete welcome', check=False)
+ self.runCmd('command script delete targetname', check=False)
+ self.runCmd('command script delete longwait', check=False)
+ self.runCmd('command script delete mysto', check=False)
+ self.runCmd('command script delete tell_sync', check=False)
+ self.runCmd('command script delete tell_async', check=False)
+ self.runCmd('command script delete tell_curr', check=False)
+ self.runCmd('command script delete bug11569', check=False)
+ self.runCmd('command script delete takes_exe_ctx', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ # Interact with debugger in synchronous mode
+ self.setAsync(False)
+
+ # We don't want to display the stdout if not in TraceOn() mode.
+ if not self.TraceOn():
+ self.HideStdout()
+
+ self.expect('welcome Enrico',
+ substrs = ['Hello Enrico, welcome to LLDB']);
+
+ self.expect("help welcome",
+ substrs = ['Just a docstring for welcome_impl',
+ 'A command that says hello to LLDB users'])
+
+ self.expect("help",
+ substrs = ['For more information run',
+ 'welcome'])
+
+ self.expect("help -a",
+ substrs = ['For more information run',
+ 'welcome'])
+
+ self.expect("help -u", matching=False,
+ substrs = ['For more information run'])
+
+ self.runCmd("command script delete welcome");
+
+ self.expect('welcome Enrico', matching=False, error=True,
+ substrs = ['Hello Enrico, welcome to LLDB']);
+
+ self.expect('targetname fail', error=True,
+ substrs = ['a test for error in command'])
+
+ self.expect('command script list',
+ substrs = ['targetname',
+ 'For more information run'])
+
+ self.expect("help targetname",
+ substrs = ['This', 'command', 'takes', '\'raw\'', 'input',
+ 'quote', 'stuff'])
+
+ self.expect("longwait",
+ substrs = ['Done; if you saw the delays I am doing OK'])
+
+ self.runCmd("b main")
+ self.runCmd("run")
+ self.runCmd("mysto 3")
+ self.expect("frame variable array",
+ substrs = ['[0] = 79630','[1] = 388785018','[2] = 0'])
+ self.runCmd("mysto 3")
+ self.expect("frame variable array",
+ substrs = ['[0] = 79630','[4] = 388785018','[5] = 0'])
+
+# we cannot use the stepover command to check for async execution mode since LLDB
+# seems to get confused when events start to queue up
+ self.expect("tell_sync",
+ substrs = ['running sync'])
+ self.expect("tell_async",
+ substrs = ['running async'])
+ self.expect("tell_curr",
+ substrs = ['I am running sync'])
+
+# check that the execution context is passed in to commands that ask for it
+ self.expect("takes_exe_ctx", substrs = ["a.out"])
+
+ # Test that a python command can redefine itself
+ self.expect('command script add -f foobar welcome -h "just some help"')
+
+ self.runCmd("command script clear")
+
+ # Test that re-defining an existing command works
+ self.runCmd('command script add my_command --class welcome.WelcomeCommand')
+ self.expect('my_command Blah', substrs = ['Hello Blah, welcome to LLDB'])
+
+ self.runCmd('command script add my_command --class welcome.TargetnameCommand')
+ self.expect('my_command', substrs = ['a.out'])
+
+ self.runCmd("command script clear")
+
+ self.expect('command script list', matching=False,
+ substrs = ['targetname',
+ 'longwait'])
+
+ self.expect('command script add -f foobar frame', error=True,
+ substrs = ['cannot add command'])
+
+ # http://llvm.org/bugs/show_bug.cgi?id=11569
+ # LLDBSwigPythonCallCommand crashes when a command script returns an object
+ self.runCmd('command script add -f bug11569 bug11569')
+ # This should not crash.
+ self.runCmd('bug11569', check=False)
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py b/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py
new file mode 100644
index 0000000..93897d8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py
@@ -0,0 +1,7 @@
+def bug11569(debugger, args, result, dict):
+ """
+ http://llvm.org/bugs/show_bug.cgi?id=11569
+ LLDBSwigPythonCallCommand crashes when a command script returns an object.
+ """
+ return ["return", "a", "non-string", "should", "not", "crash", "LLDB"];
+
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/Makefile b/packages/Python/lldbsuite/test/functionalities/command_script/import/Makefile
new file mode 100644
index 0000000..9374aef
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+EXE := hello_world
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py
new file mode 100644
index 0000000..691045a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py
@@ -0,0 +1,73 @@
+"""Test custom import command to import files by path."""
+
+from __future__ import print_function
+
+
+
+import os, sys, time
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class ImportTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_import_command(self):
+ """Import some Python scripts by path and test them"""
+ self.run_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def run_test(self):
+ """Import some Python scripts by path and test them."""
+
+ # This is the function to remove the custom commands in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('command script delete foo2cmd', check=False)
+ self.runCmd('command script delete foocmd', check=False)
+ self.runCmd('command script delete foobarcmd', check=False)
+ self.runCmd('command script delete barcmd', check=False)
+ self.runCmd('command script delete barothercmd', check=False)
+ self.runCmd('command script delete TPcommandA', check=False)
+ self.runCmd('command script delete TPcommandB', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("command script import ./foo/foo.py --allow-reload")
+ self.runCmd("command script import ./foo/foo2.py --allow-reload")
+ self.runCmd("command script import ./foo/bar/foobar.py --allow-reload")
+ self.runCmd("command script import ./bar/bar.py --allow-reload")
+
+ self.expect("command script import ./nosuchfile.py",
+ error=True, startstr='error: module importing failed')
+ self.expect("command script import ./nosuchfolder/",
+ error=True, startstr='error: module importing failed')
+ self.expect("command script import ./foo/foo.py", error=False)
+
+ self.runCmd("command script import --allow-reload ./thepackage")
+ self.expect("TPcommandA",substrs=["hello world A"])
+ self.expect("TPcommandB",substrs=["hello world B"])
+
+ self.runCmd("script import dummymodule")
+ self.expect("command script import ./dummymodule.py", error=False)
+ self.expect("command script import --allow-reload ./dummymodule.py", error=False)
+
+ self.runCmd("command script add -f foo.foo_function foocmd")
+ self.runCmd("command script add -f foobar.foo_function foobarcmd")
+ self.runCmd("command script add -f bar.bar_function barcmd")
+ self.expect("foocmd hello",
+ substrs = ['foo says', 'hello'])
+ self.expect("foo2cmd hello",
+ substrs = ['foo2 says', 'hello'])
+ self.expect("barcmd hello",
+ substrs = ['barutil says', 'bar told me', 'hello'])
+ self.expect("barothercmd hello",
+ substrs = ['barutil says', 'bar told me', 'hello'])
+ self.expect("foobarcmd hello",
+ substrs = ['foobar says', 'hello'])
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py
new file mode 100644
index 0000000..bbc41f3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py
@@ -0,0 +1,12 @@
+from __future__ import print_function
+
+def bar_function(debugger, args, result, dict):
+ global UtilityModule
+ print(UtilityModule.barutil_function("bar told me " + args), file=result)
+ return None
+
+def __lldb_init_module(debugger, session_dict):
+ global UtilityModule
+ UtilityModule = __import__("barutil")
+ debugger.HandleCommand("command script add -f bar.bar_function barothercmd")
+ return None \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py
new file mode 100644
index 0000000..0d3d2eb
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py
@@ -0,0 +1,2 @@
+def barutil_function(x):
+ return "barutil says: " + x
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py
new file mode 100644
index 0000000..dcc724e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py
@@ -0,0 +1,2 @@
+def no_useful_code(foo):
+ return foo
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py
new file mode 100644
index 0000000..659ded2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py
@@ -0,0 +1,5 @@
+from __future__ import print_function
+
+def foo_function(debugger, args, result, dict):
+ print("foobar says " + args, file=result)
+ return None
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py
new file mode 100644
index 0000000..51cc0c3
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py
@@ -0,0 +1,5 @@
+from __future__ import print_function
+
+def foo_function(debugger, args, result, dict):
+ print("foo says " + args, file=result)
+ return None
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py
new file mode 100644
index 0000000..6863454
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py
@@ -0,0 +1,9 @@
+from __future__ import print_function
+
+def foo2_function(debugger, args, result, dict):
+ print("foo2 says " + args, file=result)
+ return None
+
+def __lldb_init_module(debugger, session_dict):
+ debugger.HandleCommand("command script add -f foo2.foo2_function foo2cmd")
+ return None \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/main.c b/packages/Python/lldbsuite/test/functionalities/command_script/import/main.c
new file mode 100644
index 0000000..dffc8c7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/main.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main(int argc, char const *argv[]) {
+ printf("Hello world.\n"); // Set break point at this line.
+ if (argc == 1)
+ return 0;
+
+ // Waiting to be attached by the debugger, otherwise.
+ char line[100];
+ while (fgets(line, sizeof(line), stdin)) { // Waiting to be attached...
+ printf("input line=>%s\n", line);
+ }
+
+ printf("Exiting now\n");
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/Makefile b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/Makefile
new file mode 100644
index 0000000..7913aaa
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../../../make
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py
new file mode 100644
index 0000000..9800a08
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py
@@ -0,0 +1,31 @@
+"""Check that we handle an ImportError in a special way when command script importing files."""
+
+from __future__ import print_function
+
+
+
+import os, sys, time
+import lldb
+from lldbsuite.test.lldbtest import *
+
+class Rdar12586188TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_rdar12586188_command(self):
+ """Check that we handle an ImportError in a special way when command script importing files."""
+ self.run_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def run_test(self):
+ """Check that we handle an ImportError in a special way when command script importing files."""
+
+ self.expect("command script import ./fail12586188.py --allow-reload",
+ error=True, substrs = ['raise ImportError("I do not want to be imported")'])
+ self.expect("command script import ./fail212586188.py --allow-reload",
+ error=True, substrs = ['raise ValueError("I do not want to be imported")'])
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py
new file mode 100644
index 0000000..add85a7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py
@@ -0,0 +1,4 @@
+def f(x):
+ return x + 1
+
+raise ImportError("I do not want to be imported")
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py
new file mode 100644
index 0000000..1549a03
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py
@@ -0,0 +1,4 @@
+def f(x):
+ return x + 1
+
+raise ValueError("I do not want to be imported")
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py
new file mode 100644
index 0000000..fb65305
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py
@@ -0,0 +1,6 @@
+
+import six
+
+def command(debugger, command, result, internal_dict):
+ result.PutCString(six.u("hello world A"))
+ return None
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py
new file mode 100644
index 0000000..60b31b8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py
@@ -0,0 +1,6 @@
+
+import six
+
+def command(debugger, command, result, internal_dict):
+ result.PutCString(six.u("hello world B"))
+ return None
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py
new file mode 100644
index 0000000..faa4e3b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py
@@ -0,0 +1,6 @@
+import TPunitA
+import TPunitB
+
+def __lldb_init_module(debugger,*args):
+ debugger.HandleCommand("command script add -f thepackage.TPunitA.command TPcommandA")
+ debugger.HandleCommand("command script add -f thepackage.TPunitB.command TPcommandB")
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/main.cpp b/packages/Python/lldbsuite/test/functionalities/command_script/main.cpp
new file mode 100644
index 0000000..0b24cb7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/main.cpp
@@ -0,0 +1,70 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <fstream>
+#include <iostream>
+
+int
+product (int x, int y)
+{
+ int result = x * y;
+ return result;
+}
+
+int
+sum (int a, int b)
+{
+ int result = a + b;
+ return result;
+}
+
+int
+strange_max (int m, int n)
+{
+ if (m > n)
+ return m;
+ else if (n > m)
+ return n;
+ else
+ return 0;
+}
+
+int
+foo (int i, int j)
+{
+ if (strange_max (i, j) == i)
+ return product (i, j);
+ else if (strange_max (i, j) == j)
+ return sum (i, j);
+ else
+ return product (sum (i, i), sum (j, j));
+}
+
+int
+main(int argc, char const *argv[])
+{
+
+ int array[9];
+ memset(array,0,9*sizeof(int));
+
+ array[0] = foo (1238, 78392);
+ array[1] = foo (379265, 23674);
+ array[2] = foo (872934, 234);
+ array[3] = foo (1238, 78392);
+ array[4] = foo (379265, 23674);
+ array[5] = foo (872934, 234);
+ array[6] = foo (1238, 78392);
+ array[7] = foo (379265, 23674);
+ array[8] = foo (872934, 234);
+
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py b/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py
new file mode 100644
index 0000000..656cd15
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py
@@ -0,0 +1,23 @@
+from __future__ import print_function
+
+import lldb
+import sys
+import os
+import time
+
+def StepOver(debugger, args, result, dict):
+ """
+ Step over a given number of times instead of only just once
+ """
+ arg_split = args.split(" ")
+ print(type(arg_split))
+ count = int(arg_split[0])
+ for i in range(0,count):
+ debugger.GetSelectedTarget().GetProcess().GetSelectedThread().StepOver(lldb.eOnlyThisThread)
+ print("step<%d>"%i)
+
+def __lldb_init_module(debugger, session_dict):
+ # by default, --synchronicity is set to synchronous
+ debugger.HandleCommand("command script add -f mysto.StepOver mysto")
+ return None
+
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/py_import b/packages/Python/lldbsuite/test/functionalities/command_script/py_import
new file mode 100644
index 0000000..169daac
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/py_import
@@ -0,0 +1,12 @@
+script import sys, os
+script sys.path.append(os.path.join(os.getcwd(), os.pardir))
+script import welcome
+script import bug11569
+command script add welcome --class welcome.WelcomeCommand
+command script add targetname --class welcome.TargetnameCommand
+command script add longwait --function welcome.print_wait_impl
+command script import mysto.py --allow-reload
+command script add tell_sync --function welcome.check_for_synchro --synchronicity sync
+command script add tell_async --function welcome.check_for_synchro --synchronicity async
+command script add tell_curr --function welcome.check_for_synchro --synchronicity curr
+command script add takes_exe_ctx --function welcome.takes_exe_ctx
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py b/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py
new file mode 100644
index 0000000..5dbf09f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py
@@ -0,0 +1,46 @@
+from __future__ import print_function
+import lldb, sys
+
+class WelcomeCommand(object):
+ def __init__(self, debugger, session_dict):
+ pass
+
+ def get_short_help(self):
+ return "Just a docstring for welcome_impl\nA command that says hello to LLDB users"
+
+ def __call__(self, debugger, args, exe_ctx, result):
+ print('Hello ' + args + ', welcome to LLDB', file=result);
+ return None;
+
+class TargetnameCommand(object):
+ def __init__(self, debugger, session_dict):
+ pass
+
+ def __call__(self, debugger, args, exe_ctx, result):
+ target = debugger.GetSelectedTarget()
+ file = target.GetExecutable()
+ print('Current target ' + file.GetFilename(), file=result)
+ if args == 'fail':
+ result.SetError('a test for error in command')
+
+ def get_flags(self):
+ return lldb.eCommandRequiresTarget
+
+def print_wait_impl(debugger, args, result, dict):
+ result.SetImmediateOutputFile(sys.stdout)
+ print('Trying to do long task..', file=result)
+ import time
+ time.sleep(1)
+ print('Still doing long task..', file=result)
+ time.sleep(1)
+ print('Done; if you saw the delays I am doing OK', file=result)
+
+def check_for_synchro(debugger, args, result, dict):
+ if debugger.GetAsync() == True:
+ print('I am running async', file=result)
+ if debugger.GetAsync() == False:
+ print('I am running sync', file=result)
+
+def takes_exe_ctx(debugger, args, exe_ctx, result, dict):
+ print(str(exe_ctx.GetTarget()), file=result)
+
OpenPOWER on IntegriCloud