Commit Graph

362 Commits

Author SHA1 Message Date
Johnny Chen 8715c517d5 Add comment regarding TestHelloWorld.py's use of a dictionary to specify/overwrite the EXE name.
llvm-svn: 148418
2012-01-18 21:22:38 +00:00
Johnny Chen fef3e2797a Modify the test cases so that each uses a unique executable name for the debugger to attach/launch.
I've see cases where there are lingering processes ("hello_world") staying around and the
test_with_dsym_and_attach_to_process_with_name_api() test case just hangs.

llvm-svn: 148417
2012-01-18 21:20:03 +00:00
Johnny Chen 5886fb5bd3 rdar://problem/10492827
SBProcess.GetSTDERR() not getting stderr of the launched process

Since we are launch the inferior with:

    process = target.LaunchSimple(None, None, os.getcwd())

i.e., without specifying stdin/out/err.  A pseudo terminal is used for
handling the process I/O, and we are satisfied once the expected output
appears in process.GetSTDOUT().

llvm-svn: 147983
2012-01-12 00:29:46 +00:00
Greg Clayton 0f28986a54 Patch from Enrico Granata that moves SBData related functions into the SBData
class instead of requiring a live process in order to be able to create useful
SBData objects.

llvm-svn: 147702
2012-01-07 00:45:50 +00:00
Johnny Chen 39c6d0f9ae http://llvm.org/bugs/show_bug.cgi?id=11619
Allow creating SBData values from arrays or primitives in Python

Patch submitted by Enrico Granata.

llvm-svn: 147639
2012-01-06 00:46:12 +00:00
Johnny Chen 3f0b90dcd0 rdar://problem/10216227
LLDB (python bindings) Crashing in lldb::SBDebugger::DeleteTarget(lldb::SBTarget&)

Need to check the validity of (SBTarget&)target passed to SBDebugger::DeleteTarget()
before calling target->Destroy().

llvm-svn: 147213
2011-12-23 00:53:45 +00:00
Johnny Chen 4b730a73a2 Fix wrong test method name.
llvm-svn: 147072
2011-12-21 19:56:51 +00:00
Johnny Chen 50660440a1 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add a NULL check for SBValue.CreateValueFromExpression().

llvm-svn: 146954
2011-12-20 01:52:44 +00:00
Johnny Chen 3ac503e042 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add a NULL check for SBTarget.AttachToProcessWithName() so it will not hang.

llvm-svn: 146948
2011-12-20 01:22:03 +00:00
Johnny Chen c89c74ec2d Add fuzz call to SBStringList.AppendString(None). LLDB should not crash.
llvm-svn: 146935
2011-12-20 00:49:06 +00:00
Johnny Chen 1317b165fa Add test_frame_api_boundary_condition() test case to exercise a bunch of boundary condition inputs.
llvm-svn: 146924
2011-12-19 23:41:29 +00:00
Johnny Chen a7bd08be8d Add a test sequence which passes None to lldb.SBFileSpec(). LLDB should not crash.
llvm-svn: 146922
2011-12-19 23:09:54 +00:00
Johnny Chen c5c0247d98 Tes passing None to SetErrorString() and SetErrorStringWithFormat().
llvm-svn: 146919
2011-12-19 22:56:47 +00:00
Johnny Chen fee6e493b0 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBDebugger APIs.

llvm-svn: 146917
2011-12-19 22:51:27 +00:00
Johnny Chen b146f53de7 Add a fuzz call for SBCommunication: obj.connect(None).
llvm-svn: 146912
2011-12-19 21:47:43 +00:00
Johnny Chen a715452757 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBCommandReturnObject.AppendMessage().

llvm-svn: 146911
2011-12-19 21:36:23 +00:00
Johnny Chen 872e062566 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBCommandInterpreter APIs.

llvm-svn: 146909
2011-12-19 21:16:29 +00:00
Johnny Chen 4efffd9ae5 Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check

Add NULL checks for SBModule and SBSection APIs.

llvm-svn: 146899
2011-12-19 20:16:22 +00:00
Johnny Chen cdd7e8b14a Fix Python docstring for SBThread.GetStopDescription().
llvm-svn: 146890
2011-12-19 19:38:09 +00:00
Johnny Chen 7cc3d31e15 Simplify the setup leading to the testing of ReadMemory(), ReadCStringFromMemory(), and ReadUnsignedFromMemory().
Instead of getting the location of the variable and converting the hex string to an int, just use
val.AddressOf().GetValueAsUnsigned() to compute the address of the memory region to read from.

llvm-svn: 146719
2011-12-16 01:56:27 +00:00
Johnny Chen e7e8af807a Add a test sequence of SBProcess.ReadCStringFromMemory() with (char *)my_char_ptr as the address to read from.
char *my_char_ptr = (char *)"Does it work?";

llvm-svn: 146716
2011-12-16 00:25:30 +00:00
Johnny Chen 6e55cd5e29 Add test scenario for newly added SBProcess APIs: ReadCStringFromMemory() and ReadUnsignedFromMemory().
llvm-svn: 146704
2011-12-15 23:30:05 +00:00
Johnny Chen 10437fd336 Add fuzz call for newly added method SBTarget.GetInstructions().
llvm-svn: 146696
2011-12-15 22:45:30 +00:00
Johnny Chen 80e3e84ddb Add fuzz calls for newly added SBProcess methods. Fix a typo in the audodoc of SBProcess.ReadCStringFromMemory().
llvm-svn: 146695
2011-12-15 22:34:59 +00:00
Johnny Chen 1917bc8de4 Move disassemble-raw-data dir to reside under test/python_api where they belong.
Add debug statements for the raw bytes and the disassembled instruction.

llvm-svn: 146676
2011-12-15 19:56:28 +00:00
Johnny Chen 95873a68f4 http://llvm.org/bugs/show_bug.cgi?id=11579
lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds

SBValue::CreateValueFromAddress() should check the validity of type and its derived pointer type
before using it.  Add a test case.

llvm-svn: 146629
2011-12-15 01:55:36 +00:00
Johnny Chen c6770763e6 http://llvm.org/bugs/show_bug.cgi?id=11560 lldb::SBTarget::FindFirstType crashes when passed None
Add null checks to several functions.  Plus add test scenario for passing None to SBTarget.FindFirstType(None) and friends.

llvm-svn: 146540
2011-12-14 01:43:31 +00:00
Johnny Chen 49cb85db64 SBProcess.PutSTDIN() needs to be properly typemapped when swigging,
so that we can do Python scripting like this:

        target = self.dbg.CreateTarget(self.exe)

        self.dbg.SetAsync(True)
        process = target.LaunchSimple(None, None, os.getcwd())

        process.PutSTDIN("Line 1 Entered.\n")
        process.PutSTDIN("Line 2 Entered.\n")
        process.PutSTDIN("Line 3 Entered.\n")

Add TestProcessIO.py to exercise the process IO API: PutSTDIN()/GetSTDOUT()/GetSTDERR().

llvm-svn: 145282
2011-11-28 21:39:07 +00:00
Johnny Chen 4c1b096743 While we are at it, verify that 'my_int_ptr' points to 'g_my_int', using the SBTarget.ResolveLoadAddress() to get its SBAddress,
and SBAddress.GetSymbol() to get the corresponding symbol.

llvm-svn: 144728
2011-11-15 23:30:39 +00:00
Johnny Chen 2341380033 Add test scenario for value.GetChildAtIndex(0) where value is a pointer to a simple type.
llvm-svn: 144697
2011-11-15 21:13:13 +00:00
Johnny Chen b057196543 File renaming.
llvm-svn: 144693
2011-11-15 20:36:57 +00:00
Johnny Chen 9df05592f0 Add test cases for setting condition on a watchpoint for both command and API.
llvm-svn: 142291
2011-10-17 22:17:47 +00:00
Johnny Chen ed456eb0a9 Add SBWatchpoint::GetError() API, which is not currently populated as yet.
llvm-svn: 141979
2011-10-14 19:15:48 +00:00
Johnny Chen 6283f4b67a Remove debug 'print watchpoint' statement.
llvm-svn: 141965
2011-10-14 18:10:00 +00:00
Johnny Chen f5be9e3759 Add a test case to exercise the newly added SB API:
lldb::SBWatchpoint
SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write)

llvm-svn: 141931
2011-10-14 01:16:39 +00:00
Johnny Chen 4c3e140247 Fix wrong docstring with respect to API usage.
llvm-svn: 141928
2011-10-14 00:56:28 +00:00
Johnny Chen 01a678603a SBValue::Watch() and SBValue::WatchPointee() are now the official API for creating
a watchpoint for either the variable encapsulated by SBValue (Watch) or the pointee
encapsulated by SBValue (WatchPointee).

Removed SBFrame::WatchValue() and SBFrame::WatchLocation() API as a result of that.

Modified the watchpoint related test suite to reflect the change.

Plus replacing WatchpointLocation with Watchpoint throughout the code base.

There are still cleanups to be dome.  This patch passes the whole test suite.
Check it in so that we aggressively catch regressions.

llvm-svn: 141925
2011-10-14 00:42:25 +00:00
Johnny Chen 541b98517e Remove test logic to check for clang and skip the rest due to insufficient debug info.
Recent changes in lldb inlining robustness seem to have fixed it.

llvm-svn: 141595
2011-10-10 23:26:54 +00:00
Johnny Chen a4e8baeb33 Add fuzz call for SBBreakpointLocation.GetAddress().
llvm-svn: 141443
2011-10-07 23:54:04 +00:00
Jim Ingham 4cda6e058b Move the responsibility for translating the various eFunctionNameType lookups to the
SymbolFIle (it was done mostly in the BreakpointResolverName resolver before.)  Then
tailor our searches to the way the indexed maps are laid out.  This removes a bunch 
of test case failures using indexed dSYM's.

llvm-svn: 141428
2011-10-07 22:23:45 +00:00
Johnny Chen 6cc60e8668 Add capability to set ignore count for watchpoint on the command line:
watchpoint ignore -i <count> [<watchpt-id | watchpt-id-list>]

Add tests of watchpoint ignore_count for command line as well as API.

llvm-svn: 141217
2011-10-05 21:35:46 +00:00
Johnny Chen 524e4ccb49 Add fuzz call for sub-section iteration for SBSection.
llvm-svn: 141041
2011-10-03 22:43:06 +00:00
Johnny Chen 3dc26e839c Add SBSection API to the fuzz testing.
llvm-svn: 141039
2011-10-03 22:30:56 +00:00
Johnny Chen 8c3dc3d0fd Add fuzz call for watchpoint location iterator, too.
llvm-svn: 141036
2011-10-03 22:08:35 +00:00
Johnny Chen b92574ffb9 Add fuzz calls for various iterators, too.
llvm-svn: 141035
2011-10-03 22:02:59 +00:00
Johnny Chen b49b7b53b1 Add SBFrame.WatchLocation() to find and watch the location pointed to by
a variable usng the frame as the scope.

Add TestSetWatchpoint.py to exercise this API.  Also fix some SWIG Python
docstrings.

llvm-svn: 140914
2011-10-01 01:19:45 +00:00
Johnny Chen 1887fce184 Fix extraneous import as a result of the last change.
llvm-svn: 140832
2011-09-30 00:46:24 +00:00
Johnny Chen c44e20cec0 Migrate the in_range(symbol, section) and symbol_iter(module, section) utility functions
from lldbutil.py to the lldb.py proper.  The in_range() function becomes a function in
the lldb module.  And the symbol_iter() function becomes a method within the SBModule
called symbol_in_section_iter().  Example:

        # Iterates the text section and prints each symbols within each sub-section.
        for subsec in text_sec:
            print INDENT + repr(subsec)
            for sym in exe_module.symbol_in_section_iter(subsec):
                print INDENT2 + repr(sym)
                print INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType())

might produce this following output:

    [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
        id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
        symbol type: code
        id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
        symbol type: code
        id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
        symbol type: code
        id = {0x00000023}, name = 'start', address = 0x0000000100001780
        symbol type: code
    [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
        id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
        symbol type: trampoline
        id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
        symbol type: trampoline
        id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
        symbol type: trampoline
        id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
        symbol type: trampoline
        id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
        symbol type: trampoline
        id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
        symbol type: trampoline
        id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
        symbol type: trampoline
        id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
        symbol type: trampoline
        id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
        symbol type: trampoline
        id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
        symbol type: trampoline
        id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
        symbol type: trampoline
        id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
        symbol type: trampoline
    [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
    [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
    [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
    [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame

llvm-svn: 140830
2011-09-30 00:42:49 +00:00
Johnny Chen c0f53df8ff Modify lldbutil.in_range(symbol, section) to deal with the symbol whose
end address is an LLDB_INVALID_ADDRESS.  Modify the test case to dump
all the symbols in all the sections.

llvm-svn: 140710
2011-09-28 18:33:50 +00:00
Johnny Chen a32a13d207 Add a test sequence of iterating through a module's symbols belonging to a section.
Add the relevant utility functions to the lldbutil.py file.

llvm-svn: 140669
2011-09-28 00:51:00 +00:00
Johnny Chen b2c7825515 Add a simple test TestModuleAndSection.py to exercise some module/section-related APIs.
In particular, it iterates through the executable module's SBSections, looking for the
'__TEXT' section and further iterates on its subsections (of SBSection type, too).

llvm-svn: 140654
2011-09-27 23:15:58 +00:00
Johnny Chen 0f2ed0e5df Make the assignment of TestBase.mydir more portable.
llvm-svn: 140640
2011-09-27 21:49:34 +00:00
Johnny Chen 469683e98d SBWatchpointLocation.GetDescription() takes an additional description level arg.
Modify get_description() utility function in lldbutil.py to handle that.

llvm-svn: 140638
2011-09-27 21:27:19 +00:00
Johnny Chen 9d954d8665 Add SBTarget::GetLastCreatedWatchpointLocation() API and export to the Python interface.
Also add rich comparison methods (__eq__ and __ne__) for SBWatchpointLocation.
Modify TestWatchpointLocationIter.py to exercise the new APIs.

Add fuzz testings for the recently added SBTarget APIs related to watchpoint manipulations.

llvm-svn: 140633
2011-09-27 20:29:45 +00:00
Johnny Chen 4e6a4fa899 Add fuzz testing for newly added SBWatchpointLocation API.
llvm-svn: 140632
2011-09-27 20:23:43 +00:00
Johnny Chen d4dd7993b5 Export the watchpoint related API (SBWatchpointLocation class and added SBTarget methods)
to the Python interface.

Implement yet another (threre're 3 now) iterator protocol for SBTarget: watchpoint_location_iter(),
to iterate on the available watchpoint locations.  And add a print representation for
SBWatchpointLocation.

Exercise some of these Python API with TestWatchpointLocationIter.py.

llvm-svn: 140595
2011-09-27 01:19:20 +00:00
Johnny Chen 7da349d3a1 Remove the @expectedFailureClang custom decorator for indicating clang-specific test failures.
It has been fixed on the lldb side to compensate for bad debug info (line table information).

llvm-svn: 140550
2011-09-26 19:05:08 +00:00
Johnny Chen 57087f3df3 Fix comment.
llvm-svn: 140450
2011-09-24 05:01:53 +00:00
Johnny Chen 90d6fe5d35 Add FindValue() and WatchValue() fuzz calls to the mix.
llvm-svn: 140439
2011-09-24 01:02:22 +00:00
Greg Clayton cac9c5f971 Added to the public API to allow symbolication:
- New SBSection objects that are object file sections which can be accessed
  through the SBModule classes. You can get the number of sections, get a 
  section at index, and find a section by name.
- SBSections can contain subsections (first find "__TEXT" on darwin, then
  us the resulting SBSection to find "__text" sub section).
- Set load addresses for a SBSection in the SBTarget interface
- Set the load addresses of all SBSection in a SBModule in the SBTarget interface
- Add a new module the an existing target in the SBTarget interface
- Get a SBSection from a SBAddress object

This should get us a lot closer to being able to symbolicate using LLDB through
the public API.

llvm-svn: 140437
2011-09-24 00:52:29 +00:00
Johnny Chen 6027c94d2f Add an SB API SBFrame::WatchValue() and exported to the Python interface to
set a watchpoint Pythonically.  If the find-and-watch-a-variable operation
fails, an invalid SBValue is returned, instead.

Example Python usage:

        value = frame0.WatchValue('global',
                                  lldb.eValueTypeVariableGlobal,
                                  lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE)

Add TestSetWatchpoint.py to exercise this API.
We have 400 test cases now.

llvm-svn: 140436
2011-09-24 00:50:33 +00:00
Johnny Chen 3c7054a37b Fix wrong test method name.
llvm-svn: 139863
2011-09-15 22:13:43 +00:00
Johnny Chen 81be205460 Add fuzz calls for added API methods: FindFirstType(), FindTypes(), and GetSourceManager().
llvm-svn: 139857
2011-09-15 21:58:36 +00:00
Johnny Chen b08b736de9 Add fuzz calls to newly added methods: GetAsync() and SetSelectedTarget(SBTarget).
llvm-svn: 139855
2011-09-15 21:52:59 +00:00
Johnny Chen 1ac383c68d Test should print to stdout only if self.TraceOn() is True.
llvm-svn: 139174
2011-09-06 20:32:42 +00:00
Enrico Granata 9128ee2f7a Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
   a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
   in frozen objects ; now such reads transparently move from host to target as required
 - as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
   removed code that enabled to recognize an expression result VO as such
 - introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
   representing a T* or T[], and doing dereferences transparently
   in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
 - as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
   en lieu of doing the raw read itself
 - introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
   this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
   in public layer this returns an SBData, just like GetPointeeData()
 - introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
   the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
   of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
 - added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
 of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
 addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types

llvm-svn: 139160
2011-09-06 19:20:51 +00:00
Johnny Chen 31963cea0a Add a decorator for marking clang only expectedFailure. Use it for the test_step_over_3_times_with_dsym/dwarf()
test cases in TestThreadAPI.py by decorating it with @expectedFailureClang.

Example:

    @expectedFailureClang
    @python_api_test
    def test_step_over_3_times_with_dwarf(self):
        """Test Python SBThread.StepOver() API."""
        # We build a different executable than the default buildDwarf() does.
        d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name}
        self.buildDwarf(dictionary=d)
        self.setTearDownCleanup(dictionary=d)
        self.step_over_3_times(self.exe_name)

llvm-svn: 138019
2011-08-19 00:54:27 +00:00
Jim Ingham 5c2a57291c Re-enable the test for ValueAsUnsigned on a register Value.
llvm-svn: 137738
2011-08-16 19:03:09 +00:00
Johnny Chen 0dc84d093e Add new SBAddress APIs to the fuzz tests.
llvm-svn: 137625
2011-08-15 18:19:51 +00:00
Jim Ingham a5636fc823 Test case for changing ValueObjects with SBValue::SetValueFromCString.
llvm-svn: 137543
2011-08-13 00:45:23 +00:00
Johnny Chen e1894cf97c Add logic to SBValue.linked_list_iter() to detect infinite loop and to bail out early.
Add code to test case to create an evil linked list with:

    task_evil -> task_2 -> task_3 -> task_evil ...

and to check that the linked list iterator only iterates 3 times.

llvm-svn: 137291
2011-08-11 01:19:46 +00:00
Johnny Chen 9c1b703ac4 Change the SBValue.linked_list_iter() to treat the value object as a homogeneous linked list data structure
where an empty linked list is represented as a value object with a NULL value, instead of a special value
object which 'points' to NULL.

Also modifies the test case to comply.

rdar://problem/9933692

llvm-svn: 137289
2011-08-11 00:49:03 +00:00
Johnny Chen 76ea84eaf4 On second thought, add the IsValid() method to SBTypeList, making it similar to SBSymbolContextList and SBValueList.
Modify the test suite accordingly.

llvm-svn: 136990
2011-08-05 22:23:26 +00:00
Johnny Chen 7af935ed9a Fixed test suite failure of test_SBTypeList().
SBTypeList does not have IsValid() method defined.  It's always valid in a sense.
So the Python's truth value testing in turn delegates to __len__() method, which
is defined for SBTypeList, and returns 0.

llvm-svn: 136985
2011-08-05 21:55:15 +00:00
Johnny Chen cbf1737ea1 Add SBType.GetBasicType() to the test scenario.
Add docstring for SBType, too.

llvm-svn: 136983
2011-08-05 21:35:43 +00:00
Johnny Chen 36c5eb1327 o modify-python-lldb.py:
Add the rich comparison methods (__eq__, __ne__) to SBType, too.

o lldbtest.py:

  Add debug utility method TestBase.DebugSBType().

o test/python_api/type:

  Add tests for exercising SBType/SBTypeList API, including the SBTarget.FindTypes(type_name)
  API which returns a SBTypeList matching the type_name.

llvm-svn: 136975
2011-08-05 20:17:27 +00:00
Johnny Chen 190f2b1c21 Remove expectedFailure decorator for test_SBType, which does not take an empty constructor after the recent changes.
And remove expectedFailure decorator for test_SBTypeMember, which no longer exists after the recent changes, replace
it with test_SBTypeList.

llvm-svn: 136947
2011-08-05 00:07:41 +00:00
Greg Clayton fe42ac4d0a Cleaned up the SBType.h file to not include internal headers and reorganized
the SBType implementation classes.

Fixed LLDB core and the test suite to not use deprecated SBValue APIs.

Added a few new APIs to SBValue:

    int64_t
    SBValue::GetValueAsSigned(int64_t fail_value=0);

    uint64_t
    SBValue::GetValueAsUnsigned(uint64_t fail_value=0)

 

llvm-svn: 136829
2011-08-03 22:57:10 +00:00
Johnny Chen 5ccbccfce0 Add a @benchmarks_test decorator for test method we want to categorize as benchmarks test.
The test driver now takes an option "+b" which enables to run just the benchmarks tests.
By default, tests decorated with the @benchmarks_test decorator do not get run.

Add an example benchmarks test directory which contains nothing for the time being,
just to demonstrate the @benchmarks_test concept.

For example,

$ ./dotest.py -v benchmarks

...

----------------------------------------------------------------------
Collected 2 tests

1: test_with_gdb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with gdb. ... skipped 'benchmarks tests'
2: test_with_lldb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with lldb. ... skipped 'benchmarks tests'

----------------------------------------------------------------------
Ran 2 tests in 0.047s

OK (skipped=2)
$ ./dotest.py -v +b benchmarks

...

----------------------------------------------------------------------
Collected 2 tests

1: test_with_gdb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with gdb. ... running test_with_gdb
benchmarks result for test_with_gdb
ok
2: test_with_lldb (TestRepeatedExprs.RepeatedExprssCase)
   Test repeated expressions with lldb. ... running test_with_lldb
benchmarks result for test_with_lldb
ok

----------------------------------------------------------------------
Ran 2 tests in 0.270s

OK

Also mark some Python API tests which are missing the @python_api_test decorator.

llvm-svn: 136553
2011-07-30 01:39:58 +00:00
Enrico Granata 6f3533fb1d Public API changes:
- Completely new implementation of SBType
 - Various enhancements in several other classes
Python synthetic children providers for std::vector<T>, std::list<T> and std::map<K,V>:
 - these return the actual elements into the container as the children of the container
 - basic template name parsing that works (hopefully) on both Clang and GCC
 - find them in examples/synthetic and in the test suite in functionalities/data-formatter/data-formatter-python-synth
New summary string token ${svar :
 - the syntax is just the same as in ${var but this new token lets you read the values
   coming from the synthetic children provider instead of the actual children
 - Python providers above provide a synthetic child len that returns the number of elements
   into the container
Full bug fix for the issue in which getting byte size for a non-complete type would crash LLDB
Several other fixes, including:
 - inverted the order of arguments in the ClangASTType constructor
 - EvaluationPoint now only returns SharedPointer's to Target and Process
 - the help text for several type subcommands now correctly indicates argument-less options as such

llvm-svn: 136504
2011-07-29 19:53:35 +00:00
Johnny Chen bfdf9a36d9 The SBValue.linked_list_iter() API failed for an empty list.
Fix the bug and add a test case.

llvm-svn: 136265
2011-07-27 21:14:01 +00:00
Johnny Chen 94b431ab63 Add skip test for clang, which has insufficient debug info for call site in main().
llvm-svn: 136184
2011-07-26 23:35:38 +00:00
Johnny Chen e33b166da1 We can do better with the SBValue.linked_list_iter() API by supplying a default
end of list test function as __eol_test__.

The simple example can be reduced to:

    for t in task_head.linked_list_iter('next'):
        print t

Modify the test program to exercise the API for both cases: supplying or not
supplying an end of list test function.

llvm-svn: 136144
2011-07-26 20:57:10 +00:00
Johnny Chen 6b092e821b The test function to determine whether we have reached the end of the list was
too complex in the test case.  We can just simply test that the SBValue object
is a valid object and it does not correspond to a null pointer in order to say
that EOL has not been reached.

Modify the test case and the lldb.py docstring to have a more compact test
function.

llvm-svn: 136123
2011-07-26 20:20:13 +00:00
Johnny Chen ca24cfa427 Add a stronger assert for the test to ensure that the visited items from iterating through
the SBValue.linked_list_iter() API is equal to [1, 2, 4, 5].

llvm-svn: 135944
2011-07-25 19:57:43 +00:00
Johnny Chen 4822505338 Provide an add-on API to SBValue class by post-processing to provide a way
to iterate through an SBValue instance by treating it as the head of a linked
list.  API program must provide two args to the linked_list_iter() method:
the first being the child member name which points to the next item on the list
and the second being a Python function which an SBValue (for the next item) and
returns True if end of list is reached, otherwise it returns False.

For example, suppose we have the following sample program.

#include <stdio.h>

class Task {
public:
    int id;
    Task *next;
    Task(int i, Task *n):
        id(i),
        next(n)
    {}
};


int main (int argc, char const *argv[])
{
    Task *task_head = new Task(-1, NULL);
    Task *task1 = new Task(1, NULL);
    Task *task2 = new Task(2, NULL);
    Task *task3 = new Task(3, NULL); // Orphaned.
    Task *task4 = new Task(4, NULL);
    Task *task5 = new Task(5, NULL);

    task_head->next = task1;
    task1->next = task2;
    task2->next = task4;
    task4->next = task5;

    int total = 0; // Break at this line
    Task *t = task_head;
    while (t != NULL) {
        if (t->id >= 0)
            ++total;
        t = t->next;
    }
    printf("We have a total number of %d tasks\n", total);
    return 0;
}

The test program produces the following output while exercising the linked_list_iter() SBVAlue API:

task_head:
	TypeName      -> Task *
	ByteSize      -> 8
	NumChildren   -> 2
	Value         -> 0x0000000106400380
	ValueType     -> local_variable
	Summary       -> None
	IsPointerType -> True
	Location      -> 0x00007fff65f06e60
(Task *) next = 0x0000000106400390
  (int) id = 1
  (Task *) next = 0x00000001064003a0

(Task *) next = 0x00000001064003a0
  (int) id = 2
  (Task *) next = 0x00000001064003c0

(Task *) next = 0x00000001064003c0
  (int) id = 4
  (Task *) next = 0x00000001064003d0

(Task *) next = 0x00000001064003d0
  (int) id = 5
  (Task *) next = 0x0000000000000000

llvm-svn: 135938
2011-07-25 19:32:35 +00:00
Johnny Chen 36d7d91616 Add an additional formatter class RecursiveDecentFormatter which prints the
value and the decendents.  For an example,

rdf = lldbutil.RecursiveDecentFormatter(indent_child=2)
print rdf.format(g_table)

produces:

(const char **[2]) g_table = 0x00000001055a80f0 (location)
  (const char **) [0] = 0x00000001055a8080
    (const char *) *[0] = "Sunday"
  (const char **) [1] = 0x00000001055a80c0
    (const char *) *[1] = "Monday"

llvm-svn: 135815
2011-07-22 22:01:35 +00:00
Johnny Chen 08c0910026 Add new API for SBAddress to the fuzz test:
SetLoadAddress (lldb::addr_t load_addr, 
               	lldb::SBTarget &target);

llvm-svn: 135793
2011-07-22 19:18:45 +00:00
Greg Clayton 00e6fbfee9 Make the SBAddress class easier to use when using the public
API. 

SBTarget changes include changing:

bool
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr, 
                              lldb::SBAddress& addr);

to be:

lldb::SBAddress
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr);

SBAddress can how contruct itself using a load address and a target 
which can be used to resolve the address:

SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);

This will actually just call the new SetLoadAddress accessor:

void
SetLoadAddress (lldb::addr_t load_addr, 
                lldb::SBTarget &target);

This function will always succeed in making a SBAddress object
that can be used in API calls (even if "target" isn't valid).
If "target" is valid and there are sections currently loaded,
then it will resolve the address to a section offset address if
it can. Else an address with a NULL section and an offset that is
the "load_addr" that was passed in. We do this because a load address
might be from the heap or stack.

llvm-svn: 135770
2011-07-22 16:46:35 +00:00
Johnny Chen 989b7efd8a Add BasicFormatter and ChildVisitingFormatter utility classes to the lldbutil.py module
which provide some convenient ways to print an SBValue object.  Use that in TestValueAPI.py
to print the 'days_of_week' char* array variable.

For an example:

cvf = lldbutil.ChildVisitingFormatter(indent=2)
print cvf.format(days_of_week)

produces:

(const char *[7]) days_of_week = 0x00000001026a5060 (location)
  (const char *) [0] = "Sunday"
  (const char *) [1] = "Monday"
  (const char *) [2] = "Tuesday"
  (const char *) [3] = "Wednesday"
  (const char *) [4] = "Thursday"
  (const char *) [5] = "Friday"
  (const char *) [6] = "Saturday"

llvm-svn: 135736
2011-07-22 00:47:58 +00:00
Johnny Chen 6cbb8d684f Add test scenario of SBValue APIs for the 'days_of_week' global variable.
llvm-svn: 135716
2011-07-21 23:02:00 +00:00
Johnny Chen 6853cf66d1 Add test scenario for exercising SBValue API: TypeIsPointerType() and GetByteSize().
llvm-svn: 135699
2011-07-21 19:31:59 +00:00
Johnny Chen 2494f555b6 A more succinct assertTrue.
llvm-svn: 135544
2011-07-20 00:14:20 +00:00
Johnny Chen cd1211ef81 Minor change; add an assertTrue stmt.
llvm-svn: 135542
2011-07-20 00:11:54 +00:00
Johnny Chen 5819ab49fd Add TestValueAPI.py to exercise the newly added/modified SBValue APIs:
o GetChildAtIndex, and
o GetValueForExpressionPath

llvm-svn: 135315
2011-07-15 22:28:10 +00:00
Greg Clayton f660248238 Added the ability to get synthetic child values from SBValue objects that
represent pointers and arrays by adding an extra parameter to the 

SBValue
SBValue::GetChildAtIndex (uint32_t idx, 
                         DynamicValueType use_dynamic, 
                         bool can_create_synthetic);

The new "can_create_synthetic" will allow you to create child values that
aren't actually a part of the original type. So if you code like:

int *foo_ptr = ...

And you have a SBValue that contains the value for "foo_ptr":

SBValue foo_value = ...

You can now get the "foo_ptr[12]" item by doing this:

v = foo_value.GetChiltAtIndex (12, lldb.eNoDynamicValues, True);

Normall the "foo_value" would only have one child value (an integer), but
we can create "synthetic" child values by treating the pointer as an array.

Likewise if you have code like:

int array[2];

array_value = ....

v = array_value.GetChiltAtIndex (0);     // Success, v will be valid
v = array_value.GetChiltAtIndex (1);     // Success, v will be valid
v = array_value.GetChiltAtIndex (2);     // Fail, v won't be valid, "2" is not a valid zero based index in "array"

But if you use the ability to create synthetic children:

v = array_value.GetChiltAtIndex (0, lldb.eNoDynamicValues, True);     // Success, v will be valid
v = array_value.GetChiltAtIndex (1, lldb.eNoDynamicValues, True);     // Success, v will be valid
v = array_value.GetChiltAtIndex (2, lldb.eNoDynamicValues, True);     // Success, v will be valid

llvm-svn: 135292
2011-07-15 19:31:49 +00:00
Johnny Chen b3f07c1959 Minor change of variable name, from m to b (for breakpoint).
llvm-svn: 135214
2011-07-14 23:33:34 +00:00
Johnny Chen 13ea11afde Modify the test script to better handle the different inlining behaviors of
clang/gcc/llvm-gcc.  If the first breakpoint is due to stop at an inlined
frame, test that the call site corresponds to where it should be.  Also add
an expecr for a second break stop, if the first break stop corresponds to an
inlined call frame #0.

rdar://problem/9741470

llvm-svn: 135100
2011-07-13 22:34:29 +00:00
Johnny Chen 1d3e880c2c Passing in os.ctermid() as the arg for SBTarget.Launch(...) for stdin_path, stdout_path, and stderr_path
is just wrong and resulted in the inferior's output getting mixed into the GDB remote communication's
log file.  Change all test cases to not pass os.ctermid() and either use SBTarget.LaunchSimple() or
SBTarget.Launch() and pass None as stdin_path/stdout_path/srderr_path to use a pseudo terminal.

rdar://problem/9716499 program output is getting mixed into the GDB remote communications

llvm-svn: 134940
2011-07-11 23:38:23 +00:00
Johnny Chen 9a07aba962 The lldbtest.TestBase.DebugSBValue(self, val) method call now does not need the frame argument.
Only the val (of SBValue type) argument is needed.

llvm-svn: 134915
2011-07-11 20:06:28 +00:00
Johnny Chen 56b92a7b04 Update the test scenario for find_global_variables() to now start the inferior process
before issuing API calls to find the global variable and to get its value.

rdar://problem/9700873 has been updated to reflect the latest status.  The dwarf case
now does not seg fault if the inferior is not started; instead, for dwarf case, the
value retrieved from the global variable is None.

llvm-svn: 134909
2011-07-11 19:15:11 +00:00
Johnny Chen 07398b5d48 Add some comment.
llvm-svn: 134769
2011-07-08 23:07:53 +00:00
Johnny Chen 3a709ac7bf o TestEvents.py:
Add a usage example of SBEvent APIs.

o SBEvent.h and SBListener.h:

Add method docstrings for SBEvent.h and SBListener.h, and example usage of SBEvent into
the class docstring of SBEvent.

o lldb.swig:

Add typemap for SBEvent::SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len)
so that we can use, in Python, obj2 = lldb.SBEvent(0, "abc") to create an SBEvent.

llvm-svn: 134766
2011-07-08 23:02:33 +00:00
Johnny Chen f4e9a4c676 Rearranged the debug output to come before the assert for function name 'outer_inline'.
Right now clang-139 fails the test.

llvm-svn: 134673
2011-07-08 01:01:45 +00:00
Johnny Chen f4f54206d9 The Python API does not need SBEvent::BroadcasterMatchesPtr() when SBEvent::BroadcasterMatchesRef() suffices.
llvm-svn: 134659
2011-07-07 23:45:49 +00:00
Johnny Chen f8ae3c7396 Add assert to check the SBModule of SBSymbolContextList returned from SBTarget.FindFunctions().
llvm-svn: 134651
2011-07-07 22:45:54 +00:00
Johnny Chen 4bc80decfb Add test cases to exercise the SBTarget.FindFunctions() API.
llvm-svn: 134646
2011-07-07 22:22:51 +00:00
Johnny Chen f82eb4043b Add fuzz calls for SBType::IsPointerType(void *opaque_type).
llvm-svn: 134551
2011-07-06 22:11:38 +00:00
Johnny Chen 34ed733c69 Add swig docstrings for SBModule.h, plus ifndef the SBModule::GetUUIDBytes() API out if swig.
Fix typos in the comment for Module.h.

llvm-svn: 134446
2011-07-05 22:03:36 +00:00
Johnny Chen 086b1b774e While we are at it, let's also exercise the similar SBModule.FindGlobalVariables() API within
the find_global_variables() test method.

Skipping test_find_global_variables_with_dwarf(self) due to segmentation fault.

llvm-svn: 134118
2011-06-30 00:24:31 +00:00
Johnny Chen 466c593912 Add test cases to TestTargetAPI.py to exercise the newly added SBTarget.FindGlobalVariables() API.
llvm-svn: 134109
2011-06-29 22:45:06 +00:00
Johnny Chen d1ef780bb3 Add fuzz calls for SBModule/SBTarget.FindGlobalVariables(...).
llvm-svn: 134107
2011-06-29 22:26:59 +00:00
Johnny Chen 8bae20f7f7 Add fuzz calls for SBTypeMember.
llvm-svn: 134098
2011-06-29 21:42:46 +00:00
Johnny Chen 6999f86617 Add fuzz calls to SBType, SBValue, and SBValueList.
Fixed crashes for SBValue fuzz calls.
And change 'bool SBType::IsPointerType(void)' to
'bool SBType::IsAPointerType(void)' to avoid name collision with the static 'bool SBType::IsPointerType(void *)'
function, which SWIG cannot handle.

llvm-svn: 134096
2011-06-29 21:19:39 +00:00
Johnny Chen 8ebed74e6e Add fuzz calls for SBTarget and SBThread.
llvm-svn: 134046
2011-06-29 00:05:40 +00:00
Johnny Chen c74ed6b0de Add fuzz calls for SBSymbol and SBSymbolContext.
llvm-svn: 134042
2011-06-28 23:38:38 +00:00
Johnny Chen dedd7d6ed6 Add fuzz calls for SBStringList and add obj.Clear() calls for some files.
llvm-svn: 134040
2011-06-28 23:29:14 +00:00
Johnny Chen a25bf6efb5 Add fuzz calls for SBModule and SBProcess.
llvm-svn: 134037
2011-06-28 22:32:15 +00:00
Johnny Chen 4e77f6f499 Add fuzz calls for SBListener.
llvm-svn: 134029
2011-06-28 20:57:22 +00:00
Johnny Chen 520eeff0ef Add fuzz calls for SBLineEntry.
llvm-svn: 134028
2011-06-28 20:46:03 +00:00
Johnny Chen 6f306a4859 Add fuzz calls for SBInstruction and SBInstructionList.
llvm-svn: 134020
2011-06-28 19:07:02 +00:00
Johnny Chen 24c5296957 Add fuzz calls for SBInputReader.
llvm-svn: 133972
2011-06-28 00:12:06 +00:00
Johnny Chen 40e978f7b3 Add fuzz calls for SBFrame and SBFunction.
llvm-svn: 133965
2011-06-27 23:53:55 +00:00
Johnny Chen d982f039a1 Add fuzz calls for SBFileSpec.
llvm-svn: 133956
2011-06-27 22:55:51 +00:00
Johnny Chen 71eabde2f8 Add fuzz calls for SBEvent.
llvm-svn: 133954
2011-06-27 22:38:57 +00:00
Johnny Chen a9dd83be4b Move hello_world to now reside under python_api dir.
llvm-svn: 133890
2011-06-26 20:59:36 +00:00
Johnny Chen 06657625b8 Add fuzz calls for SBError.
llvm-svn: 133850
2011-06-25 00:21:00 +00:00
Johnny Chen 3c7a726a6d Add fuzz calls for SBDebugger.
llvm-svn: 133848
2011-06-25 00:09:29 +00:00
Johnny Chen a81d2af5bc Add fuzz calls for SBCompileUnit.
llvm-svn: 133843
2011-06-24 23:33:03 +00:00
Johnny Chen 6e3dfa6025 Add fuzz calls for SBCommunication.
llvm-svn: 133839
2011-06-24 23:16:27 +00:00
Johnny Chen 57e34b21db Add fuzz calls for SBBroadcaster.
llvm-svn: 133837
2011-06-24 22:53:12 +00:00
Johnny Chen b5491a6e60 Add fuzz calls for SBBreakpointLocation.
llvm-svn: 133810
2011-06-24 19:00:22 +00:00
Johnny Chen 1bd3d731d9 Add fuzz calls for SBBreakpoint.
llvm-svn: 133809
2011-06-24 18:49:27 +00:00
Johnny Chen 2f675dcb39 Add fuzz calls for SBBlock.
llvm-svn: 133780
2011-06-24 00:21:36 +00:00
Johnny Chen 4d1f660ace Start adding API calls to the invalid SB API object after default construction.
It should not crash lldb.

This checkin adds calls for SBAddress.

llvm-svn: 133778
2011-06-24 00:06:53 +00:00
Johnny Chen b7373c92e6 o lldbtest.py:
Assign the test method name to self.testMethodName.  This can be useful for the
test directory (see test/types for a good example) which houses a bunch of executables
compiled from different source files.  The default build action is to create a.out as
the binary executable, which can confuse the module cacheing mechanism and result in
the debugger getting a stale image as the target to be debugged, and chaos ensues.

o AbstractBase.py, TestThreadAPI.py:

Use self.testMethodName to our advantage.

o TestLoadUnload.py:

Add expected failure marker to test case test_modules_search_paths().

llvm-svn: 133768
2011-06-23 22:11:20 +00:00
Johnny Chen 02028fa190 For now, use 'b.out' compiled from main2.cpp as the executable name for test_run_to_address_with_dsym/dwarf()
to distinguish between other test cases which use 'a.out' compiled from main.cpp.

llvm-svn: 133764
2011-06-23 21:22:01 +00:00
Johnny Chen fdfa26fba0 Add docstring to test_SBSymbolContextList(self) explaining that upon default construction, the API object is valid.
llvm-svn: 133644
2011-06-22 20:57:52 +00:00
Johnny Chen e98f7f2cfa Recent change to SBSymbolContextList (r133498) makes the default constructor return
a valid SB API object.  Modify the test case to accommodate.

llvm-svn: 133602
2011-06-22 02:39:46 +00:00
Johnny Chen 3343c13c6e Minor module-level docstring change.
llvm-svn: 133476
2011-06-20 22:33:35 +00:00
Johnny Chen dd68ab83b9 Test lldb Python API object's default constructor and make sure it is invalid
after initial construction.

There are two exceptions to the above general rules, though; the API objects are
SBCommadnReturnObject and SBStream.

llvm-svn: 133475
2011-06-20 22:30:48 +00:00
Johnny Chen 4cfd07ef07 Add TestInlinedFrame.py to exercise the newly added SBFrame APIs: IsInlined() and GetFunctionName().
llvm-svn: 133404
2011-06-20 00:26:39 +00:00
Johnny Chen 0d4f6dd01e o lldbutil.py:
For the print_stacktrace(thread, string_buffer = False) function, if we have debug info
  for a frame function, let's also emit the args for the current function.

o TestFrameUtils.py:

  Add stronger assertTrue for frame0's args.

o TestPrintStackTraces.py:

  Launch the inferior with ["abc", "xyz"] and expect '(int)argc=3' in the stack traces, since
  by design the inferior is built with debug info.

llvm-svn: 133204
2011-06-16 22:07:48 +00:00
Johnny Chen 5a0bee7c5f The extra burden for the Python API test case to assign its process object to self.process
in order to have its process cleaned up (terminated) upon tearDown is gone for good.
Let's simplify a bunch of Python API test cases.

llvm-svn: 133097
2011-06-15 22:14:12 +00:00
Johnny Chen 4b6fed4bab Comment out the debug stmts.
llvm-svn: 132808
2011-06-09 22:09:52 +00:00
Johnny Chen e2b5cfd826 Add rich comparison methods for the SBAddress object.
If two SBAddress's have the same module and file address, they are considered equal.

Add a test snippet 'sa1 == sa2' to exercise the rich comparison methods for SBAddress.

llvm-svn: 132807
2011-06-09 22:04:56 +00:00
Johnny Chen 792ed4c616 Comment change.
llvm-svn: 132150
2011-05-26 21:50:47 +00:00
Johnny Chen 0c0f977840 Simplify test setup; there's no need to pass a customized dictionary here.
llvm-svn: 132147
2011-05-26 21:43:19 +00:00
Johnny Chen 4ebd019b97 Now that we have added a post-processing step for adding truth value testing to
those lldb objects which implement the IsValid() method, let's change the rest of
the test suite to use the more compact truth value testing pattern (the Python way).

llvm-svn: 131970
2011-05-24 18:22:45 +00:00
Johnny Chen 112f5696fb Add truth value testing to those lldb Python objects with the IsValid() method definitions.
object.__nonzero__(self) is called to implement truth value testing and the built-in operation bool(),
via a simple delegation to self.IsValid().

Change tests under python_api/lldbutil to utilize this mechanism.

llvm-svn: 131494
2011-05-17 22:14:39 +00:00
Johnny Chen fac7b3aae6 Add implementation of built-in function len() for those lldb containers with
unambiguous iteration support.  So that we could, for example:

    ...

    REGs = lldbutil.get_GPRs(frame)
    print "Number of general purpose registers: %d" % len(REGs)
    for reg in REGs:
        print "%s => %s" %(reg.GetName(), reg.GetValue())

    ...

llvm-svn: 131418
2011-05-16 20:31:18 +00:00
Johnny Chen 29fd504c09 Renamed the test cases more properly to test_lldb_iter_module/breakpoint/farme.
llvm-svn: 131412
2011-05-16 18:30:00 +00:00
Johnny Chen c8134cee01 Clean up the test a little bit; and use lldbutil.get_GPRs(frame) to retrieve the general purpose register set.
llvm-svn: 131324
2011-05-13 23:42:44 +00:00
Johnny Chen ad7372c538 Add two utility functions:
o get_parent_frame(frame)
    o get_args_as_string(frame)

to lldbutil.py and create TestFrameUtils.py to exercise the utils.
Plus re-arrange the test/python_api/lldbutil to have three directories
for testing iteration, process stack traces, and the just added frame utils.

llvm-svn: 131213
2011-05-12 00:32:41 +00:00
Johnny Chen 64ff7e6eee Add a utility function get_registers(frame, kind) to get the registers of a given frame and of a given kind.
Also add three convenience functions get_GPRs(frame), get_FPRs(frame), and get_ESRs(frame) to get the general
purpose registers, the floating point registers, and the exception state registers.

Add TestRegistersIterator.py to test these added functions of lldbutil.py.

llvm-svn: 131144
2011-05-10 19:21:13 +00:00
Johnny Chen 7209d84f1c Add an API test script file for SBCommandInterpreter.
llvm-svn: 131035
2011-05-06 23:26:12 +00:00
Johnny Chen d71670c04a Add implementation of '==' and '!=' for SBFileSpec and SBModule. Modify a test case to take advantage of 'ths_module == that_module'.
llvm-svn: 130709
2011-05-02 19:05:52 +00:00
Johnny Chen 0f023fa4af Add the Python rich comparison methods for SBBreakpoint, where GetID() returns
the breakpoint ID and provides the semantics needed for '==' and '!='.  And
modify LLDBIteratorTestCase.lldb_iter_2() to use '==' between two SBBreakpoint's.

llvm-svn: 130531
2011-04-29 19:03:02 +00:00
Johnny Chen e69c748328 Modify the test suite and lldbutil.py to utilize the Python iteration pattern now that
the lldb iteration protocol has been added to lldb.py module.

llvm-svn: 130452
2011-04-28 22:57:01 +00:00
Johnny Chen fbc0d27144 Move the iteration protocol of lldb objects to the auto-generated lldb Python module.
This is so that the objects which support the iteration protocol are immediately obvious
from looking at the lldb.py file.

SBTarget supports two types of iterations: module and breakpoint.  For an SBTarget instance,
you will need to issue either:

    for m in target.module_iter()

or

    for b in target.breakpoint_iter()

For other single iteration protocol objects, just use, for example:

    for thread in process:
        ID = thread.GetThreadID()
        for frame in thread:
            frame.Disassemble()
            ....

llvm-svn: 130442
2011-04-28 21:31:18 +00:00
Johnny Chen b2e1a5c998 Add a utility function smart_iter() which has knowledge of the getsize and the getelem
method names of all the lldb container objects and returns an iterator object when
passed an eligible lldb container object.

Example:

    from lldb_util import smart_iter
    for thread in smart_iter(process):
        ID = thread.GetThreadID()
        if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
            stopped_due_to_breakpoint = True
        for frame in smart_iter(thread):
            self.assertTrue(frame.GetThread().GetThreadID() == ID)
        ...

Add a test case for lldb.smart_iter().

llvm-svn: 130332
2011-04-27 21:44:09 +00:00
Johnny Chen f6c61a34bf Use new string formatting operations in assert messages to simplify things.
llvm-svn: 130325
2011-04-27 19:52:41 +00:00
Johnny Chen 3c7a72c5ad Add another test case for lldb_iter(), this time using SBTarget to get at its SBBreakpoint containees.
llvm-svn: 130323
2011-04-27 19:29:39 +00:00
Johnny Chen de90f1dd93 Change the rest of lldbutil.py's function names to all lower case formats to be consistent.
And modify the test cases accordingly.

llvm-svn: 130314
2011-04-27 17:43:07 +00:00
Johnny Chen c5f121e3c0 Add a test case for lldbutil.lldb_iter() which returns an iterator object
for lldb objects which can contain other lldb objects.  Examples are:
SBTarget contains SBModule, SBModule contains SBSymbols, SBProcess contains
SBThread, SBThread contains SBFrame, etc.

llvm-svn: 130258
2011-04-26 23:54:25 +00:00
Johnny Chen d0fef81e38 For lldbutil.py, Change a bunch of function names to all lower case formats to be consistent.
And modify the test cases accordingly.

llvm-svn: 130174
2011-04-25 23:38:13 +00:00
Johnny Chen fc87e2dd5c Make SBBreakpointLocation::GetDescription() API to be consistent with SBTarget,
i.e., with 'SBStream &description' first, followed by 'DescriptionLevel level'.

Modify lldbutil.py so that get_description() for a target or breakpoint location
can just take the lldb object itself without specifying an option to mean option
lldb.eDescriptionLevelBrief.  Modify TestTargetAPI.py to exercise this logic path.

llvm-svn: 130147
2011-04-25 20:23:05 +00:00
Johnny Chen 9ae982053f Convert the rest of the test suite to use the lldbutil.get_description() utility function.
llvm-svn: 130041
2011-04-23 00:34:56 +00:00
Johnny Chen 90256cdaba Add a simple utility function get_description(lldb_obj, option=None) to lldbutil.py
and use it from TestTargetAPI.py.

llvm-svn: 130038
2011-04-23 00:13:34 +00:00
Johnny Chen 787f71f269 Add test cases for the SBTarget.GetDescription() API which takes an extra lldb::DescriptionLevel enum.
llvm-svn: 130029
2011-04-22 23:20:17 +00:00
Johnny Chen 0b8fd43397 Rename test/threads to python_api/lldbutil; it uses lldbutil functions to print stack traces.
llvm-svn: 129828
2011-04-19 22:44:20 +00:00
Johnny Chen c1c92a2ab3 Converted to use SBProcess.LaunchSimple().
And use self.TraceOn() API.

llvm-svn: 129797
2011-04-19 20:11:58 +00:00
Johnny Chen bd9b6e9ffb Converted to use SBProcess.LaunchSimple().
llvm-svn: 129795
2011-04-19 19:54:06 +00:00
Johnny Chen aedbe0f347 Converted to use SBProcess.LaunchSimple().
llvm-svn: 129793
2011-04-19 19:50:43 +00:00
Johnny Chen 90da3ccadb Use self.TraceOn() API.
llvm-svn: 129792
2011-04-19 19:49:09 +00:00
Johnny Chen 9efcb0ec4d Converted to use SBProcess.LaunchSimple() API.
And use self.TraceOn() in order to print more debug output.

llvm-svn: 129791
2011-04-19 19:44:26 +00:00
Johnny Chen fbf1cfea12 Converted to use SBProcess.LaunchSimple().
And use self.TraceOn() API.

llvm-svn: 129790
2011-04-19 19:34:41 +00:00
Johnny Chen 272ae4df7c Converted to use SBProcess.LaunchSimple().
llvm-svn: 129789
2011-04-19 19:25:37 +00:00
Jim Ingham 78a685aa2d Add support for "dynamic values" for C++ classes. This currently only works for "frame var" and for the
expressions that are simple enough to get passed to the "frame var" underpinnings.  The parser code will
have to be changed to also query for the dynamic types & offsets as it is looking up variables.

The behavior of "frame var" is controlled in two ways.  You can pass "-d {true/false} to the frame var
command to get the dynamic or static value of the variables you are printing.

There's also a general setting:

target.prefer-dynamic-value (boolean) = 'true'

which is consulted if you call "frame var" without supplying a value for the -d option.

llvm-svn: 129623
2011-04-16 00:01:13 +00:00
Johnny Chen df2963ed46 Add TestSymbolAPI.py to test the newly added SBSymbol and SBAddress APIs:
lldb::SymbolType SBSymbol::GetType();

  lldb::SectionType SBAddress::GetSectionType ();
  lldb::SBModule SBAddress::GetModule ();

Also add an lldb::SBModule::GetUUIDString() API which is easier for Python
to work with in the test script.

llvm-svn: 128695
2011-04-01 00:35:55 +00:00
Jim Ingham 8d543de400 Remove unneeded ExecutionContextScope variables.
llvm-svn: 128685
2011-03-31 23:01:21 +00:00
Johnny Chen fdc94ff97e Add test cases to exercise the SBThread.GetProcess() API. We launch the process using the
SBTarget.Launch() API, stop at a breakpoint, get the stopped thread, and verify that the
pid of the stopped thread's process is equal to the pid of the process returned by
SBTarget.Launch().

llvm-svn: 127444
2011-03-11 01:16:03 +00:00
Johnny Chen 2d799cca03 Add a test case test_run_to_address() to exercise the SBThread.RunToAddress(lldb::addr_t addr) API.
The test itself is not working yet.

llvm-svn: 127436
2011-03-11 00:00:15 +00:00
Johnny Chen f93286f20c Add test cases to TestThreadAPI.py to exercise SBThread.StepOver() by stopping at a breakpoint,
doing three step-over's, then verifying that the correct source line number is reached.

llvm-svn: 127432
2011-03-10 22:32:47 +00:00
Johnny Chen d9f2c08a0a Test cleanup. Check for the full caller symbol of malloc -- b(int).
llvm-svn: 127421
2011-03-10 19:18:04 +00:00
Johnny Chen a460316d81 Add test cases for Python SBThread.StepOut() API by stepping out of a malloc call where the call site is at function b().
Verifies that after the thread.StepOut(), we are at the correct line within function b.

llvm-svn: 127374
2011-03-09 23:45:56 +00:00
Johnny Chen d648135902 Add an extra twist of stopping the inferior in a breakpoint, and then continue till it's done.
We should still see the entire stdout redirected once the process is finished.

llvm-svn: 127184
2011-03-07 22:46:30 +00:00
Johnny Chen 75625aa118 Add test cases for SBTarget.Launch() API with the stdout of the inferior redirected to a file.
llvm-svn: 127179
2011-03-07 22:29:04 +00:00
Johnny Chen 2f6f7ba879 Add TestThreadAPI.py file to house the Python SBThread API test cases.
Currently it has only test cases for SBThread.GetStopDescription() API.

Also modified lldb.swig to add typemap for (char *dst, size_t dst_len)
which occurs for SBThread::GetStopDescription() C++ API.  For Python
scripting:

    # Due to the typemap magic (see lldb.swig), we pass in an (int)length to GetStopDescription
    # and expect to get a Python string as the result object!
    # The 100 is just an arbitrary number specifying the buffer size.
    stop_description = thread.GetStopDescription(100)

llvm-svn: 127173
2011-03-07 21:28:57 +00:00
Johnny Chen 930e3ad51e Add a test case ProcessAPITestCase.test_remote_launch() which tests SBProcess.RemoteLaunch()
API with a process not in eStateConnected, and checks that the remote launch failed.

Modify SBProcess::RemoteLaunch()/RemoteAttachToProcessWithID()'s log statements to fix a
crasher when logging is turned on.

llvm-svn: 127055
2011-03-05 01:20:11 +00:00
Johnny Chen 05178f6e54 Add a test case for the lldb command 'process connect'.
We start a fake debugserver listening on localhost:12345 and issue the command
'process connect connect://localhost:12345' to connect to it.

llvm-svn: 127048
2011-03-04 23:40:06 +00:00
Johnny Chen ed4019802d Add TestDisasmAPI.py which exercises the newly added SBFunction/SBSymbol.GetStartAddress(),
among other things:

// When stopped on breakppint 1, we can get the line entry using SBFrame API
// SBFrame.GetLineEntry().  We'll get the start address for the the line entry
// with the SBAddress type, resolve the symbol context using the SBTarget API
// SBTarget.ResolveSymbolContextForAddress() in order to get the SBSymbol.
//
// We then stop at breakpoint 2, get the SBFrame, and the the SBFunction object.
//
// The address from calling GetStartAddress() on the symbol and the function
// should point to the same address, and we also verify that.

And add one utility function disassemble(target, function_or_symbol) to lldbutil.py:

    """Disassemble the function or symbol given a target.

    It returns the disassembly content in a string object.
    """

TestDisasm.py uses the disassemble() function to do disassembly on the SBSymbol, and
then the SBFunction object.

llvm-svn: 126955
2011-03-03 19:14:00 +00:00
Johnny Chen d61816b5b8 Add TestTargetAPI.py:
// When stopped on breakppint 1, and then 2, we can get the line entries using
// SBFrame API SBFrame.GetLineEntry().  We'll get the start addresses for the
// two line entries; with the start address (of SBAddress type), we can then
// resolve the symbol context using the SBTarget API
// SBTarget.ResolveSymbolContextForAddress().
//
// The two symbol context should point to the same symbol, i.e., 'a' function.


Add two utility functions to lldbutil.py:

o get_stopped_threads(process, reason):

  return the list of threads with the specified stop reason or an empty list if not found

o get_stopped_thread(process, reason):

  return the first thread with the given stop reason or None if not found

llvm-svn: 126916
2011-03-03 01:41:57 +00:00
Johnny Chen 4e90a7e503 Add some comments.
llvm-svn: 126867
2011-03-02 19:49:27 +00:00
Johnny Chen 43766d6f12 Add two utility functions to lldbutil.py:
o int_to_bytearray()
o bytearray_to_int()

They return/interpret the bytearray in the little endian format.
For big endian, simply perform ba.reverse() on the bytearray object.

And modify TestProcessAPI.py to take advantage of the functions.

llvm-svn: 126813
2011-03-02 01:36:45 +00:00
Johnny Chen cf386e24ab Add an API SBProcess::GetByteOrder() and add test cases which utilizes GetByteOrder(),
among other SBProcess APIs, to write (int)256 into a memory location of a global variable
(int)my_int and reads/checks the variable afterwards.

llvm-svn: 126792
2011-03-01 22:56:31 +00:00
Johnny Chen 0dd049204c Fix wrong placement of skipUnless() decorator.
llvm-svn: 126774
2011-03-01 19:53:43 +00:00
Johnny Chen 90aa594c5e Add test methods for SBProcess.WriteMemory() API to the TestProcessAPI.py file.
This makes the number of total tests equal to 201.

llvm-svn: 126769
2011-03-01 18:51:47 +00:00
Johnny Chen 37f99fdb73 Add TestProcessAPI.py which exercises some Python SBProcess API. In particular, this tests
the SBProcess.ReadMemory() API, which, due to SWIG typemap'ing, expects 3 arguments (the location
to read from, the size in bytes to read, and an SBError object), and returns the result as a
Python string object.

On SnowLeopard where this has been tested, the SWIG script needs to be pampered (use the exact
same parameter names as in SBProcess.h) in order for this to work.

llvm-svn: 126736
2011-03-01 02:20:14 +00:00
Johnny Chen d762ff1faa Modify test scripts to accomodate SBTarget.Launch() API change.
llvm-svn: 124828
2011-02-03 23:15:53 +00:00