summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
Commit message (Collapse)AuthorAgeFilesLines
* Add a few more needed bits to the scripted thread plans.Jim Ingham2016-08-051-0/+2
| | | | llvm-svn: 277879
* Add support for synthetic child providers to optionally return a customized ↵Enrico Granata2016-05-021-0/+2
| | | | | | typename for display llvm-svn: 268208
* Revert "Restore the lazy initialization of ScriptInterpreterPython, which ↵Pavel Labath2016-04-121-3/+3
| | | | | | | | | | was lost as part of the SystemLifetimeManager work" This change breaks python unit tests. This reverts commit 266033. llvm-svn: 266050
* Restore the lazy initialization of ScriptInterpreterPython, which was lost ↵Enrico Granata2016-04-121-3/+3
| | | | | | as part of the SystemLifetimeManager work llvm-svn: 266033
* Fixed the python interpreter so that it correctly inherits the top ↵Greg Clayton2016-03-101-0/+3
| | | | | | | | | | IOHandler's files instead of always using stdin/out/err. Removed lldb_private::File::Duplicate() and the copy constructor and the assignment operator that used to duplicate the file handles and made them private so no one uses them. Previously the lldb_private::File::Duplicate() function duplicated files that used file descriptors, (int) but not file streams (FILE *), so the lldb_private::File::Duplicate() function only worked some of the time. No one else excep thee ScriptInterpreterPython was using these functions, so that aren't needed nor desired. Previously every time you would drop into the python interpreter we would duplicate files, and now we avoid this file churn. <rdar://problem/24877720> llvm-svn: 263161
* Fix Clang-tidy modernize-use-override warnings in some files in ↵Eugene Zelenko2015-10-241-51/+63
| | | | | | source/Plugins; other minor fixes. llvm-svn: 251167
* [SBValue] Add a method GetNumChildren(uint32_t max)Siva Chandra2015-10-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Along with this, support for an optional argument to the "num_children" method of a Python synthetic child provider has also been added. These have been added with the following use case in mind: Synthetic child providers currently have a method "has_children" and "num_children". While the former is good enough to know if there are children, it does not give any insight into how many children there are. Though the latter serves this purpose, calculating the number for children of a data structure could be an O(N) operation if the data structure has N children. The new method added in this change provide a middle ground. One can call GetNumChildren(K) to know if a child exists at an index K which can be as large as the callers tolerance can be. If the caller wants to know about children beyond K, it can make an other call with 2K. If the synthetic child provider maintains state about it counting till K previosly, then the next call is only an O(K) operation. Infact, all calls made progressively with steps of K will be O(K) operations. Reviewers: vharron, clayborg, granata.enrico Subscribers: labath, lldb-commits Differential Revision: http://reviews.llvm.org/D13778 llvm-svn: 250930
* Fix potential file i/o problem with python handles.Zachary Turner2015-10-201-3/+3
| | | | llvm-svn: 250838
* Fix linkage of `init_lldb` SWIG method in Python 3.Zachary Turner2015-10-161-1/+5
| | | | llvm-svn: 250531
* Introduce a `PythonFile` object, and use it everywhere.Zachary Turner2015-10-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Python file handling got an overhaul in Python 3, and it affects the way we have to interact with files. Notably: 1) `PyFile_FromFile` no longer exists, and instead we have to use `PyFile_FromFd`. This means having a way to get an fd from a FILE*. For this we reuse the lldb_private::File class to convert between FILE*s and fds, since there are some subtleties regarding ownership rules when FILE*s and fds refer to the same file. 2) PyFile is no longer a builtin type, so there is no such thing as `PyFile_Check`. Instead, files in Python 3 are just instances of `io.IOBase`. So the logic for checking if something is a file in Python 3 is to check if it is a subclass of that module. Additionally, some unit tests are added to verify that `PythonFile` works as expected on Python 2 and Python 3, and `ScriptInterpreterPython` is updated to use `PythonFile` instead of manual calls to the various `PyFile_XXX` methods. llvm-svn: 250444
* Fix ref counting of Python objects.Zachary Turner2015-10-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PythonObjects were being incorrectly ref-counted. This problem was pervasive throughout the codebase, leading to an unknown number of memory leaks and potentially use-after-free. The issue stems from the fact that Python native methods can either return "borrowed" references or "owned" references. For the former category, you *must* incref it prior to decrefing it. And for the latter category, you should not incref it before decrefing it. This is mostly an issue when a Python C API method returns a `PyObject` to you, but it can also happen with a method accepts a `PyObject`. Notably, this happens in `PyList_SetItem`, which is documented to "steal" the reference that you give it. So if you pass something to `PyList_SetItem`, you cannot hold onto it unless you incref it first. But since this is one of only two exceptions in the entire API, it's confusing and difficult to remember. Our `PythonObject` class was indiscriminantely increfing every object it received, which means that if you passed it an owned reference, you now have a dangling reference since owned references should not be increfed. We were doing this in quite a few places. There was also a fair amount of manual increfing and decrefing prevalent throughout the codebase, which is easy to get wrong. This patch solves the problem by making any construction of a `PythonObject` from a `PyObject` take a flag which indicates whether it is an owned reference or a borrowed reference. There is no way to construct a `PythonObject` without this flag, and it does not offer a default value, forcing the user to make an explicit decision every time. All manual uses of `PyObject` have been cleaned up throughout the codebase and replaced with `PythonObject` in order to make RAII the predominant pattern when dealing with native Python objects. Differential Revision: http://reviews.llvm.org/D13617 Reviewed By: Greg Clayton llvm-svn: 250195
* Fix Clang-tidy misc-use-override warnings in some files in ↵Pavel Labath2015-08-181-4/+4
| | | | | | | | | | include/lldb/Core, unify closing inclusion guards patch by Eugene Zelenko Differential Revision: http://reviews.llvm.org/D11695 llvm-svn: 245275
* First step in getting LLDB ready to support multiple different type systems.Greg Clayton2015-08-111-2/+2
| | | | | | | | This is the work done by Ryan Brown from http://reviews.llvm.org/D8712 that makes a TypeSystem class and abstracts types to be able to use a type system. All tests pass on MacOSX and passed on linux the last time this was submitted. llvm-svn: 244679
* Convert the ScriptInterpreter system to a plugin-based one.Zachary Turner2015-07-301-0/+590
Previously embedded interpreters were handled as ad-hoc source files compiled into source/Interpreter. This made it hard to disable a specific interpreter, or to add support for other interpreters and allow the developer to choose which interpreter(s) were enabled for a particular build. This patch converts script interpreters over to a plugin-based system. Script interpreters now live in source/Plugins/ScriptInterpreter, and the canonical LLDB interpreter, ScriptInterpreterPython, is moved there as well. Any new code interfacing with the Python C API must live in this location from here on out. Additionally, generic code should never need to reference or make assumptions about the presence of a specific interpreter going forward. Differential Revision: http://reviews.llvm.org/D11431 Reviewed By: Greg Clayton llvm-svn: 243681
OpenPOWER on IntegriCloud