summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python
Commit message (Collapse)AuthorAgeFilesLines
...
* Suppress python readline module under Linux to fix a seg fault.Todd Fiala2014-02-266-0/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug fix for pr18841: http://llvm.org/bugs/show_bug.cgi?id=18841 This change creates a stub Python readline.so module that does almost nothing. Its whole purpose is to prevent Python from loading the real module, something it does during the embedded Python interpreter's initialization sequence (and way before lldb ever requests it within embedded_interpreter.py). On Ubuntu 12.04 and 13.10 x86_64, and in the Python 2.7.6 tree, the stock Python readline module links against the GNU readline library. This appears to be the case on all Pythons except where __APPLE__ is defined. LLDB now requires linking against the libedit library. Something about having both libedit.so and libreadline.so linked into the same process space is causing the Python readline.so to trigger a NULL memory access. I have put in a separate patch to python.org. This suppression of embedded interpreter readline support can be removed if at least any one of the following happens: 1. The stock python distribution accepts a patch similar to what I submitted to Python 2.7.6's Modules/readline.c file. 2. The stock python distribution implements Modules/readline.c in terms of libedit's readline compatibility mode (i.e. essentially compiles it the way __APPLE__ compiles that module) under Linux. 3. a clean-room implementation of the python readline module is implemented against libedit (either readline compatibility mode or native libedit). This could be implemented within the readline.cpp file that this change introduces. It cannot be a fork of python's readline.c module due to llvm licensing. The net effect of this change on Linux is that the embedded python's readline support will not exist. llvm-svn: 202243
* Make sure we don't try to print the SystemExit exception, or we will cause ↵Enrico Granata2014-02-181-1/+1
| | | | | | the containing process to exit() from under us llvm-svn: 201600
* Change the Mac OS X SystemRuntime plugin from using the placeholderJason Molenda2014-02-052-2/+21
| | | | | | | | | | | | | | libldi library to collect extended backtrace information; switch to the libBacktraceRecording library and its APIs. Complete the work of adding QueueItems to Queues and allow for the QueueItems to be interrogated about their extended backtraces in turn. There's still cleanup and documentation to do on this code but the code is functional and I it's a good time to get the work-in-progress checked in. <rdar://problem/15314027> llvm-svn: 200822
* <rdar://problem/15936507>Enrico Granata2014-01-291-0/+1
| | | | | | | | PyTuple_SetItem steals a reference to the item it inserts in the tuple This, plus the Py_XDECREF of the tuple a few lines below, causes our session dictionary to go away after the first time a SWIG layer function is called - with disastrous effects for the first subsequent attempt to use any functionality in ScriptInterpreterPython This fixes it llvm-svn: 200429
* Merging the iohandler branch back into main. Greg Clayton2014-01-278-155/+13
| | | | | | | | | | | | The many many benefits include: 1 - Input/Output/Error streams are now handled as real streams not a push style input 2 - auto completion in python embedded interpreter 3 - multi-line input for "script" and "expression" commands now allow you to edit previous/next lines using up and down arrow keys and this makes multi-line input actually a viable thing to use 4 - it is now possible to use curses to drive LLDB (please try the "gui" command) We will need to deal with and fix any buildbot failures and tests and arise now that input/output and error are correctly hooked up in all cases. llvm-svn: 200263
* Added the ability to get the type that a typedef points to via:Greg Clayton2014-01-232-0/+6
| | | | | | | | | | SBType SBType::GetTypedefedType(); Also added the ability to get a type by type ID from a SBModule: SBType SBModule::GetTypeByID (lldb::user_id_t uid); llvm-svn: 199939
* Patch by Ari GrantEnrico Granata2014-01-091-1/+1
| | | | | | | | | | | | | | | "Open LLDB and run: (lldb) script print lldb.debugger.GetInputFileHandle() This puts the debugger into a catatonic state and all interactions seem to enter a black hole. The reason is that executing this commnand actually *CLOSES* the input file handle and so all input is dropped on the floor. Oof! The fix is simple: flush a descriptor, instead of closing it, when transferring ownership." llvm-svn: 198835
* Add a new way to bind a format to a type: by enum typeEnrico Granata2013-12-281-0/+8
| | | | | | | | | | | The "type format add" command gets a new flag --type (-t). If you pass -t <sometype>, upon fetching the value for an object of your type, LLDB will display it as-if it was of enumeration type <sometype> This is useful in cases of non-contiguous enums where there are empty gaps of unspecified values, and as such one cannot type their variables as the enum type, but users would still like to see them as-if they were of the enum type (e.g. DWARF field types with their user-reserved ranges) The SB API has also been improved to handle both types of formats, and a test case is added llvm-svn: 198105
* Adding a document that describes the architecture of data formatters. ↵Enrico Granata2013-12-261-3/+1
| | | | | | Suggestions and ideas for improvements most welcome llvm-svn: 198038
* Add new Queue, QueueItem, Queuelist, SBQueue, SBQueueItem classes to representJason Molenda2013-12-134-0/+113
| | | | | | | | | libdispatch aka Grand Central Dispatch (GCD) queues. Still fleshing out the documentation and testing of these but the overall API is settling down so it's a good time to check it in. <rdar://problem/15600370> llvm-svn: 197190
* As consistency, invoke python with /usr/bin/env (like it is done in the rest ↵Sylvestre Ledru2013-12-101-1/+1
| | | | | | of the file). Thanks to Xavier De Gaye for the patch llvm-svn: 196933
* For logical backtrace work, lldb needs to track Module unloads etc & ↵Greg Clayton2013-12-061-0/+3
| | | | | | | | | | symoblicate an address based on a point in time <rdar://problem/15314403> This patch adds a new lldb_private::SectionLoadHistory class that tracks what shared libraries were loaded given a process stop ID. This allows us to keep a history of the sections that were loaded for a time T. Many items in history objects will rely upon the process stop ID in the future. llvm-svn: 196557
* Change lldb from building against a Python framework out ofJason Molenda2013-11-232-68/+0
| | | | | | | | | the installed SDK to using the current OS installed headers/libraries. This change is to address the removal of the Python framework from the Mac OS X 10.9 (Mavericks) SDK, and is the recommended workaround via https://developer.apple.com/library/mac/technotes/tn2328/_index.html llvm-svn: 195557
* Expose SBPlatform through the public API.Greg Clayton2013-11-206-0/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example code: remote_platform = lldb.SBPlatform("remote-macosx"); remote_platform.SetWorkingDirectory("/private/tmp") debugger.SetSelectedPlatform(remote_platform) connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); err = remote_platform.ConnectRemote(connect_options) if err.Success(): print >> result, 'Connected to remote platform:' print >> result, 'hostname: %s' % (remote_platform.GetHostname()) src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False) dst = lldb.SBFileSpec() # copy src to platform working directory since "dst" is empty err = remote_platform.Install(src, dst); if err.Success(): print >> result, '%s installed successfully' % (src) else: print >> result, 'error: failed to install "%s": %s' % (src, err) Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories. The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform. The API in SBPlatform is subject to change and will be getting many new functions. llvm-svn: 195273
* Add a new SBThread::GetExtendedBacktraceOriginatingIndexID() methodJason Molenda2013-11-161-1/+13
| | | | | | | | | | (and same thing to Thread base class) which can be used when looking at an ExtendedBacktrace thread; it will try to find the IndexID() of the original thread that was executing this backtrace when it was recorded. If lldb can't find a record of that thread, it will return the same value as IndexID() for the ExtendedBacktrace thread. llvm-svn: 194912
* Change SBThread::GetExtendedBacktrace toJason Molenda2013-11-121-2/+2
| | | | | | | SBThread::GetExtendedBacktraceThread to make it more clear what is being returned. llvm-svn: 194531
* This patch does a couple of things. Jim Ingham2013-11-071-0/+7
| | | | | | | | | | | | | | | | | | | | | | It completes the job of using EvaluateExpressionOptions consistently throughout the inferior function calling mechanism in lldb begun in Greg's patch r194009. It removes a handful of alternate calls into the ClangUserExpression/ClangFunction/ThreadPlanCallFunction which were there for convenience. Using the EvaluateExpressionOptions removes the need for them. Using that it gets the --debug option from Greg's patch to work cleanly. It also adds another EvaluateExpressionOption to not trap exceptions when running expressions. You shouldn't use this option unless you KNOW your expression can't throw beyond itself. This is: <rdar://problem/15374885> At present this is only available through the SB API's or python. It fixes a bug where function calls would unset the ObjC & C++ exception breakpoints without checking whether they were set by somebody else already. llvm-svn: 194182
* Rename extended backtrace methods to take out the "ThreadOrigin"Jason Molenda2013-11-062-6/+6
| | | | | | | bit from the method names. <rdar://problem/15314369> llvm-svn: 194122
* Add a new GetThreadOriginExtendedBacktrace method to the Jason Molenda2013-11-061-0/+13
| | | | | | | SystemRuntime and SBThread classes. <rdar://problem/15314369> llvm-svn: 194111
* Add the GetNumThreadOriginExtendedBacktraceTypes andJason Molenda2013-11-052-0/+30
| | | | | | | | | | | GetThreadOriginExtendedBacktraceTypeAtIndex methods to SBProcess. Add documentation for the GetQueueName and GetQueueID methods to SBThread. <rdar://problem/15314369> llvm-svn: 194063
* Roll back the changes I made in r193907 which created a new FrameJason Molenda2013-11-041-3/+3
| | | | | | | | | | pure virtual base class and made StackFrame a subclass of that. As I started to build on top of that arrangement today, I found that it wasn't working out like I intended. Instead I'll try sticking with the single StackFrame class -- there's too much code duplication to make a more complicated class hierarchy sensible I think. llvm-svn: 193983
* Add a new base class, Frame. It is a pure virtual function whichJason Molenda2013-11-021-3/+3
| | | | | | | | | | | | | | | | | | | | | defines a protocol that all subclasses will implement. StackFrame is currently the only subclass and the methods that Frame vends are nearly identical to StackFrame's old methods. Update all callers to use Frame*/Frame& instead of pointers to StackFrames. This is almost entirely a mechanical change that touches a lot of the code base so I'm committing it alone. No new functionality is added with this patch, no new subclasses of Frame exist yet. I'll probably need to tweak some of the separation, possibly moving some of StackFrame's methods up in to Frame, but this is a good starting point. <rdar://problem/15314068> llvm-svn: 193907
* Fix for a mistake spotted by Enrico with the SBThread::queue_id accessor.Jason Molenda2013-10-221-1/+1
| | | | llvm-svn: 193136
* Expose the Thread::GetQueueID() method through the SBThread API, similar toJason Molenda2013-10-211-0/+6
| | | | | | the existing SBThread::GetQueueName() method. llvm-svn: 193132
* <rdar://problem/14972424>Greg Clayton2013-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When debugging with the GDB remote in LLDB, LLDB uses special packets to discover the registers on the remote server. When those packets aren't supported, LLDB doesn't know what the registers look like. This checkin implements a setting that can be used to specify a python file that contains the registers definitions. The setting is: (lldb) settings set plugin.process.gdb-remote.target-definition-file /path/to/module.py Inside module there should be a function: def get_dynamic_setting(target, setting_name): This dynamic setting function is handed the "target" which is a SBTarget, and the "setting_name", which is the name of the dynamic setting to retrieve. For the GDB remote target definition the setting name is 'gdb-server-target-definition'. The return value is a dictionary that follows the same format as the OperatingSystem plugins follow. I have checked in an example file that implements the x86_64 GDB register set for people to see: examples/python/x86_64_target_definition.py This allows LLDB to debug to any archticture that is support and allows users to define the registers contexts when the discovery packets (qRegisterInfo, qHostInfo) are not supported by the remote GDB server. A few benefits of doing this in Python: 1 - The dynamic register context was already supported in the OperatingSystem plug-in 2 - Register contexts can use all of the LLDB enumerations and definitions for things like lldb::Format, lldb::Encoding, generic register numbers, invalid registers numbers, etc. 3 - The code that generates the register context can use the program to calculate the register context contents (like offsets, register numbers, and more) 4 - True dynamic detection could be used where variables and types could be read from the target program itself in order to determine which registers are available since the target is passed into the python function. This is designed to be used instead of XML since it is more dynamic and code flow and functions can be used to make the dictionary. llvm-svn: 192646
* Add the capability for LLDB to query an arbitrary Python module (passed in ↵Enrico Granata2013-10-141-0/+24
| | | | | | | | | | | as a file path) for target-specific settings This is implemented by means of a get_dynamic_setting(target, setting_name) function vended by the Python module, which can respond to arbitrary string names with dynamically constructed settings objects (most likely, some of those that PythonDataObjects supports) for LLDB to parse This needs to be hooked up to the debugger via some setting to allow users to specify which module will vend the information they want to supply llvm-svn: 192628
* <rdar://problem/14028923>Enrico Granata2013-10-081-0/+3
| | | | | | | Implement SBTarget::CreateValueFromAddress() with a behavior equivalent to SBValue::CreateValueFromAddress() (but without the need to grab an SBValue first just as a starting point to make up another SBValue out of whole cloth) llvm-svn: 192239
* Add missing GetBroadcasterClassName and event types enum to SBThread.iDaniel Malea2013-10-031-0/+16
| | | | llvm-svn: 191933
* Convert to UNIX line endings.Joerg Sonnenberger2013-09-251-998/+998
| | | | llvm-svn: 191367
* Added a 'jump' command, similar to GDBs.Richard Mitton2013-09-121-2/+5
| | | | | | | | | This allows the PC to be directly changed to a different line. It's similar to the example python script in examples/python/jump.py, except implemented as a builtin. Also this version will track the current function correctly even if the target line resolves to multiple addresses. (e.g. debugging a templated function) llvm-svn: 190572
* merge lldb-platform-work branch (and assorted fixes) into trunkDaniel Malea2013-08-261-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This merge brings in the improved 'platform' command that knows how to interface with remote machines; that is, query OS/kernel information, push and pull files, run shell commands, etc... and implementation for the new communication packets that back that interface, at least on Darwin based operating systems via the POSIXPlatform class. Linux support is coming soon. Verified the test suite runs cleanly on Linux (x86_64), build OK on Mac OS X Mountain Lion. Additional improvements (not in the source SVN branch 'lldb-platform-work'): - cmake build scripts for lldb-platform - cleanup test suite - documentation stub for qPlatform_RunCommand - use log class instead of printf() directly - reverted work-in-progress-looking changes from test/types/TestAbstract.py that work towards running the test suite remotely. - add new logging category 'platform' Reviewers: Matt Kopec, Greg Clayton Review: http://llvm-reviews.chandlerc.com/D1493 llvm-svn: 189295
* Don't recommend using bytearray(buf, 'ascii') for binary data read with Jason Molenda2013-08-241-2/+1
| | | | | | SBProcess::ReadMemory - it will fail for anything with the high bit set. llvm-svn: 189154
* Add an SBFrame::FindRegister() method to make it a littleJason Molenda2013-07-261-0/+3
| | | | | | easier to retrieve a register value. llvm-svn: 187184
* Second attempt at getting the PyCallable changes in trunkEnrico Granata2013-07-093-1407/+1024
| | | | | | Thanks to Daniel Malea for helping test this patch for Linux happiness! llvm-svn: 185965
* Added a way to extract the module specifications from a file. A module ↵Greg Clayton2013-07-085-1/+172
| | | | | | | | | | | | | specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files). There are two new classes: lldb::SBModuleSpec lldb::SBModuleSpecList The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList. llvm-svn: 185877
* Revert commits that cause broken builds on GCC buildbotsDaniel Malea2013-07-033-368/+761
| | | | | | | | - build fails due to PyCallable template definition inside an extern "C" scope This commit reverts 185240, 184893 and 184608. llvm-svn: 185560
* <rdar://problem/14309010>Enrico Granata2013-06-281-1/+2
| | | | | | | | OS Plugins' __init__ method takes two arguments: (self,process) I was erroneously passing the session_dict as well as part of my PyCallable changes and that caused plugins to fail to work llvm-svn: 185240
* <rdar://problem/14266411>Enrico Granata2013-06-252-22/+10
| | | | | | | | | | | | The semi-unofficial way of returning a status from a Python command was to return a string (e.g. return "no such variable was found") that LLDB would pick as a clue of an error having happened This checkin changes that: - SBCommandReturnObject now exports a SetError() call, which can take an SBError or a plain C-string - script commands now drop any return value and expect the SBCommandReturnObject ("return object") to be filled in appropriately - if you do nothing, a success will be assumed If your commands were relying on returning a value and having LLDB pick that up as an error, please change your commands to SetError() through the return object or expect changes in behavior llvm-svn: 184893
* Lots of cleanup on the SWIG wrapping layerEnrico Granata2013-06-212-750/+368
| | | | | | | | | | Now, the way SWIG wrappers call into Python is through a utility PyCallable object, which overloads operator () to look like a normal function call Plus, using the SBTypeToSWIGWrapper() family of functions, we can call python functions transparently as if they were plain C functions Using this new technique should make adding new Python call points easier and quicker The PyCallable is a generally useful facility, and we might want to consider moving it to a separate layer where other parts of LLDB can use it llvm-svn: 184608
* Change the SWIG wrappers to stop directly casting SB object to SWIG objects, ↵Enrico Granata2013-06-213-18/+125
| | | | | | | | | | | and instead use a safer type-checked API (thanks templates) Any time a SWIG wrapper needs a PyObject for an SB object, it now should call into SBTypeToSWIGWrapper<SBType>(SBType*) If you try to use it on an SBType for which there is not an implementation yet, LLDB will fail to link - just add your specialization to python-swigsafecast.swig and rebuild This is the first step in simplifying our SWIG Wrapper layer llvm-svn: 184580
* In thread and frame format strings, it is now allowed to use Python ↵Enrico Granata2013-06-201-0/+344
| | | | | | | | | | | | | | | functions to generate part or all of the output text Specifically, the ${target ${process ${thread and ${frame specifiers have been extended to allow a subkeyword .script:<fctName> (e.g. ${frame.script:FooFunction}) The functions are prototyped as def FooFunction(Object,unused) where object is of the respective SB-type (SBTarget for target.script, ... and so on) This has not been implemented for ${var because it would be akin to a Python summary which is already well-defined in LLDB llvm-svn: 184500
* Implemented a types.py module that allows types to be inspected for padding.Greg Clayton2013-06-192-2/+5
| | | | | | The script was able to point out and save 40 bytes in each lldb_private::Section by being very careful where we need to have virtual destructors and also by re-ordering members. llvm-svn: 184364
* Sort out a number of mismatched integer types in order to cut down the ↵Andy Gibbs2013-06-191-1/+1
| | | | | | number of compiler warnings. llvm-svn: 184333
* Added a new decorator function in the "lldb" module that can register a ↵Greg Clayton2013-06-191-0/+20
| | | | | | | | | | | | command automatically. We have just a few kinks to work out for the Xcode workflow and we will be ready to switch over to using this. To use this, you can decorate your python function as: @lldb.command("new_command", "Documentation string for new_command...") def new_command(debugger, command, result, dict): .... No more need to register your command in the __lldb_init_module function! llvm-svn: 184274
* Added the ability to get a list of types from a SBModule or SBCompileUnit. ↵Greg Clayton2013-06-182-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sebastien Metrot wanted this, and sent a hollowed out patch. I filled in the blanks and did the low level implementation. The new functions are: //------------------------------------------------------------------ /// Get all types matching \a type_mask from debug info in this /// module. /// /// @param[in] type_mask /// A bitfield that consists of one or more bits logically OR'ed /// together from the lldb::TypeClass enumeration. This allows /// you to request only structure types, or only class, struct /// and union types. Passing in lldb::eTypeClassAny will return /// all types found in the debug information for this module. /// /// @return /// A list of types in this module that match \a type_mask //------------------------------------------------------------------ lldb::SBTypeList SBModule::GetTypes (uint32_t type_mask) //------------------------------------------------------------------ /// Get all types matching \a type_mask from debug info in this /// compile unit. /// /// @param[in] type_mask /// A bitfield that consists of one or more bits logically OR'ed /// together from the lldb::TypeClass enumeration. This allows /// you to request only structure types, or only class, struct /// and union types. Passing in lldb::eTypeClassAny will return /// all types found in the debug information for this compile /// unit. /// /// @return /// A list of types in this compile unit that match \a type_mask //------------------------------------------------------------------ lldb::SBTypeList SBCompileUnit::GetTypes (uint32_t type_mask = lldb::eTypeClassAny); This lets you request types by filling out a mask that contains one or more bits from the lldb::TypeClass enumerations, so you can only get the types you really want. llvm-svn: 184251
* Added a SBSection::GetParent() to the API.Greg Clayton2013-06-131-0/+3
| | | | llvm-svn: 183948
* Improvements to the data formatters SB API:Enrico Granata2013-06-111-0/+97
| | | | | | | | - exposing new accessors: formats/format, ..., that allow you to iterate over all formatters e.g. sys_category = lldb.debugger.GetCategory("system").summary['char *'] - ensuring that C++-based synthetic children provider can at least print their description accurately, if nothing else llvm-svn: 183805
* <rdar://problem/13646047>Enrico Granata2013-06-111-0/+40
| | | | | | | Providing a Python helper SBData.CreateDataFromInt() to make an SBData out of a single integer number It tries to use the current target, if any, for endianness and pointer size, and it picks a reasonable size on your behalf - if there is no way it can infer anything reasonable it essentially picks a 64-bit Mac as the reference model llvm-svn: 183793
* Making our Python decrefs NULL-safeEnrico Granata2013-06-111-17/+17
| | | | llvm-svn: 183774
* <rdar://problem/13759177>Enrico Granata2013-06-111-1/+7
| | | | | | | Allowing LLDB to resolve names of Python functions when they are located in classes This allows things like *bound* classmethods to be used for formatters, commands, ... llvm-svn: 183772
OpenPOWER on IntegriCloud