Commit Graph

192 Commits

Author SHA1 Message Date
Johnny Chen 9c48b8d79c Added a subtest to exercise the capability of lldb Python objects to print
themselves.  Right now, it tests a breakpoint both before and after it has been
resolved.

Updated lldbtest.TestBase.expect() with an additional keyword argument 'exe' (
default to True), which if set to False, will treat the mandatory first argument
as just the string to be matched/or not-matched against the golden input.

llvm-svn: 114501
2010-09-21 23:33:30 +00:00
Johnny Chen 90312a8492 Wrapped the subclass-specific cleanup call within a try:except: clause.
And removed the informational output from the conditional_break test case.

llvm-svn: 114493
2010-09-21 22:34:45 +00:00
Johnny Chen ea88e94318 Added a more complex test case of breakpoint commands, which executes a sequence
of 'breakpoint command add/list/remove' commands to set breakpoint callbacks,
list them, and then remove one.

Modified the lldbtest.TestBase.expect() method to add two additional keyword
arguments:

o matching (default to True), which, if set to False, reverses the semantics of
  'expect' to 'expect not'

o patterns (default to None), which specifies a list of regexp patterns to match
  against the output from running the command

TestBreakpointCommand.py uses the matching=False and the patterns=[...] expect()
API.

llvm-svn: 114480
2010-09-21 21:08:53 +00:00
Johnny Chen 2989bfa88b Decorated PersistentVariablesTestCase.test_persistent_variables() with
@expectedFailure as of r114384.

llvm-svn: 114466
2010-09-21 19:12:39 +00:00
Johnny Chen 958da040e4 Changed the order of two assignment stmts.
llvm-svn: 114381
2010-09-21 00:16:09 +00:00
Johnny Chen 209cdbef64 Added the capability to source the configFile specified via the "-c" option in
order to customize the running of the test suite.  For the time being, the
supported customizations are:

o redirecting stdout and/or stderr
o specifying a list of compilers to build the test programs
o specifying a list of architectures to build the test programs for

Also checked into the examples/test directory some example files which
demonstrate the usage for the above customizations.

$ ./dotest.py -v -c ~/.lldbtest-config persistent_variables
$ cat ~/.lldbtest-config
sys.stderr = open("/tmp/lldbtest-stderr", "w")
sys.stdout = open("/tmp/lldbtest-stdout", "w")
compilers = ["gcc", "llvm-gcc"]
archs = ["x86_64", "i386"]
$ cat /tmp/lldbtest-stderr
----------------------------------------------------------------------
Collected 1 test


Configuration: arch=x86_64 compiler=gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.397s

OK

Configuration: arch=x86_64 compiler=llvm-gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.282s

OK

Configuration: arch=i386 compiler=gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.297s

OK

Configuration: arch=i386 compiler=llvm-gcc
test_persistent_variables (TestPersistentVariables.PersistentVariablesTestCase)
Test that lldb persistent variables works correctly. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.269s

OK
$ cat /tmp/lldbtest-stdout
$ 

llvm-svn: 114380
2010-09-21 00:09:27 +00:00
Johnny Chen dba0a0fbef Changed this breakpoint callback function to print to the stdout instead of
stderr so as not to disrupt the information emitted by the unittest framework.

llvm-svn: 114377
2010-09-20 23:51:27 +00:00
Caroline Tice daccaa9e83 Add UserSettings to Target class, making Target settings
the parent of Process settings;   add 'default-arch' as a
class-wide setting for Target.    Replace            lldb::GetDefaultArchitecture
with Target::GetDefaultArchitecture & Target::SetDefaultArchitecture.

Add 'use-external-editor' as user setting to Debugger class & update
code appropriately.

Add Error parameter to methods that get user settings, for easier
reporting of bad requests.

Fix various other minor related bugs.

Fix test cases to work with new changes.

llvm-svn: 114352
2010-09-20 20:44:43 +00:00
Johnny Chen daebb6d805 More modularizations.
llvm-svn: 114333
2010-09-20 18:07:50 +00:00
Johnny Chen a4b9aa0538 Added comments.
llvm-svn: 114332
2010-09-20 17:25:45 +00:00
Johnny Chen ea9fc18163 Fixed lldb 'settings set term-widt 70' command not working.
rdar://problem/8449849

llvm-svn: 114328
2010-09-20 16:36:43 +00:00
Johnny Chen 8409284a32 Added @expectedFailure decorator for test_set_term_width().
llvm-svn: 114307
2010-09-19 02:47:18 +00:00
Johnny Chen dd4da82c92 Removed the @expectedFailure decorators; it was fixed with r114258.
llvm-svn: 114305
2010-09-19 02:31:53 +00:00
Johnny Chen 49b415de1f Added a hook for the test driver to take an optional config file to customize
the running of the test suite.  Right now, it doesn't do anything with the
config file.

Pass "-c myConfigFile" to specify the config file.

llvm-svn: 114245
2010-09-18 00:16:47 +00:00
Johnny Chen aa90292126 Fixed a typo and supplied a more appropriate assert message.
llvm-svn: 114232
2010-09-17 22:45:27 +00:00
Johnny Chen b330786d1f Added test cases to FoundationTestCase to exercise lookup of objc data types and
to evaluate expressions.  Marked with @expectedFailure decorators for the time
being.

Enhanced the lldbtest.TestBase.expect() API to allow an additional keyword arg
named "error".  If the client passes "error=True", it signifies that an error
while running the command is expected.  The golden input is then compared
against the return object's error output.

llvm-svn: 114228
2010-09-17 22:28:51 +00:00
Johnny Chen b219d281b0 Changed test case method names.
llvm-svn: 114210
2010-09-17 21:14:02 +00:00
Johnny Chen 2756d60563 Added extra test scenarios to break on a selector with:
(lldb) breakpoint set -S description

and a compilation unit defined instance method with:

(lldb) breakpoint set -n '-[MyString initWithNSString:]'

llvm-svn: 114134
2010-09-16 23:57:33 +00:00
Johnny Chen ce65073696 Fixed wrong doc strings from cut-and-paste.
llvm-svn: 114120
2010-09-16 21:01:39 +00:00
Johnny Chen 6c17c0807e Added a simple test case to set breakpoints on objc class/instance methods.
Modified Makefile.rules to allow for overwriting the ARCH make variable.

llvm-svn: 114118
2010-09-16 20:54:06 +00:00
Johnny Chen 2fcc0e5555 Added a test case for the settings command which sets process.output-path and
checks that the launched process writes its standard output there.

llvm-svn: 114102
2010-09-16 18:26:06 +00:00
Johnny Chen df80a4cf25 Cleaned up the option processing logic and added a '-i' option to ignore the
build tree relative search path in order to locate the lldb.py module.  When
'-i' is present, the test driver relies on the PYTHONPATH environment variable
to locate the lldb.py module.

llvm-svn: 114094
2010-09-16 17:11:30 +00:00
Johnny Chen e9a1ef700b Added some comments.
llvm-svn: 114081
2010-09-16 15:44:23 +00:00
Johnny Chen 1a9f4dd5a0 Provided a mechanism for the test class to cleanup after itself once it's done.
This will remove the confusion experienced when previous test runs left some
files (both intermediate or by-product as a result of the test).

lldbtest.TestBase defines a classmethod tearDownClass(cls) which invokes the
platform-specific cleanup() function as defined by the plugin; after that, it
invokes a subclass-specific function classCleanup(cls) if defined; and, finally,
it restores the old working directory.

An example of classCleanup(cls) is in settings/TestSettings.py:

    @classmethod
    def classCleanup(cls):
        system(["/bin/sh", "-c", "rm output.txt"])

where it deletes the by-product "output.txt" as a result of running a.out.

llvm-svn: 114058
2010-09-16 01:53:04 +00:00
Johnny Chen f7f627104b Simplied main() and emits a message to the standard out.
llvm-svn: 114033
2010-09-15 22:48:40 +00:00
Johnny Chen d5e111c2c1 Added two test cases to TestSettings.py which exercise the lldb's:
(lldb) settings set process.run-args A B C
(lldb) settings set process.env-vars ["MY_ENV_VAR"]=YES

commands.  The main.cpp checks whether A, B, C is passed to main and whether
the $MY_ENV_VAR env variable is defined and outputs the findings to a file.

llvm-svn: 114031
2010-09-15 22:27:29 +00:00
Johnny Chen 73982b94e3 Also added BuildAndIntegration to the directories to search for an existing
lldb.py module.  The priorities to search for are Debug, Release, then
BuildAndIntegration.  You can always override this with a valid PYTHONPATH
environment variable before running the test driver.

For example:

$ PYTHONPATH=/Find/My/LLDB/Module/Here ./dotest.py -v .

Python runtime will try to locate the lldb.py module from
/Find/My/LLDB/Module/Here first before trying the Debug, Release, and then
BuildAndIntegration directories.

llvm-svn: 113991
2010-09-15 18:11:19 +00:00
Johnny Chen 9fa032173a Changed to a more informative message.
llvm-svn: 113989
2010-09-15 18:00:19 +00:00
Johnny Chen f7f0cabe9f We believed the intermittent process launch failure while running the test suite
has been fixed by r113947.  But just in case it still fails, emits a prominent
message always.

llvm-svn: 113986
2010-09-15 17:33:57 +00:00
Johnny Chen bce48fb06f Removed the @expectedFailure decorator for test_with_dwarf() test case. It has
been fixed.

llvm-svn: 113981
2010-09-15 16:59:20 +00:00
Johnny Chen 93f336a203 Fixed typo in the doc strings.
llvm-svn: 113906
2010-09-15 00:02:30 +00:00
Johnny Chen ae74556ff6 Added two test cases to exercise 'expr this->m_c_int' with @expectedFailure
decorators for the time being.

llvm-svn: 113905
2010-09-15 00:00:54 +00:00
Johnny Chen 32a7044a84 Updated to add a printf() stmt.
llvm-svn: 113901
2010-09-14 23:49:44 +00:00
Johnny Chen 1d8ab8a26b Test order file with both dsym and dwarf combination.
llvm-svn: 113884
2010-09-14 22:55:48 +00:00
Johnny Chen 6c3f6862cc Need to call self.buildDefault() before running the test logic.
llvm-svn: 113881
2010-09-14 22:50:50 +00:00
Johnny Chen e049051e68 More appropriate headings for the traceoutput: stdout & stderr.
llvm-svn: 113879
2010-09-14 22:39:02 +00:00
Johnny Chen 1aad5c61f8 Removed the expectedFailure decorator from test_with_dwarf_and_run_command() test case
as it now passes.  Added some extra tests to breakpoint_creation_by_filespec_python().

More clarification for the "os command" output and error as defined in
lldbtest.system() function.

Cleaned up the option processing of the test driver (dotest.py) and fixed the comment
about enabling gdb-remote logging.  Example:

$ GDB_REMOTE_LOG=/tmp/log.txt ./dotest.py -v -t enum_types

llvm-svn: 113868
2010-09-14 22:01:40 +00:00
Johnny Chen c13ee52c2f Fixed an error in Debugger::UpdateExecutionContext() where an invalid index ID 0
was used to set the selected thread if none was selected.  Use a more robust
API to accomplish the task.

Also fixed an error found, while investigating, in CommandObjectThreadSelect::
Execute() where the return status was not properly set if successful.

As a result, both the stl step-in test cases with expectedFailure decorators now
passed.

llvm-svn: 113825
2010-09-14 00:53:53 +00:00
Johnny Chen 1394a4b715 Extend the build mechanism to allow for specifying the compiler used to build
the binaries.

If the build* function is passed the compiler argument, for example, 'llvm-gcc',
it is passed as a make variable to the make command.  Otherwise, we check the
LLDB_CC environment variable; if it is defined, it is passed as a make variable
to the make command.

If neither the compiler keyword argument nor the LLDB_CC environment variable is
specified, no CC make variable is passed to the make command.  The Makefile gets
to define the default CC being used.

--------------------------------------------------------------------------------
Example usage follows:

o Via the keyword argument:

class ArrayTypesTestCase(TestBase):

    mydir = "array_types"

    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    def test_with_dsym_and_run_command(self):
        """Test 'frame variable var_name' on some variables with array types."""
        self.buildDsym(compiler='llvm-gcc')
        self.array_types()
...

o Via LLDB_CC environment variable:

$ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types
----------------------------------------------------------------------
Collected 4 tests

test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... 
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']]
output: rm -rf "a.out" "a.out.dSYM"  main.o main.d
llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0  -c -o main.o main.c
llvm-gcc -arch x86_64 -gdwarf-2 -O0  main.o -o "a.out"
/usr/bin/dsymutil  -o "a.out.dSYM" "a.out"

...

llvm-svn: 113781
2010-09-13 20:54:30 +00:00
Johnny Chen 9440d1c008 Updated the expected matching strings.
llvm-svn: 113756
2010-09-13 16:59:11 +00:00
Johnny Chen 661f8069c7 Updated the expected matching strings.
llvm-svn: 113755
2010-09-13 16:45:59 +00:00
Johnny Chen 8458405a36 Updated the expected matching strings, and added a radar comment.
llvm-svn: 113753
2010-09-13 16:31:46 +00:00
Johnny Chen e00234e0c7 Updated the expected matching strings.
llvm-svn: 113751
2010-09-13 16:19:09 +00:00
Johnny Chen eb1b8dabc0 Removed the two expectedFailure decorators from the test cases. They have been fixed.
llvm-svn: 113750
2010-09-13 16:14:55 +00:00
Johnny Chen 9aae728ef6 Updated the expected matching string after the recent flurry of check ins.
llvm-svn: 113748
2010-09-13 16:06:19 +00:00
Greg Clayton 0c5550a998 A few modifications to the class arrays test case.
llvm-svn: 113732
2010-09-13 02:31:18 +00:00
Greg Clayton ac32b4ddc0 I made this example after noting that I was unable to display an unsized
static class array. It turns out that gcc 4.2 will emit DWARF that correctly
describes the PointType, but it will incorrectly emit debug info for the
"g_points" array where the following things are wrong:
 - the DW_TAG_array_type won't have a subrange info
 - the DW_TAG_variable for "g_points" won't have a valid byte size, so even
   though we know the size of PointType, we can't infer the actual size
   of the array by dividing the size of the variable by the number of
   elements.

We want to make sure clang and llvm-gcc handle this correctly.

llvm-svn: 113730
2010-09-13 00:50:27 +00:00
Johnny Chen 39d7d4f056 Added [-o <one-liner>] to the "breakpoint command add" lldb command to be able
to specify a one-liner (either scripting or lldb command) inline.

Refactored CommandObjectBreakpointCommandAdd::Execute() a little bit and added
some comments.

Sn now, we use:

breakpoint command add -p 1 -o "conditional_break.stop_if_called_from_a()"

to specify a Python one-liner as the callback for breakpoint #1.

llvm-svn: 113672
2010-09-11 00:18:09 +00:00
Johnny Chen bc1857ba36 These two files should have been in r113596. Oops!
llvm-svn: 113598
2010-09-10 18:28:27 +00:00
Johnny Chen 94de55d5c2 Added the capability to specify a one-liner Python script as the callback
command for a breakpoint, for example:

(lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()"

The ScriptInterpreter interface has an extra method:

    /// Set a one-liner as the callback for the breakpoint command.
    virtual void 
    SetBreakpointCommandCallback (CommandInterpreter &interpreter,
                                  BreakpointOptions *bp_options,
                                  const char *oneliner);

to accomplish the above.

Also added a test case to demonstrate lldb's use of breakpoint callback command
to stop at function c() only when its immediate caller is function a().  The
following session shows the user entering the following commands:

1) command source .lldb (set up executable, breakpoint, and breakpoint command)
2) run (the callback mechanism will skip two breakpoints where c()'s immeidate caller is not a())
3) bt (to see that indeed c()'s immediate caller is a())
4) c (to continue and finish the program)

test/conditional_break $ ../../build/Debug/lldb
(lldb) command source .lldb
Executing commands in '.lldb'.
(lldb) file a.out
Current executable set to 'a.out' (x86_64).
(lldb) breakpoint set -n c
Breakpoint created: 1: name = 'c', locations = 1
(lldb) script import sys, os
(lldb) script sys.path.append(os.path.join(os.getcwd(), os.pardir))
(lldb) script import conditional_break
(lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()"
(lldb) run
run
Launching '/Volumes/data/lldb/svn/trunk/test/conditional_break/a.out'  (x86_64)
(lldb) Checking call frames...
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`a at main.c:25
  frame #3: a.out`main at main.c:44
  frame #4: a.out`start
c called from b
Continuing...
Checking call frames...
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`b at main.c:34
  frame #2: a.out`main at main.c:47
  frame #3: a.out`start
c called from b
Continuing...
Checking call frames...
Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread:
  frame #0: a.out`c at main.c:39
  frame #1: a.out`a at main.c:27
  frame #2: a.out`main at main.c:50
  frame #3: a.out`start
c called from a
Stopped at c() with immediate caller as a().
a(1) returns 4
b(2) returns 5
Process 20420 Stopped
* thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread
  36   	
  37   	int c(int val)
  38   	{
  39 ->	    return val + 3;
  40   	}
  41   	
  42   	int main (int argc, char const *argv[])
(lldb) bt
bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
  frame #0: 0x0000000100000de8 a.out`c + 7 at main.c:39
  frame #1: 0x0000000100000dbc a.out`a + 44 at main.c:27
  frame #2: 0x0000000100000e4b a.out`main + 91 at main.c:50
  frame #3: 0x0000000100000d88 a.out`start + 52
(lldb) c
c
Resuming process 20420
Process 20420 Exited
a(3) returns 6
(lldb) 

llvm-svn: 113596
2010-09-10 18:21:10 +00:00