Commit Graph

588 Commits

Author SHA1 Message Date
Enrico Granata e0afce767a Add a few functions to SBType to handle arrays and typedefs. Fixes rdar://12675166
llvm-svn: 220824
2014-10-28 21:44:06 +00:00
Enrico Granata 88282c69f3 Add a feature where a string data formatter can now be partially composed of Python summary functions
This works similarly to the {thread/frame/process/target.script:...} feature - you write a summary string, part of which is

${var.script:someFuncName}
someFuncName is expected to be declared as
def someFuncName(SBValue,otherArgument) - essentially the same as a summary function

Since . -> [] are the only allowed separators, and % is used for custom formatting, .script: would not be a legitimate symbol anyway, which makes this non-ambiguous

llvm-svn: 220821
2014-10-28 21:07:00 +00:00
Matthew Gardiner c928de3e8e Added functions to the C++ API, for the benefit of non-8-bit byte architectures.
New functions to give client applications to tools to discover target byte sizes
for addresses prior to ReadMemory. Also added GetPlatform and ReadMemory to the
SBTarget class, since they seemed to be useful utilities to have.

Each new API has had a test case added.

http://reviews.llvm.org/D5867

llvm-svn: 220372
2014-10-22 07:22:56 +00:00
Enrico Granata 622be238eb Expose the type-info flags at the public API layer. These flags provide much more informational content to consumers of the LLDB API than the existing TypeClass. Part of the fix for rdar://18517593
llvm-svn: 220322
2014-10-21 20:52:14 +00:00
Enrico Granata dd86f33902 Add typemaps to handle the transformation of Python list of strings into a 'char const **'. This fixes zephyr's issue with SBTarget::Launch without splitting the API into multiple names
llvm-svn: 220306
2014-10-21 17:49:24 +00:00
Jason Molenda 3206b1e077 Remove unnecessary update of 'name' local.
clang static analyzer fixit.

llvm-svn: 219892
2014-10-16 01:55:21 +00:00
Jim Ingham ffc9f1de34 This adds a "batch mode" to lldb kinda like the gdb batch mode. It will quit the debugger
after all the commands have been executed except if one of the commands was an execution control
command that stopped because of a signal or exception.

Also adds a variant of SBCommandInterpreter::HandleCommand that takes an SBExecutionContext.  That
way you can run an lldb command targeted at a particular target, thread or process w/o having to 
select same before running the command.

Also exposes CommandInterpreter::HandleCommandsFromFile to the SBCommandInterpreter API, since that
seemed generally useful.

llvm-svn: 219654
2014-10-14 01:20:07 +00:00
Kuba Brecka 6392754839 Add a IsInstrumentationRuntimePresent SB API
Reviewed at http://reviews.llvm.org/D5738

This adds an SB API into SBProcess:
  bool SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
which simply tells whether a particular InstrumentationRuntime (read "ASan") plugin is present and active.

llvm-svn: 219560
2014-10-11 01:59:32 +00:00
Kuba Brecka 9b7f36b521 include compiler-rt in build-llvm.pl
Reviewed at http://reviews.llvm.org/D5736

The new test cases for ASan fail if the llvm build that is used with LLDB doesn't have compiler-rt (because the resulting compiler then cannot build with -fsanitize=address). Let's include compiler-rt in build-llvm.pl script and make sure we actually *build* it by removing the NO_RUNTIME_LIBS=1 argument used in the make line. After this, the ASan tests pass on a fresh svn checkout.

llvm-svn: 219555
2014-10-11 00:53:32 +00:00
Jim Ingham 26c7bf9312 Rework the way we pass "run multiple command" options to the various API's that
do that (RunCommandInterpreter, HandleCommands, HandleCommandsFromFile) to gather
the options into an options class.  Also expose that to the SB API's.

Change the way the "-o" options to the lldb driver are processed so:
1) They are run synchronously - didn't really make any sense to run the asynchronously.
2) The stop on error
3) "quit" in one of the -o commands will not quit lldb - not the command interpreter
that was running the -o commands.

I added an entry to the run options to stop-on-crash, but I haven't implemented that yet.

llvm-svn: 219553
2014-10-11 00:38:27 +00:00
Kuba Brecka afdf842b3f LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592

This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.

More precisely this patch...

adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.

Kuba

llvm-svn: 219546
2014-10-10 23:43:03 +00:00
Enrico Granata 8387e2fafe Add a (Python only) lldb.SBSyntheticValueProvider class to our API surface
On a suggestion from Jim Ingham, this class allows you to very easily define synthetic child providers that return a synthetic value (in the sense of r219330), but no children

Also, document this new feature in our www docs

llvm-svn: 219337
2014-10-08 20:10:09 +00:00
Enrico Granata d07cfd3ae4 Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function.
If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value

The rationale for doing things this way is twofold:

- there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial
- we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix
On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature

Comes with a test case

llvm-svn: 219330
2014-10-08 18:27:36 +00:00
Enrico Granata 06be059ad9 Allow Python commands to optionally take an SBExecutionContext argument in case they need to handle 'where they want to act' separately from the notion of 'currently-selected entity' that is associated to the debugger. Do this in an (hopefully) non-breaking way by running an argcount check before passing in the new argument. Update the test case to also check for this new feature. www update to follow
llvm-svn: 218834
2014-10-01 21:47:29 +00:00
Enrico Granata d1fd3ce42e Add an accessor to PyCallable that allows one to determine the count of arguments that a Python function allows, and whether varargs/kwargs are also accepted by the same function
llvm-svn: 218812
2014-10-01 20:51:50 +00:00
Enrico Granata e85e84a769 Add a new SBExecutionContext class that wraps an ExecutionContextRef. This class is a convenient way at the API level to package a target,process,thread and frame all together - or just a subset of those
llvm-svn: 218808
2014-10-01 20:43:45 +00:00
Jim Ingham 2bdbfd50d2 This checkin is the first step in making the lldb thread stepping mechanism more accessible from
the user level.  It adds the ability to invent new stepping modes implemented by python classes,
and to view the current thread plan stack and to some extent alter it.

I haven't gotten to documentation or tests yet.  But this should not cause any behavior changes
if you don't use it, so its safe to check it in now and work on it incrementally.

llvm-svn: 218642
2014-09-29 23:17:18 +00:00
Todd Fiala 5bc56a4b34 android: add a command script to help display mixed Java/native backtraces.
This script supports displaying developer-focused backtraces when working
with mixed Java and C/C++ stack frames within lldb.  On Android, this represents
just about every app, since all apps start in Java code.

The script currently supports the Art JVM when run on host-side x86_64 and x86,
but does require a patch not yet accepted in AOSP:
AOSP patch: https://android-review.googlesource.com/#/c/106523/

The backtraces will hide Art VM machinery for interpreted and AOT code
and display the Java file/line numbers for Java code, while displaying
native backtrace info for native frames.  Effectively the developer will
get an app-centric view of the call stack.

This script is not yet tested on device-side Art nor is it tested on
any architecture other than x86_64 or x86 32-bit.  Several changes were
needed on the AOSP side to enable it to work properly for x86_64 and x86, 
so it is quite likely we'll need to do something similar for other cpu
architectures as well.

Change by Tong Shen

llvm-svn: 218315
2014-09-23 16:28:01 +00:00
Carlo Kok b77aba7708 Fix for 218140 for SBTarget.i, the added functions were in the wrong class definition
llvm-svn: 218147
2014-09-19 20:12:24 +00:00
Carlo Kok 0fd6fd4fd4 Adds two new functions to SBTarget FindGlobalVariables and FindGlobalFunctions that lets you search by name, by regular expression and by starts with.
llvm-svn: 218140
2014-09-19 19:38:19 +00:00
Enrico Granata 47caf9a956 Extend the member function discovery APIs to also support Objective-C as well as C++
For the Objective-C case, we do not have a "function type" notion, so we actually end up wrapping the clang ObjCMethodDecl in the Impl object, and ask function-y questions of it
In general, you can always ask for return type, number of arguments, and type of each argument using the TypeMemberFunction layer - but in the C++ case, you can also acquire a Type object for the function itself, which instead you can't do in the Objective-C case

llvm-svn: 218132
2014-09-19 18:21:05 +00:00
Enrico Granata 6c42cb11d6 Change SBType.GetMemberFunctionAtIndex() to return an object describing the member function in more detail. A type was really quite vague. This now has function name, kind, as well as function type
llvm-svn: 217828
2014-09-15 21:30:36 +00:00
Enrico Granata 190064ad0d Add logic to LLDB to figure out the types of member functions of C++ classes. Add plumbing for that all the way up to the SB layer
llvm-svn: 217701
2014-09-12 18:45:43 +00:00
Keno Fischer 15d5e2b4d8 Fix configure & make build with python disabled
This makes sure that nothing that requires Python is being built
when the LLDB_DISABLE_PYTHON flag is being passed in.
It also changes a use of CPPFLAGS to CPP.Flags since the former is overridden
when external flags are passed in while the later is not. I'm not sure exactly
why LLDB_DISABLE_PYTHON is in CXXFLAGS rather than CPPFLAGS,
but cleaning that up is for another commit.

Differential Revision: http://reviews.llvm.org/D4918

llvm-svn: 217414
2014-09-09 04:52:37 +00:00
Kuba Brecka a51ea3822a Implement ASan history threads in SB API
Reviewed at
http://reviews.llvm.org/D5219
and
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140901/012809.html

llvm-svn: 217300
2014-09-06 01:33:13 +00:00
Enrico Granata edc4414094 Expose the ability to retrieve the result of a type validator via the SB API. To keep it simple, do not expose the pair, but just return a NULL string for success, and a non-NULL string for error; If we were to decide to expose the pair, we would need an SBTypeValidatorResult, which is fine, but it should come as part of exposing type validators through the SB API rather than as a one-off thing. So, KISS for now
llvm-svn: 217299
2014-09-06 01:30:04 +00:00
Kuba Brecka a5ea1e2b6c Expose ThreadCollection in SB API
Reviewed at
http://reviews.llvm.org/D5218
and
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140901/012828.html

llvm-svn: 217296
2014-09-06 01:21:19 +00:00
Jim Ingham 4eb1b271fc Make it clear that the load_addr property on SBAddress relies on lldb.target,
and so can only be used in the script interpreter.

llvm-svn: 216625
2014-08-27 22:05:14 +00:00
Deepak Panickal b709222b8a Fix the Windows build by removing the unused lldb_python_module.cmake inclusion from CMakeLists.
llvm-svn: 216392
2014-08-25 18:16:22 +00:00
Sylvestre Ledru f6102892ef Fix some typos:
* transfered => transferred
* unkown => unknown
* sucessfully => successfully

llvm-svn: 215367
2014-08-11 18:06:28 +00:00
Jim Ingham 7ab079b6d0 Add an option to suppress the persistent result variable when running EvaluateExpression
from Python.  If you don't need to refer to the result in another expression, there's no
need to bloat the persistent variable table with them since you already have the result
SBValue to work with.

<rdar://problem/17963645>

llvm-svn: 215244
2014-08-08 21:45:36 +00:00
Zachary Turner fb903ab7d4 Make the swig generation script use the correct python executable.
It was hardcoding the value "python", which will end up at best
getting a different python executable (if the user has overridden
the value of PYTHON_EXECUTABLE), and at worst encountering an
error (if there is no copy of python on the system path).

This patch changes the script to use sys.executable so that it
runs the sub-script with the same executable that it was run with.

llvm-svn: 214618
2014-08-02 07:11:22 +00:00
Greg Clayton 06357c930c (no commit message)
llvm-svn: 214319
2014-07-30 17:38:47 +00:00
Zachary Turner 05c30880b6 Use the designated PYTHON_EXECUTABLE during build.
We were hardcoding "python" as the command to run the swig wrapper
scripts.  We should be using PYTHON_EXECUTABLE instead.

llvm-svn: 213354
2014-07-18 07:06:13 +00:00
Zachary Turner fa59e62012 Create an _d suffixed symlink when doing a debug Windows build.
_lldb is built as an extension module on Windows.  Normally to load
an extension module named 'foo', Python would look for the file
'foo.pyd'.  However, when a debug interpreter is used, Python will
look for the file 'foo_d.pyd'.  This change checks the build
configuration and creates the correct symlink name based on the
build configuration.

llvm-svn: 213306
2014-07-17 20:36:14 +00:00
Greg Clayton 205ca1e89f Enable the ability to enable debug info generation when evaluating expressions.
llvm-svn: 212792
2014-07-11 01:03:57 +00:00
Zachary Turner 0ab4b48992 Get the python scripting interface working on Windows.
This patch fixes a number of issues with embedded Python on
Windows.  In particular:

1) The script that builds the python modules was normalizing the
   case of python filenames during copies.  The module name is
   the filename, and is case-sensitive, so this was breaking code.

2) Changes the build to not attempt to link against python27.lib
   (e.g. the release library) when linking against msvcrt debug
   library.  Doing a debug build of LLDB with embedded python
   support now requires you to provide your own self-compiled
   debug version of python.

3) Don't import termios when initializing the interpreter.  This
   is part of a larger effort to remove the dependency on termios
   since it is not available on Windows.  This particular instance
   was unnecessary and unused.

Reviewed by: Todd Fiala

Differential Revision: http://reviews.llvm.org/D4441

llvm-svn: 212785
2014-07-10 23:47:42 +00:00
Zachary Turner 026861b87d Move the post-build step that creates lldb.py.
Being in lldb\source, ${CMAKE_CURRENT_BINARY_DIR} would resolve to
the build\tools\lldb\source directory.  For correct operation, and
parity with the shell script, it needs to resolve to the
build\tools\lldb\scripts directory.

llvm-svn: 212760
2014-07-10 20:37:47 +00:00
Zachary Turner 454955e1b3 Add better logging to the new Python-based SWIG generation scripts.
llvm-svn: 212759
2014-07-10 20:25:18 +00:00
Bruce Mitchener d93c4a3339 Fix typos.
llvm-svn: 212132
2014-07-01 21:22:11 +00:00
Deepak Panickal 9b35cf52d2 This creates a valid Python API for Windows, pending some issues. The changes included are -
- Ported the SWIG wrapper shell scripts to Python so that they would work on Windows too along with other platforms
 - Updated CMake handling to fix SWIG errors and manage sym-linking on Windows to liblldb.dll
 - More build fixes for Windows

The pending issues are that two Python modules, termios and pexpect are not available on Windows.
These are currently required for the Python command interpreter to be used from within LLDB.

llvm-svn: 212111
2014-07-01 17:57:19 +00:00
Bruce Mitchener 6a7f33387d Fix a few typos.
llvm-svn: 211851
2014-06-27 02:42:12 +00:00
Todd Fiala 34413ec640 Fix an incomplete null structure spec in Python readline suppression module.
Now that I'm building Linux with clang, I'm seeing more clang warnings.
This fills in some extra fields missing in the final end-of-structure-array
marker.

llvm-svn: 211812
2014-06-26 22:35:36 +00:00
Jim Ingham 106d02866d Added an option to turn OFF the "detach on error" behavior that was added
to debugserver when launching processes.

<rdar://problem/16216199>

llvm-svn: 211658
2014-06-25 02:32:56 +00:00
Ed Maste 703c3c8746 Add SBUnixSignals.i
From the patch posted by Russell Harmon.

llvm-svn: 211534
2014-06-23 20:49:41 +00:00
Todd Fiala 802dc40228 Add API control of the signal disposition.
See http://reviews.llvm.org/D4221 for details.

This commit allows you to control the signals that lldb will suppress, stop or forward using the Python and C++ APIs.

Change by Russell Harmon.

Xcode build system changes (and any mistakes) by Todd Fiala.  Tested on MacOSX 10.9.3 and Xcode 6 beta.  (Xcode 5 is hitting the dependency checker crasher on all my systems).

llvm-svn: 211526
2014-06-23 19:30:49 +00:00
Chandler Carruth 4c3376de0a [cmake] Switch python install to use an 'install(DIRECTORY...)' cmake
command instead of a script.

In addition to cleaning things up, this allows more easy access to the
variables. In the old version, it tried to pass variables as -D flags to
cmake, but this didn't actually work. CMake drops all of those arguments
on the floor (try passing garbage through them) and just picks up the
limited subset of pre-defined macros. So, for example, this fixes the
build with LLVM_LIBDIR_SUFFIX=64 which is how I ended up here. =]

llvm-svn: 211028
2014-06-16 15:02:21 +00:00
Jason Molenda 705b180964 Initial merge of some of the iOS 8 / Mac OS X Yosemite specific
lldb support.  I'll be doing more testing & cleanup but I wanted to
get the initial checkin done.

This adds a new SBExpressionOptions::SetLanguage API for selecting a
language of an expression.

I added adds a new SBThread::GetInfoItemByPathString for retriving
information about a thread from that thread's StructuredData.

I added a new StructuredData class for representing
key-value/array/dictionary information (e.g. JSON formatted data).
Helper functions to read JSON and create a StructuredData object,
and to print a StructuredData object in JSON format are included.

A few Cocoa / Cocoa Touch data formatters were updated by Enrico
to track changes in iOS 8 / Yosemite.

Before we query a thread's extended information, the system runtime may 
provide hints to the remote debug stub that it will use to retrieve values
out of runtime structures.  I added a new SystemRuntime method 
AddThreadExtendedInfoPacketHints which allows the SystemRuntime to add 
key-value type data to the initial request that we send to the remote stub.

The thread-format formatter string can now retrieve values out of a thread's
extended info structured data.  The default thread-format string picks up
two of these - thread.info.activity.name and thread.info.trace_messages.

I added a new "jThreadExtendedInfo" packet in debugserver; I will
add documentation to the lldb-gdb-remote.txt doc soon.  It accepts
JSON formatted arguments (most importantly, "thread":threadnum) and
it returns a variety of information regarding the thread to lldb
in JSON format.  This JSON return is scanned into a StructuredData
object that is associated with the thread; UI layers can query the
thread's StructuredData to see if key-values are present, and if
so, show them to the user.  These key-values are likely to be
specific to different targets with some commonality among many
targets.  For instance, many targets will be able to advertise the
pthread_t value for a thread.

I added an initial rough cut of "thread info" command which will print
the information about a thread from the jThreadExtendedInfo result.
I need to do more work to make this format reasonably.

Han Ming added calls into the pmenergy and pmsample libraries if
debugserver is run on Mac OS X Yosemite to get information about the
inferior's power use.

I added support to debugserver for gathering the Genealogy information
about threads, if it exists, and returning it in the jThreadExtendedInfo
JSON result.

llvm-svn: 210874
2014-06-13 02:37:02 +00:00
Todd Fiala 732215f989 Add support for inspecting enum members.
Change by Russell Harmon.

Xcode project updates (and all errors therein)
by Todd Fiala.

llvm-svn: 210046
2014-06-02 20:55:29 +00:00
Enrico Granata e8daa2f843 Introduce the concept of a "display name" for types
Rationale:
Pretty simply, the idea is that sometimes type names are way too long and contain way too many details for the average developer to care about. For instance, a plain ol' vector of int might be shown as
std::__1::vector<int, std::__1::allocator<....
rather than the much simpler std::vector<int> form, which is what most developers would actually type in their code

Proposed solution:
Introduce a notion of "display name" and a corresponding API GetDisplayTypeName() to return such a crafted for visual representation type name
Obviously, the display name and the fully qualified (or "true") name are not necessarily the same - that's the whole point
LLDB could choose to pick the "display name" as its one true notion of a type name, and if somebody really needs the fully qualified version of it, let them deal with the problem
Or, LLDB could rename what it currently calls the "type name" to be the "display name", and add new APIs for the fully qualified name, making the display name the default choice

The choice that I am making here is that the type name will keep meaning the same, and people who want a type name suited for display will explicitly ask for one
It is the less risky/disruptive choice - and it should eventually make it fairly obvious when someone is asking for the wrong type

Caveats:
- for now, GetDisplayTypeName() == GetTypeName(), there is no logic to produce customized display type names yet.
- while the fully-qualified type name is still the main key to the kingdom of data formatters, if we start showing custom names to people, those should match formatters

llvm-svn: 209072
2014-05-17 19:14:17 +00:00