Commit Graph

154 Commits

Author SHA1 Message Date
Johnny Chen 8a8ce4ad2f Fixed the error message:
./build-swig-Python.sh: line 76: INTERFACE_FILES: command not found

when running SWIG, which was introduced during the last checkin.

llvm-svn: 139376
2011-09-09 17:37:06 +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
Enrico Granata dc9407308e Additional code cleanups ; Short option name for --python-script in type summary add moved from -s to -o (this is a preliminary step in moving the short option for --summary-string from -f to -s) ; Accordingly updated the test suite
llvm-svn: 138315
2011-08-23 00:32:52 +00:00
Johnny Chen 30123f114a Check the timesatmps of includees python-extensions.swig and python-wrapper.swig and force
a re-SWIG if newer than the SWIG-generated LLDBWrapPython.cpp file.

llvm-svn: 138280
2011-08-22 22:10:57 +00:00
Enrico Granata def5391ae5 - Support for Python namespaces:
If you have a Python module foo, in order to use its contained objects in LLDB you do not need to use
  'from foo import *'. You can use 'import foo', and then refer to items in foo as 'foo.bar', and LLDB
  will know how to resolve bar as a member of foo.
  Accordingly, GNU libstdc++ formatters have been moved from the global namespace to gnu_libstdcpp and a few
  test cases are also updated to reflect the new convention. Python docs suggest using a plain 'import' en lieu of
  'from-import'.

llvm-svn: 138244
2011-08-22 17:34:47 +00:00
Enrico Granata e73d96f659 Further fix for SWIG interoperability; making sure the Release() method of SBCommandReturnObject is called at all times
llvm-svn: 138169
2011-08-20 00:26:17 +00:00
Enrico Granata 274fd6e965 Fixed some SWIG interoperability issues
llvm-svn: 138154
2011-08-19 23:56:34 +00:00
Enrico Granata 58ad33440a Taking care of an issue with using lldb_private types in SBCommandInterpreter.cpp ; Making NSString test case work on Snow Leopard ; Removing an unused variable warning
llvm-svn: 138105
2011-08-19 21:56:10 +00:00
Enrico Granata c482a19294 First round of code cleanups:
- all instances of "vobj" have been renamed to "valobj"
 - class Debugger::Formatting has been renamed to DataVisualization (defined in FormatManager.h/cpp)
   The interface to this class has not changed
 - FormatCategory now uses ConstString's as keys to the navigators instead of repeatedly casting
   from ConstString to const char* and back all the time
   Next step is making the same happen for categories themselves
 - category gnu-libstdc++ is defined in the constructor for a FormatManager
   The source code for it is defined in gnu_libstdcpp.py, drawn from examples/synthetic at compile time
   All references to previous 'osxcpp' name have been removed from both code and file names
Functional changes:
 - the name of the option to use a summary string for 'type summary add' has changed from the previous --format-string
   to the new --summary-string. It is expected that the short option will change from -f to -s, and -s for --python-script
   will become -o

llvm-svn: 137886
2011-08-17 22:13:59 +00:00
Enrico Granata 217f91fc57 New category "gnu-libstdc++" provides summary for std::string and synthetic children for types std::map, std::list and std::vector
The category is enabled by default. If you run into issues with it, disable it and the previous behavior of LLDB is restored
 ** This is a temporary solution. The general solution to having formatters pulled in at startup should involve going through the Platform.
Fixed an issue in type synthetic list where a category with synthetic providers in it was not shown if all the providers were regex-based

llvm-svn: 137850
2011-08-17 19:07:52 +00:00
Enrico Granata 223383ed6c Changes to Python commands:
- They now have an SBCommandReturnObject instead of an SBStream as third argument
 - The class CommandObjectPythonFunction has been merged into CommandObjectCommands.cpp
 - The command to manage them is now:
  command script with subcommands add, list, delete, clear
   command alias is returned to its previous functionality
 - Python commands are now part of an user dictionary, instead of being seen as aliases
 

llvm-svn: 137785
2011-08-16 23:24:13 +00:00
Enrico Granata be93a35a8a Python commands:
It is now possible to use 'command alias --python' to define a command name that actually triggers execution of a Python function
 (e.g. command alias --python foo foo_impl makes a command named 'foo' that runs Python function 'foo_impl')
 The Python function foo_impl should have as signature: def foo_impl(debugger, args, stream, dict): where
  debugger is an object wrapping an LLDB SBDebugger
  args is the command line arguments, as an unparsed Python string
  stream is an SBStream that represents the standard output
  dict is an internal utility parameter and should be left untouched
 The function should return None on no error, or an error string to describe any problems

llvm-svn: 137722
2011-08-16 16:49:25 +00:00
Johnny Chen 53cb46ebd7 Update the SBAddress.i Python interface file to the latest SBAddress.h,
and add some docstrings.

llvm-svn: 137528
2011-08-12 22:52:11 +00:00
Enrico Granata a365f296e6 Fixed an issue where LLDB was complaining about the lack of 'update' in a synthetic provider, despite it being optional
llvm-svn: 137330
2011-08-11 19:20:44 +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 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 9b97f1c3e6 Add docstring & example usage for SBTypeList.
llvm-svn: 136979
2011-08-05 20:48:02 +00:00
Johnny Chen 20208b37e3 Fix indentation and remove the private section of SBTypeList.
SWIG doesn't care about the private section of class SBTypeList.

llvm-svn: 136976
2011-08-05 20:30:56 +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 05c998ceda The recently introduced SBTypeList is also iterable.
This patch takes some time because the old Python constructor pattern was not a valid one,
and breaks with SBTypeList's __init__ signature.  Oops.

llvm-svn: 136958
2011-08-05 01:35:49 +00:00
Enrico Granata 6fd87d5d33 APIs to GetValueAsSigned/Unsigned() in SBValue now also accept an SBError parameter to give more info about any problem
The synthetic children providers now use the new (safer) APIs to get the values of objects
As a side effect, fixed an issue in ValueObject where ResolveValue() was not always updating the value before reading it

llvm-svn: 136861
2011-08-04 01:41:02 +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
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 07c10246b5 Add docstrings and cross refs to SBCompileUnit and SBLineEntry.
llvm-svn: 136230
2011-07-27 18:28:07 +00:00
Johnny Chen 3b67d57ae2 Add cross reference to SBThread from the SBFrame docstring. Also add a simple iteration example.
llvm-svn: 136227
2011-07-27 18:13:32 +00:00
Johnny Chen 2af257cd0d Add deprecation docstrings for some APIs which take an SBFrame - SBValues know their own frames.
llvm-svn: 136194
2011-07-27 00:08:59 +00:00
Johnny Chen 33c0c77073 Fix indentation and add a docstring for the ctor.
llvm-svn: 136187
2011-07-26 23:42:01 +00:00
Enrico Granata 0efa71aeb6 adding required utility function to SWIG interface
llvm-svn: 136147
2011-07-26 21:02:56 +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 11346d3136 lldb.swig (the SWIG input file) has become too large. Modularize a bit by introducing two files
to be included from lldb.swig: python-typemaps.swig and python-wrapper.swig.

llvm-svn: 136117
2011-07-26 19:09:03 +00:00
Johnny Chen 882b28b7bf Rename the parameter for the end-of-list test function from end_of_list to end_of_list_test.
llvm-svn: 136016
2011-07-25 23:44:48 +00:00
Johnny Chen a4bc3a7091 Add cross references between the docstrings for regular SBValue iteration:
for child in value:
        # do something with the child value

and SBValue.linked_list_iter():

    for task in task_head.linked_list_iter('next', eol_test):
        # visit each item in the linked list

llvm-svn: 136015
2011-07-25 23:41:08 +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
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 c7ed223d2a Change docstring wording: from 'method' to 'function'.
llvm-svn: 135648
2011-07-21 00:50:54 +00:00
Johnny Chen 3a31573f31 Add docstring for SBInstructionList class.
llvm-svn: 135647
2011-07-21 00:48:02 +00:00
Johnny Chen 098ca0e7e6 Add docstring for SBCommandReturnObject class.
llvm-svn: 135642
2011-07-21 00:32:12 +00:00
Johnny Chen ad4fe1b46e Add docstring for SBCommandInterpreter class.
llvm-svn: 135631
2011-07-20 22:50:58 +00:00
Johnny Chen 2e16d5dc8f Add docstring for SBBroadcaster class.
llvm-svn: 135630
2011-07-20 22:29:58 +00:00
Johnny Chen 5cb19e7725 Add some docstrings for SBFileSpec class.
llvm-svn: 135553
2011-07-20 01:06:37 +00:00
Johnny Chen 8957729268 Add some docstrings for SBError class.
llvm-svn: 135547
2011-07-20 00:23:11 +00:00
Johnny Chen 755e083ef6 Add some docstrings for SBSourceManager class.
llvm-svn: 135539
2011-07-19 23:35:10 +00:00
Johnny Chen e012858bd6 Add some docstrings for SBStream class.
llvm-svn: 135536
2011-07-19 23:24:36 +00:00
Johnny Chen fdc4a86c05 Move the rest of the SB headers to interface files.
They are not docstring'ed yet.

llvm-svn: 135531
2011-07-19 22:41:47 +00:00
Johnny Chen 349f076330 Add SWIG interface files for SBSymbol, SBSymbolContext, and SBSymbolContextList.
llvm-svn: 135459
2011-07-19 01:07:06 +00:00
Johnny Chen f74cb50cda Add SWIG Python interface files for SBLineEntry, SBListener, and SBModule.
llvm-svn: 135441
2011-07-18 23:11:07 +00:00
Johnny Chen d84a9a1249 Missed the interface file for SBFunction in the previous checkin.
llvm-svn: 135436
2011-07-18 22:15:37 +00:00
Johnny Chen 0eca544b45 Add SWIG Python interface files for SBDebugger, SBCompileUnit, and SBEvent.
llvm-svn: 135432
2011-07-18 22:11:53 +00:00
Johnny Chen 5de6a790f2 Add SWIG Python interface files for SBAddress, SBBlock, SBBreakpoint, and SBBreakpointLocation.
llvm-svn: 135430
2011-07-18 21:30:21 +00:00
Johnny Chen 357033b337 Add SWIG Python interface files for SBProcess, SBThread, and SBFrame.
llvm-svn: 135419
2011-07-18 20:13:38 +00:00
Johnny Chen 9a5b16b87c Fix header documentations.
llvm-svn: 135417
2011-07-18 19:15:22 +00:00
Johnny Chen 67ae7bdb54 Add two new interface files SBValue.i and SBValueList.i, instead of directly swigging the header files.
llvm-svn: 135416
2011-07-18 19:08:30 +00:00
Johnny Chen 482ad087ef Cleaned up the interface file for SBTarget.
llvm-svn: 135405
2011-07-18 17:53:20 +00:00
Johnny Chen 9ffc9f7a18 Have SWIG generate autodoc strings with parameter types for all SB API objects by default.
llvm-svn: 135357
2011-07-16 21:27:36 +00:00
Johnny Chen dc7d3c121b Create an interface file for SBTarget named SBTarget.i which relieves SBTarget.h
of the duty of having SWIG docstring features and multiline string literals
embedded within.

lldb.swig now %include .../SBTarget.i, instead of .../SBTarget.h.  Will create
other interface files and transition them over.

Also update modify-python-lldb.py to better handle the trailing blank line right
before the ending '"""' Python docstring delimiter.

llvm-svn: 135355
2011-07-16 21:15:39 +00:00
Johnny Chen 135f63fb30 Add some more docstrings for SBCompileUnit and SBBreakpoint, plus incorporate the doxgen doc block of
SBValue::GetChildAtIndex(uint32_t idx, 
                         lldb::DynamicValueType use_dynamic,
                         bool can_create_synthetic);

into the SBValue docstrings.

llvm-svn: 135295
2011-07-15 20:46:19 +00:00
Johnny Chen fa181f4fdb Add some more docstrings (includng example usages) to SBTarget.h.
Add logic to modify-python-lldb to correct swig's transformation of 'char **argv' and 'char **envp'
to 'char argv' and 'char envp' by morphing them into the 'list argv' and 'list envp' (as a list of
Python strings).

llvm-svn: 135114
2011-07-14 00:17:49 +00:00
Johnny Chen 02a07299b7 Missed the char_to_str_xform on the docstrings for the module level function definitions.
llvm-svn: 134775
2011-07-08 23:57:20 +00:00
Johnny Chen 102ac765f0 Add post-processing step to transform the docstring from 'char', i.e., 'char *', to 'str', i.e., Python string.
llvm-svn: 134543
2011-07-06 21:55:45 +00:00
Johnny Chen c201d8a999 Add a CLEANUP_DOCSTRING state to our FSM to do cleanup of the Python docstrings
generated from the swig docstring features instead of blindly applying the
cleanup action for all input lines.

llvm-svn: 134368
2011-07-03 19:55:50 +00:00
Johnny Chen b8f7603526 Add swig docstrings for SBFrame.h.
Add post-processing step to remove the trailing blank lines from the docstrings of lldb.py.

llvm-svn: 134360
2011-07-03 01:43:29 +00:00
Johnny Chen ed48137734 Refine the post-processing phase of lldb.py to remove some more doxygen/c++-comment residues.
llvm-svn: 134326
2011-07-02 20:01:09 +00:00
Johnny Chen b9a2c32219 Add some documentation blocks to SBTarget.h and use swig docstring feature to
take advantage of them.  Update modify-python-lldb.py to remove some 'residues'
resulting from swigification.

llvm-svn: 134269
2011-07-01 22:14:07 +00:00
Peter Collingbourne 059640b521 Generalise pattern for matching IsValid signature
Previously the IsValid pattern matched only function signatures of
the form:
    def IsValid(*args): ...

However under SWIG 1.3.40 on Linux the signature reads:
    def IsValid(self): ...

The new pattern matches both signature types by matching only up to
the left paren.

llvm-svn: 132968
2011-06-14 03:55:41 +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 755faf7744 Make it clear that the Python script modify-python-lldb.py is responsible for post-processing
the SWIG-generated lldb.py module by adding comments in the post-processed file in order to
facilitate reading of the code.

llvm-svn: 132417
2011-06-01 19:21:08 +00:00
Johnny Chen 2ced507a1e Fix comment.
llvm-svn: 132412
2011-06-01 18:40:11 +00:00
Charles Davis 4ce288e3e4 Fix remaining Python issues leftover from my previous patch.
- The Swig post-processing scripts are now run.
- edit-swig-python-wrapper-file.py has been modified so it can be run
from the Makefile.
- The issue that prompted me to pass -classic to swig is fixed by this,
so -classic isn't passed anymore.

Python shouldn't complain anymore about a missing method 'FindDebuggerByID'
on the SBDebugger object whenever lldb is run.

llvm-svn: 132383
2011-06-01 02:33:12 +00:00
Johnny Chen bf9cf5ec1e Use the with statement to simplify the build script.
llvm-svn: 132221
2011-05-27 21:58:22 +00:00
Johnny Chen 624ddf2f20 Added comment.
llvm-svn: 132019
2011-05-24 22:57:42 +00:00
Johnny Chen 2f1ee9a09c Comment change.
llvm-svn: 132018
2011-05-24 22:53:03 +00:00
Johnny Chen 93e7b3a8bd Fix a potential bug resulting from the wrong assumption that SWIG puts out the __init__
method definition before other method definitions.  Instead, do without it and process
the class with IsValid() method definition in all possible states.

llvm-svn: 132016
2011-05-24 22:29:49 +00:00
Johnny Chen 685b2b080f Update comment.
llvm-svn: 132002
2011-05-24 21:05:16 +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 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 17bae4c5e6 Fix a typo in comment.
llvm-svn: 130698
2011-05-02 17:53:04 +00:00
Johnny Chen f1c95f8bcb Update comments.
llvm-svn: 130533
2011-04-29 19:22:24 +00:00
Johnny Chen 31e4be06c4 Fix a bug introduced in my previous checkin, where the state was not properly
restored after parsing "SBTarget".  Indentation matters in Python. :-)

llvm-svn: 130532
2011-04-29 19:19:13 +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 51cc833af7 Fix a typo.
llvm-svn: 130461
2011-04-28 23:53:16 +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 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
Greg Clayton e0d378b334 Fixed the LLDB build so that we can have private types, private enums and
public types and public enums. This was done to keep the SWIG stuff from
parsing all sorts of enums and types that weren't needed, and allows us to
abstract our API better.

llvm-svn: 128239
2011-03-24 21:19:54 +00:00
Jim Ingham 6b90ba414a Look for swig in /usr/bin and /usr/local/bin.
llvm-svn: 126732
2011-03-01 01:39:04 +00:00
Caroline Tice 3cc8751d59 Remove references to particular Python version (use the system default
version);  change include statements to use Python.h in the Python framework
on Mac OS X systems; leave it using regular Python.h on other systems.

Note:  I think this *ought* to work properly on Linux systems, but I don't have
a system to test it on...

llvm-svn: 117612
2010-10-28 21:51:20 +00:00
Caroline Tice ceb6b1393d First pass at adding logging capabilities for the API functions. At the moment
it logs the function calls, their arguments and the return values.  This is not
complete or polished, but I am committing it now, at the request of someone who
really wants to use it, even though it's not really done.  It currently does not
attempt to log all the functions, just the most important ones.  I will be 
making further adjustments to the API logging code over the next few days/weeks.
(Suggestions for improvements are welcome).


Update the Python build scripts to re-build the swig C++ file whenever 
the python-extensions.swig file is modified.

Correct the help for 'log enable' command (give it the correct number & type of
arguments).

llvm-svn: 117349
2010-10-26 03:11:13 +00:00
Caroline Tice e206be2129 Add header files that were added to lldb.swig to the build
script, so it can keep track of dependencies accurately (for
knowing when to re-build LLDBWrapPython.cpp).

llvm-svn: 116765
2010-10-18 23:00:51 +00:00
Johnny Chen 7518ff0dda Wrap the file writing operations inside a with statement to simplify code.
llvm-svn: 116486
2010-10-14 16:57:08 +00:00
Johnny Chen cd8b2bbed2 Change the call within lldb.py to 'SBDebugger.Initialize()' from 'lldb.SBDebugger.Initialize()'.
Inside the lldb module, there's no need (and as a matter of fact, incorrect) to specify the 'lldb'
module name.

Comment out the call to lldb.SBDebugger.Initialize() within the test driver itself, since it is
already done when we import the lldb.py module.

llvm-svn: 116485
2010-10-14 16:36:49 +00:00
Caroline Tice 4ab31c98e6 Fix some memory leaks.
Add call to lldb.SBDebugger.Initialize() to lldb.py, so it automatically gets called when
the lldb Python module gets loaded.

llvm-svn: 116345
2010-10-12 21:57:09 +00:00
Greg Clayton 05faeb7135 Cleaned up the SWIG stuff so all includes happen as they should, no pulling
tricks to get types to resolve. I did this by correctly including the correct
files: stdint.h and all lldb-*.h files first before including the API files.
This allowed me to remove all of the hacks that were in the lldb.swig file
and it also allows all of the #defines in lldb-defines.h and enumerations
in lldb-enumerations.h to appear in the lldb.py module. This will make the
python script code a lot more readable.

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

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

llvm-svn: 115902
2010-10-07 04:19:01 +00:00
Greg Clayton 1d27316606 Added the ability to get the disassembly instructions from the function and
symbol.

llvm-svn: 115734
2010-10-06 03:09:58 +00:00
Caroline Tice dac97f31a3 Remove all the __repr__ methods from the API/*.h files, and put them
into python-extensions.swig, which gets included into lldb.swig, and
adds them back into the classes when swig generates it's C++ file.  This
keeps the Python stuff out of the general API classes.

Also fixed a small bug in the copy constructor for SBSymbolContext.

llvm-svn: 114602
2010-09-22 23:01:29 +00:00
Caroline Tice 7740412f2b Remove SBCommandContext which was not needed or doing anything.
Add SBValueList.h & SBStream.h to build-swig-Python.sh; add SBValueList.h to lldb.swig

llvm-svn: 114549
2010-09-22 16:41:52 +00:00
Johnny Chen 23fd10cb4e o Exposed SBFileSpec to the Python APIs in lldb.py.
o Fixed a crasher when getting it via SBTarget.GetExecutable().

>>> filespec = target.GetExecutable()
Segmentation fault

o And renamed SBFileSpec::GetFileName() to GetFilename() to be consistent with FileSpec::GetFilename().

llvm-svn: 112308
2010-08-27 22:35:26 +00:00