Commit Graph

16775 Commits

Author SHA1 Message Date
Pavel Labath 7da84753a3 Handle O reply packets during qRcmd
Summary:
Gdb servers like openocd may send many $O reply packets for the client to output during a qRcmd command sequence.  Currently, lldb interprets the first O packet as an unexpected response.  Besides generating no output, this causes lldb to get out of sync with future commands because it continues reading O packets from the first command as response to subsequent commands.

This patch handles any O packets during an qRcmd, treating the first non-O packet as the true response.

Preliminary discussion at http://lists.llvm.org/pipermail/lldb-dev/2018-January/013078.html

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: labath, lldb-commits

Differential Revision: https://reviews.llvm.org/D41745
Patch by Owen Shaw <llvm@owenpshaw.net>

llvm-svn: 322190
2018-01-10 14:39:08 +00:00
Pavel Labath e71429d1d8 Add empty() function to the Environment class
Needed to make the previous Freebsd fix work.

llvm-svn: 322188
2018-01-10 14:17:40 +00:00
Pavel Labath 75c6de0be2 Another attempt to fix FreeBsd build
the previous fix did not work because of different const qualifications
on the envp pointer.

This should resolve that (and remove a couple of const_casts in the
process).

llvm-svn: 322187
2018-01-10 13:53:40 +00:00
Tim Northover 400c7b3c7a Fix Xcode build for r322174
llvm-svn: 322183
2018-01-10 13:32:01 +00:00
Pavel Labath 3ff377a927 Fix windows and freebsd builds for r322174 (Environment)
llvm-svn: 322176
2018-01-10 12:25:48 +00:00
Pavel Labath 62930e57eb Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.

This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
  Instead of trying to maintain a constantly up-to-date envp view, it
  provides a function which creates a envp view on demand, with the
  expectation that this will be called as the very last thing before
  handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
  pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
  into "KEY=VALUE" representation.

With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.

(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)

Reviewers: zturner, davide, jingham, clayborg

Subscribers: emaste, lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D41359

llvm-svn: 322174
2018-01-10 11:57:31 +00:00
Pavel Labath 698d63a61a [dotest] Remove crashinfo hook
Summary:
This used to be important when all tests were run in a single process,
but that has no longer been the case for a while. Furthermore, this hook fails
to build on new mac versions for several people, and it's not clear
whether fixing it is worth the effort.

Reviewers: jingham, clayborg, davide

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D41871

llvm-svn: 322167
2018-01-10 10:18:47 +00:00
Jason Molenda 6b7daba64a This change updates the deployment target for lldb and debugserver
(built with Xcode) from 10.9 to 10.11.  It also enables the use of
libcompression in debugserver by default (these API are only present
in macOS 10.11 and newer -- 10.11 was released c. Sep 2015).

I don't know if we have people / bots building lldb on older mac
releases; if this turns out to be a problem I will revert the change.
There are some parts of lldb (e.g. debugserer's ability to report
the OS version #) that only work with 10.10 and this changes the
behavior of lldb (whether the older or newer dyld interfaces are
used) so there is some importance to updating the min required
version.

llvm-svn: 322128
2018-01-09 22:17:10 +00:00
Michal Gorny c5e0b63e56 [test] Fix tests to use more portable LLVM_ENABLE_ZLIB
The HAVE_LIBZ variable is not exported by LLVM, and therefore is not
available in stand-alone builds of other tools. Use LLVM_ENABLE_ZLIB
which is the name under which the effective value is exported.

Additional, use llvm_canonicalize_cmake_booleans() to make sure that
a correct (Python-safe) boolean value is passed down to lit.

Differential Revision: https://reviews.llvm.org/D41725

llvm-svn: 322081
2018-01-09 14:44:04 +00:00
Pavel Labath 03ed2249a6 TestConflictingSymbols: simplify test by using run_break_set_by_source_regexp
follow-up to r321271 based on post-commit feedback by Jim Ingham.

llvm-svn: 322075
2018-01-09 13:22:22 +00:00
Jim Ingham 9c7ba8e047 Cut and paste error - I wasn't actually running both tests...
llvm-svn: 322054
2018-01-09 03:03:20 +00:00
Michal Gorny 15a86ef5af [test] Use full PATH lookup for tools
Use full PATH when looking up test tools rather than just llvm tools
directory. r320813 has added a lookup for 'lldb-test' which is part
of LLDB tools rather than LLVM, and therefore is not present
in llvm_tools_dir before LLDB is installed.

While technically we could introduce separate per-directory lookup
logic, there is no real reason not to use the PATH formed earlier here,
and this is what other tools are doing.

Differential Revision: https://reviews.llvm.org/D41726

llvm-svn: 321932
2018-01-06 10:20:25 +00:00
Davide Italiano 08e52bc801 [ArchSpec] Add a unittest to complement the change in r321856.
<rdar://problem/35778442>

llvm-svn: 321879
2018-01-05 18:00:44 +00:00
Davide Italiano c910aa67b3 [ArchSpec] Don't consider Unknown MachO64 as invalid.
Even without a proper arch we can access line tables, etc..

<rdar://problem/35778442>

llvm-svn: 321856
2018-01-05 02:50:24 +00:00
Davide Italiano 45925d77d6 [IRExecutionUnit] Remove broken/dead code.
llvm-svn: 321833
2018-01-04 23:37:18 +00:00
Adrian Prantl dce4a9aa59 Look for external types in all clang modules imported by the current symbol file.
This fixes a bug in -gmodules DWARF handling when debugging without a .dSYM bundle
that was particularly noticable when debugging LLVM itself.

Debugging without clang modules and DWO handling should be unaffected by this patch.

<rdar://problem/32436209>

llvm-svn: 321802
2018-01-04 16:42:05 +00:00
Davide Italiano 0d0f1ff719 [Core/Debugger] Remove some code that doesn't compile anymore.
llvm-svn: 321654
2018-01-02 16:27:01 +00:00
Davide Italiano 29e1856966 [MacOSX-Kernel] Remove broken KDP_IMAGEPATH support.
llvm-svn: 321652
2018-01-02 16:24:30 +00:00
Davide Italiano aae267d7f2 [ARM64] Remove unused function. NFCI.
llvm-svn: 321651
2018-01-02 16:22:09 +00:00
Aaron Smith 5a81bb73ad Remove duplicate declaration from D41550; NFC
llvm-svn: 321514
2017-12-28 07:48:10 +00:00
Aaron Smith 364cbfe964 Update failing PDB unit tests that are searching for symbols by regex
Summary: D41086 fixed an exception in FindTypes()/FindTypesByRegex() and caused two lldb unit test to fail. This change updates the unit tests to pass again.

Reviewers: zturner, lldb-commits, labath, clayborg, asmith

Reviewed By: asmith

Differential Revision: https://reviews.llvm.org/D41550

llvm-svn: 321511
2017-12-28 06:29:59 +00:00
Pavel Labath deb45f2043 debugserver: Propagate environment in launch-mode (pr35671)
Summary:
Make sure we propagate environment when starting debugserver with a pre-loaded
inferior. AFAIK, RNBRunLoopLaunchInferior is only called in pre-loaded inferior
scenario, so we can just pick up the debugserver environment instead of trying
to construct an envp from the (empty) context.

This makes debugserver pass an test added for an equivalent lldb-server fix.

Reviewers: jasonmolenda, clayborg

Subscribers: JDevlieghere, lldb-commits

Differential Revision: https://reviews.llvm.org/D41352

llvm-svn: 321355
2017-12-22 11:09:21 +00:00
Pavel Labath b8318155eb Enable TestReadMemCString on non-darwin targets
The test works fine on linux, and I believe other targets should not
have an issue with as well. If they do, we can start blacklisting
instead of whitelisting.

The idea of using "-1" as the value of the pointer on non-apple targets
backfired, as it fails the "address != LLDB_INVALID_ADDRESS" test (-1 is
the value of LLDB_INVALID_ADDRESS).  However, it should be safe to use
0x100 for other targets as well. The first page of memory is generally
kept unreadable to catch null pointer dereferences.

llvm-svn: 321353
2017-12-22 10:26:59 +00:00
Aaron Smith 86e9434db9 [lldb] Stop searching for a symbol in a pdb by regex
Summary:
It was possible when searching for a symbol by regex in a pdb that an invalid regex would cause an exception on Windows. This updates the code to avoid throwing an exception.

When fixing the exception it was decided there is no reason to search for a symbol in a pdb by regex. To support this, SymbolFilePDB::FindTypes() now only searches for types by name and no longer calls FindTypesByRegEx().

Reviewers: zturner, lldb-commits

Reviewed By: zturner

Subscribers: clayborg

Differential Revision: https://reviews.llvm.org/D41086

llvm-svn: 321344
2017-12-22 05:26:50 +00:00
Jason Molenda 16b386de15 Change SBProcess::ReadCStringFromMemory() back to returning
an empty Python string object when it reads a 0-length 
string out of memory (and a successful SBError object).

<rdar://problem/26186692> 

llvm-svn: 321338
2017-12-22 03:27:02 +00:00
Jason Molenda a22e923106 Change the default Aarch64 ISA to be v8.2 to correctly decode newer
instructions (e.g. on the new iphones).
<rdar://problem/30585124> 

llvm-svn: 321328
2017-12-22 00:16:04 +00:00
Aaron Smith 1f8552abf3 Enable more abilities in SymbolFilePDB
Summary:
1) Finding symbols through --symfile
2) More abilities: Functions, Blocks, GlobalVariables, LocalVariables, VariableTypes

Reviewers: zturner, lldb-commits

Reviewed By: zturner

Subscribers: clayborg

Differential Revision: https://reviews.llvm.org/D41092

llvm-svn: 321327
2017-12-22 00:04:36 +00:00
Adrian Prantl 559d2c98a8 Bring clang options in error messages up to date.
llvm-svn: 321322
2017-12-21 23:04:51 +00:00
Pavel Labath 71ff9fa65f Make one more test redhat-compatible
This test was also using "a" in an expression.

llvm-svn: 321277
2017-12-21 15:52:59 +00:00
Pavel Labath 3db29a1b3e Work around test failures on red-hat linux
Two tests were failing because the debugger was picking up multiply
defined internal symbols from the system libraries. This is a bug, as
there should be no ambiguity because the tests are defining variables
with should shadow these symbols, but lldb is not smart enough to figure
that out.

I work around the issue by renaming the variables in these tests, and in
exchange I create a self-contained test which reproduces the issue
without depending on the system libraries.

This increases the predictability of our test suite.

llvm-svn: 321271
2017-12-21 14:40:03 +00:00
Pavel Labath 50251fc715 Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.

This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.

This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.

Reviewers: zturner, clayborg, jingham

Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits

Differential Revision: https://reviews.llvm.org/D40079

llvm-svn: 321255
2017-12-21 10:54:30 +00:00
Adrian Prantl 7e13aef428 Replace an accidentally added "break" with an LLVM_FALLTHROUGH.
Thanks to Greg Clayton for catchting this!

llvm-svn: 321123
2017-12-19 23:16:38 +00:00
Adrian Prantl a01e024ad7 Fix a couple of warnings (NFC)
llvm-svn: 321120
2017-12-19 22:54:37 +00:00
Adrian Prantl 3519a27635 Temporarily XFAIL test/functionalities/exec while investiagting bot breakage.
When building with cmake on green gragon or on ci.swift.org, this test fails.

rdar://problem/36134350

llvm-svn: 321095
2017-12-19 18:21:28 +00:00
Jason Molenda b1e350f71f Tweak to the debugserver entitlements setup in the xcode project
file.  For macos builds specifically, use the macosx entitlements
files; for all other builds, use the ios etc entitlements.

llvm-svn: 321051
2017-12-19 01:41:47 +00:00
Dimitry Andric e4f5d01033 Fix more inconsistent line endings. NFC.
llvm-svn: 321016
2017-12-18 19:46:56 +00:00
Pavel Labath 8c92c899c6 Fix regression in jModulesInfo packet handling
The recent UUID cleanups exposed a bug in the parsing code for the
jModulesInfo response, which was passing wrong value for the second
argument to UUID::SetFromStringRef (it passed the length of the string,
whereas the correct value should be the number of decoded bytes we
expect to receive).

This was not picked up by tests, because they test with 16-byte uuids,
for which the function happens to do the right thing even if the length
does not match (if the length does not match, the function does not
update m_num_uuid_bytes member, but that member is already 16 to begin
with).

I fix that and add a test with 20-byte uuid to catch if this regresses.
I have also added more safeguards into the parsing code to fail if we
cannot parse the entire uuid field we recieve. While testing the latter
part, I noticed that the "negative" jModulesInfo tests were succeeding
because we were sending malformed json (and not because the json
contents was invalid), so I make those tests a bit more robuts as well.

llvm-svn: 320985
2017-12-18 14:31:44 +00:00
Pavel Labath 11e5917d2a llgs: Propagate the environment when launching the inferior from command line
Summary:
We were failing to propagate the environment when lldb-server was
started with a pre-loaded process
(e.g.: lldb-server gdbserver -- inferior --inferior_args)

This patch makes sure the environment is propagated. Instead of adding a
new GDBRemoteCommunicationServerLLGS::SetLaunchEnvironment function to
complement SetLaunchArgs and SetLaunchFlags, I replace these with a
more generic SetLaunchInfo, which can be used to set any launch-related
property.

The accompanying test also verifies that the server correctly terminates
the connection after sending the exit packet (specifically, that it does
not send the exit packet twice).

Reviewers: clayborg, eugene

Subscribers: lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D41070

llvm-svn: 320984
2017-12-18 14:31:39 +00:00
Pavel Labath 45fda904d9 Fix FreeBSD build broken by r320966
llvm-svn: 320969
2017-12-18 11:05:28 +00:00
Pavel Labath 9b95b32323 Add LLVMObject dependency to our ObjectFileELF plugin
llvm-svn: 320967
2017-12-18 10:51:03 +00:00
Pavel Labath a0e3c6f6f5 Reduce x86 register context boilerplate.
Summary:
The x86 FPR struct was defined as a struct containing a union between
two members: XSAVE and FXSAVE. This patch makes FPR a union directly to
remove one layer of indirection when trying to access the members.

The initial layout of these two structs is identical, which is
recognised by the fact that XSAVE has FXSAVE as its first member, so we
also considered removing one more layer and leave FPR identical to XSAVE
struct, but stopped short of doing that, as the FPR may be used to store
different layouts in the future (e.g., ones generated by the FSAVE
instruction).

Reviewers: clayborg, krytarowski

Subscribers: emaste, lldb-commits

Differential Revision: https://reviews.llvm.org/D41245

llvm-svn: 320966
2017-12-18 10:50:59 +00:00
Pavel Labath d8b3c1a135 NPL: Clean up handling of inferior exit
Summary:
lldb-server was sending the "exit" packet (W??) twice. This happened
because it was handling both the pre-exit (PTRACE_EVENT_EXIT) and
post-exit (WIFEXITED) as exit events. We had some code which was trying
to detect when we've already sent the exit packet, but this stopped
working quite a while ago.

This never really caused any problems in practice because the client
automatically closes the connection after receiving the first packet, so
the only effect of this was some warning messages about extra packets
from the lldb-server test suite, which were ignored because they didn't
fail the test.

The new test suite will be stricter about this, so I fix this issue
ignoring the first event. I think this is the correct behavior, as the
inferior is not really dead at that point, so it's premature to send the
exit packet.

There isn't an actual test yet which would verify the exit behavior, but
in my next patch I will add a test which will also test this
functionality.

Reviewers: eugene

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D41069

llvm-svn: 320961
2017-12-18 09:44:29 +00:00
Davide Italiano 5cc82f24ff [testsuite] Un-XFAIL the global variables tests.
<rdar://problem/28725399>

Differential Revision:	https://reviews.llvm.org/D41312

llvm-svn: 320952
2017-12-17 18:58:27 +00:00
Davide Italiano 864a6edf8b [CMake] darwin-debug is an hard dependency for tests on macOS.
Fixes a few failured on the testsuite with CMake.

llvm-svn: 320891
2017-12-15 23:27:10 +00:00
Davide Italiano 8539edb0f3 [MacOSX/Queues] Relax an overly aggressive assertion in a test.
"Default" is a valid QoS for a thread on older versions of macOS,
like the one installed in the bot.
Thanks to Jason Molenda for helping me figuring out the problem.

<rdar://problem/28346273>

llvm-svn: 320883
2017-12-15 22:22:51 +00:00
Pavel Labath 93a582c00a llgs-tests: Add support for "exit" stop-reply packets
Summary:
This makes StopReply class abstract, so that we can represent different
types of stop replies such as StopReplyStop and StopReplyExit (there
should also be a StopReplySignal, but I don't need that right now so I
haven't implemented it yet).

This prepares the ground for a new test I'm writing.

Reviewers: eugene, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D41067

llvm-svn: 320820
2017-12-15 15:19:45 +00:00
Pavel Labath 4c2eb8b244 Fix 32-bit builds broken by 320813
cast to size_t to avoid narrowing error.

llvm-svn: 320816
2017-12-15 14:39:12 +00:00
Pavel Labath e2867bc4a0 ObjectFileELF: Add support for compressed sections
Summary:
We use the llvm decompressor to decompress SHF_COMPRESSED sections. This enables
us to read data from debug info sections, which are sometimes compressed,
particuarly in the split-dwarf case.  This functionality is only available if
llvm is compiled with zlib support.

Reviewers: clayborg, zturner

Subscribers: emaste, mgorny, aprantl, lldb-commits

Differential Revision: https://reviews.llvm.org/D40616

llvm-svn: 320813
2017-12-15 14:23:58 +00:00
Pavel Labath 671d3e6318 llgs-tests: Make addition of new tests easier
Summary:
Adding a new test would require one to duplicate a significant part of
the existing test that we have. This attempts to reduce that by moving
some part of that code to the test fixture. The StandardStartupTest
fixture automatically starts up the server and connects it to the
client. I also add a more low-level TestBase fixture, which allows one
to start up the client and server in a custom way (I am going to need
this for the test I am writing).

Reviewers: eugene, zturner

Subscribers: lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D41066

llvm-svn: 320809
2017-12-15 13:56:22 +00:00
Davide Italiano 89419f88bc [ExpressionParser] Fix evaluation failures due to mismatch in C++ versions.
Clang recently switched to C++14 (with GNU extensions) as the default
dialect, but LLDB didn't catch up. This causes failures as LLDB still
evaluates ObjectiveC expressions as Objective C++ using C++98 as standard.

There are things not available in C++98, including, e.g. nullptr.
In some cases Objective-C `nil` is defined as `nullptr` so this causes
an evaluation failure. Switch the default to overcome this issue
(actually, currently lldb evaluates both C++11 and C++14 as C++11,
but that seems a larger change and definitely could be re-evaluated
in the future).

No test as this is currently failing on the LLDB bots after the clang
switch (so, de facto, there's a test already for it).

This is a recommit, with a thinko fixed (the code was previously
placed incorrectly).

<rdar://problem/36011995>

llvm-svn: 320778
2017-12-15 00:50:43 +00:00