Commit Graph

876 Commits

Author SHA1 Message Date
Johnny Chen cd9b7779f3 Avoid using hardcoded line number to break on. Use the line_number() utility
function to get the line number to break on during setUp().

llvm-svn: 116275
2010-10-12 00:09:25 +00:00
Jim Ingham 30f9b21bf4 Add a way to temporarily divert events from a broadcaster to a private listener.
llvm-svn: 116271
2010-10-11 23:53:14 +00:00
Johnny Chen 47ceb03210 Add a utility function to lldbtest.py to return the line number of a matched string
within a file.  This is to be used within the test case to avoid hardcoded line number.

array_types/TestArrayTypes.py is modified first to use this pattern.  Other test modules
to follow.

rdar://problem/8537816
Testsuite: don't set breakpoints by exact file & line number

llvm-svn: 116270
2010-10-11 23:52:19 +00:00
Johnny Chen 707b3c9c73 Added the capability for the test driver to relocate the tests and the intermediate
files to a different top level directory than those specified on the command line.

When relocated, the test clanups normally performed afterwards after each test method
and after each test class will not be exercised at all.  This allows for an easier
postmortem analysis of test failures.

Example:

./dotest.py -v -t -r /tmp/lldbtest types

will create a /tmp/lldbtest directory which houses the types directory and its supported
files.

Files modified:

o dotest.py, lldbtest.py:

  Add logic to process '-r dir' option to support relocating the tests to a different
  top level directory instead of exected in place.

o darwin.py, test/types/Makefile:

  The 'make clean' should only clean the minimum .o and .d files.

llvm-svn: 116255
2010-10-11 22:25:46 +00:00
Johnny Chen afef640a9a Help text modification.
llvm-svn: 116206
2010-10-11 16:19:48 +00:00
Greg Clayton aaf99e04ca Fixed an issue where objc types weren't ever getting fully resolved (beyond
forward declarations).

llvm-svn: 116181
2010-10-11 02:25:34 +00:00
Greg Clayton e46dd32b69 Exit if the command line is started with "--help".
llvm-svn: 116180
2010-10-11 01:13:37 +00:00
Greg Clayton 6eee5aa067 Added a "--no-lldbinit" option (-n for short (which magically matches
what gdb uses)) so we can tell our "lldb" driver program to not automatically
parse any .lldbinit files. 

llvm-svn: 116179
2010-10-11 01:05:37 +00:00
Greg Clayton 46747022d2 Added the ability to get error strings back from failed
lldb_private::RegularExpression compiles and matches with:

    size_t
    RegularExpression::GetErrorAsCString (char *err_str, 
                                          size_t err_str_max_len) const;
    
Added the ability to search a variable list for variables whose names match
a regular expression:

    size_t
    VariableList::AppendVariablesIfUnique (const RegularExpression& regex, 
                                           VariableList &var_list, 
                                           size_t& total_matches);


Also added the ability to append a variable to a VariableList only if it is 
not already in the list:

    bool
    VariableList::AddVariableIfUnique (const lldb::VariableSP &var_sp);

Cleaned up the "frame variable" command:
- Removed the "-n NAME" option as this is the default way for the command to
  work.
- Enable uniqued regex searches on variable names by fixing the "--regex RE"
  command to work correctly. It will match all variables that match any
  regular expressions and only print each variable the first time it matches.
- Fixed the option type for the "--regex" command to by eArgTypeRegularExpression
  instead of eArgTypeCount

llvm-svn: 116178
2010-10-10 23:55:27 +00:00
Greg Clayton 864174e100 Added a new test case to test signals with.
Added frame relative frame selection to "frame select". You can now select
frames relative to the current frame (which defaults to zero if the current
frame hasn't yet been set for a thread):

The gdb "up" command can be done as:
(lldb) frame select -r 1
The gdb "down" command can be done as:
(lldb) frame select -r -1

Place the following in your ~/.lldbinit file for "up" and "down":

command alias up frame select -r 1
command alias down frame select -r -1

llvm-svn: 116176
2010-10-10 22:28:11 +00:00
Greg Clayton 222f5700c2 Plugged memory leak.
llvm-svn: 116175
2010-10-10 22:07:18 +00:00
Greg Clayton 6d7e77b9dc Added new options to memory read to allow saving memory to disk
as binary bytes or as an ASCII text dump. 
- The output file is specified with the  "--outfile FILE" option.
- The memory can be appended to an existing file using the "--append" option. 
- The memory will be written as an ASCII text dump by default, or as 
  binary with the "--binary" option. 

Added new options to memory write to allow writing all or part of
a file on disk to target memory:
- The input file is specified using the "--infile FILE" option
- The offset at which to start in the file defaults to zero, but
  can be overridden using the "--offset OFFSET" option. If the
  size is not specified, the remaining number of bytes in the file
  will be used as the default byte size.
- The number of bytes to write defaults to the entire file byte
  size, but can be changed with the "--size COUNT" option.
 

llvm-svn: 116172
2010-10-10 20:52:20 +00:00
Johnny Chen 493b526bf7 Simplify the generator adaptor to a Python function instead of a class definition,
with the function name 'lldb_iter'.  Example:

def disassemble_instructions (insts):
    from lldbutil import lldb_iter
    for i in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'):
        print i

llvm-svn: 116171
2010-10-10 20:25:10 +00:00
Greg Clayton 237cd90620 Fixed process.gdb-remote to be able to properly propagate the signals and
obey the UnixSignals table that we have in the process.

llvm-svn: 116139
2010-10-09 01:40:57 +00:00
Johnny Chen f4de10d290 Add a generator adaptor class named 'Iterator' which turns lldb aggregate data
structures into an iterable Python object.

Example:

    def disassemble_instructions (insts):
        from lldbutil import Iterator
        for i in Iterator(insts, 'GetSize', 'GetInstructionAtIndex'):
            print i

llvm-svn: 116137
2010-10-09 01:31:09 +00:00
Greg Clayton b7c046248c Fixed a missing space when using the "apropos" command and you don't find any matches.
llvm-svn: 116133
2010-10-09 00:51:35 +00:00
Greg Clayton 74f6e9f523 Fixed a typo from my previous "Added support for LC_LOAD_UPWARD_DYLIB in mach-o files".
llvm-svn: 116132
2010-10-09 00:48:53 +00:00
Greg Clayton f9f78e3aae Added support for LC_LOAD_UPWARD_DYLIB in mach-o files.
llvm-svn: 116128
2010-10-09 00:16:01 +00:00
Johnny Chen 701edc1546 Minor change.
llvm-svn: 116127
2010-10-09 00:15:46 +00:00
Johnny Chen bfde8dc627 Update do_conditional_break() method impl to use all lldb Python APIs.
llvm-svn: 116117
2010-10-08 22:51:03 +00:00
Johnny Chen 277c8f0f1d Wrap the rest of file reading operations inside a with block and convert a assertTrue()
usage to self.expect() which is more descriptive.

llvm-svn: 116115
2010-10-08 22:10:42 +00:00
Johnny Chen e6acf35582 Emit a diagnostic message instead of crashing when an argument entry is missing.
llvm-svn: 116114
2010-10-08 22:01:52 +00:00
Johnny Chen be7da21d33 Convert two instances of assertTrue() and string matching usages to self.expect()
which is more descriptive.  And wrap the file open operation inside a with block
so that close() is automatically called upon exiting the block.

llvm-svn: 116096
2010-10-08 20:01:03 +00:00
Johnny Chen 65045f2168 o TestStdCXXDisassembly.py:
Update the expected match string.

o lldbtest.py:

  Indicate when a command fails, even if there is nothing in the error stream.

o TestHelp.py:

  Add a regression test case for 'help image dump symtab'.

o CommandObjectHelp.cpp:

  Some of the logic branches with successful help command results were not tagged
  with a Success Status.  They are fixed now.  This is important for Python
  interaction.

llvm-svn: 116062
2010-10-08 17:21:27 +00:00
Johnny Chen e5e2b0c307 Fixed a crasher when doing 'help image dump symtab'. Supply the entry to the global arguments table.
llvm-svn: 116058
2010-10-08 16:36:25 +00:00
Greg Clayton 8087ca2160 Added mutex protection to the Symtab class.
Added a new SortOrder enumeration and hooked it up to the "image dump symtab"
command so we can dump symbol tables in the original order, sorted by address, 
or sorted by name.

llvm-svn: 116049
2010-10-08 04:20:14 +00:00
Sean Callanan 6b1b95376f Added extra logging, and made sure that the argument
struct for expressions is deallocated when the
ClangExpressionDeclMap is taken down.

llvm-svn: 116028
2010-10-08 01:58:41 +00:00
Johnny Chen 06b89fe646 Pass '-f' option to rm command so that it won't report an error if the file to
be removed does not exist for any reason.

llvm-svn: 116025
2010-10-08 00:50:36 +00:00
Johnny Chen 138532af06 The expected term-width output string should be put within a list, not as a list of characters.
Also uncomment the cleanup of "stdout.txt" file as part of the class cleanup routine even though
test_set_output_path() is failing right now.

llvm-svn: 116023
2010-10-08 00:47:30 +00:00
Greg Clayton 09f2265eac Bumped versions to lldb-26 and debugserver-114 for a build.
llvm-svn: 116019
2010-10-08 00:23:57 +00:00
Greg Clayton 8941142af8 Hooked up ability to look up data symbols so they show up in disassembly
if the address comes from a data section. 

Fixed an issue that could occur when looking up a symbol that has a zero
byte size where no match would be returned even if there was an exact symbol
match.

Cleaned up the section dump output and added the section type into the output.

llvm-svn: 116017
2010-10-08 00:21:05 +00:00
Sean Callanan 5c67a628b0 Fixed a launching issue.
llvm-svn: 115999
2010-10-07 22:51:14 +00:00
Johnny Chen 28ae29420a Move the enum to string utility functions from lldbtest.py to lldbuti.py and
update the affected API clients.

llvm-svn: 115995
2010-10-07 22:15:58 +00:00
Greg Clayton 68f4b4f2a2 Make sure to lock down the sequence mutex and select the thread we want when read or write all registers.
llvm-svn: 115992
2010-10-07 22:06:19 +00:00
Johnny Chen 7ea9aee9be Add a test case which uses the SBProcess and SBThread APIs to iterate through
the threads and print their stack traces when stopped on a breakpoint.

Add a PrintStackTraces(process) utility function into the lldbutil.py module.

llvm-svn: 115983
2010-10-07 21:38:28 +00:00
Johnny Chen 6c70499030 Add a keyword argument string_buffer (with a default value of False) to the
PrintStackTrace(thread) function.  If string_buffer is True, PrintStackTrace()
will return the content of the stack trace as a string, instead.

llvm-svn: 115960
2010-10-07 18:52:48 +00:00
Johnny Chen 28f5dd8525 Minor cleanup with added comment.
llvm-svn: 115955
2010-10-07 18:49:04 +00:00
Sean Callanan 4451136102 Changed the timeout for expressions from 10
milliseconds to 10 seconds, which was the
original intent.

llvm-svn: 115942
2010-10-07 18:17:31 +00:00
Greg Clayton c6ed542c90 More SWIG cleanup. Moved the breakpoint callback function back to the
ScriptInterpreterPython class and made a simple callback function that
ScriptInterpreterPython::BreakpointCallbackFunction() now calls so we don't
include any internal API stuff into the cpp file that is generated by SWIG.

Fixed a few build warnings in debugserver.

llvm-svn: 115926
2010-10-07 17:14:24 +00:00
Johnny Chen c5b06ebe82 Clean up the StateType and StopReason enums now that they reside in the lldb module.
llvm-svn: 115922
2010-10-07 16:51:56 +00:00
Johnny Chen 9ac4482d78 Updated expected match strings because the print representations of SBProcess, SBThread, SBBreakpoint, and SBFrame have changed.
llvm-svn: 115918
2010-10-07 16:23:37 +00:00
Johnny Chen b792cc1d50 Use the updated process launch API.
llvm-svn: 115917
2010-10-07 16:06:12 +00:00
Johnny Chen fbfba899a6 Fix logic error of the option processing loop.
llvm-svn: 115916
2010-10-07 15:41:55 +00:00
Greg Clayton 05faeb7135 Cleaned up the SWIG stuff so all includes happen as they should, no pulling
tricks to get types to resolve. I did this by correctly including the correct
files: stdint.h and all lldb-*.h files first before including the API files.
This allowed me to remove all of the hacks that were in the lldb.swig file
and it also allows all of the #defines in lldb-defines.h and enumerations
in lldb-enumerations.h to appear in the lldb.py module. This will make the
python script code a lot more readable.

Cleaned up the "process launch" command to not execute a "process continue"
command, it now just does what it should have with the internal API calls
instead of executing another command line command.

Made the lldb_private::Process set the state to launching and attaching if
WillLaunch/WillAttach return no error respectively.

llvm-svn: 115902
2010-10-07 04:19:01 +00:00
Johnny Chen 0ed37c9615 o SBtarget.cpp/.h:
Temporarily commenting out the deprecated LaunchProcess() method.
  SWIG is not able to handle the overloaded functions.

o dotest.py/lldbtest.py:

  Add an '-w' option to insert some wait time between consecutive test cases.

o TestClassTypes.py:

  Make the breakpoint_creation_by_filespec_python() test method more robust and
  more descriptive by printing out a more insightful assert message.

o lldb.swig: Coaches swig to treat StateType as an int type, instead of a C++ class.

llvm-svn: 115899
2010-10-07 02:04:14 +00:00
Greg Clayton 524e60b4e4 Expose the error contained within an SBValue.
Move anything that creates a new process into SBTarget. Marked some functions
as deprecated. I will remove them after our new API changes make it through
a build cycle.

llvm-svn: 115854
2010-10-06 22:10:17 +00:00
Johnny Chen 56e6cbdaf0 Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test
driver to only admit the module which satisfy the filterspec condition to the
test suite.

Example:

# This only runs the test case under the array_types directory which has class
# name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'.

/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types
----------------------------------------------------------------------
Collected 1 test

test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.353s

OK

# And this runs the test cases under the array_types and the hello_world directories.
# If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command'
# attribute, only the test case specified by the filterspec for the module will be run.
# If the module does not have the said attribute, e.g., the module under hello_world,
# the whole module is still admitted to the test suite.

/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world
----------------------------------------------------------------------
Collected 3 tests

test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase)
Test 'frame variable var_name' on some variables with array types. ... ok
test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok
test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase)
Create target, breakpoint, launch a process, and then kill it. ... ok

----------------------------------------------------------------------
Ran 3 tests in 4.964s

OK

llvm-svn: 115832
2010-10-06 20:40:56 +00:00
Johnny Chen 2bdb0575ab Remove the @expectedFailure decorator since the SBTarget.LaunchProcess() race
condition has been fixed.

llvm-svn: 115826
2010-10-06 20:13:28 +00:00
Johnny Chen 1a5d93d589 Use the SBTarget process launch API for api testings.
llvm-svn: 115822
2010-10-06 20:03:28 +00:00
Johnny Chen 2c2d69dff5 Change the regular expression used to grok the data type associated the output of
expression parser in light of the recent check ins.

Example:
    runCmd: expr a
    output: (double) $0 = 1100.12

llvm-svn: 115821
2010-10-06 20:00:48 +00:00