aboutsummaryrefslogtreecommitdiff
path: root/lldb/scripts/Python/python-wrapper.swig
AgeCommit message (Collapse)AuthorFilesLines
2012-10-22<rdar://problem/12437442>Enrico Granata1-0/+1
Given our implementation of ValueObjects we could have a scenario where a ValueObject has a dynamic type of Foo* at one point, and then its dynamic type changes to Bar* If Bar* has synthetic children enabled, by the time we figure that out, our public API is already vending SBValues wrapping a DynamicVO, instead of a SyntheticVO and there was no trivial way for us to change the SP inside an SBValue on the fly This checkin reimplements SBValue in terms of a wrapper, ValueImpl, that allows this substitutions on-the-fly by overriding GetSP() to do The Right Thing (TM) As an additional bonus, GetNonSyntheticValue() now works, and we can get rid of the ForceDisableSyntheticChildren idiom in ScriptInterpreterPython Lastly, this checkin makes sure the synthetic VOs get the correct m_value and m_data from their parents (prevented summaries from working in some cases) llvm-svn: 166426
2012-08-27Fixing a potential control may reach end of non-void function issueEnrico Granata1-0/+1
llvm-svn: 162685
2012-08-25Added SBDebugger's log callbacks to Python-landFilipe Cabecinhas1-28/+42
- Tweaked a parameter name in SBDebugger.h so my typemap will catch it; - Added a SBDebugger.Create(bool, callback, baton) to the swig interface; - Added SBDebugger.SetLoggingCallback to the swig interface; - Added a callback utility function for log callbacks; - Guard against Py_None on both callback utility functions; - Added a FIXME to the SBDebugger API test; - Added a __del__() stub for SBDebugger. We need to be able to get both the log callback and baton from an SBDebugger if we want to protect against memory leaks (or make the user responsible for holding another reference to the callback). Additionally, it's impossible to revert from a callback-backed log mechanism to a file-backed log mechanism. llvm-svn: 162633
2012-08-24Fixing a bunch of issues with the OS plugin codeEnrico Granata1-1/+1
llvm-svn: 162527
2012-08-24Adding bindings to the Script Interpreter for some basic Python OS plugin ↵Enrico Granata1-0/+97
functionality (still WIP) llvm-svn: 162513
2012-08-22Fixed a Linux building bug pointed out by Daniel Malea.Filipe Cabecinhas1-1/+1
llvm-svn: 162373
2012-08-22Added a typemap and wrappers for SBInputReader callbacksFilipe Cabecinhas1-0/+56
Now it's possible to use SBInputReader callbacks in Python. We leak the callback object, unfortunately. A __del__ method can be added to SBInputReader, but we have no way to check the callback function that is on the reader. So we can't call Py_DECREF on it when we have our PythonCallback function. One way to do it is to assume that reified SBInputReaders always have a Python callback (and always call Py_DECREF). Another one is to add methods or properties to SBInputReader (or make the m_callback_function property public). llvm-svn: 162356
2012-08-09rdar://problem/11457143 [ER] need "watchpoint command ..."Johnny Chen1-0/+79
Add 'watchpoint command add/delete/list' to lldb, plus two .py test files. llvm-svn: 161638
2012-03-19Massive enumeration name changes: a number of enums in ValueObject were not ↵Enrico Granata1-5/+13
following the naming pattern Changes to synthetic children: - the update(self): function can now (optionally) return a value - if it returns boolean value True, ValueObjectSyntheticFilter will not clear its caches across stop-points this should allow better performance for Python-based synthetic children when one can be sure that the child ValueObjects have not changed - making a difference between a synthetic VO and a VO with a synthetic value: now a ValueObjectSyntheticFilter will not return itself as its own synthetic value, but will (correctly) claim to itself be synthetic - cleared up the internal synthetic children architecture to make a more consistent use of pointers and references instead of shared pointers when possible - major cleanup of unnecessary #include, data and functions in ValueObjectSyntheticFilter itself - removed the SyntheticValueType enum and replaced it with a plain boolean (to which it was equivalent in the first place) Some clean ups to the summary generation code Centralized the code that clears out user-visible strings and data in ValueObject More efficient summaries for libc++ containers llvm-svn: 153061
2012-02-29This commit:Enrico Granata1-91/+65
a) adds a Python summary provider for NSDate b) changes the initialization for ScriptInterpreter so that we are not passing a bulk of Python-specific function pointers around c) provides a new ScriptInterpreterObject class that allows for ref-count safe wrapping of scripting objects on the C++ side d) contains much needed performance improvements: 1) the pointer to the Python function generating a scripted summary is now cached instead of looked up every time 2) redundant memory reads in the Python ObjC runtime wrapper are eliminated 3) summaries now use the m_summary_str in ValueObject to store their data instead of passing around ( == copying) an std::string object e) contains other minor fixes, such as adding descriptive error messages for some cases of summary generation failure llvm-svn: 151703
2011-12-14Add more robustness - use PyString_CheckExact(pvalue) to check whether ↵Johnny Chen1-1/+1
pvalue is a Python string before calling PyString_AsString(pvalue). Similar to http://llvm.org/viewvc/llvm-project?rev=146584&view=rev. llvm-svn: 146606
2011-12-14http://llvm.org/bugs/show_bug.cgi?id=11569Johnny Chen1-2/+4
LLDBSwigPythonCallCommand crashes when a command script returns an object Add more robustness to LLDBSwigPythonCallCommand. It should check whether the returned Python object is a string, and only assign it as the error msg when the check holds. Also add a regression test. llvm-svn: 146584
2011-10-17this patch introduces a new command script import command which takes as ↵Enrico Granata1-1/+83
input a filename for a Python script and imports the module contained in that file. the containing directory is added to the Python path such that dependencies are honored. also, the module may contain an __lldb_init_module(debugger,dict) function, which gets called after importing, and which can somehow initialize the module's interaction with lldb llvm-svn: 142283
2011-09-06Redesign of the interaction between Python and frozen objects:Enrico Granata1-1/+1
- 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-08-23Additional code cleanups ; Short option name for --python-script in type ↵Enrico Granata1-2/+0
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-22- Support for Python namespaces:Enrico Granata1-206/+133
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-20Further fix for SWIG interoperability; making sure the Release() method of ↵Enrico Granata1-13/+30
SBCommandReturnObject is called at all times llvm-svn: 138169
2011-08-19Fixed some SWIG interoperability issuesEnrico Granata1-13/+26
llvm-svn: 138154
2011-08-19Taking care of an issue with using lldb_private types in ↵Enrico Granata1-2/+2
SBCommandInterpreter.cpp ; Making NSString test case work on Snow Leopard ; Removing an unused variable warning llvm-svn: 138105
2011-08-16Changes to Python commands:Enrico Granata1-4/+6
- 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-16Python commands:Enrico Granata1-0/+140
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-11Fixed an issue where LLDB was complaining about the lack of 'update' in a ↵Enrico Granata1-0/+15
synthetic provider, despite it being optional llvm-svn: 137330
2011-07-26adding required utility function to SWIG interfaceEnrico Granata1-0/+43
llvm-svn: 136147
2011-07-26lldb.swig (the SWIG input file) has become too large. Modularize a bit by ↵Johnny Chen1-0/+527
introducing two files to be included from lldb.swig: python-typemaps.swig and python-wrapper.swig. llvm-svn: 136117