summaryrefslogtreecommitdiffstats
path: root/lldb/test/python_api
Commit message (Collapse)AuthorAgeFilesLines
...
* Export the watchpoint related API (SBWatchpointLocation class and added ↵Johnny Chen2011-09-271-0/+118
| | | | | | | | | | | | | | 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
* Remove the @expectedFailureClang custom decorator for indicating ↵Johnny Chen2011-09-261-2/+3
| | | | | | | | clang-specific test failures. It has been fixed on the lldb side to compensate for bad debug info (line table information). llvm-svn: 140550
* Fix comment.Johnny Chen2011-09-241-1/+1
| | | | llvm-svn: 140450
* Add FindValue() and WatchValue() fuzz calls to the mix.Johnny Chen2011-09-241-0/+3
| | | | llvm-svn: 140439
* Added to the public API to allow symbolication:Greg Clayton2011-09-243-4/+4
| | | | | | | | | | | | | | | | | - 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
* Add an SB API SBFrame::WatchValue() and exported to the Python interface toJohnny Chen2011-09-243-0/+126
| | | | | | | | | | | | | | | | 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
* Fix wrong test method name.Johnny Chen2011-09-151-1/+1
| | | | llvm-svn: 139863
* Add fuzz calls for added API methods: FindFirstType(), FindTypes(), and ↵Johnny Chen2011-09-151-0/+3
| | | | | | GetSourceManager(). llvm-svn: 139857
* Add fuzz calls to newly added methods: GetAsync() and ↵Johnny Chen2011-09-151-0/+2
| | | | | | SetSelectedTarget(SBTarget). llvm-svn: 139855
* Test should print to stdout only if self.TraceOn() is True.Johnny Chen2011-09-061-10/+20
| | | | llvm-svn: 139174
* Redesign of the interaction between Python and frozen objects:Enrico Granata2011-09-063-0/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Add a decorator for marking clang only expectedFailure. Use it for the ↵Johnny Chen2011-08-191-0/+4
| | | | | | | | | | | | | | | | | | | | 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
* Re-enable the test for ValueAsUnsigned on a register Value.Jim Ingham2011-08-161-5/+3
| | | | llvm-svn: 137738
* Add new SBAddress APIs to the fuzz tests.Johnny Chen2011-08-151-0/+8
| | | | llvm-svn: 137625
* Test case for changing ValueObjects with SBValue::SetValueFromCString.Jim Ingham2011-08-133-0/+181
| | | | llvm-svn: 137543
* Add logic to SBValue.linked_list_iter() to detect infinite loop and to bail ↵Johnny Chen2011-08-112-0/+21
| | | | | | | | | | | | 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
* Change the SBValue.linked_list_iter() to treat the value object as a ↵Johnny Chen2011-08-111-3/+3
| | | | | | | | | | | | | 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
* On second thought, add the IsValid() method to SBTypeList, making it similar ↵Johnny Chen2011-08-051-4/+2
| | | | | | | | to SBSymbolContextList and SBValueList. Modify the test suite accordingly. llvm-svn: 136990
* Fixed test suite failure of test_SBTypeList().Johnny Chen2011-08-051-1/+4
| | | | | | | | 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
* Add SBType.GetBasicType() to the test scenario.Johnny Chen2011-08-051-0/+9
| | | | | | Add docstring for SBType, too. llvm-svn: 136983
* o modify-python-lldb.py:Johnny Chen2011-08-053-0/+162
| | | | | | | | | | | | | | | 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
* Remove expectedFailure decorator for test_SBType, which does not take an ↵Johnny Chen2011-08-052-30/+15
| | | | | | | | | 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
* Cleaned up the SBType.h file to not include internal headers and reorganizedGreg Clayton2011-08-033-14/+14
| | | | | | | | | | | | | | | | | | 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
* Add a @benchmarks_test decorator for test method we want to categorize as ↵Johnny Chen2011-07-304-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Public API changes:Enrico Granata2011-07-291-0/+2
| | | | | | | | | | | | | | | | | | | | | - 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
* The SBValue.linked_list_iter() API failed for an empty list.Johnny Chen2011-07-272-2/+24
| | | | | | Fix the bug and add a test case. llvm-svn: 136265
* Add skip test for clang, which has insufficient debug info for call site in ↵Johnny Chen2011-07-261-1/+3
| | | | | | main(). llvm-svn: 136184
* We can do better with the SBValue.linked_list_iter() API by supplying a defaultJohnny Chen2011-07-261-10/+26
| | | | | | | | | | | | | | 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
* The test function to determine whether we have reached the end of the list wasJohnny Chen2011-07-261-17/+12
| | | | | | | | | | | 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
* Add a stronger assert for the test to ensure that the visited items from ↵Johnny Chen2011-07-251-0/+9
| | | | | | | | iterating through the SBValue.linked_list_iter() API is equal to [1, 2, 4, 5]. llvm-svn: 135944
* Provide an add-on API to SBValue class by post-processing to provide a wayJohnny Chen2011-07-253-0/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add an additional formatter class RecursiveDecentFormatter which prints theJohnny Chen2011-07-222-1/+26
| | | | | | | | | | | | | | | | | 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
* Add new API for SBAddress to the fuzz test:Johnny Chen2011-07-221-0/+1
| | | | | | | SetLoadAddress (lldb::addr_t load_addr, lldb::SBTarget &target); llvm-svn: 135793
* Make the SBAddress class easier to use when using the publicGreg Clayton2011-07-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add BasicFormatter and ChildVisitingFormatter utility classes to the ↵Johnny Chen2011-07-222-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add test scenario of SBValue APIs for the 'days_of_week' global variable.Johnny Chen2011-07-211-0/+7
| | | | llvm-svn: 135716
* Add test scenario for exercising SBValue API: TypeIsPointerType() and ↵Johnny Chen2011-07-211-0/+10
| | | | | | GetByteSize(). llvm-svn: 135699
* A more succinct assertTrue.Johnny Chen2011-07-201-2/+1
| | | | llvm-svn: 135544
* Minor change; add an assertTrue stmt.Johnny Chen2011-07-201-0/+1
| | | | llvm-svn: 135542
* Add TestValueAPI.py to exercise the newly added/modified SBValue APIs:Johnny Chen2011-07-153-0/+122
| | | | | | | o GetChildAtIndex, and o GetValueForExpressionPath llvm-svn: 135315
* Added the ability to get synthetic child values from SBValue objects thatGreg Clayton2011-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Minor change of variable name, from m to b (for breakpoint).Johnny Chen2011-07-141-2/+2
| | | | llvm-svn: 135214
* Modify the test script to better handle the different inlining behaviors ofJohnny Chen2011-07-132-10/+37
| | | | | | | | | | | 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
* Passing in os.ctermid() as the arg for SBTarget.Launch(...) for stdin_path, ↵Johnny Chen2011-07-115-21/+17
| | | | | | | | | | | | 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
* The lldbtest.TestBase.DebugSBValue(self, val) method call now does not need ↵Johnny Chen2011-07-111-3/+3
| | | | | | | | the frame argument. Only the val (of SBValue type) argument is needed. llvm-svn: 134915
* Update the test scenario for find_global_variables() to now start the ↵Johnny Chen2011-07-111-1/+21
| | | | | | | | | | | | 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
* Add some comment.Johnny Chen2011-07-081-0/+1
| | | | llvm-svn: 134769
* o TestEvents.py:Johnny Chen2011-07-082-0/+88
| | | | | | | | | | | | | | | | 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
* Rearranged the debug output to come before the assert for function name ↵Johnny Chen2011-07-081-6/+6
| | | | | | | | 'outer_inline'. Right now clang-139 fails the test. llvm-svn: 134673
* The Python API does not need SBEvent::BroadcasterMatchesPtr() when ↵Johnny Chen2011-07-071-1/+0
| | | | | | SBEvent::BroadcasterMatchesRef() suffices. llvm-svn: 134659
OpenPOWER on IntegriCloud