Commit Graph

784 Commits

Author SHA1 Message Date
Jim Ingham c134810cfb Check for a NULL input filehandle before referencing it.
<rdar://problem/25105824>

llvm-svn: 263274
2016-03-11 18:49:38 +00:00
Jim Ingham d815c9ab88 Fix SBDebugger.GetOutputFileHandle() on OS X.
The swig typemaps had some magic for output File *'s on OS X that made:

SBDebugger.GetOutputFileHandle() 

actually work.  That was protected by a "#ifdef __MACOSX__", but the corresponding define
got lost going from the Darwin shell scripts to the python scripts for running
swig, so the code was elided.  I need to pass the define to SWIG, but only when
targetting Darwin.

So I added a target-platform argument to prepare_bindings, and if that 
is Darwin, I pass -D__APPLE__ to swig, and that activates this code again, and
GetOutputFileHandle works again.  Note, I only pass that argument for the Xcode
build.  I'm sure it is possible to do that for cmake, but my cmake-foo is weak.

I should have been able to write a test for this by creating a debugger, setting the 
output file handle to something file, writing to it, getting the output file handle 
and reading it.  But SetOutputFileHandle doesn't seem to work from Python, so I'd 
have to write a pexpect test to test this, which I'd rather not do.

llvm-svn: 263183
2016-03-11 01:57:45 +00:00
Jim Ingham 2411167fb5 Add an "offset" option to "break set -n" and "break set -f -l".
That way you can set offset breakpoints that will move as the function they are 
contained in moves (which address breakpoints can't do...)

I don't align the new address to instruction boundaries yet, so you have to get
this right yourself for now.

<rdar://problem/13365575>

llvm-svn: 263049
2016-03-09 18:59:13 +00:00
Stephane Sezer c691b14a41 Use shallow clones in build-llvm.py.
Summary:
This makes cloning (and therefore the whole build) faster.
The checkout step goes from ~4m to ~30s on my host.

Reviewers: tfiala

Subscribers: lldb-commits

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

llvm-svn: 262513
2016-03-02 20:53:19 +00:00
Jason Molenda 878ae01889 This patch stops lldb from loading a .lldbinit file from the current
working directory by default -- a typical security problem that we
need to be more conservative about.

It adds a new target setting, target.load-cwd-lldbinit which may
be true (always read $cwd/.lldbinit), false (never read $cwd/.lldbinit)
or warn (warn if there is a $cwd/.lldbinit and don't read it).  The
default is set to warn.  If this is met with unhappiness, we can look
at changing the default to true (to match current behavior) on a 
different platform.

This does not affect reading of ~/.lldbinit - that will still be read,
as before.  If you run lldb in your home directory, it will not warn
about the presence of a .lldbinit file there.

I had to add two SB API - SBHostOS::GetUserHomeDirectory and 
SBFileSpec::AppendPathComponent - for the lldb driver code to be
able to get the home directory path in an OS neutral manner.

The warning text is

There is a .lldbinit file in the current directory which is not being read.
To silence this warning without sourcing in the local .lldbinit,
add the following to the lldbinit file in your home directory:
    settings set target.load-cwd-lldbinit false
To allow lldb to source .lldbinit files in the current working directory,
set the value of this variable to true.  Only do so if you understand and
accept the security risk.

<rdar://problem/24199163> 

llvm-svn: 261280
2016-02-19 00:05:17 +00:00
Jim Ingham cbf6f9b243 Adding an SBThread::StepInto that takes an end-line, also moved the code that figures
out the address range for the step to SymbolContext.

llvm-svn: 260772
2016-02-13 00:31:47 +00:00
Siva Chandra 29d9bea93f Adjust for Python-3.
Summary:
This does not yet give us a clean testsuite run but it does help with:
1. Actually building on linux
2. Run the testsuite with over 70% tests passing on linux.

Reviewers: tfiala, labath, zturner

Subscribers: lldb-commits

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

llvm-svn: 260721
2016-02-12 20:30:47 +00:00
Enrico Granata 14086ed75d Change lldb.value.__int__() so that it takes into account the signedness of the value being cast to return a Python number with the proper value
The explicit APIs on SBValue obviously remain if one wants to be explicit in intent, or override this guess, but since __int__() has to pick one, an educated guess is definitely better than than always going to signed regardless

Fixes rdar://24556976

llvm-svn: 260349
2016-02-10 02:12:42 +00:00
Jim Ingham 5c94f2942e Add a note on how to create an empty target and use it to attach to
processes whose executables you don't know up front.

llvm-svn: 259396
2016-02-01 20:05:37 +00:00
Eugene Zelenko c33088f41e Remove autoconf support from source directories.
Differential revision: http://reviews.llvm.org/D16662

llvm-svn: 259098
2016-01-28 22:05:24 +00:00
Todd Fiala 2c0802c559 modify Xcode build to use cmake/ninja for internal llvm/clang
This change restores the Xcode build to working after Makefile support
was stripped from LLVM and clang recently.

With this change, the Xcode build now requires cmake (2.8.12.2+).
The cmake must either be on the path that Xcode sees, or it must
exist in one of the following locations:

* /usr/local/bin/cmake
* /opt/local/bin/cmake
* $HOME/bin/cmake

If the ninja build tool is present on the path, it will be used.
If not, ninja will be cloned (via git), bootstrap-built, and
used for the llvm/clang build.

LLDB now requires a minimum deployment target of OS X 10.9.  Prior
to this, it was 10.8.  The llvm/clang cmake build will not run
with Xcode 7.2 or Xcode 7.3 beta's compiler with the minimum
deployment target set to anything lower than 10.9.  This is
related to #include <atomic>.

When llvm or clang source code does not exist in the lldb tree,
it will be cloned via git using http://llvm.org/git/{project}.git.
Previously it used SVN.  If this causes any heartache, we can
make this smarter, autodetect an embedded svn and use svn instead.
(And/or use SVN if a git command is not available).

This change also fixes an lldb-mi linkage failure (needed
libncurses) as exposed by one of the LLVM libs.

llvm-svn: 259027
2016-01-28 07:36:44 +00:00
Bhushan D. Attarde df5f0b448c [LLDB][MIPS] A small fix in GetBreakableLoadAddress() for MIPS
SUMMARY:
    Get the load address for the address given by symbol and function.
    Earlier, this was done for function only, this patch does it for symbol too.
    This patch also adds TestAvoidBreakpointInDelaySlot.py to test this change.
    
    Reviewers: clayborg
    Subscribers: labath, zturner, mohit.bhakkad, sagar, jaydeep, lldb-commits
    Differential Revision: http://reviews.llvm.org/D16049

llvm-svn: 258919
2016-01-27 10:16:30 +00:00
Zachary Turner 4407396fb9 Fix some issues with bytes and strings in Python 3.
SBProcess::ReadMemory and other related functions such as
WriteMemory are returning Python string() objects.  This means
that in Python 3 that are returning Unicode objects.  In reality
they should be returning bytes objects which is the same as a string
in Python 2, but different in Python 3.  This patch updates the
generated SWIG code to return Python bytes objects for all
memory related functions.

One quirk of this patch is that the C++ signature of ReadCStringFromMemory
has it writing c-string data into a void*.  This confuses our swig
typemaps which expect that a void* means byte data.  So I hacked up
a custom typemap which maps this specific function to treat the
void* as string data instead of byte data.

llvm-svn: 258743
2016-01-25 23:21:18 +00:00
Zachary Turner bea3a85151 Fix more occurrences of string/bytes/bytearray in swig typemaps.
llvm-svn: 258742
2016-01-25 23:21:13 +00:00
Zachary Turner f9d6d204e8 Fix swig typemap for SBEvent.
This needs to be able to handle bytes, strings, and bytearray objects.
In Python 2 this was easy because bytes and strings are the same thing,
but in Python 3 the 2 cases need to be handled separately.  So as not
to mix raw Python C API code with PythonDataObjects code, I've also
introduced a PythonByteArray class to PythonDataObjects to make the
paradigm used here consistent.

llvm-svn: 258741
2016-01-25 23:21:09 +00:00
Zachary Turner 21da1ed15b Fix ResourceWarning about unclosed file in use_lldb_suite_root.py.
llvm-svn: 257945
2016-01-15 22:22:35 +00:00
Zachary Turner 673cf7e80b Get rid of const char** typemaps.
We already have char** typemaps which were near copy-pastes of
the const char** versions.  This way we have only one version that
works for both.

llvm-svn: 257670
2016-01-13 21:21:54 +00:00
Zachary Turner 19e2ea8fb6 Fix TestProcessLaunch for Python 3.
There were a number of problems preventing this from working:

1. The SWIG typemaps for converting Python lists to and from C++
   arrays were not updated for Python 3.  So they were doing things
   like PyString_Check instead of using the PythonString from
   PythonDataObjects.
2. ProcessLauncherWindows was ignoring the environment completely.
   So any test that involved launching an inferior with any kind
   of environment variable would have failed.
3. The test itself was using process.GetSTDOUT(), which isn't
   implemented on Windows.  So this was changed to save the
   value of the environment variable in a local variable and
   have the debugger look at the value of the variable.

llvm-svn: 257669
2016-01-13 21:21:49 +00:00
Enrico Granata 744959b9c9 Fix an issue where scripted commands would not actually print any of their output if an immediate output file was set in the result object via a Python file object
Fixes rdar://24130303

llvm-svn: 257644
2016-01-13 18:11:45 +00:00
Zachary Turner 7a76845c48 Fix Python 3 issues related to OS plugins.
* lldb::tid_t was being converted incorrectly, so this is updated to use
PythonInteger instead of manual Python Native API calls.
* OSPlugin_RegisterContextData was assuming that the result of
  get_register_data was a string, when in fact it is a bytes.  So this
  method is updated to use PythonBytes to do the work.

llvm-svn: 257398
2016-01-11 22:16:17 +00:00
Enrico Granata 31ccb51a7f __ne__ is the actual Python operator; __neq__ is a typo
llvm-svn: 256053
2015-12-18 22:46:58 +00:00
Enrico Granata e242624ca9 Add API to support retrieving the formatters category for a specific language
llvm-svn: 256033
2015-12-18 21:25:24 +00:00
Ted Woodward ec2422364f Change finishSwigPythonLLDB.py to copy six.py instead of simlink it
Summary: If six.py is simlink'd, an installation won't be able to find it unless it has access to the source tree that lldb was built from.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 255340
2015-12-11 15:43:36 +00:00
Jim Ingham 6dd8aa2ed2 Make it clear how you would get the pointee out of an SBValue with
GetType().IsPointerType() returns true.

llvm-svn: 254790
2015-12-04 22:51:19 +00:00
Jim Ingham 9d27f1b0b2 Add documentation for SBTarget::CreateValueFromAddress.
llvm-svn: 254763
2015-12-04 20:16:51 +00:00
Zachary Turner 7cc4477637 Use sub-commands instead of --mode={client,server}.
This is more pythonic and allows a more idiomatic way of getting
detailed usage information for each individual sub-command.

llvm-svn: 254533
2015-12-02 19:00:52 +00:00
Zachary Turner 6f12d3335d Unpack the output on the client, completing the cycle.
llvm-svn: 254341
2015-11-30 22:31:24 +00:00
Zachary Turner 24a95f852d Have swig_bot actually run swig, and send back the output.
llvm-svn: 254340
2015-11-30 22:31:13 +00:00
Zachary Turner 5de07b078d Be *stupider* about what constitutes a supported language binding.
We were trying to be super smart and find all the supported language
bindings.  This led to us scanning the directory and treating all
subdirectories as language binding directories.  This makes it
hard to add unrelated code in this folder.

Besides, we only support one at the moment - Python.  And when new
ones are added it will be trivial to just add their names to a list.

So this patch gets stupider about how to look for language binding
subfolders.  Just put them in a list, and use the list.

llvm-svn: 254078
2015-11-25 17:49:47 +00:00
Zachary Turner 933626229b Another hack to fix the build bot.
This script really should not be assuming every subdirectory is
a language directory for swig generation.  Using a hack to get
this working for now, but this should be solved once this script
is re-written similar to how prepare_bindings was.

llvm-svn: 254037
2015-11-24 23:11:54 +00:00
Zachary Turner f6a30d3172 Fix build after swig_bot_lib changes.
llvm-svn: 254033
2015-11-24 22:27:02 +00:00
Zachary Turner 48102bd186 swig-bot - Close the socket when shutting down.
llvm-svn: 254026
2015-11-24 21:35:58 +00:00
Zachary Turner 9befc01064 Include config settings in the archive, and extract on the remote.
llvm-svn: 254025
2015-11-24 21:35:50 +00:00
Zachary Turner cc3609362e Make swig_bot server support Ctrl+C
llvm-svn: 254024
2015-11-24 21:35:40 +00:00
Zachary Turner 0a2899ca82 swig_bot remote path connection / preliminary implementation.
With this patch, the client will package up all the required
inputs into a compressed zip file, establish a connection to the
server, send the input to the server, and wait for the server to
send a response (in this case the response is just echoed back to
the client).

This gets the network communication in place, and in a subsequent
patch I will follow up with the code that actually runs swig on
the server and sends back the output instead of echoing back the
input.

llvm-svn: 254023
2015-11-24 21:35:32 +00:00
Zachary Turner 2db36097b4 First implementation of swig_bot.py
This version supports local generation only.  It's intentionally
stupid, and does not support any kind of dependency checking.
If you run the script, it's going to call SWIG.  While this is
a slow process, we are going to combine the use of the swig bot
with checked in static bindings, meaning that it won't be terribly
important to only regenerate the bindings when the input files
have actually changed.

A side benefit of this is that the implementation is drastically
simpler.

This is all experimental at the moment, but it duplicates a lot
of the logic currently found in prepare_bindings.py.  There was
not a good way to reuse some of the logic without invasive changes
on that script, and since this script is still experimental, it
makes sense to just copy them over, and if / when this becomes
more mature, we can get rid of the other ones.

llvm-svn: 254022
2015-11-24 21:35:17 +00:00
Zachary Turner a3037bd5f9 Create `lldbsuite.support.fs` and move `find_executable` there.
I have plans to reuse this function in another script, so raising
this out of prepare_bindings allows this.

llvm-svn: 253755
2015-11-21 01:39:04 +00:00
Adrian McCarthy f7d1893f5b Enable saving of mini dumps with lldb process save-core.
Also adds SB API to save a core and tests that use it.

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

llvm-svn: 253734
2015-11-20 23:09:11 +00:00
Adrian McCarthy f9a2697e13 Revert "FOO"
Accidentally commited before I was done.

This reverts commit 2ec2da4ee52780582d5e9c88b2e982a688fbdbe1.

llvm-svn: 253685
2015-11-20 18:18:21 +00:00
Adrian McCarthy af75dab383 FOO
llvm-svn: 253684
2015-11-20 18:15:14 +00:00
Zachary Turner 4c152690be Remove `lldb.root` and just look for the file we care about.
llvm-svn: 253679
2015-11-20 17:40:57 +00:00
Todd Fiala f6508db485 Revert "prepare_bindings.py: enable static bindings"
This reverts commit 40f789f2dc6bb80fd25a33f91e452d081ed9d0ee.

llvm-svn: 253575
2015-11-19 16:56:12 +00:00
Todd Fiala 223f4bb9b2 Remove superseded buildSwigWrapperClasses.py and buildSwigPython.py classes
This closes:
http://reviews.llvm.org/D14783

llvm-svn: 253513
2015-11-18 22:21:47 +00:00
Todd Fiala a52e2c8376 Remove the scripts/Python/build-swig-Python.sh script.
This logically goes with my previous commit.

llvm-svn: 253491
2015-11-18 19:37:51 +00:00
Todd Fiala f6b2aa5882 remove defunct scripts/build-swig-wrapper-classes.sh; switch autoconf build to prepare_bindings.py.
Xcode moved off of build-swig-wrapper-classes.sh earlier this week.

llvm-svn: 253490
2015-11-18 19:34:03 +00:00
Zachary Turner 48ef8d4c37 Fix some issues with swig & string conversion.
This patch fixes two issues:

1) Popen needs to be used with universal_newlines=True by default.
   This elicits automatic decoding from bytes -> string in Py3,
   and has no negative effects in other Py versions.
2) The swig typemaps for converting between string and (char*, int)
   did not work correctly when the length of the string was 0,
   indicating an error.  In this case we would try to construct a
   string from uninitialized data.
3) Ironically, the bug mentioned in #2 led to a test passing on
   Windows that was actually broken, because the test was written
   such that the assertion was never even getting checked, so it
   passed by default.  So we additionally fix this test to also
   fail if the method errors.  By fixing this test it's now broken
   on Windows, so we also xfail it.

llvm-svn: 253487
2015-11-18 18:40:16 +00:00
Todd Fiala 7d1da7e91c Switched cmake build from using buildSwigWrapperClases.py to the cleaned up version.
This change does not introduce static bindings.  It is simply using
the pylinted cleaned up code in prepare_bindings.py.

If this breaks anyting, I'll revert immediately and figure out what
needs to be addressed.  I'm looking to wrap up
the cleanup aspect of the code change (pylinted, removal of code that
implements existing python stdlib code, fixes for Xcode adoption, etc.).

llvm-svn: 253478
2015-11-18 17:36:15 +00:00
Todd Fiala d434a1d3e0 prepare_bindings.py: enable static bindings
Added a new flag, --allow-static-binding.  When specified,
if (and only if) the swig binary cannot be found, then the
LLDBWrapPython.cpp and lldb.py from the
scripts/Python/{static-binding-dir} are copied into the place where
swig would have generated them.

{static-binding-dir} defaults to static-binding, and can be
overridden with the --static-binding-dir command line argument.

The static bindings checked in are from r253424.

llvm-svn: 253448
2015-11-18 08:52:33 +00:00
Todd Fiala 9af81570c7 Added --find-swig option to allow searching for swig in path or other likely locations.
llvm-svn: 253346
2015-11-17 17:13:06 +00:00
Todd Fiala 84c72b6d75 Add Pythonic language binding wrapper generation script.
This is only used by Xcode at the moment.  It replaces the
buildSwigWrapperClasses.py and related per-script-language
scripts.  It also fixes a couple bugs in those w/r/t Xcode
usage:

* the presence of the GCC_PREPROCESSOR_DEFINITIONS env var
  should not be short-circuiting generation of the language
  binding; rather, only if LLDB_DISABLE_PYTHON is present
  within that environment variable.

* some logic around what to do when building in "non-Makefile"
  mode.  I've switched the handling of that to be on a
  "--framework" flag - if specified, we build an OS X-style
  framework; otherwise, we go with non.

Putting this up now only attached to the Xcode build so
others can look at it but not be affected by it yet.
After this, I'll tackle the finalizer, along with trying
it locally on Linux.

llvm-svn: 253317
2015-11-17 07:17:38 +00:00