Commit Graph

588 Commits

Author SHA1 Message Date
Jason Molenda b4892cd266 Add a new SBThread::SafeToCallFunctions API; this calls over to
the SystemRuntime to check if a thread will have any problems 
performing an inferior function call so the driver can skip
making that function call on that thread.  Often the function
call can be executed on another thread instead.
<rdar://problem/16777874> 

llvm-svn: 208732
2014-05-13 22:02:48 +00:00
Greg Clayton 3e32ad65fb Allow clients to control the exact path that is used to launch processes by adding new calls to SBLaunchInfo.
The new calls are:

SBFileSpec
SBLaunchInfo::GetExecutableFile ();

void
SBLaunchInfo::SetExecutableFile (SBFileSpec exe_file, bool add_as_first_arg);

<rdar://problem/16833939>

llvm-svn: 208245
2014-05-07 20:16:06 +00:00
Ed Maste d010f9a8a5 If CMake finds a python interpreter, use it
The FreeBSD package building cluster installs e.g. 'python2.7', but no
plain 'python' to avoid version-related issues.

CMake's FindPythonInterp locates an interpreter with such a name and
provides it in the PYTHON_EXECUTABLE variable.  Use that if it's set,
falling back to the original '/usr/bin/env python' otherwise.

This is a missing part of LLDB commit r207122.
Patch by Brooks Davis in FreeBSD ports commit r353052

llvm-svn: 208204
2014-05-07 12:52:08 +00:00
Jason Molenda b9ffa98cab Add a new SBThread::GetQueue() method to get the queue that is
currently associated with a given thread, on relevant targets.

Change the queue detection code to verify that the queues 
associated with all live threads are included in the list.
<rdar://problem/16411314> 

llvm-svn: 207160
2014-04-25 00:01:15 +00:00
Greg Clayton b0d5e4d6ed Remove print statements I was using to debug this script additions.
llvm-svn: 207150
2014-04-24 22:05:25 +00:00
Greg Clayton 676d4de918 Fix the build-llvm.pl to use glob to find all llvm and clang .a files for libllvmclang.a.
llvm-svn: 207149
2014-04-24 21:53:40 +00:00
Ed Maste 97b9dfaa3d If CMake finds a python interpreter, use it
The FreeBSD package building cluster installs e.g. 'python2.7', but no
plain 'python' to avoid version-related issues.

CMake's FindPythonInterp locates an interpreter with such a name and
provides it in the PYTHON_EXECUTABLE variable.  Use that if it's set,
falling back to the original '/usr/bin/env python' otherwise.

Patch by Brooks Davis in FreeBSD ports commit r352012

llvm-svn: 207122
2014-04-24 16:18:21 +00:00
Ed Maste 8ddc423afa Honour DESTDIR when installing LLDB python module
llvm-svn: 206978
2014-04-23 12:59:28 +00:00
Greg Clayton 81057edda3 Include additional libLLVMARM64Utils.a file.
llvm-svn: 206212
2014-04-14 21:33:10 +00:00
Ed Maste 0dcccf7bf3 Add explict dependencies on swig .i files for cmake builds
llvm.org/pr19316

llvm-svn: 205539
2014-04-03 15:03:11 +00:00
Jim Ingham d80102e420 Add the ability to set python breakpoint commands from the SBBreakpoint & SBBreakpointLocation API's.
You can either provide the function name, or function body text.
Also propagate the compilation error up from where it is checked so we can report compilation errors.

<rdar://problem/9898371>

llvm-svn: 205380
2014-04-02 01:04:55 +00:00
Jason Molenda a332978b2a lldb arm64 import.
These changes were written by Greg Clayton, Jim Ingham, Jason Molenda.

It builds cleanly against TOT llvm with xcodebuild.  I updated the
cmake files by visual inspection but did not try a build.  I haven't
built these sources on any non-Mac platforms - I don't think this
patch adds any code that requires darwin, but please let me know if
I missed something.

In debugserver, MachProcess.cpp and MachTask.cpp were renamed to
MachProcess.mm and MachTask.mm as they picked up some new Objective-C
code needed to launch processes when running on iOS.

llvm-svn: 205113
2014-03-29 18:54:20 +00:00
Jim Ingham 914f4e7092 Add the ability from the SB API's to set the "one thread" timeout
for expression evaluations that try one and then all threads.

<rdar://problem/15598528>

llvm-svn: 205060
2014-03-28 21:58:28 +00:00
Jason Molenda 14c604ecc0 Link in the llvm/lib/ProfileData build product.
llvm-svn: 204895
2014-03-27 03:03:24 +00:00
Greg Clayton 9bb8cb1965 Move LLDBWrapPython.cpp into the build folder for Xcode builds so it doesn't muck with cmake builds.
llvm-svn: 203956
2014-03-14 18:24:30 +00:00
Jason Molenda aac16e0f80 Add a SBQueue::GetKind() method to retrieve the type of libdispatch queue (serial or concurrent).
<rdar://problem/7964505>

llvm-svn: 203748
2014-03-13 02:54:54 +00:00
Greg Clayton bf56cb50a8 Detect when llvm or clang sources have changed and rebuild llvm/clang automatically.
llvm-svn: 203594
2014-03-11 18:24:32 +00:00
Jason Molenda 37e9b5ab38 libBacktraceRecording __introspection_dispatch_queue_get_pending_items is
changing the data it returns; this change accepts either the old format or
the new format.  It doesn't yet benefit from the new format's additions -
but I need to get this checked in so we aren't rev-locked.
Also add a missing .i entry for SBQueue::GetNumRunningItems() missing from
the last checkin.
<rdar://problem/16272115> 

llvm-svn: 203421
2014-03-09 21:17:08 +00:00
Jim Ingham 286fb1ef32 Plumb the EvaluateExpressionOptions::{Set,Get}StopOthers through the SB API, and make it work in RunThreadPlan.
Also remove SetStopOthers from the ThreadPlanCallFunction, because if the value you have doesn't match what is
in the EvaluateExpressionOptions the plan was passed when created it won't work correctly.

llvm-svn: 202464
2014-02-28 02:52:06 +00:00
Sylvestre Ledru 743e2b2139 * Rename PYTHON_INCLUDES to PYTHON_INC_DIR to match the similar declaration
in lldb.svn/Makefile
* Use CPP.Flags to export the declaration. The current solution broke all builds
on http://llvm-jenkins.debian.net/

llvm-svn: 202270
2014-02-26 15:05:48 +00:00
Todd Fiala 9bb71b73d9 Suppress python readline module under Linux to fix a seg fault.
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
2014-02-26 07:39:20 +00:00
Enrico Granata 9422fd0c14 Make sure we don't try to print the SystemExit exception, or we will cause the containing process to exit() from under us
llvm-svn: 201600
2014-02-18 20:00:20 +00:00
Jason Molenda 2fd83355a8 Change the Mac OS X SystemRuntime plugin from using the placeholder
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
2014-02-05 05:44:54 +00:00
Enrico Granata 1ba7305974 <rdar://problem/15936507>
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
2014-01-29 23:18:58 +00:00
Greg Clayton 44d937820b Merging the iohandler branch back into main.
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
2014-01-27 23:43:24 +00:00
Greg Clayton 1f4db7da8f Added the ability to get the type that a typedef points to via:
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
2014-01-23 21:38:34 +00:00
Todd Fiala 5000e28a5e Make lldb build with Makefiles on OS X.
This change does the following:

* Adds Makefile build scripts to debug server.

* Fixes a few small mistakes in the other makefiles.

* Modifies generate-vers.pl slightly to also work for debugserver.

* Changes the OS X, non-framework python search path from libdir to
  libdir/python2.X/site-packages where it is installed by the build
  system (also where it is installed on other operating systems).

Patch by Keno Fischer.

llvm-svn: 199543
2014-01-18 08:05:32 +00:00
Jason Molenda be1261a1ab Add -stdlib=c++ to the LDFLAGS when configuring llvm. The lldb
xcode project file sets the MACOSX_DEPLOYMENT_TARGET to 10.7.
llvm/configure (as of r199313) tries to compile a .cpp file which
includes <atomic> with -std=c++0x.  If the deployment target is set
to earlier than 10.9 and no C++ library is specified, clang will
error out at this point.

Fixes xcode building of lldb on Mac OS X.  If this change causes
problems for any of the other build workflows, please let me know
and I'll fix it.

llvm-svn: 199511
2014-01-17 20:59:32 +00:00
Enrico Granata d9bd4ae77b Patch by Ari Grant
"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
2014-01-09 02:28:25 +00:00
Enrico Granata 30f287fde5 Add a new way to bind a format to a type: by enum type
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
2013-12-28 08:44:02 +00:00
Enrico Granata 0e0e9f531f Adding a document that describes the architecture of data formatters. Suggestions and ideas for improvements most welcome
llvm-svn: 198038
2013-12-26 07:21:41 +00:00
Jason Molenda 5e8dce4dbf Add new Queue, QueueItem, Queuelist, SBQueue, SBQueueItem classes to represent
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
2013-12-13 00:29:16 +00:00
Sylvestre Ledru a7830a47f1 As consistency, invoke python with /usr/bin/env (like it is done in the rest of the file). Thanks to Xavier De Gaye for the patch
llvm-svn: 196933
2013-12-10 16:51:35 +00:00
Sylvestre Ledru c061cceed2 Fixed Makefile-based install to place python packages in the LLDB install tree.
Failure to install python packages now fails the make install.
This patch properly handles the optional DESTDIR variable.

Patch by Todd Fiala

llvm-svn: 196624
2013-12-06 23:16:23 +00:00
Greg Clayton d5944cd118 For logical backtrace work, lldb needs to track Module unloads etc & 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
2013-12-06 01:12:00 +00:00
Sylvestre Ledru 13b0fba48b Revert: "Patch from Todd Fiala that install the lldb.py module in the prefix directory and also makes install fail if the prefix directory can't be accessed"
Does not respect the prefix

llvm-svn: 196499
2013-12-05 12:51:47 +00:00
Greg Clayton 8fbbb5b421 Patch from Todd Fiala that install the lldb.py module in the prefix directory and also makes install fail if the prefix directory can't be accessed
llvm-svn: 196413
2013-12-04 21:27:40 +00:00
Jean-Daniel Dupas 48a6060c2c Request for review: Fix build-llvm.pl
Summary:
- Stop to try to rebuild llvm on each invocation by removing the invalid library entry libLLVMArchive.a which no longer exists.
- Remove the useless ranlib invocation. "libtools -static" automatically takes care of the archive table of content.

CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2296

llvm-svn: 196128
2013-12-02 18:32:35 +00:00
Jason Molenda 906f329724 Change lldb from building against a Python framework out of
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
2013-11-23 20:07:29 +00:00
Jason Molenda 612cb6ef2b Add --enable-cxx11 to llvm builds. As of r195239, SmallPtrSet.h /
SmallPtrSet.cpp use different methods if SmallPtrSet.h is included
in C++11 mode.  Building llvm in C++03 mode and lldb in C++11 mode
resulted in a link-time failure with the C++11-mode-specific method
not being found in the llvm build.

llvm-svn: 195544
2013-11-23 04:59:07 +00:00
Greg Clayton fbb7634934 Expose SBPlatform through the public API.
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
2013-11-20 21:07:01 +00:00
Sean Callanan 51f3d07313 Updated build-llvm to use a more generic ioctl
to determine the number of available processors.

llvm-svn: 195172
2013-11-19 23:59:38 +00:00
Jason Molenda 8ee9cb5891 Add a new SBThread::GetExtendedBacktraceOriginatingIndexID() method
(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
2013-11-16 01:24:22 +00:00
Jason Molenda 008c45f1a1 Change SBThread::GetExtendedBacktrace to
SBThread::GetExtendedBacktraceThread to make it more clear what is
being returned.

llvm-svn: 194531
2013-11-12 23:33:32 +00:00
Jim Ingham 6fbc48bc42 This patch does a couple of things.
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
2013-11-07 00:11:47 +00:00
Jason Molenda 95d005c789 Rename extended backtrace methods to take out the "ThreadOrigin"
bit from the method names.
<rdar://problem/15314369> 

llvm-svn: 194122
2013-11-06 03:07:33 +00:00
Jason Molenda 5dd4916f63 Add a new GetThreadOriginExtendedBacktrace method to the
SystemRuntime and SBThread classes.
<rdar://problem/15314369> 

llvm-svn: 194111
2013-11-06 00:04:44 +00:00
Jason Molenda 8c71337abc Add the GetNumThreadOriginExtendedBacktraceTypes and
GetThreadOriginExtendedBacktraceTypeAtIndex methods to
SBProcess.

Add documentation for the GetQueueName and GetQueueID methods
to SBThread.
<rdar://problem/15314369> 

llvm-svn: 194063
2013-11-05 11:00:35 +00:00
Jason Molenda b57e4a1bc6 Roll back the changes I made in r193907 which created a new Frame
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
2013-11-04 09:33:30 +00:00
Jason Molenda f23bf7432c Add a new base class, Frame. It is a pure virtual function which
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
2013-11-02 02:23:02 +00:00
Jason Molenda 5e873dbc40 Fix for a mistake spotted by Enrico with the SBThread::queue_id accessor.
llvm-svn: 193136
2013-10-22 01:37:18 +00:00
Jason Molenda 4fdb5863b9 Expose the Thread::GetQueueID() method through the SBThread API, similar to
the existing SBThread::GetQueueName() method.

llvm-svn: 193132
2013-10-21 23:52:54 +00:00
Greg Clayton ef8180a3f6 <rdar://problem/14972424>
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
2013-10-15 00:14:28 +00:00
Enrico Granata c0f8ca0e74 Add the capability for LLDB to query an arbitrary Python module (passed in 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
2013-10-14 21:39:38 +00:00
Enrico Granata 347c2aa3e3 <rdar://problem/14028923>
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
2013-10-08 21:49:02 +00:00
Daniel Malea 54e14615e7 Add missing GetBroadcasterClassName and event types enum to SBThread.i
llvm-svn: 191933
2013-10-03 22:21:09 +00:00
Joerg Sonnenberger 340a17595e Convert to UNIX line endings.
llvm-svn: 191367
2013-09-25 10:37:32 +00:00
Richard Mitton f86248d9ba Added a 'jump' command, similar to GDBs.
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
2013-09-12 02:20:34 +00:00
Daniel Malea e0f8f574c7 merge lldb-platform-work branch (and assorted fixes) into trunk
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
2013-08-26 23:57:52 +00:00
Jason Molenda c7e828eef1 Don't recommend using bytearray(buf, 'ascii') for binary data read with
SBProcess::ReadMemory - it will fail for anything with the high bit set.

llvm-svn: 189154
2013-08-24 00:16:19 +00:00
Sean Callanan c0a5cddfa8 Changed LLVM configure options to reflect the new
way of making LLVM not rely on terminfo.

llvm-svn: 188305
2013-08-13 18:11:20 +00:00
Sean Callanan 0e89fa7894 Ensure that we don't build LLVM with a dependency
on curses.

llvm-svn: 188015
2013-08-08 21:30:51 +00:00
Jason Molenda ad9a53c510 Add an SBFrame::FindRegister() method to make it a little
easier to retrieve a register value.

llvm-svn: 187184
2013-07-26 02:08:48 +00:00
Enrico Granata eff81a471a Second attempt at getting the PyCallable changes in trunk
Thanks to Daniel Malea for helping test this patch for Linux happiness!

llvm-svn: 185965
2013-07-09 20:14:26 +00:00
Greg Clayton 226cce2511 Added a way to extract the module specifications from a file. A module 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
2013-07-08 22:22:41 +00:00
Daniel Malea 9a71a7d81b Revert commits that cause broken builds on GCC buildbots
- build fails due to PyCallable template definition inside an extern "C" scope

This commit reverts 185240, 184893 and 184608.

llvm-svn: 185560
2013-07-03 17:58:31 +00:00
Enrico Granata 5c47650fe0 <rdar://problem/14309010>
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
2013-06-28 23:33:18 +00:00
Enrico Granata b4675a4e12 <rdar://problem/14266411>
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
2013-06-25 23:43:28 +00:00
Enrico Granata c20eed4280 Lots of cleanup on the SWIG wrapping layer
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
2013-06-21 23:27:16 +00:00
Enrico Granata c972c70e60 Change the SWIG wrappers to stop directly casting SB object to SWIG objects, 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
2013-06-21 18:57:30 +00:00
Enrico Granata aad8e48054 In thread and frame format strings, it is now allowed to use Python 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
2013-06-20 23:40:21 +00:00
Greg Clayton d8c3d4b1e9 Implemented a types.py module that allows types to be inspected for padding.
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
2013-06-19 21:50:28 +00:00
Andy Gibbs a297a97e09 Sort out a number of mismatched integer types in order to cut down the number of compiler warnings.
llvm-svn: 184333
2013-06-19 19:04:53 +00:00
Greg Clayton 88e0f618ea Added a new decorator function in the "lldb" module that can register a 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
2013-06-19 01:38:02 +00:00
Greg Clayton f02500c74c Added the ability to get a list of types from a SBModule or SBCompileUnit. 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
2013-06-18 22:51:05 +00:00
Enrico Granata fd4bc4e58f Fixing a linking issue when building LLDB with ToT LLVM
llvm-svn: 184127
2013-06-17 21:42:39 +00:00
Greg Clayton 1d4c540688 Added a SBSection::GetParent() to the API.
llvm-svn: 183948
2013-06-13 21:23:23 +00:00
Sylvestre Ledru cbd5c4c98a Remove the windows CR
llvm-svn: 183911
2013-06-13 16:05:41 +00:00
Enrico Granata e34ade7986 Improvements to the data formatters SB API:
- 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
2013-06-11 22:58:32 +00:00
Enrico Granata b0c72d99dc <rdar://problem/13646047>
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
2013-06-11 22:06:06 +00:00
Enrico Granata 05db523f3c Making our Python decrefs NULL-safe
llvm-svn: 183774
2013-06-11 19:13:50 +00:00
Enrico Granata 8d6e5ec292 <rdar://problem/13759177>
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
2013-06-11 19:04:32 +00:00
Enrico Granata c01dc4af1f Adding properties to the SBBreakpoint class
llvm-svn: 183707
2013-06-10 22:39:08 +00:00
Enrico Granata a5c0308bde Adding a diagnose-nsstring command
This should help us figure out issues with the NSString data formatter

llvm-svn: 182972
2013-05-30 23:36:47 +00:00
Enrico Granata 0f6a057147 This checkin enables Python summaries to return any string-convertible object
Upon encountering an object not of type string, LLDB will get the string representation of it (akin to calling str(X) in Python code) and use that as the summary to display

Feedback is welcome as to whether repr() should be used instead (but the argument for repr() better be highly persuasive :-)

llvm-svn: 182953
2013-05-30 18:56:47 +00:00
Daniel Malea 01b384c978 Fix CMake install target
- copy lldb python module into directory specified with CMAKE_INSTALL_PREFIX
- make liblldb.so a symlink (to liblldb.so.X.Y where X.Y is the LLVM version)

llvm-svn: 182157
2013-05-17 20:55:19 +00:00
Enrico Granata c8fcaab6ce <rdar://problem/13883385>
Python breakpoint actions can return False to say that they don't want to stop at the breakpoint to which they are associated
Almost all of the work to support this notion of a breakpoint callback was in place, but two small moving parts were missing:
a) the SWIG wrapper was not checking the return value of the script
b) when passing a Python function by name, the call statement was dropping the return value of the function
This checkin addresses both concerns and makes this work
Care has been taken that you only keep running when an actual value of False has been returned, and that any other value (None included) means Stop!

llvm-svn: 181866
2013-05-15 02:46:08 +00:00
Enrico Granata c3387333ce <rdar://problem/11742979>
SWIG is smart enough to recognize that C++ operators == and != mean __eq__ and __ne__ in Python and do the appropriate translation
But it is not smart enough to recognize that mySBObject == None should return False instead of erroring out
The %pythoncode blocks are meant to provide those extra smarts (and they play some SWIG&Python magic to find the right function to call behind the scenes with no risk of typos :-)
Lastly, SBBreakpoint provides an == but never provided a != operator - common courtesy is to provide both

llvm-svn: 180987
2013-05-03 01:29:27 +00:00
Enrico Granata e55f77aec8 <rdar://problem/13499317>
Enabling Python commands to produce Unicode output via:

result.PutCString(u”whatever”)

llvm-svn: 180930
2013-05-02 17:29:04 +00:00
Jason Molenda f7305a6103 Rename unwind_diagnose.py to diagnose_unwind.py. Change
finish-swig-Python-LLDB.sh to create a new lldb.diagnose subdirectory
in the LLDB framework; the first diagnostic command in this directory
is diagnose-unwind.  There may be others added in the future.

Users can load these diagnostic tools into their session with 
"script import lldb.diagnose".

llvm-svn: 180768
2013-04-30 03:03:06 +00:00
Jason Molenda 8ed67139c4 Forgot to include the diagnose_unwind.py script in the initialization of
the lldb.macosx folder.

llvm-svn: 180078
2013-04-23 04:21:14 +00:00
Greg Clayton 7b0992d9cd After discussing with Chris Lattner, we require C++11, so lets get rid of the macros and just use C++11.
llvm-svn: 179805
2013-04-18 22:45:39 +00:00
Greg Clayton e01e07b6e7 Since we use C++11, we should switch over to using std::unique_ptr when C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++.
Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro.

llvm-svn: 179779
2013-04-18 18:10:51 +00:00
Andrew Kaylor a75418dbd6 Adding new Python API function to check for stopped threads.
llvm-svn: 179577
2013-04-15 23:33:53 +00:00
Sylvestre Ledru b9555e8e4a Remove the useless SRCROOT declaration from the call of build-swig-wrapper-classes.sh & finish-swig-wrapper-classes.sh
Two reasons for that:
* the declaration is not used. the LLDB_SOURCE_DIR is provided as the first argument in the script ($1) (called SRC_ROOT in the source code)
* add_custom_command is quoting the first argument of the command. Usually, it is the script itself (and then the full path to the script) but, here, it is the declaration of a variable.
It was failing with:
cd "/llvm-toolchain-3.3~svn179457/build-llvm/tools/lldb/scripts" && "SRCROOT=/llvm-toolchain-3.3~svn179457/tools/lldb" /llvm-toolchain-3.3~svn179457/tools/lldb/scripts/build-swig-wrapper-classes.sh /llvm-toolchain-3.3~svn179457/tools/lldb /llvm-toolchain-3.3~svn179457/build-llvm/tools/lldb/scripts /llvm-toolchain-3.3~svn179457/build-llvm/tools/lldb/scripts /llvm-toolchain-3.3~svn179457/build-llvm -m
/bin/sh: 1: SRCROOT=/llvm-toolchain-3.3~svn179457/tools/lldb: not found

llvm-svn: 179459
2013-04-13 13:20:12 +00:00
Sean Callanan d3f9968af6 Make sure we expose SetData() through the Python
interface.

llvm-svn: 179439
2013-04-13 01:28:33 +00:00
Greg Clayton dda8c7d56f Fixed SBValueList to have a __str__ function like all other SB classes. Previously this was done as __repr__.
llvm-svn: 179327
2013-04-11 22:24:25 +00:00
Enrico Granata f15ee4e89f <rdar://problem/13563628>
Introducing a negative cache for ObjCLanguageRuntime::LookupInCompleteClassCache()
This helps speed up the (common) case of us looking for classes that are hidden deep within Cocoa internals and repeatedly failing at finding type information for them.
In order for this to work, we need to clean this cache whenever debug information is added. A new symbols loaded event is added that is triggered with add-dsym (before modules loaded would be triggered for both adding modules and adding symbols).
Interested parties can register for this event. Internally, we make sure to clean the negative cache whenever symbols are added.
Lastly, ClassDescriptor::IsTagged() has been refactored to GetTaggedPointerInfo() that also (optionally) returns info and value bits. In this way, data formatters can share tagged pointer code instead of duplicating the required arithmetic.

llvm-svn: 178897
2013-04-05 18:49:06 +00:00
Greg Clayton 4d8ad55c78 Modified patch from Prabhat Verma to enable loading core files through the SBTarget API.
llvm-svn: 177932
2013-03-25 22:40:51 +00:00
Enrico Granata ac9df2d1a6 <rdar://problem/13434476>
Making value objects properly iterable in constructs of the form
[ x for x in value_with_children ]

This would previously cause an endless loop because lacking a proper iterator object, Python will keep calling __getitem__() with increasing values of the index until it gets an IndexError
since SBValue::GetValueForExpressionPath() supports synthetic array members, no array index will ever really cause an IndexError to be raised, hence the endless iteration

class value_iter is an implementation of __iter__() that provides a terminating iterator over a value

llvm-svn: 177885
2013-03-25 18:53:07 +00:00