Commit Graph

14493 Commits

Author SHA1 Message Date
Pavel Labath 3c924653c1 Remove flaky decorator from two tests on linux
The flakyness is no longer reproducible, and the tests seem to be passing reliably now.

llvm-svn: 267392
2016-04-25 10:32:23 +00:00
Enrico Granata 520a422bd8 Add a --element-count option to the expression command
This option evaluates an expression and, if the result is of pointer type, treats it as if it was an array of that many elements and displays such elements

This has a couple subtle points but is mostly as straightforward as it sounds

Add a parray N <expr> alias for this new mode

Also, extend the --object-description mode to do the moral equivalent of the above but display each element in --object-description mode
Add a poarray N <expr> alias for this

llvm-svn: 267372
2016-04-25 00:52:47 +00:00
Ulrich Weigand 7793ba86d1 Fix unwind failures when PC points beyond the end of a function
RegisterContextLLDB::InitializeNonZerothFrame already has code to attempt
to detect and handle the case where the PC points beyond the end of a
function, but there are certain cases where this doesn't work correctly.

In fact, there are *two* different places where this detection is attempted,
and the failure is in fact a result of an unfortunate interaction between
those two separate attempts.

First, the ResolveSymbolContextForAddress routine is called with the
resolve_tail_call_address flag set to true.  This causes the routine
to internally accept a PC pointing beyond the end of a function, and
still resolving the PC to that function symbol.

Second, the InitializeNonZerothFrame routine itself maintains a
"decr_pc_and_recompute_addr_range" flag and, if that turns out to
be true, itself decrements the PC by one and searches again for
a symbol at that new PC value.

Both approaches correctly identify the symbol associated with the PC.
However, the problem is now that later on, we also need to find the
DWARF CFI record associated with the PC.  This is done in the
RegisterContextLLDB::GetFullUnwindPlanForFrame routine, and uses
the "m_current_offset_backed_up_one" member variable.

However, that variable only actually contains the PC "backed up by
one" if the *second* approach above was taken.  If the function was
already identified via the first approach above, that member variable
is *not* backed up by one but simply points to the original PC.
This in turn causes GetEHFrameUnwindPlan to not correctly identify
the DWARF CFI record associated with the PC.

Now, in many cases, if the first method had to back up the PC by one,
we *still* use the second method too, because of this piece of code:

    // Or if we're in the middle of the stack (and not "above" an asynchronous event like sigtramp),
    // and our "current" pc is the start of a function...
    if (m_sym_ctx_valid
        && GetNextFrame()->m_frame_type != eTrapHandlerFrame
        && GetNextFrame()->m_frame_type != eDebuggerFrame
        && addr_range.GetBaseAddress().IsValid()
        && addr_range.GetBaseAddress().GetSection() == m_current_pc.GetSection()
        && addr_range.GetBaseAddress().GetOffset() == m_current_pc.GetOffset())
    {
        decr_pc_and_recompute_addr_range = true;
    }

In many cases, when the PC is one beyond the end of the current function,
it will indeed then be exactly at the start of the next function.  But this
is not always the case, e.g. if there happens to be alignment padding
between the end of one function and the start of the next.

In those cases, we may sucessfully look up the function symbol via
ResolveSymbolContextForAddress, but *not* set decr_pc_and_recompute_addr_range,
and therefore fail to find the correct DWARF CFI record.

A very simple fix for this problem is to just never use the first method.
Call ResolveSymbolContextForAddress with resolve_tail_call_address set
to false, which will cause it to fail if the PC is beyond the end of
the current function; or else, identify the next function if the PC
is also at the start of the next function.  In either case, we will
then set the decr_pc_and_recompute_addr_range variable and back up the
PC anyway, but this time also find the correct DWARF CFI.

A related problem is that the ResolveSymbolContextForAddress sometimes
returns a "symbol" with empty name.  This turns out to be an ELF section
symbol.  Now, usually those get type eSymbolTypeInvalid.  However, there
is code in ObjectFileELF::ParseSymbols that tries to change the type of
invalid symbols to eSymbolTypeCode or eSymbolTypeData if the symbol
lies within the code or data section.

Unfortunately, this check also hits the symbol for the code section
itself, which is then marked as eSymbolTypeCode.  While the size of
the section symbol is 0 according to the ELF file, LLDB considers
this size invalid and attempts to figure out the "correct" size.
Depending on how this goes, we may end up with a symbol that overlays
part of the code section, even outside areas covered by real function
symbols.

Therefore, if we call ResolveSymbolContextForAddress with PC pointing
beyond the end of a function, we may get this bogus section symbol.
This again means InitializeNonZerothFrame thinks we have a valid PC,
but then we don't find any unwind info for it.

The fix for this problem is me to simply always leave ELF section
symbols as type eSymbolTypeInvalid.

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

llvm-svn: 267363
2016-04-24 20:49:56 +00:00
Saleem Abdulrasool d2d1504805 ObjectFile: parse EABI Attributes
This adds basic parsing of the EABI attributes section.  This section contains
additional information about the target for which the file was built.  Attempt
to infer additional architecture information from that section.

llvm-svn: 267291
2016-04-23 16:00:15 +00:00
Greg Clayton cae0855a62 DWARF layout for bitfields is wrong when the bit offset is negative.
Some older versions of clang emitted bit offsets that were negative and these bitfields would have their bitfield-ness stripped off and it would cause a clang assertion in clang assertions were enabled. I updated the bitfield C test to make sure we don't regress.

<rdar://problem/21082998> 

llvm-svn: 267248
2016-04-22 23:14:35 +00:00
Saleem Abdulrasool 6010f97ee6 Source: fix another -Wunused-variable warning
Conditionalise a variable definition which may be unused in certain compilations
due to the preprocessor.  Protect the variable accordingly.  NFC.

llvm-svn: 267247
2016-04-22 23:08:34 +00:00
Greg Clayton f443135b8c Fixed in issue with ObjectFileMachO where it would add empty sections to the section list that was used to try and cap symbols to the max address of the section in which it is contained. The empty sections would make cap the symbols and make their sizes zero. Also fixed a few other things that could cause problems in the SymbolFileDWARFDebugMap when zero sized symbols were found and used to make OSO range map entries.
<rdar://problem/25886773>

llvm-svn: 267237
2016-04-22 22:35:08 +00:00
Greg Clayton b6bd4618eb Fix a build-llvm.py crasher when we can't find cmake. Now it exits with a valid error that explains what went wrong.
llvm-svn: 267235
2016-04-22 22:15:59 +00:00
Kuba Brecka 5b31c423a0 Renumber ThreadSanitizer-provided thread IDs to match LLDB thread numbers.
llvm-svn: 267133
2016-04-22 10:40:14 +00:00
Pavel Labath 69ef42cc42 Update comment in lldb-enumerations.h
llvm-svn: 267124
2016-04-22 08:41:07 +00:00
Ryan Brown 5852c5a12f Update Go OS Plugin for newer runtimes.
Differential Revision: http://reviews.llvm.org/D19273

llvm-svn: 267048
2016-04-21 20:57:28 +00:00
Saleem Abdulrasool 358efd6557 API: fix a -Wunused-variable warning
expr_log is only conditionally used via preprocessing.  Ensure that we guard the
definition accordingly.  NFC.

llvm-svn: 267001
2016-04-21 16:56:02 +00:00
Saleem Abdulrasool 25b75a2f7d Host: fix some -Wformat-pedantic warnings
Add explicit casts for function pointer to void * for %p conversion.  NFC.

llvm-svn: 267000
2016-04-21 16:55:58 +00:00
Jim Ingham 0d6a90dfc3 Expressions can run without a process.
Code was added in ClangExpressionParser::ClangExpressionParser that was calling through
the process w/o checking that it was good.  Also, we were pretending that we could do something
reasonable if we had no target, but that's actually not true, so I check for a target at the
beginning of the constructor and don't make a compiler in that case.

<rdar://problem/25841198>

llvm-svn: 266944
2016-04-21 01:46:11 +00:00
Kate Stone 0761202612 Corrected wording of REPL not available messaging (contained a repeated word and lacked clarity.)
llvm-svn: 266941
2016-04-21 00:56:08 +00:00
Kate Stone 25d6072adc Added command prefix to new help messages to ensure that they're correctly words in REPL mode.
llvm-svn: 266940
2016-04-21 00:55:20 +00:00
Kate Stone 7cc41e02c1 Removed extraneous print() in decorator for enabling module debugging
llvm-svn: 266924
2016-04-20 21:59:43 +00:00
Greg Clayton 0257603c2d When making an array or stuct/union/class elements, make sure the type is complete. If the type isn't complete, complete the type so that clang won't assert and kill your program. Since the DWARF assists in doing layout, it won't show the array or struct/unions/class elements correctly, but it will stop you from crashing if you have a struct/union/class that contains one of these arrays.
<rdar://problem/25057391>

llvm-svn: 266922
2016-04-20 21:47:56 +00:00
Todd Fiala a8c37c8fa1 update Jenkins Xcode buildbot target for r266885
llvm-svn: 266917
2016-04-20 20:54:59 +00:00
Enrico Granata 612917c784 Fix a bug where LLDB would crash if 'apropos <anything>' was used after spawning an inferior process
llvm-svn: 266911
2016-04-20 20:48:05 +00:00
Zachary Turner b987df4b17 Add missing file needed for PDB unittests.
llvm-svn: 266886
2016-04-20 16:41:02 +00:00
Todd Fiala 49d3c15c3e test infra: move test event-related handling into its own package
This change moves all the test event handling and its related
ResultsFormatter classes out of the packages/Python/lldbsuite/test dir
into a packages/Python/lldbsuite/test_event package. Formatters are
moved into a sub-package under that.

I am limiting the scope of this change to just the motion and a few
minor issues caught by a static Python checker (e.g. removing unused
import statements).

This is a pre-step for adding package-level tests to the test event
system. I also intend to simplify test event results formatter selection
after I make sure this doesn't break anybody.

See:
http://reviews.llvm.org/D19288

Reviewed by:
Pavel Labath

llvm-svn: 266885
2016-04-20 16:27:27 +00:00
Tamas Berghammer 1a8b821099 Fix xfail for test_tilde_home_directory on windows
llvm-svn: 266867
2016-04-20 09:54:47 +00:00
Greg Clayton f258bf9017 llvm::sys::path::home_directory() relies on having "HOME" set in the environment and that might not always be set. Our FileSpec class uses this function to resolve any paths that start with "~/" on systems that support home directories as '~'. I have modified FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) to deal with the cases where llvm::sys::path::home_directory() returns false by digging a little further on unix systems and setting "HOME" in the environment so that subsequent calls to llvm::sys::path::home_directory() will succeed.
I also added a test to ensure we don't regress.

<rdar://problem/25342377> 

llvm-svn: 266832
2016-04-19 23:04:35 +00:00
Kate Stone 317871d793 Eliminate circular dependency introduced between lldbtest.py and decorators.py
llvm-svn: 266815
2016-04-19 20:45:47 +00:00
Kate Stone 8410ddd8b6 Adds a test to detect when clang omits specialized generic types from debug information when using precompiled headers and -gmodules.
llvm-svn: 266791
2016-04-19 18:20:11 +00:00
Pavel Labath 6145366510 Revert "LLDB: Fixed two race conditions when stopping private state thread"
This reverts commit r266733 as it causes a number of failures on linux buildbots.

llvm-svn: 266736
2016-04-19 14:03:43 +00:00
Marianne Mailhot-Sarrasin 0c6d7c0a2c LLDB: Fixed two race conditions when stopping private state thread
When stopping the private state thread, there was a race condition between the time the thread exits (resetting the HostThread object) and the time a Join was attempted, especially in the case of a timeout.

The previous workaround of copying the HostThread object is not enough, since on a Reset the internal thread stuff gets nulled out regardless of which HostThread object actually has Reset called on it, resulting in an attempt to dereference a null pointer on the subsequent call to Join from the copy as well.

Additionally, there was a race between the detach (called when stopping the process) and the stop itself, causing the stop to time out because it was waiting for the private state thread to see the stop state, but it had exited immediately after entering the detached state.

Patch by cameron314

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

llvm-svn: 266733
2016-04-19 13:21:46 +00:00
Pavel Labath 79b25d5ea4 Fix typo in TestSourceManager.py
llvm-svn: 266725
2016-04-19 09:31:14 +00:00
Todd Fiala ca5793ea5c test infra cleanup: convert test_runner lib into package
Also does the following:
* adopts PEP8 naming convention for OptionalWith class (now
  optional_with).
* moves test_runner/lldb_utils.py to lldbsuite/support/optional_with.py.
* packages tests in a subpackage of test_runner per recommendations in
  http://the-hitchhikers-guide-to-packaging.readthedocs.org/en/latest/creation.html

Tests can be run from within pacakges/Python/lldbsuite/test via this
command:

  python -m unittest discover test_runner

The primary cleanup this allows is avoiding the need to muck with the
PYTHONPATH variable from within the source files.  This also aids some
of the static code checkers as they don't need to run code to determine
the proper python path.

llvm-svn: 266710
2016-04-19 04:20:35 +00:00
Chaoren Lin 167c796232 Fix Windows build.
llvm-svn: 266702
2016-04-19 01:09:37 +00:00
Todd Fiala dad52cee4b ensure lldbinline remembers .py extension
This ensure lldbinline.test_file paths are tracked as .py
files rather than .pyc files.

Also, this change adds an assert to the test infrastructure
if a filename that is not ending in .py is attempted to be
added to the test events infrastructure where we track test
results.

See:
http://reviews.llvm.org/D19215

Earlier revision reviewed by:
Pavel Labath

llvm-svn: 266664
2016-04-18 20:26:56 +00:00
Todd Fiala 430309f13a fix a race is the LLDB test suite results collection
The race boiled down to this:

If a test worker queue is able to run the test inferior and
clean up before the dosep.py listener socket is spun up, and
the worker queue is the last one (as would be the case when
there's only one test rerunning in the rerun queue), then
the test suite will exit the main loop before having a chance
to process any test events coming from the test inferior or
the worker queue job control.

I found this race to be far more likely on fast hardware.
Our Linux CI is one such example.  While it will show
up primarily during meta test events generated by
a worker thread when a test inferior times out or
exits with an exceptional exit (e.g. seg fault), it only
requires that the OS takes longer to hook up the
listener socket than it takes for the final test inferior
and worker thread to shut down.

See:
http://reviews.llvm.org/D19214

reviewed by:
Pavel Labath

llvm-svn: 266624
2016-04-18 16:09:21 +00:00
Pavel Labath 7eafdced6e Attempt to fix darwin build after header refactor in llvm (r266595)
llvm-svn: 266605
2016-04-18 12:18:35 +00:00
Pavel Labath 8222151a7e Fixup r266327
Fix XFAILed tests in TestThreadStates for the new signature of wait_for_running_event.

llvm-svn: 266598
2016-04-18 11:01:41 +00:00
Mohit K. Bhakkad 76a7ca0f67 [LLDB][MIPS] Fix TestConcurrentEvents
Patch by Nitesh Jain

Reviewers: clayborg
Subscribers: jaydeep, bhushan, mohit.bhakkad, sagar
Differential Revision: http://reviews.llvm.org/D18389

llvm-svn: 266589
2016-04-18 05:27:42 +00:00
Oleksiy Vyalov 37a09e72bc Fix cmake build after r266524.
llvm-svn: 266530
2016-04-16 16:29:17 +00:00
Alex Denisov 4e0cc9e0fd Replace hardcoded comment at 'lit.site.cfg.in'
At the moment almost every lit.site.cfg.in contains two lines comment:

  ## Autogenerated by LLVM/Clang configuration.
  # Do not edit!

The patch adds variable LIT_SITE_CFG_IN_HEADER, that is replaced from
configure_lit_site_cfg with the note and some useful information.

llvm-svn: 266522
2016-04-16 07:14:05 +00:00
Pavel Labath 7ef36b5c15 Work around a linux libc bug causing a crash in TaskPool
Summary:
Doing a pthread_detach while the thread is exiting can cause crashes or other mischief, so we
make sure the thread stays around long enough. The performance impact of the added
synchronization should be minimal, as the parent thread is already holding a mutex, so I am just
making sure it holds it for a little while longer. It's possible the new thread will block on
this mutex immediately after startup, but it should be unblocked really quickly and some
blocking is unavoidable if we actually want to have this synchronization.

Reviewers: tberghammer

Subscribers: lldb-commits

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

llvm-svn: 266423
2016-04-15 10:49:07 +00:00
Ulrich Weigand 9521ad2a49 Fix usage of APInt.getRawData for big-endian systems
Recommit modified version of r266311 including build bot regression fix.

This differs from the original r266311 by:

- Fixing Scalar::Promote to correctly zero- or sign-extend value depending
  on signedness of the *source* type, not the target type.

- Omitting a few stand-alone fixes that were already committed separately.

llvm-svn: 266422
2016-04-15 09:55:52 +00:00
Ulrich Weigand 9a0fdfe009 Make Scalar::SChar return an explicit signed type
This is needed for platforms where the default "char" type is unsigned.

Originally committed as part of (now reverted) r266311.

llvm-svn: 266420
2016-04-15 09:15:47 +00:00
Ulrich Weigand fb7207ef89 Fix Scalar::MakeSigned for 128- and 256-bit types.
Obvious fix for incorrect result types of the operation.

Originally committed as part of (now reverted) r266311.

llvm-svn: 266419
2016-04-15 09:15:22 +00:00
Ulrich Weigand d8d2c5c81c Fix Scalar::SetValueFromData for 128- and 256-bit types
Obvious fix for incorrect use of GetU64 offset pointer.

Originally committed as part of (now reverted) r266311.

llvm-svn: 266418
2016-04-15 09:14:59 +00:00
Ulrich Weigand 2b6c791930 Fix ABISysV_s390x::GetArgumentValues
This routine contained a stray "return false;" making part of the code
never executed.  Also, the stack offset where to find on-stack arguments
was incorrect.

llvm-svn: 266417
2016-04-15 09:14:32 +00:00
Pavel Labath 5c17454cd6 Make destructor breakpoint location test more resilient
Summary:
The original breakpoint location test was failing for linux, because the compilers here tend to
merge the full-object and subobject destructors even at -O0 (as a result, we are getting only 2
breakpoint locations, and not 4 as the test expected. The fixup in r266164 substantially weakened
the test, as it now did not check whether both kinds of destructors were being found.

Because of these contraints, I have altered the logic of the test. It sets the
breakpoint by name, and then independently verifies that the breakpoint is set on the correct
demangled symbol name (which is not very meaningful since both kinds of destructors demangle to
the same name) *and* the correct symbol address (which is obtained by looking up the mangled
symbol name).

Reviewers: clayborg

Subscribers: ovyalov, zturner, lldb-commits

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

llvm-svn: 266416
2016-04-15 09:11:22 +00:00
Jim Ingham 4cd7c3b7d5 Add the PDBParser.{cpp,h} files to the Xcode project.
llvm-svn: 266407
2016-04-15 01:42:30 +00:00
Oleksiy Vyalov 987c8788d4 Rename out->std_out in AppleObjCRuntimeV2.cpp.
llvm-svn: 266401
2016-04-15 00:56:11 +00:00
Sean Callanan 91de55f161 Blocks are only reliably supported on Darwin. Disable the test otherwise.
llvm-svn: 266400
2016-04-15 00:44:59 +00:00
Sean Callanan 812e559589 Added a testcase for defining and using lambdas in the expression parser.
<rdar://problem/25739133>

llvm-svn: 266397
2016-04-15 00:26:32 +00:00
Zachary Turner 42dff79068 Initial support for reading type information from PDBs.
This implements a PDBASTParser and corresponding logic in
SymbolFilePDB to do type lookup by name.  This is just a first
pass and leaves many aspects of type lookup unimplemented, and
just focuses on laying the framework.  With this patch, you should
be able to lookup basic types by name from a PDB.

Full class definitions are not completed yet, we will instead
just return a forward declaration of the class.

Differential Revision: http://reviews.llvm.org/D18848
Reviewed by: Greg Clayton

llvm-svn: 266392
2016-04-15 00:21:26 +00:00
Sean Callanan 5d7ddfda2d Added a testcase for defining and using a block in the expression parser.
<rdar://problem/25738696>

llvm-svn: 266389
2016-04-15 00:05:50 +00:00
Adrian McCarthy f6034c4f3d Don't disable stdin buffering on Windows
Disabling buffering exposes a bug in the MS VS 2015 CRT implementation of fgets, where you sometimes have to hit Enter twice, depending on if the input had an odd or even number of characters.

This was hidden until a few days ago by the Python initialization which was re-enabling buffering on the streams. A few days ago, Enrico make the Python initialization on-demand, which exposed this problem.

llvm-svn: 266384
2016-04-14 23:31:17 +00:00
Greg Clayton dfa63248c7 Fix Xcode project after recent s390x changes.
llvm-svn: 266361
2016-04-14 20:05:21 +00:00
Ulrich Weigand acc50e0a99 Fix regression in gnu_libstdcpp.py introduced by r266313
CreateChildAtOffset needs a byte offset, not an element number.

llvm-svn: 266352
2016-04-14 18:31:12 +00:00
Ulrich Weigand 4f42310dfb Disable LinuxCoreTestCase.test_s390x
This seems to hang on non-s390x hosts.  Disable for now to get the build
bots going again.

llvm-svn: 266343
2016-04-14 17:36:41 +00:00
Ulrich Weigand da70c17bfc Revert r266311 - Fix usage of APInt.getRawData for big-endian systems
Try to get 32-bit build bots running again.

llvm-svn: 266341
2016-04-14 17:22:18 +00:00
Pavel Labath 7e49e3d97c [test] make expect_state_changes actually expect *only* them
The android dirty stderr problem has uncovered an issue where lldbutil.expect_state_changes was
reading events other than state change events, which resulted in general confusion. Make it more
strict to accept *only* state changes.

llvm-svn: 266327
2016-04-14 15:52:58 +00:00
Pavel Labath e6961d0306 [test] Relax stderr expectations on targets with chatty output
Summary:
On some android targets, a binary can produce additional garbage (e.g. warning messages from the
dynamic linker) on the standard error, which confuses some tests. This relaxes the stderr
expectations for targets known for their chattyness.

Reviewers: tfiala, ovyalov

Subscribers: tberghammer, danalbert, srhines, lldb-commits

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

llvm-svn: 266326
2016-04-14 15:52:53 +00:00
Ulrich Weigand bd5262629d Find .plt section in object files generated by recent ld
Code in ObjectFileELF::ParseTrampolineSymbols assumes that the sh_info
field of the .rel(a).plt section identifies the .plt section.

However, with recent GNU ld this is no longer true.  As a result of this:
https://sourceware.org/bugzilla/show_bug.cgi?id=18169
in object files generated with current linkers the sh_info field of
.rel(a).plt now points to the .got.plt section (or .got on some targets).

This causes LLDB to fail to identify any PLT stubs, causing a number of
test case failures.

This patch changes LLDB to simply always look for the .plt section by
name.  This should be safe across all linkers and targets.

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

llvm-svn: 266316
2016-04-14 14:36:29 +00:00
Ulrich Weigand 7e8de59b90 Fix test cases for big-endian systems
A number of test cases were failing on big-endian systems simply due to
byte order assumptions in the tests themselves, and no underlying bug
in LLDB.

These two test cases:
  tools/lldb-server/lldbgdbserverutils.py
  python_api/process/TestProcessAPI.py
actually check for big-endian target byte order, but contain Python errors
in the corresponding code paths.

These test cases:
  functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
  functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
  functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
  lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py
  python_api/sbdata/TestSBData.py  (first change)
could be fixed to check for big-endian target byte order and update the
expected result strings accordingly.  For the two synthetic tests, I've
also updated the source to make sure the fake_a value is always nonzero
on both big- and little-endian platforms.

These test case:
  python_api/sbdata/TestSBData.py  (second change)
  functionalities/memory/cache/TestMemoryCache.py
simply accessed memory with the wrong size, which wasn't noticed on LE
but fails on BE.

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

llvm-svn: 266315
2016-04-14 14:35:02 +00:00
Ulrich Weigand 91a2ad182d Fix ARM instruction emulation tests on big-endian systems
Running the ARM instruction emulation test on a big-endian system
would fail, since the code doesn't respect endianness properly.

In EmulateInstructionARM::TestEmulation, code assumes that an
instruction opcode read in from the test file is in target byte
order, but it was in fact read in in host byte order.

More difficult to fix, the EmulationStateARM structure models
the overlapping sregs and dregs by a union in _sd_regs.  This
only works correctly if the host is a little-endian system.
I've removed the union in favor of a simple array containing
the 32 sregs, and changed any code accessing dregs to explicitly
use the correct two sregs overlaying that dreg in the proper
target order.

Also, the EmulationStateARM::ReadPseudoMemory and WritePseudoMemory
track memory as a map of uint32_t values in host byte order, and
implement 64-bit memory accessing by splitting them up into two
uint32_t ones.  However, callers expect memory contents to be
provided in the form of a byte array (in target byte order).
This means the uint32_t contents need to be byte-swapped on
BE systems, and when splitting up a 64-bit access into two 32-bit
ones, byte order has to be respected.

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

llvm-svn: 266314
2016-04-14 14:34:19 +00:00
Ulrich Weigand 0501eebda6 Miscellaneous fixes for big-endian systems
This patch fixes a bunch of issues that show up on big-endian systems:

- The gnu_libstdcpp.py script doesn't follow the way libstdc++ encodes
  bit vectors: it should identify the enclosing *word* and then access
  the appropriate bit within that word.  Instead, the script simply
  operates on bytes.  This gives the same result on little-endian
  systems, but not on big-endian.

- lldb_private::formatters::WCharSummaryProvider always assumes wchar_t
  is UTF16, even though it could also be UTF8 or UTF32.  This is mostly
  not an issue on little-endian systems, but immediately fails on BE.
  Fixed by checking the size of wchar_t like WCharStringSummaryProvider
  already does.

- ClangASTContext::GetChildCompilerTypeAtIndex uses uint32_t to access
  the virtual base offset stored in the vtable, even though the size
  of this field matches the target pointer size according to the C++
  ABI.  Again, this is mostly not visible on LE, but fails on BE.

- Process::ReadStringFromMemory uses strncmp to search for a terminator
  consisting of multiple zero bytes.  This doesn't work since strncmp
  will stop already at the first zero byte.  Use memcmp instead.

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

llvm-svn: 266313
2016-04-14 14:33:47 +00:00
Ulrich Weigand 461bd680c3 Handle bit fields on big-endian systems correctly
Currently, the DataExtractor::GetMaxU64Bitfield and GetMaxS64Bitfield
routines assume the incoming "bitfield_bit_offset" parameter uses
little-endian bit numbering, i.e. a bitfield_bit_offset 0 refers to
a bitfield whose least-significant bit coincides with the least-
significant bit of the surrounding integer.

On many big-endian systems, however, the big-endian bit numbering
is used for bit fields.  Here, a bitfield_bit_offset 0 refers to
a bitfield whose most-significant bit conincides with the most-
significant bit of the surrounding integer.

Now, in principle LLDB could arbitrarily choose which semantics of
bitfield_bit_offset to use.  However, there are two problems with
the current approach:

- When parsing DWARF, LLDB decodes bit offsets in little-endian
  bit numbering on LE systems, but in big-endian bit numbering
  on BE systems.  Passing those offsets later on into the
  DataExtractor routines gives incorrect results on BE.

- In the interim, LLDB's type layer combines byte and bit offsets
  into a single number.  I.e. instead of recording bitfields by
  specifying the byte offset and byte size of the surrounding
  integer *plus* the bit offset of the bit field within that field,
  it simply records a single bit offset number.

  Now, note that converting from byte offset + bit offset to a
  single offset value and back is well-defined if we either use
  little-endian byte order *and* little-endian bit numbering,
  or use big-endian byte order *and* big-endian bit numbering.
  Any other combination will yield incorrect results.

Therefore, the simplest approach would seem to be to always use
the bit numbering that matches the system byte order.  This makes
storing a single bit offset valid, and makes the existing DWARF
code correct.  The only place to fix is to teach DataExtractor
to use big-endian bit numbering on big endian systems.

However, there is only additional caveat: we also get bit offsets
from LLDB synthetic bitfields.  While the exact semantics of those
doesn't seem to be well-defined, from test cases it appears that
the intent was for the user-provided synthetic bitfield offset to
always use little-endian bit numbering.  Therefore, on a big-endian
system we now have to convert those to big-endian bit numbering
to remain consistent.

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

llvm-svn: 266312
2016-04-14 14:32:57 +00:00
Ulrich Weigand ca07434234 Fix usage of APInt.getRawData for big-endian systems
The Scalar implementation and a few other places in LLDB directly
access the internal implementation of APInt values using the
getRawData method.  Unfortunately, pretty much all of these places
do not handle big-endian systems correctly.  While on little-endian
machines, the pointer returned by getRawData can simply be used as
a pointer to the integer value in its natural format, no matter
what size, this is not true on big-endian systems: getRawData
actually points to an array of type uint64_t, with the first element
of the array always containing the least-significant word of the
integer.  This means that if the bitsize of that integer is smaller
than 64, we need to add an offset to the pointer returned by
getRawData in order to access the value in its natural type, and
if the bitsize is *larger* than 64, we actually have to swap the
constituent words before we can access the value in its natural type.

This patch fixes every incorrect use of getRawData in the code base.
For the most part, this is done by simply removing uses of getRawData
in the first place, and using other APInt member functions to operate
on the integer data.

This can be done in many member functions of Scalar itself, as well
as in Symbol/Type.h and in IRInterpreter::Interpret.  For the latter,
I've had to add a Scalar::MakeUnsigned routine to parallel the existing
Scalar::MakeSigned, e.g. in order to implement an unsigned divide.

The Scalar::RawUInt, Scalar::RawULong, and Scalar::RawULongLong
were already unused and can be simply removed.  I've also removed
the Scalar::GetRawBits64 function and its few users.

The one remaining user of getRawData in Scalar.cpp is GetBytes.
I've implemented all the cases described above to correctly
implement access to the underlying integer data on big-endian
systems.  GetData now simply calls GetBytes instead of reimplementing
its contents.

Finally, two places in the clang interface code were also accessing
APInt.getRawData in order to actually construct a byte representation
of an integer.  I've changed those to make use of a Scalar instead,
to avoid having to re-implement the logic there.

The patch also adds a couple of unit tests verifying correct operation
of the GetBytes routine as well as the conversion routines.  Those tests
actually exposed more problems in the Scalar code: the SetValueFromData
routine didn't work correctly for 128- and 256-bit data types, and the
SChar routine should have an explicit "signed char" return type to work
correctly on platforms where char defaults to unsigned.

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

llvm-svn: 266311
2016-04-14 14:32:01 +00:00
Ulrich Weigand b00ef10b70 Make Scalar::GetBytes and RegisterValue::GetBytes const
Scalar::GetBytes provides a non-const access to the underlying bytes
of the scalar value, supposedly allowing for modification of those
bytes.  However, even with the current implementation, this is not
really possible.  For floating-point scalars, the pointer returned
by GetBytes refers to a temporary copy; modifications to that copy
will be simply ignored.  For integer scalars, the pointer refers
to internal memory of the APInt implementation, which isn't
supposed to be directly modifyable; GetBytes simply casts aways
the const-ness of the pointer ...

With my upcoming patch to fix Scalar::GetBytes for big-endian
systems, this problem is going to get worse, since there we need
temporary copies even for some integer scalars.  Therefore, this
patch makes Scalar::GetBytes const, fixing all those problems.

As a follow-on change, RegisterValues::GetBytes must be made const
as well.  This in turn means that the way of initializing a
RegisterValue by doing a SetType followed by writing to GetBytes
no longer works.  Instead, I've changed SetValueFromData to do
the equivalent of SetType itself, and then re-implemented
SetFromMemoryData to work on top of SetValueFromData. 

There is still a need for RegisterValue::SetType, since some
platform-specific code uses it to reinterpret the contents of
an already filled RegisterValue.  To make this usage work in
all cases (even changing from a type implemented via Scalar
to a type implemented as a byte buffer), SetType now simply
copies the old contents out, and then reloads the RegisterValue
from this data using the new type via SetValueFromData.

This in turn means that there is no remaining caller of
Scalar::SetType, so it can be removed.

The only other follow-on change was in MIPS EmulateInstruction
code, where some uses of RegisterValue::GetBytes could be made
const trivially.

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

llvm-svn: 266310
2016-04-14 14:31:08 +00:00
Ulrich Weigand 377e4213e1 Fixes for platforms that default to unsigned char
This fixes several test case failure on s390x caused by the fact that
on this platform, the default "char" type is unsigned.

- In ClangASTContext::GetBuiltinTypeForEncodingAndBitSize we should return
  an explicit *signed* char type for encoding eEncodingSint and bit size 8,
  instead of the default platform char type (which may be unsigned).
  This fix matches existing code in ClangASTContext::GetIntTypeFromBitSize,
  and fixes the TestClangASTContext.TestBuiltinTypeForEncodingAndBitSize
  unit test case.

- The test/expression_command/char/TestExprsChar.py test case is known to
  fail on platforms defaulting to unsigned char (pr23069), and just needs
  to be xfailed on s390x like on arm.

- The test/functionalities/watchpoint/watchpoint_on_vectors/main.c test
  case defines a vector of "char" and implicitly assumes to be signed.
  Use an explicit "signed char" instead.

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

llvm-svn: 266309
2016-04-14 14:30:12 +00:00
Ulrich Weigand bb00d0b6b2 Support Linux on SystemZ as platform
This patch adds support for Linux on SystemZ:
- A new ArchSpec value of eCore_s390x_generic
- A new directory Plugins/ABI/SysV-s390x providing an ABI implementation
- Register context support
- Native Linux support including watchpoint support
- ELF core file support
- Misc. support throughout the code base (e.g. breakpoint opcodes)
- Test case updates to support the platform

This should provide complete support for debugging the SystemZ platform.
Not yet supported are optional features like transaction support (zEC12)
or SIMD vector support (z13).

There is no instruction emulation, since our ABI requires that all code
provide correct DWARF CFI at all PC locations in .eh_frame to support
unwinding (i.e. -fasynchronous-unwind-tables is on by default).

The implementation follows existing platforms in a mostly straightforward
manner.  A couple of things that are different:

- We do not use PTRACE_PEEKUSER / PTRACE_POKEUSER to access single registers,
  since some registers (access register) reside at offsets in the user area
  that are multiples of 4, but the PTRACE_PEEKUSER interface only allows
  accessing aligned 8-byte blocks in the user area.  Instead, we use a s390
  specific ptrace interface PTRACE_PEEKUSR_AREA / PTRACE_POKEUSR_AREA that
  allows accessing a whole block of the user area in one go, so in effect
  allowing to treat parts of the user area as register sets.

- SystemZ hardware does not provide any means to implement read watchpoints,
  only write watchpoints.  In fact, we can only support a *single* write
  watchpoint (but this can span a range of arbitrary size).  In LLDB this
  means we support only a single watchpoint.  I've set all test cases that
  require read watchpoints (or multiple watchpoints) to expected failure
  on the platform.  [ Note that there were two test cases that install
  a read/write watchpoint even though they nowhere rely on the "read"
  property.  I've changed those to simply use plain write watchpoints. ]

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

llvm-svn: 266308
2016-04-14 14:28:34 +00:00
Ulrich Weigand 7311bb34f6 Add new ABI callback to provide fallback unwind register locations
If the UnwindPlan did not identify how to unwind the stack pointer
register, LLDB currently assumes it can determine to caller's SP
from the current frame's CFA.  This is true on most platforms
where CFA is by definition equal to the incoming SP at function
entry.

However, on the s390x target, we instead define the CFA to equal
the incoming SP plus an offset of 160 bytes.  This is because
our ABI defines that the caller has to provide a register save
area of size 160 bytes.  This area is allocated by the caller,
but is considered part of the callee's stack frame, and therefore
the CFA is defined as pointing to the top of this area.

In order to make this work on s390x, this patch introduces a new
ABI callback GetFallbackRegisterLocation that provides platform-
specific fallback register locations for unwinding.  The existing
code to handle SP unwinding as well as volatile registers is moved
into the default implementation of that ABI callback, to allow
targets where that implementation is incorrect to override it.

This patch in itself is a no-op for all existing platforms.
But it is a pre-requisite for adding s390x support.

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

llvm-svn: 266307
2016-04-14 14:25:20 +00:00
Pavel Labath a212c58db0 FileSpec: make matching separator-agnostic again
Summary:
In D18689, I removed the call to Normalize() in FileSpec::SetFile, because it no longer seemed
needed, and it resolved a quirk in the FileSpec API (spec.GetCString() returnes a path with
backslashes, but spec.GetDirectory().GetCString() has forward slashes). This turned out to be a
problem because we would consider paths with different separators as different (which led to
unresolved breakpoints for instance).

Here, I am putting back in the call to Normalize() and adding a unittest for FileSpec::Equal. I
am commenting out the GetDirectory unittests until we figure out the what is the expected
behaviour here.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 266286
2016-04-14 09:38:06 +00:00
Oleksiy Vyalov 2f5f100e72 Fix Android build after r266267
llvm-svn: 266274
2016-04-14 02:02:12 +00:00
Enrico Granata efcac211e5 Don't use auto - (try to) appease the Android g++ bot
llvm-svn: 266271
2016-04-14 01:23:01 +00:00
Enrico Granata 39c9fb7360 Augment the 'language objc class-table dump' command to take a "-v" option, which makes it print ivar and method information, as well as an optional regex argument which filters out all class names that don't match the regex
llvm-svn: 266267
2016-04-14 00:43:20 +00:00
Ed Maste 11c0b227f5 Match types in for loop to fix signedness comparison warning
llvm-svn: 266197
2016-04-13 13:32:06 +00:00
Pavel Labath b0743fb2e9 Remove obsolete comments
llvm-svn: 266196
2016-04-13 13:26:45 +00:00
Pavel Labath 9fb77fcfef Fix test rerun logic
result_formatter used inspect.getfile() to get the python file name, which returned "*.pyc" if
the bytecode file was present. This resulted in files being displayed with the wrong extension,
and more critically, would confuse the rerun logic because it would try to rerun the pyc file
(which resulted in an empty rerun list as unittest refused to run those).

Fix: use inspect.getsourcefile() instead.

I am not sure why does was not an issue before. I can only assume that some system update
tricked python into producing bytecode files more aggressively.

llvm-svn: 266192
2016-04-13 12:05:48 +00:00
Jason Molenda 17423dd422 Update Symtab::InitAddressIndexes so that computed symbol sizes
will not exceed the bounds of their Section.  This is addressing a
problem where a file had a large space between two sections that
were not used by this module - the last symbol in the text section
had an enormous size because the distance between that and the first
symbol in the data section were used to compute the size.

http://reviews.llvm.org/D19004
<rdar://problem/25227945> 

llvm-svn: 266165
2016-04-13 04:32:49 +00:00
Oleksiy Vyalov 939b084bd7 Attempt to fix TestCPPBreakpointLocations on Linux/Android.
llvm-svn: 266164
2016-04-13 04:21:05 +00:00
Adrian McCarthy 0a385532dd Fix breakpoint_set_restart test for Windows
When run with the multiprocess test runner, the getchar() trick doesn't work, so ninja check-lldb would fail on this test, but running the test directly worked fine.

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

llvm-svn: 266145
2016-04-12 22:45:03 +00:00
Greg Clayton 08f5674bfe Fixed being able to set breakpoints on destructors when we don't fully specify the demangled name. So all of the following now work:
(lldb) b ~Foo
(lldb) b Foo::~Foo
(lldb) b Bar::Foo::~Foo

Improved out C++ breakpoint locations tests as well to cover this issue.

<rdar://problem/25577252>

llvm-svn: 266139
2016-04-12 22:02:37 +00:00
Enrico Granata ade56c3ea0 Use the FormatEntity work for great good - parse summary strings before accepting them, and fail to add any strings that fail parsing
llvm-svn: 266138
2016-04-12 21:57:11 +00:00
Enrico Granata d09ae3bfc5 Cleanup the arguments for 'memory find' such that the help system reflects the real way to invoke it
llvm-svn: 266129
2016-04-12 21:26:48 +00:00
Greg Clayton 9f64fe9c14 Revert to using libdispatch to reap threads on MacOSX. Code was accidentally checked in that is now reverted.
<rdar://problem/25643874>

llvm-svn: 266118
2016-04-12 20:26:41 +00:00
Enrico Granata 15d1b4e2aa Initialize the Python script interpreter lazily (i.e. not at debugger startup)
This time it should also pass the gtests

llvm-svn: 266103
2016-04-12 18:23:18 +00:00
Jim Ingham ff7ac6a7b9 Breakpoint conditions were making result variables, which they should not do.
The result variables aren't useful, and if you have a breakpoint on a
common function you can generate a lot of these.  So I changed the
code that checks the condition to set ResultVariableIsInternal in the
EvaluateExpressionOptions that we pass to the execution.
Unfortunately, the check for this variable was done in the wrong place
(the static UserExpression::Evaluate) which is not how breakpoint
conditions execute expressions (UserExpression::Execute).  So I moved
the check to UserExpression::Execute (which Evaluate also calls) and made the
overridden method DoExecute.

llvm-svn: 266093
2016-04-12 17:17:35 +00:00
Jim Ingham 5e2b489049 'int' is reported as an exception on OS X not as a signal. I don't think
this test ever succeeded on OS X.

llvm-svn: 266092
2016-04-12 17:04:12 +00:00
Pavel Labath 541dff5acd Fixup TestFdLeak
this test was unintentionally XFAILed due to a change in the behavior of the expectedFailure
decorator. Fix that. Also, mark the test as debug-info independent while I'm in there.

llvm-svn: 266072
2016-04-12 13:55:54 +00:00
Pavel Labath ec26f3bdf3 Bump up timeout in TestGdbRemoteProcessInfo
the process info packet is slow, and sometimes it does not arrive on time when run on the android
emulator.

llvm-svn: 266058
2016-04-12 11:59:41 +00:00
Pavel Labath bc79e8923a Skip a test in TestNamespaceLookup on linux to avoid a crash
llvm-svn: 266054
2016-04-12 10:06:37 +00:00
Pavel Labath ba45680758 Revert "Restore the lazy initialization of ScriptInterpreterPython, which was lost as part of the SystemLifetimeManager work"
This change breaks python unit tests.

This reverts commit 266033.

llvm-svn: 266050
2016-04-12 09:06:08 +00:00
Saleem Abdulrasool dd4799c28e Process: fix the build with certain kernel versions
The structure definitions are not provided, but we perform a sizeof operation of
them which causes a build failure.  Include `asm/ptrace.h` to get the structure
definitions.

llvm-svn: 266042
2016-04-12 05:40:51 +00:00
Enrico Granata b184bfa13b Restore the lazy initialization of ScriptInterpreterPython, which was lost as part of the SystemLifetimeManager work
llvm-svn: 266033
2016-04-12 01:08:35 +00:00
Greg Clayton a15942ff05 Fixed Variable::GetDecl() and Variable::GetDeclContext() to check the "Type *" before using it so we don't crash if a variable's type can't be realized which happens more often recently due to -gmodules.
<rdar://problem/25612626>

llvm-svn: 266023
2016-04-12 00:06:27 +00:00
Enrico Granata ea0ef6b19d Add support for resolving dynamic types of extended ObjC tagged pointers
rdar://problem/24401051

llvm-svn: 266001
2016-04-11 21:50:35 +00:00
Enrico Granata c28b3e8883 Add support for additional NSArray formatters
llvm-svn: 265979
2016-04-11 18:46:37 +00:00
Enrico Granata f22325c7aa Add a formatter for zero-sized NSData
llvm-svn: 265978
2016-04-11 18:46:26 +00:00
Pavel Labath d6201b83ac Mark TestPrintStackTraces as flaky on android arm
llvm-svn: 265959
2016-04-11 16:50:08 +00:00
Pavel Labath bb5c39d79e [Driver] Fix a segfault in signal handlers
Summary:
If we recieve a SIGCONT or SIGTSTP, while the driver is shutting down (which, sometimes, we do,
for reasons which are not completely clear to me), we would crash to due a null pointer
dereference. Guard against this situation.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 265958
2016-04-11 16:40:09 +00:00
Adrian McCarthy 121571b7ce Retry deletion of temporary files to avoid race conditions on Windows.
Differential Revision: http://reviews.llvm.org/D18912

llvm-svn: 265948
2016-04-11 15:21:01 +00:00
Bhushan D. Attarde 2cab00fb5b Remove unintentional return
llvm-svn: 265931
2016-04-11 11:19:37 +00:00
Tamas Berghammer 86bc97b79e Fix makefile for TestMiThreadInfo after rL265858 (2nd try)
llvm-svn: 265921
2016-04-11 08:54:57 +00:00
Tamas Berghammer 4b28ee359f Fix makefile for TestMiThreadInfo after rL265858
The makefile was explicitly setting LDFLAGS what is breaking some rules
in the global makefile.

llvm-svn: 265920
2016-04-11 08:45:01 +00:00
Kuba Brecka 369bced2b1 Add a ThreadSanitizer testcase that tests multiple reported issues.
llvm-svn: 265906
2016-04-10 19:29:40 +00:00
Kuba Brecka 1aad8fb772 Provide more information in ThreadSanitizer's JSON data. Move remaining TSan logic from SBThread to InstrumentationRuntime plugin.
llvm-svn: 265905
2016-04-10 18:57:38 +00:00
Oleksiy Vyalov d8bcf3a74b Fix TestBreakpointSetRestart failure on Android.
llvm-svn: 265869
2016-04-09 03:08:02 +00:00
Enrico Granata f96fd0dd1d Remove what I believe are the last known instances of formatters that run code
llvm-svn: 265865
2016-04-08 22:49:31 +00:00
Chuck Ries da21e98932 -thread-info in lldbmi does not conform to protocol. Should end with current thread id
-thread-info in lldbmi does not conform to protocol. Should end with
current thread id as described here:
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Thread-Commands.html#GDB_002fMI-Thread-Commands

When printing all threads, the current thread id should be printed
afterwards.

Example:
-thread-info
     ^done,threads=[
     {id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
        frame={level="0",addr="0xffffe410",func="__kernel_vsyscall",
                args=[]},state="running"},
     {id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
        frame={level="0",addr="0x0804891f",func="foo",
                args=[{name="i",value="10"}],
                file="/tmp/a.c",fullname="/tmp/a.c",line="158"},
                state="running"}],
     current-thread-id="1"
     (gdb)

Patch from jacdavis@microsoft.com

Reviewers: zturner, chuckr

Differential Revision: http://reviews.llvm.org/differential/revision/edit/18880/

llvm-svn: 265858
2016-04-08 22:17:53 +00:00
Enrico Granata f4d521836d Remove even more of the data formatters that silently run code
Fixes <rdar://problem/25629755>

llvm-svn: 265849
2016-04-08 21:24:24 +00:00
Oleksiy Vyalov bdea8dd57f Reset continue_after_async only if neither SIGINIT nor SIGSTOP received.
http://reviews.llvm.org/D18886

llvm-svn: 265843
2016-04-08 20:44:28 +00:00
Todd Fiala c4a2134f26 Fix #ifdef __APPLE__ code is the swig Python bindings
This code was getting evaluated unintentionally at binding
generation time instead of binding file compilation time.

Addresses:
https://bugs.swift.org/browse/SR-1192

llvm-svn: 265829
2016-04-08 18:58:07 +00:00
Todd Fiala 464f7dfd04 fix missing import of 'time' in lldbutil.wait_for_file_on_target
This triggers in some timeout scenarios in the LLDB test suite.

Fixes:
https://bugs.swift.org/browse/SR-1193

llvm-svn: 265821
2016-04-08 18:06:11 +00:00
Enrico Granata d72e412f68 Cleanups to command alias to refer to itself as 'command alias' and not allow to make aliases starting with a - as that isn't really supported, and is most often a mistake (trying to pass options)
llvm-svn: 265820
2016-04-08 17:56:57 +00:00
Enrico Granata 648e438a34 Add help for our regular expression commands when aliased
llvm-svn: 265819
2016-04-08 17:56:26 +00:00
Enrico Granata 979663236f Append a missing \n
llvm-svn: 265818
2016-04-08 17:55:59 +00:00
Luke Drummond d04a6a9a39 Remove bad indentation introduced in 263859
This commit touches whitespace only.
This commit was the original intention of the botched 265797

llvm-svn: 265808
2016-04-08 16:52:40 +00:00
Luke Drummond c316357fa6 Revert bad commit 265797.
llvm-svn: 265799
2016-04-08 16:35:58 +00:00
Luke Drummond 1694cb5c3f Fix indentation for commit 263859.
llvm-svn: 265797
2016-04-08 16:30:55 +00:00
Tamas Berghammer b905e9d06f Fix-up LLDB build after rL13179
llvm-svn: 265787
2016-04-08 14:31:13 +00:00
Adrian McCarthy f9f3609704 Fix TestImport for Windows by ensuring backslashes in the directory paths are properly escaped in Python.
The Python import works by ensuring the directory of the module or package is in sys.path, and then it does a Python `import foo`.  The original code was not escaping the backslashes in the directory path, so this wasn't working.

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

llvm-svn: 265738
2016-04-07 22:52:12 +00:00
Jason Molenda 7d0027627b In GDBRemoteCommunicationClient::GetHostInfo, don't set the
os to "ios" or "macosx" if it is unspecified.  For environments
where there genuinely is no os, we don't want to errantly 
convert that to ios/macosx, e.g. bare board debugging.

Change PlatformRemoteiOS, PlatformRemoteAppleWatch, and
PlatformRemoteAppleTV to not create themselves if we have
an unspecified OS.  Same problem - these are not appropriate
platforms for bare board debugging environments.

Have Process::Attach's logging take place if either 
process or target logging is enabled.

<rdar://problem/25592378> 

llvm-svn: 265732
2016-04-07 22:00:55 +00:00
Kuba Brecka 28c081b97b Enabling AddressSanitizer tests, they should pass now (and this time I mean it).
llvm-svn: 265656
2016-04-07 11:01:05 +00:00
Kuba Brecka 0d66a85421 Simplify the ASan expression (follow-up for the previous commit, r265651).
llvm-svn: 265652
2016-04-07 10:07:45 +00:00
Kuba Brecka 97fe60f450 Tentative fix (add `extern "C"` declarations to expression prefix) and printing evaluation errors for AddressSanitizer (both MemoryHistoryASan.cpp and AddressSanitizerRuntime.cpp). Hopefully this will make the ASan testcases pass or at least the failure should be easier to diagnose.
llvm-svn: 265651
2016-04-07 10:02:43 +00:00
Pavel Labath e91e7bab8d Enable TestDebugBreak on x86_64 as well
Test passes there, and this would have helped me catch the snafu in the previous commit.

llvm-svn: 265650
2016-04-07 09:25:04 +00:00
Pavel Labath ef40912a2f Revert "Reduce code duplication in ProcessGDBRemote"
In turns out this does make a functional change, in case when the inferior hits an int3 that was
not placed by the debugger. Backing out for now.

llvm-svn: 265647
2016-04-07 08:16:10 +00:00
Saleem Abdulrasool 8bd973c90b Symbol: fix build
TargetOptions is ambiguous due to a definition in LLVM and in clang.  This was
exposed by SVN r265640.  Update to fix the build against the newer revision.

llvm-svn: 265644
2016-04-07 06:51:10 +00:00
Pavel Labath 97a67572d6 Reduce code duplication in ProcessGDBRemote
Summary:
SetThreadStopInfo was checking for a breakpoint at the current PC several times. This merges the
identical code into a separate function. I've left one breakpoint check alone, as it was doing
more complicated stuff, and it did not see a way to merge that without making the interface
complicated. NFC.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 265560
2016-04-06 16:49:13 +00:00
Pavel Labath b1f7d4d79c Fixup TestLinuxCore on windows
test_same_pid_running couldn't delete the temporary files, while we had them open. Deleting the
target should make things work.

llvm-svn: 265529
2016-04-06 11:05:30 +00:00
Tamas Berghammer b05a37f347 Fix and xfail TestRegisterVariables after rL265498
llvm-svn: 265527
2016-04-06 10:34:29 +00:00
Pavel Labath 3ce324af6b Fix a cornercase in breakpoint reporting
Summary:
This resolves a similar problem as D16720 (which handled the case when we single-step onto a
breakpoint), but this one deals with involutary stops: when we stop a thread (e.g. because
another thread has hit a breakpont and we are doing a full stop), we can end up stopping it right
before it executes a breakpoint instruction. In this case, the stop reason will be empty, but we
will still step over the breakpoint when do the next resume, thereby missing a breakpoint hit.

I have observed this happening in TestConcurrentEvents, but I have no idea how to reproduce this
behavior more reliably.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 265525
2016-04-06 09:10:29 +00:00
Pavel Labath a95e0effc0 Fixup r265398
llvm-svn: 265524
2016-04-06 08:55:31 +00:00
Todd Fiala 58c4dd7a71 make TestRegisterVariables slightly more resilient
This test sets the compiler optimization level to -O1 and
makes some assumptions about how local frame vars will be
stored (i.e. in registers).  These assumptions are not always
true.

I did a first-pass set of improvements that:
(1) no longer assumes that every one of the target locations has
    every variable in a register.  Sometimes the compiler
    is even smarter and skips the register entirely.
(2) simply expects one of the 5 or so variables it checks
    to be in a register.

This test probably passes on a whole lot more systems than it
used to now.  This is certainly true on OS X.

llvm-svn: 265498
2016-04-06 01:14:37 +00:00
Jim Ingham bbadf2b7e5 The FixItList typedef should have been inside "class ClangDiagnostic".
llvm-svn: 265496
2016-04-06 00:25:44 +00:00
Jim Ingham b29c42f9eb If the fixed expression doesn't parse, don't tell the user about it.
llvm-svn: 265495
2016-04-06 00:25:04 +00:00
Jim Ingham 2fcb27b08c Don't write "using $_lldb_local_vars" statements for variables with
no name.  These were showing up with a recent clang, I haven't tracked
down why yet, but adding them is clearly wrong. 

llvm-svn: 265494
2016-04-06 00:24:17 +00:00
Adrian McCarthy c8b1be0c71 Revert "XFail TestImport.py on Windows because Python 3 import rules don't work that way."
This reverts commit e5f0ba4fcf977ad6baaaca700d3646675cdac19b.

llvm-svn: 265476
2016-04-05 21:49:41 +00:00
Adrian McCarthy 9def2afd5c XFail TestImport.py on Windows because Python 3 import rules don't work that way.
llvm-svn: 265461
2016-04-05 20:49:09 +00:00
Greg Clayton a19af5812f Fix a crasher that could happen if ClangASTSource::CompleteType() found a type whose name matched, but came from a different language. We need to verify that any types we find are clang types before trying to extra a clang::QualType and then use it.
<rdar://problem/24138711>

llvm-svn: 265443
2016-04-05 19:29:05 +00:00
Stephane Sezer 0036ac4236 Fix dotest.py '-p' option for multi-process mode
Summary:
The '-p' option for dotest.py was ignored in multiprocess mode,
as the -p argument to the inferior would overwrite the -p argument
passed on the command line.

Reviewers: zturner, tfiala

Subscribers: lldb-commits, sas

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

Change by Francis Ricci <fjricci@fb.com>

llvm-svn: 265422
2016-04-05 17:34:38 +00:00
Stephane Sezer 6944f0eeb0 Update watchpoint help to use new -s flag
Summary: Flag updated in D233237

Reviewers: spyffe, jingham, Eugene.Zelenko

Subscribers: lldb-commits, sas

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

Change by Francis Ricci <fjricci@fb.com>

llvm-svn: 265421
2016-04-05 17:30:31 +00:00
Stephane Sezer bef0ff8c7f Print environment when dumping arch triple
Summary: Print environment from triple if it exists.

Reviewers: tfiala, clayborg

Subscribers: lldb-commits, sas

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

Change by Francis Ricci <fjricci@fb.com>

llvm-svn: 265420
2016-04-05 17:29:19 +00:00
Stephane Sezer 03f650ff14 Make sure to update Target arch if environment changed
Summary: Fixes "target list" for non-android linux platforms (ie gnu, gnueabi)

Reviewers: jasonmolenda, tfiala, clayborg, tberghammer

Subscribers: tberghammer, danalbert, lldb-commits, sas

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

Change by Francis Ricci <fjricci@fb.com>

llvm-svn: 265419
2016-04-05 17:27:52 +00:00
Stephane Sezer 3553c0e5e7 Allow gdbremote process to read modules from memory
Summary:
The logic to read modules from memory was added to LoadModuleAtAddress
in the dynamic loader, but not in process gdb remote. This means that when
the remote uses svr4 packets to give library info, libraries only present
on the remote will not be loaded.

This patch therefore involves some code duplication from LoadModuleAtAddress
in the dynamic loader, but removing this would require some amount of code
refactoring.

Reviewers: ADodds, tberghammer, tfiala, deepak2427, ted

Subscribers: tfiala, lldb-commits, sas

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

Change by Francis Ricci <fjricci@fb.com>

llvm-svn: 265418
2016-04-05 17:25:32 +00:00
Kuba Brecka d9f724e04a Reverting r265401 ("Enabling AddressSanitizer tests, they should work now.")
llvm-svn: 265406
2016-04-05 15:22:00 +00:00
Kuba Brecka b693068cfe Enabling AddressSanitizer tests, they should work now.
llvm-svn: 265401
2016-04-05 14:14:07 +00:00
Kuba Brecka 3b275db195 Fixing AddressSanitizer tests (update expectations for current ASan, make it work on OS X 10.10 and older).
llvm-svn: 265400
2016-04-05 14:13:22 +00:00
Tamas Berghammer 19fc1d4e3c [NFC] Cleanup the code used to run shell commands from tests
Previously we had 3 different method to run shell commands on the
target and 4 copy of code waiting until a given file appears on the
target device (used for syncronization). This CL merges these methods
to 1 run_platform_command and 1 wait_for_file_on_target functions
located in some utility classes.

Differential revision: http://reviews.llvm.org/D18789

llvm-svn: 265398
2016-04-05 14:08:18 +00:00
Kuba Brecka a0beb762a4 Enabling TSan tests, they should work now.
llvm-svn: 265396
2016-04-05 13:59:45 +00:00
Kuba Brecka 0bab7bf9f4 Fix ThreadSanitizer test cases to work on OS X 10.10 and older.
llvm-svn: 265395
2016-04-05 13:57:42 +00:00
Tamas Berghammer 97b3a76234 Fix TestPlatformProcessConnect after rL265357
llvm-svn: 265392
2016-04-05 13:18:08 +00:00
Pavel Labath a933d5179e Fix a bug in linux core file handling
Summary:
There was a bug in linux core file handling, where if there was a running process with the same
process id as the id in the core file, the core file debugging would fail, as we would pull some
pieces of information (ProcessInfo structure) from the running process instead of the core file.
I fix this by routing the ProcessInfo requests through the Process class and overriding it in
ProcessElfCore to return correct data.

A (slightly convoluted) test is included.

Reviewers: clayborg, zturner

Subscribers: lldb-commits

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

llvm-svn: 265391
2016-04-05 13:07:16 +00:00