summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* First round of code cleanups:Enrico Granata2011-08-171-1/+1
| | | | | | | | | | | | | | | | | | - 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
* New category "gnu-libstdc++" provides summary for std::string and synthetic ↵Enrico Granata2011-08-171-0/+5
| | | | | | | | | | 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
* When defining a scripted command, it is possible to provide a docstring and ↵Enrico Granata2011-08-171-2/+22
| | | | | | | | | | that will be used as the help text for the command If no docstring is provided, a default help text is created LLDB will refuse to create scripted commands if the scripting language is anything but Python Some additional comments in AppleObjCRuntimeV2.cpp to describe the memory layout expected by the dynamic type lookup code llvm-svn: 137801
* Changes to Python commands:Enrico Granata2011-08-161-3/+3
| | | | | | | | | | | | - 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
* Python commands:Enrico Granata2011-08-161-1/+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
* To silence the static analyzer.Johnny Chen2011-08-111-1/+1
| | | | llvm-svn: 137329
* Public API changes:Enrico Granata2011-07-291-3/+38
| | | | | | | | | | | | | | | | | | | | | - 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
* new flag -P to type synth add lets you type a Python class interactivelyEnrico Granata2011-07-251-0/+48
| | | | | | | | added a final newline to fooSynthProvider.py new option to automatically save user input in InputReaderEZ checking for NULL pointers in several new places llvm-svn: 135916
* Python synthetic children:Enrico Granata2011-07-241-2/+201
| | | | | | | | | | | | | | - you can now define a Python class as a synthetic children producer for a type the class must adhere to this "interface": def __init__(self, valobj, dict): def get_child_at_index(self, index): def get_child_index(self, name): then using type synth add -l className typeName (e.g. type synth add -l fooSynthProvider foo) (This is still WIP with lots to be added) A small test case is available also as reference llvm-svn: 135865
* Python summary strings:Enrico Granata2011-07-151-2/+173
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - you can use a Python script to write a summary string for data-types, in one of three ways: -P option and typing the script a line at a time -s option and passing a one-line Python script -F option and passing the name of a Python function these options all work for the "type summary add" command your Python code (if provided through -P or -s) is wrapped in a function that accepts two parameters: valobj (a ValueObject) and dict (an LLDB internal dictionary object). if you use -F and give a function name, you're expected to define the function on your own and with the right prototype. your function, however defined, must return a Python string - test case for the Python summary feature - a few quirks: Python summaries cannot have names, and cannot use regex as type names both issues will be fixed ASAP major redesign of type summary code: - type summary working with strings and type summary working with Python code are two classes, with a common base class SummaryFormat - SummaryFormat classes now are able to actively format objects rather than just aggregating data - cleaner code to print descriptions for summaries the public API now exports a method to easily navigate a ValueObject hierarchy New InputReaderEZ and PriorityPointerPair classes Several minor fixes and improvements llvm-svn: 135238
* Add 'batch_mode' to CommandInterpreter. Modify InputReaders toCaroline Tice2011-06-161-21/+35
| | | | | | | | | | not write output (prompts, instructions,etc.) if the CommandInterpreter is in batch_mode. Also, finish updating InputReaders to write to the asynchronous stream, rather than using the Debugger's output file directly. llvm-svn: 133162
* Add error message; clean up comment.Caroline Tice2011-06-141-1/+1
| | | | llvm-svn: 132997
* Cleaning up the Python script interpreter: Use theCaroline Tice2011-06-131-133/+7
| | | | | | | | embedded_interpreter.py file rather than keeping it all in a string and compiling the string (easier to maintain, easier to read, remove redundancy). llvm-svn: 132935
* Use Py_InitializeEx(0) instead of Py_Initialize,Caroline Tice2011-06-021-1/+1
| | | | | | | to prevent Python from installing its own signal handlers. llvm-svn: 132492
* Pre-load the Python script interpreter with the followingCaroline Tice2011-05-031-0/+41
| | | | | | | | | | | convenience variables (from the ExecutionContext) each time it is entered: lldb.debugger, lldb.target, lldb.process, lldb.thread, lldb.frame. If a frame (or thread, process, etc) does not currently exist, the variable contains the Python value 'None'. llvm-svn: 130792
* This patch captures and serializes all output being written by theCaroline Tice2011-05-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | command line driver, including the lldb prompt being output by editline, the asynchronous process output & error messages, and asynchronous messages written by target stop-hooks. As part of this it introduces a new Stream class, StreamAsynchronousIO. A StreamAsynchronousIO object is created with a broadcaster, who will eventually broadcast the stream's data for a listener to handle, and an event type indicating what type of event the broadcaster will broadcast. When the Write method is called on a StreamAsynchronousIO object, the data is appended to an internal string. When the Flush method is called on a StreamAsynchronousIO object, it broadcasts it's data string and clears the string. Anything in lldb-core that needs to generate asynchronous output for the end-user should use the StreamAsynchronousIO objects. I have also added a new notification type for InputReaders, to let them know that a asynchronous output has been written. This is to allow the input readers to, for example, refresh their prompts and lines, if desired. I added the case statements to all the input readers to catch this notification, but I haven't added any code for handling them yet (except to the IOChannel input reader). llvm-svn: 130721
* Abtracted the innards of lldb-core away from the SB interface. There was someGreg Clayton2011-03-221-63/+64
| | | | | | | | | | | | | | | | overlap in the SWIG integration which has now been fixed by introducing callbacks for initializing SWIG for each language (python only right now). There was also a breakpoint command callback that called into SWIG which has been abtracted into a callback to avoid cross over as well. Added a new binary: lldb-platform This will be the start of the remote platform that will use as much of the Host functionality to do its job so it should just work on all platforms. It is pretty hollowed out for now, but soon it will implement a platform using the GDB remote packets as the transport. llvm-svn: 128053
* Minor typo fix and TAB removals.Johnny Chen2011-03-111-4/+4
| | | | llvm-svn: 127439
* Add some explanatory comments.Caroline Tice2011-03-111-0/+11
| | | | llvm-svn: 127438
* Add thread state initialization to the thread where the interactiveCaroline Tice2011-03-071-0/+7
| | | | | | | interpreter is run (which is separate from the thread where Py_Initialize is called, where this normally gets set up). llvm-svn: 127191
* Use Host::File in lldb_private::StreamFile and other places to cleanup hostGreg Clayton2011-02-091-29/+20
| | | | | | layer a bit more. llvm-svn: 125149
* Patch that allows for thread_t to be something more complex than anGreg Clayton2011-02-081-1/+1
| | | | | | integer. Modified patch from Kirk Beitz. llvm-svn: 125067
* Abtract terminal stuff into a new lldb_private::Terminal classGreg Clayton2011-02-071-28/+31
| | | | | | | | where the implementation is hidden in the host layer. This avoids a slew of "#if LLDB_CONFIG_TERMIOS_SUPPORTED" statements in the code and keeps things cleaner. llvm-svn: 125057
* More termios fixes. We need to currently make sure to include:Greg Clayton2011-02-071-4/+2
| | | | | | | | | | | | | | | | | #include "lldb/Host/Config.h" Or the LLDB_CONFIG_TERMIOS_SUPPORTED defined won't be set. I will fix all of this Termios stuff later today by moving lldb/Core/TTYState.* into the host layer and then we conditionalize all of this inside TTYState.cpp and then we get rid of LLDB_CONFIG_TERMIOS_SUPPORTED all together. Typically, when we start to see too many "#if LLDB_CONFIG_XXXX" preprocessor directives, this is a good indicator that something needs to be moved over to the host layer. TTYState can be modified to do all of the things that many areas of the code are currently doing, and it will avoid all of the preprocessor noise. llvm-svn: 125027
* More termios fixes from Kirk Beitz.Greg Clayton2011-02-071-2/+12
| | | | llvm-svn: 125024
* Header patch, virtual dtor patch and missed UUID patch from Kirk Beitz.Greg Clayton2011-02-051-18/+2
| | | | llvm-svn: 124931
* Fix exit instructions for interactive interpreter, now that ctrl-D works.Caroline Tice2011-02-031-2/+1
| | | | llvm-svn: 124811
* Added support for some new environment variables within LLDB to enable someGreg Clayton2011-01-271-0/+8
| | | | | | | | | | | | | | | | extra launch options: LLDB_LAUNCH_FLAG_DISABLE_ASLR disables ASLR for all launched processes LLDB_LAUNCH_FLAG_DISABLE_STDIO will disable STDIO (reroute to "/dev/null") for all launched processes LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY will force all launched processes to be launched in new terminal windows. Also, don't init python if we never create a script interpreter. llvm-svn: 124341
* Enabled extra warnings and fixed a bunch of small issues.Greg Clayton2011-01-251-1/+0
| | | | llvm-svn: 124250
* Replace Mutex guarding python interpreter access with Predicate,Caroline Tice2011-01-171-35/+223
| | | | | | | | | | allowing timeouts & informing the user when the lock is unavailable. Fixed problem where Debugger::Terminate was clearing the debugger list even when the global ref count was greater than zero. llvm-svn: 123674
* Recent modifications to the Python script interpreter caused some problemsCaroline Tice2011-01-141-6/+87
| | | | | | | | | | | | when handling one-liner commands that contain escaped characters. In order to deal with the new namespace/dictionary stuff, the command was being embedded within a second string, which messed up the escaping. This fixes the problem by handling one-liners in a different manner, so they no longer need to be embedded within another string, and can still be processed in the proper namespace/dictionary context. llvm-svn: 123467
* Split up the Python script interpreter code to allow multiple script ↵Caroline Tice2011-01-141-128/+434
| | | | | | | | | | | interpreter objects to exist within the same process (one script interpreter object per debugger object). The python script interpreter objects are all using the same global Python script interpreter; they use separate dictionaries to keep their data separate, and mutex's to prevent any object attempting to use the global Python interpreter when another object is already using it. llvm-svn: 123415
* Add termination instructions when entering the interactive script interpreter.Caroline Tice2010-12-151-0/+9
| | | | llvm-svn: 121884
* Add the ability to catch and do the right thing with Interrupts (often ↵Caroline Tice2010-11-191-31/+23
| | | | | | | | control-c) and end-of-file (often control-d). llvm-svn: 119837
* Move the embedded Python interpreter onto a separate thread, to preventCaroline Tice2010-11-101-9/+118
| | | | | | | main thread from having to wait on it (which was causing some I/O hangs). llvm-svn: 118700
* Remove references to particular Python version (use the system defaultCaroline Tice2010-10-281-0/+4
| | | | | | | | | | 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
* Flush the prompts immediately in the breakpoint command input readers, to make Caroline Tice2010-10-271-0/+7
| | | | | | sure they come out at the correct times. llvm-svn: 117470
* Prevent Python script interpreter initialization from changingCaroline Tice2010-10-181-8/+40
| | | | | | the termios settings on the debugger's input handle. llvm-svn: 116725
* Added a new Host call to find LLDB related paths:Greg Clayton2010-10-171-26/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | static bool Host::GetLLDBPath (lldb::PathType path_type, FileSpec &file_spec); This will fill in "file_spec" with an appropriate path that is appropriate for the current Host OS. MacOSX will return paths within the LLDB.framework, and other unixes will return the paths they want. The current PathType enums are: typedef enum PathType { ePathTypeLLDBShlibDir, // The directory where the lldb.so (unix) or LLDB mach-o file in LLDB.framework (MacOSX) exists ePathTypeSupportExecutableDir, // Find LLDB support executable directory (debugserver, etc) ePathTypeHeaderDir, // Find LLDB header file directory ePathTypePythonDir // Find Python modules (PYTHONPATH) directory } PathType; All places that were finding executables are and python paths are now updated to use this Host call. Added another new host call to launch the inferior in a terminal. This ability will be very host specific and doesn't need to be supported on all systems. MacOSX currently will create a new .command file and tell Terminal.app to open the .command file. It also uses the new "darwin-debug" app which is a small app that uses posix to exec (no fork) and stop at the entry point of the program. The GDB remote plug-in is almost able launch a process and attach to it, it currently will spawn the process, but it won't attach to it just yet. This will let LLDB not have to share the terminal with another process and a new terminal window will pop up when you launch. This won't get hooked up until we work out all of the kinks. The new Host function is: static lldb::pid_t Host::LaunchInNewTerminal ( const char **argv, // argv[0] is executable const char **envp, const ArchSpec *arch_spec, bool stop_at_entry, bool disable_aslr); Cleaned up FileSpec::GetPath to not use strncpy() as it was always zero filling the entire path buffer. Fixed an issue with the dynamic checker function where I missed a '$' prefix that should have been added. llvm-svn: 116690
* More SWIG cleanup. Moved the breakpoint callback function back to theGreg Clayton2010-10-071-2/+44
| | | | | | | | | | ScriptInterpreterPython class and made a simple callback function that ScriptInterpreterPython::BreakpointCallbackFunction() now calls so we don't include any internal API stuff into the cpp file that is generated by SWIG. Fixed a few build warnings in debugserver. llvm-svn: 115926
* Fix one-liner Python breakpoint commands to be wrapped up in an automaticallyCaroline Tice2010-09-271-5/+11
| | | | | | | generated Python function, and passed the stoppoint context frame and bp_loc as parameters. llvm-svn: 114894
* Automatically wrap *all* Python code entered for a breakpoint command insideCaroline Tice2010-09-271-198/+22
| | | | | | | | an auto-generated Python function, and pass the stoppoint context frame and breakpoint location as parameters to the function (named 'frame' and 'bp_loc'), to be used inside the breakpoint command Python code, if desired. llvm-svn: 114849
* Update help text for breakpoint command one-liners.Caroline Tice2010-09-211-1/+1
| | | | | | | | | | Fix minor bug in 'commands alias'; alias commands can now handle command options and arguments in the same alias. Also fixes problem that disallowed "process launch --" as an alias. Fix typo in comment in Python script interpreter. llvm-svn: 114499
* Re-write/clean up code that generated Python breakpoint commands.Caroline Tice2010-09-211-113/+158
| | | | | | | Add a warning if no command was attached to the breakpoint. Update the help slightly. llvm-svn: 114467
* Fixed the way set/show variables were being accessed to being natively Greg Clayton2010-09-181-12/+8
| | | | | | | | | | | | | | | | | | accessed by the objects that own the settings. The previous approach wasn't very usable and made for a lot of unnecessary code just to access variables that were already owned by the objects. While I fixed those things, I saw that CommandObject objects should really have a reference to their command interpreter so they can access the terminal with if they want to output usaage. Fixed up all CommandObjects to take an interpreter and cleaned up the API to not need the interpreter to be passed in. Fixed the disassemble command to output the usage if no options are passed down and arguments are passed (all disassebmle variants take options, there are no "args only"). llvm-svn: 114252
* Remove help text that is no longer correct.Caroline Tice2010-09-141-4/+26
| | | | | | | Fix Python script interpreter to not fail when the Debugger does not have input/output file handles. llvm-svn: 113880
* Fixed some comments.Johnny Chen2010-09-111-1/+1
| | | | llvm-svn: 113673
* Added the capability to specify a one-liner Python script as the callbackJohnny Chen2010-09-101-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | command for a breakpoint, for example: (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" The ScriptInterpreter interface has an extra method: /// Set a one-liner as the callback for the breakpoint command. virtual void SetBreakpointCommandCallback (CommandInterpreter &interpreter, BreakpointOptions *bp_options, const char *oneliner); to accomplish the above. Also added a test case to demonstrate lldb's use of breakpoint callback command to stop at function c() only when its immediate caller is function a(). The following session shows the user entering the following commands: 1) command source .lldb (set up executable, breakpoint, and breakpoint command) 2) run (the callback mechanism will skip two breakpoints where c()'s immeidate caller is not a()) 3) bt (to see that indeed c()'s immediate caller is a()) 4) c (to continue and finish the program) test/conditional_break $ ../../build/Debug/lldb (lldb) command source .lldb Executing commands in '.lldb'. (lldb) file a.out Current executable set to 'a.out' (x86_64). (lldb) breakpoint set -n c Breakpoint created: 1: name = 'c', locations = 1 (lldb) script import sys, os (lldb) script sys.path.append(os.path.join(os.getcwd(), os.pardir)) (lldb) script import conditional_break (lldb) breakpoint command add -p 1 "conditional_break.stop_if_called_from_a()" (lldb) run run Launching '/Volumes/data/lldb/svn/trunk/test/conditional_break/a.out' (x86_64) (lldb) Checking call frames... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`a at main.c:25 frame #3: a.out`main at main.c:44 frame #4: a.out`start c called from b Continuing... Checking call frames... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`b at main.c:34 frame #2: a.out`main at main.c:47 frame #3: a.out`start c called from b Continuing... Checking call frames... Stack trace for thread id=0x2e03 name=None queue=com.apple.main-thread: frame #0: a.out`c at main.c:39 frame #1: a.out`a at main.c:27 frame #2: a.out`main at main.c:50 frame #3: a.out`start c called from a Stopped at c() with immediate caller as a(). a(1) returns 4 b(2) returns 5 Process 20420 Stopped * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread 36 37 int c(int val) 38 { 39 -> return val + 3; 40 } 41 42 int main (int argc, char const *argv[]) (lldb) bt bt thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread frame #0: 0x0000000100000de8 a.out`c + 7 at main.c:39 frame #1: 0x0000000100000dbc a.out`a + 44 at main.c:27 frame #2: 0x0000000100000e4b a.out`main + 91 at main.c:50 frame #3: 0x0000000100000d88 a.out`start + 52 (lldb) c c Resuming process 20420 Process 20420 Exited a(3) returns 6 (lldb) llvm-svn: 113596
* Don't flatten lldb and import everything into the global namespace. Instead,Johnny Chen2010-09-101-2/+2
| | | | | | set the debugger_unique_id with the lldb prefix. llvm-svn: 113589
* There is no need to restore (sys.stdin, sys.stdout) of the python scriptJohnny Chen2010-08-101-5/+0
| | | | | | | interpreter right before calling Py_Finalize(). This also fixed the crash as reported in rdar://problem/8252903. llvm-svn: 110731
OpenPOWER on IntegriCloud