Commit Graph

244 Commits

Author SHA1 Message Date
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