Commit Graph

23887 Commits

Author SHA1 Message Date
Jonas Devlieghere 99a99c29c6 [lldb] Remove Crashlog/interactive.test
This test requires running under the Python we built against (which is
easy) and setting up the PYTHONPATH (which is not worth it for this
simple test).
2020-11-05 17:10:52 -08:00
Vedant Kumar 65d15fefe3 [TargetList] Delete the destructor
AFAICT, ~TargetList simply implements the default destructor, plus some
locking.

The history is murky, so I'm not sure why we do this locking. Perhaps,
at some point, it was possible to delete the same TargetList instance
from two different threads, setting up a race. If that were true, then
the locking would protect against the race.

Since TargetList is uniquely owned by Debugger (m_target_list), no such
race is possible today.

Testing: check-lldb

Differential Revision: https://reviews.llvm.org/D90895
2020-11-05 16:56:37 -08:00
Vedant Kumar 16e5a347e7 [TargetList] Simplify dummy target creation
Factor out dummy target creation from CreateTargetInternal.

This makes it impossible for dummy target creation to accidentally fail
due to too-strict checking in one of the CreateTargetInternal overloads.

Testing: check-lldb

rdar://70630655

Differential Revision: https://reviews.llvm.org/D90872
2020-11-05 16:04:02 -08:00
Pedro Tammela ca17571051 [LLDB-lua] modify Lua's 'print' to respect 'io.stdout'
This patch changes the implementation of Lua's `print()` function to
respect `io.stdout`.

The original implementation uses `lua_writestring()` internally, which is
hardcoded to `stdout`.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D90787
2020-11-05 21:23:20 +00:00
Michał Górny 40140e122f [lldb] [Process/FreeBSDRemote] Remove thread name caching
Remove the thread name caching code.  It does not handle the possibility
of thread name changing between requests, therefore breaking
TestGdbRemoteThreadName.  While technically we could cache the results
and reset the cache on resuming process, the gain from doing that
does not seem worth the effort.

Differential Revision: https://reviews.llvm.org/D90863
2020-11-05 20:45:34 +01:00
Michał Górny b643deb03f [lldb] [test] Fix TestGdbRemoteThreadName code on FreeBSD
Fix TestGdbRemoteThreadName to call ::pthread_setname_np instead
of ::pthread_set_name_np on FreeBSD.  While technically both names
are correct, the former is preferable because of compatibility
with Linux.  Furthermore, the latter requires `#include <pthread_np.h>`
that was missing causing the test to fail to compile.

Differential Revision: https://reviews.llvm.org/D90862
2020-11-05 20:45:34 +01:00
Michał Górny 2c2eb5e670 [lldb] Enable FreeBSDRemote plugin by default and update test status
The new FreeBSDRemote plugin has reached feature parity on i386
and amd64 targets.  Use it by default on these architectures, while
allowing the use of the legacy plugin via FREEBSD_LEGACY_PLUGIN envvar.

Revisit the method of switching plugins.  Apparently, the return value
of PlatformFreeBSD::CanDebugProcess() is what really decides whether
the legacy or the new plugin is used.

Update the test status.  Reenable the tests that were previously
disabled on FreeBSD and do not cause hangs or are irrelevant to FreeBSD.
Mark all tests that fail reliably as expectedFailure.  For now, tests
that are flaky (i.e. produce unstable results) are left enabled
and cause unpredictable test failures.

Differential Revision: https://reviews.llvm.org/D90757
2020-11-05 17:49:46 +01:00
Michał Górny 6ba2c2bf90 [lldb] [test/Shell] Simplify -pthread condition
Pass -pthread on all systems except for Darwin and Windows.
Suggested by Pavel Labath.
2020-11-05 17:49:20 +01:00
Raphael Isemann 79d16764dd [lldb][NFC] Fix compiler warnings after removal of eValueTypeVector
5d64574301 removes this enum value and now
all the switch statements that previously relied on handling this in the
'default' branch are causes compiler warnings due to redundant default cases.

This just removes the now unreachable code in there.
2020-11-05 17:17:33 +01:00
Raphael Isemann b9b5f12bd4 [lldb] Set the default architecture also in buildDefault
In D89056 the default value for architecture was moved to `build` so that
all called functions see the same architecture value. It seems there are a
few functions that call buildDefault directly (and not via build), so
on some test configurations that set a custom arch value the architecture
value is no longer available.

This just adds the architecture code from build to buildDefault to get
the bots green again while I'm looking for a better solution.
2020-11-05 16:32:05 +01:00
Raphael Isemann 26a8e8502b [lldb] Add Apple simulator platforms to lldbplatform.py
This just adds the simulator platforms to the lldbplatform enumerations
and the respective test decorator.

The platform names for the simulator are just the SDK names since D85537, so
that's why we are not using LLDB's usual platform names here (e.g., SDK =
"iphonesimulator" vs LLDB platform ="ios-simulator").

Also removes the duplicate platform enumaration in lldbplatformutil.py.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D89694
2020-11-05 15:34:42 +01:00
Raphael Isemann d68ebea767 Reland [lldb] Explicitly use the configuration architecture when building test executables
This originally broke the TestQuoting which explicitly called buildDefault
instead of calling build() and marking the test as no_debug_info_test.
TestQuoting has been rewritten by now and is using `build`, so this should now
pass on all platforms.

Original summary:

The Darwin builder currently assumes in `getArchCFlags` that the passed `arch`
value is an actual string it can string.join with vendor/os/version/env strings:

```
   triple = '-'.join([arch, vendor, os, version, env])
```

However this is not true for most tests as we just pass down the `arch=None`
default value from `TestBase.build`. This causes that if we actually end up in
this function we just error out when concatenating `None` with the other actual
strings of vendor/os/version/env. What we should do instead is check that if
there is no test-specific architecture that we fall back to the configuration's
architecture value.

It seems we already worked around this in `builder.getArchSpec` by explicitly
falling back to the architecture specified in the configuration.

This patch just moves this fallback logic to the top `build` function so that it
affects all functions called from `TestBase.build`.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D89056
2020-11-05 15:13:48 +01:00
Raphael Isemann 239f488fd6 [lldb] Skip TestChangeProcessGroup on watchOS/tvOS
`fork` is marked as `__WATCHOS_PROHIBITED __TVOS_PROHIBITED` so the test source
which is calling fork will never compile on watchOS/tvOS. This just adds the
skip decorator for these platforms.

Reviewed By: mib

Differential Revision: https://reviews.llvm.org/D89695
2020-11-05 15:11:30 +01:00
Raphael Isemann 2f84b59a4c [lldb] Also Catch invalid calls to TestPExpectTest's expect()
This is a follow up to D88792 which found an issue in a call to PExpectTest's
expect function that allows passing a string to the `substrs` parameter. However
this issue was found by just grepping and TestPExpect's expect function is still
accepting a single string as a value to `substrs`.

This patch adds the same sanity check that D88792 added to the PExpectTest's
implementation of `expect` and also adds a small test for it.

Reviewed By: kastiglione, JDevlieghere

Differential Revision: https://reviews.llvm.org/D89302
2020-11-05 14:08:46 +01:00
Jonas Devlieghere c29c24be63 [crashlog] Pass the debugger around instead of relying on lldb.debugger
The lldb.debugger et al convenience variables are only available from
the interactive script interpreter. In all other scenarios, they are
None (since fc1fd6bf9f) before that they
were default initialized.

The crashlog script was hacking around that by setting the lldb.debugger
to a newly created debugger instance when running outside of the script
interpreter, which works fine until lldb creates a script interpreter
instance under the hood and clears the variables. This was resulting in
an AttributeError when invoking the script directly (from outside of
lldb):

  AttributeError: 'NoneType' object has no attribute 'GetSourceManager'

This patch fixes that by passing around the debugger instance.

rdar://64775776

Differential revision: https://reviews.llvm.org/D90706
2020-11-04 12:51:26 -08:00
Pavel Labath 586c375fa3 [lldb] Remove [US]IntValueIsValidForSize from CommandObjectMemory
Use llvm::is(U)IntN (MathExtras.h) instead.
2020-11-04 16:28:10 +01:00
Pavel Labath e2d24d91c2 [lldb/Utility] Delete Scalar::[US]IntValueIsValidForSize
It's unused, and the same functionality is available in llvm (is(U)IntN
in MathExtras.h).
2020-11-04 16:28:10 +01:00
Pavel Labath ac6799d25a [lldb] Improve RegisterValue::GetScalarValue
Using Scalar::SetValueFromData, we make the code simpler, handle
big-endian systems properly, _and_ avoid type aliasing issues.
2020-11-04 14:53:06 +01:00
Pavel Labath 5d64574301 [lldb] Delete Value::Vector class
This class and it's surroundings contain a lot of shady code, but as far
as I can tell all of that code is unreachable (there is no code actually
setting the value to eValueTypeVector).

According to history this class was introduced in 2012 in
r167033/0665a0f09. At that time, the code seemed to serve some purpose,
and it had two entry points (in Value::SetContext and
ClangExpressionDeclMap::LookupDecl). The first entry point was deleted
in D17897 and the second one in r179842/44342735.

The stated purpose of the patch introducing this class was to fix
TestRegisters.py, and "expr $xmm0" in particular. Both of these things
function perfectly well these days without this class.
2020-11-04 10:21:56 +01:00
Jordan Rupprecht 33945cdd62 [NFC] Fix call to lldb RegisterValue constructor 2020-11-03 13:24:06 -08:00
Michał Górny 98257c3006 [lldb] [test] Update XFAILs/skips for FreeBSD
Update expected failures and test skips based on common results
for the old and new FreeBSD plugins.
2020-11-03 22:01:59 +01:00
Michał Górny 051da2bede [lldb] [test/Shell] Pass -pthread to host toolchain on FreeBSD too 2020-11-03 22:01:59 +01:00
Michał Górny b7de7be098 [lldb] [test] Remove xfail from tests that pass on FreeBSD 2020-11-03 22:01:59 +01:00
Jonas Devlieghere f0fd4349a7 [crashlog] Print the actual exception in the CommandReturnObject
Before:

  error: python exception <class 'AttributeError'>

After:

  error: python exception: 'DarwinImage' object has no attribute 'debugger'
2020-11-03 11:51:40 -08:00
Andy Yankovsky f35a82384d Return actual type from SBType::GetArrayElementType
SBType::GetArrayElementType should return the actual type, not the
canonical type (e.g. int32_t, not the underlying int).

Added a test case to validate the new behavior. I also ran all other
tests on Linux (ninja check-lldb), they all pass.

Differential revision: https://reviews.llvm.org/D90318
2020-11-03 10:53:44 -08:00
Jonas Devlieghere 16dd69347d [crashlog] Modularize parser
Instead of parsing the crashlog in one big loop, use methods that
correspond to the different parsing modes.

Differential revision: https://reviews.llvm.org/D90665
2020-11-03 10:21:21 -08:00
Jonas Devlieghere 4b84682044 [crashlog] Move crash log parsing into its own class
Move crash log parsing out of the CrashLog class and into its own class
and add more tests.

Differential revision: https://reviews.llvm.org/D90664
2020-11-03 09:04:35 -08:00
Michał Górny fbc0d41bb0 [lldb] [Process/FreeBSDRemote] Fix "Fix attaching via lldb-server"
One of the changes seems to have been lost in rebase.  Reapply.
2020-11-03 17:16:57 +01:00
Pavel Labath d2700b7873 [lldb/Utility] Add unit tests for RegisterValue::GetScalarValue
Buggy cases are commented out.

Also sneak in a modernization of a RegisterValue constructor.
2020-11-03 16:12:32 +01:00
Pedro Tammela 4b9fa3b705 [LLDB][NFC] treat Lua error codes in a more explicit manner
This patch is a minor suggestion to not rely on the fact
that the `LUA_OK` macro is 0.

This assumption could change in future versions of the C API.

Differential Revision: https://reviews.llvm.org/D90556
2020-11-03 09:39:47 +00:00
Michał Górny 952ddc9866 [lldb] [Plugins/FreeBSDRemote] Disable GetMemoryRegionInfo()
Disable GetMemoryRegionInfo() in order to unbreak expression parsing.
For some reason, the presence of non-stub function causes LLDB to fail
to detect system libraries correctly.  Through being unable to find
mmap() and allocate memory, this leads to expression parser being
broken.

The issue is non-trivial and it is going to require more time debugging.
On the other hand, the downsides of missing the function are minimal
(2 failing tests), and the benefit of working expression parser
justifies disabling it temporarily.  Furthermore, the old FreeBSD plugin
did not implement it anyway, so it allows us to switch to the new plugin
without major regressions.

The really curious part is that the respective code in the NetBSD plugin
yields very similar results, yet does not seem to break the expression
parser.

Differential Revision: https://reviews.llvm.org/D90650
2020-11-03 09:45:51 +01:00
Michał Górny 40d26bc4b1 [lldb] [Process/FreeBSDRemote] Remove GetSharedLibraryInfoAddress override
Remove the NetBSD-specific override of GetSharedLibraryInfoAddress(),
restoring the generic implementation from NativeProcessELF.

Differential Revision: https://reviews.llvm.org/D90620
2020-11-03 09:45:50 +01:00
Michał Górny 8e6bcbb417 [lldb] [Process/FreeBSDRemote] Fix attaching via lldb-server
Fix two bugs that caused attaching to a process in a pre-connected
lldb-server to fail.  These are:

1. Prematurely reporting status in NativeProcessFreeBSD::Attach().
   The SetState() call defaulted to notify the process, and LLGS tried
   to send the stopped packet before the process instance was assigned
   to it.  While at it, add an assert for that in LLGS.

2. Duplicate call to ReinitializeThreads() (via SetupTrace()) that
   overwrote the stopped status in threads.  Now SetupTrace() is called
   directly by NativeProcessFreeBSD::Attach() (not the Factory) in place
   of ReinitializeThreads().

This fixes at least commands/process/attach/TestProcessAttach.py
and python_api/hello_world/TestHelloWorld.py.

Differential Revision: https://reviews.llvm.org/D90525
2020-11-03 09:45:50 +01:00
Michał Górny f893b29397 [lldb] [Host/{free,net}bsd] Fix process matching by name
Fix process matching by name to make 'process attach -n ...' work.

The process finding code has an optimization that defers getting
the process name and executable format after the numeric (PID, UID...)
parameters are tested.  However, the ProcessInstanceInfoMatch.Matches()
method has been matching process name against the incomplete process
information as well, and effectively no process ever matched.

In order to fix this, create a copy of ProcessInstanceInfoMatch, set
it to ignore process name and se this copy for the initial match.
The same fix applies to FreeBSD and NetBSD host code.

Differential Revision: https://reviews.llvm.org/D90454
2020-11-03 09:45:50 +01:00
Michał Górny 326d235300 [lldb] [Process/FreeBSDRemote] Implement thread GetName()
Implement NativeThreadFreeBSD::GetName().  This is based
on the equivalent code in the legacy FreeBSD plugin, except it is
modernized a bit to use llvm::Optional and std::vector for data storage.

Differential Revision: https://reviews.llvm.org/D90298
2020-11-03 09:45:49 +01:00
Jonas Devlieghere 66009a19e5 [crashlog] Remove commented out code (NFC)
Remove commented out code and print statements.
2020-11-02 19:46:53 -08:00
Jonas Devlieghere 6c9f3fe908 [crashlog] Turn crash log parsing modes into a Python 'enum' (NFC)
Python doesn't support enums before PEP 435, but using a class with
constants is how it's commonly emulated. It can be converted into a real
Enum (in Python 3.4 and later) by extending the Enum class:

  class CrashLogParseMode(Enum):
      NORMAL = 0
      THREAD = 1
      IMAGES = 2
      THREGS = 3
      SYSTEM = 4
      INSTRS = 5
2020-11-02 19:42:34 -08:00
Jonas Devlieghere fb6d1c020c [crashlog] Fix and simplify the way we import lldb
Don't try to guess the location of LLDB.framework but use xcrun to ask
the command line driver for the location of the lldb module.
2020-11-02 18:59:48 -08:00
Pedro Tammela 4d7d6f276c [LLDB/Lua] call lua_close() on Lua dtor
This patch calls `lua_close()` on Lua dtor.

This guarantees that the Lua GC finalizers are honored, aside from the
usual internal clean up.

It also guarantees a call to the `__close` metamethod of any active
to-be-closed variable in Lua 5.4.

Since the previous `luaL_openlibs()` was a noop, because the standard
library is cached internally, I've removed it.

Differential Revision: https://reviews.llvm.org/D90557
2020-11-02 16:52:30 +00:00
Pavel Labath 1695c8420a [lldb] Generalize an deflake gdb-remote *client* tests
This is similar in spirit to what D90313 did for server tests.
2020-11-02 16:34:25 +01:00
Pavel Labath e3645fdff4 [lldb/test] Fix a fragile assumption in TestTypeGetModule
the binary can contain more than three compile units if the compiler
support files (crtbegin/end, etc.) come with their own debug info.
2020-11-02 15:42:14 +01:00
Nathan James ba447f38f6
[NFC][lldb] Silence unused variable warning 2020-11-01 14:37:06 +00:00
Ilya Bukonkin 1267bb2e41 [lldb] TestTypeGetModule.py review improvements 2020-11-01 13:55:57 +03:00
Pedro Gonnet 43e451f9f3 Fix gendered documentation
Changed two references to developers as "he" or "him" to the more neutral "they".

Reviewed By: JDevlieghere, sylvestre.ledru

Differential Revision: https://reviews.llvm.org/D78807
2020-10-31 12:17:19 +01:00
Jonas Devlieghere 136d06749b [lldb] Fix XcodeSDKModuleTests
Update XcodeSDKModuleTests for YAMLModuleTester changes in D90393.
2020-10-30 23:08:35 -07:00
Joseph Tremoulet d20aa7ca42 [lldb] Report old modules from ModuleList::ReplaceEquivalent
This allows the Target to update its module list when loading a shared
module replaces an equivalent one.

A testcase is added which hits this codepath -- without the fix, the
target reports libbreakpad.so twice in its module list.

Reviewed By: jingham

Differential Revision: https://reviews.llvm.org/D89157
2020-10-30 15:14:32 -04:00
Joseph Tremoulet 61bfc703c3 [lldb] GetSharedModule: Collect old modules in SmallVector
The various GetSharedModule methods have an optional out parameter for
the old module when a file has changed or been replaced, which the
Target uses to keep its module list current/correct.  We've been using
a single ModuleSP to track "the" old module, and this change switches
to using a SmallVector of ModuleSP, which has a couple benefits:
 - There are multiple codepaths which may discover an old module, and
   this centralizes the code for how to handle multiples in one place,
   in the Target code.  With the single ModuleSP, each place that may
   discover an old module is responsible for how it handles multiples,
   and the current code is inconsistent (some code paths drop the first
   old module, others drop the second).
 - The API will be more natural for identifying old modules in routines
   that work on sets, like ModuleList::ReplaceEquivalent (which I plan
   on updating to report old module(s) in a subsequent change to fix a
   bug).

I'm not convinced we can ever actually run into the case that multiple
old modules are found in the same GetOrCreateModule call, but I think
this change makes sense regardless, in light of the above.

When an old module is reported, Target::GetOrCreateModule calls
m_images.ReplaceModule, which doesn't allow multiple "old" modules; the
new code calls ReplaceModule for the first "old" module, and for any
subsequent old modules it logs the event and calls m_images.Remove.

Reviewed By: jingham

Differential Revision: https://reviews.llvm.org/D89156
2020-10-30 15:14:31 -04:00
Zequan Wu 4348e0eee4 [lldb][NFC] Refactor getUUID functionality
Differential Revision: https://reviews.llvm.org/D90325
2020-10-30 10:44:37 -07:00
Jonas Devlieghere 5b17b6d924 [lldb] Ignore binary data in crashlog
Skip the instruction stream section in the crashlog section.

Differential revision: https://reviews.llvm.org/D90414
2020-10-30 09:17:45 -07:00
Pavel Labath 1d1d916f96 Fix an embarrasing use-after-free from a895a446bc 2020-10-30 16:54:24 +01:00
Jan Kratochvil a136699b2a [nfc] [lldb] Align `user_id_t` format to the current `DIERef` format
Current user_id_t format is:
        63{isDebugTypes} 62..32{dwo || 7fffffff}
        31..0 {die_offset}
while current DIERef format is (I have made up the bit positions but the
field widths do match):
        63{m_section==isDebugTypes} 62{m_dwo_num_valid} 61..32{m_dwo_num}
        31..0 {m_die_offset}

Proposing to change user_id_t to:
        63{isDebugTypes} 62{dwo_is_valid} 61..32{dwo; 0 if !valid}
        31..0 {die_offset}

There is no benefit of having 31-bits wide dwo_num in user_id_t when it
gets converted to 30-bits width in DIERef.

This patch is for future DWZ patchset which extends the dwo_is_valid bit
into a 2-bit field (normal, DWO, DWZ, DWZcommon) so that both user_id_t
and DIERef can be changed then the same way.

It would be best to somehow unify user_id_t and DIERef but I do not plan
to do that. user_id_t should probably remain a number for the Python API
compatibility while there still needs to be some class with all the
methods to access it.

SymbolFileDWARF::GetDwpSymbolFile() and SymbolFileDWARF::GetDIE use
0x3fffffff for DWP but that does not clash:

formerly:
  31bits32..62:0x7fffffff = normal unit / not any DWO
  31bits32..62:0x3fffffff = DWP
  31bits32..62:others = DWO unit number

after this patch:
  bit62=0 30bits32..61:any = normal unit / not any DWO
  bit62=1 30bits32..61:0x3fffffff = DWP
  bit62=1 30bits32..61:others = DWO unit number

Differential Revision: https://reviews.llvm.org/D90413
2020-10-30 16:50:52 +01:00
Pavel Labath 8485ee781f [lldb/DWARF] Fix dwo flavour of TestTypeGetModule
SymbolFileDWARF::GetTypes was not handling dwo correctly. The fix is
simple -- adding a GetNonSkeletonUnit call -- but I've snuck in a small
refactor as well.
2020-10-30 15:20:27 +01:00
Pavel Labath 62286c569d [lldb/test] Remove a double debugserver launch in TestGdbRemoteGPacket
Debug server is already launched by prep_debug_monitor_and_inferior. The
second seems to have been benign so far, but after 8cc49bec2 this test
started failing frequently on GreenDragon, and this is the only unusual
thing about it.
2020-10-30 14:27:50 +01:00
Pavel Labath a895a446bc [lldb/test] Simplify/generalize YAMLModuleTester
The class only supports a single DWARF unit (needed for my new test), and it
reimplements chunks of object and symbol file classes. We can just make it use
the real thing, save some LOC and get the full feature set.

Differential Revision: https://reviews.llvm.org/D90393
2020-10-30 14:27:50 +01:00
Jonas Devlieghere 30e7df0d58 [lldb] XFAIL TestTypeGetModule.py (temporarily)
Temporarily XFAIL'ing TestTypeGetModule.py while the DWO failure is
being investigated.
2020-10-29 18:37:46 -07:00
Ilya Bukonkin 56282cf7e2 [lldb] Update TestTypeGetModule.py
Differential revision: https://reviews.llvm.org/D88483
2020-10-29 18:28:57 -07:00
Jim Ingham 32a85b268a This is a preliminary version of the test for https://reviews.llvm.org/D88483.
The test can be cleaned up a bit, but this should be good to see why the
Debian bot is failing...
2020-10-29 16:39:35 -07:00
Jim Ingham fa5a132767 Provide a reasonable value for PATH_MAX if the lldb headers don't provide it. 2020-10-29 15:02:51 -07:00
Jim Ingham c8c07b76b2 Use !hasLocalLinkage instead of listing the symbol types
we should be exporting one by one.

Differential Revision: https://reviews.llvm.org/D78972
2020-10-29 14:44:06 -07:00
Jim Ingham a37672e2db Mark the execution of stop-hooks as non-interactive.
The intention is not to allow stop-hook commands to query the
user, so this is correct.  It also works around a deadlock in
switching to the Python Session to execute python based commands
in the stop hook when the Debugger stdin is backed by a FILE *.

Differential Revision: https://reviews.llvm.org/D90332
2020-10-29 14:41:53 -07:00
Ilya Bukonkin 2c0cbc47ca GetModule, GetExeModule methods added 2020-10-29 23:44:51 +03:00
Marcel Hlopko 9bb9b737c5 Remove HAVE_VCS_VERSION_INC, not needed
This preprocessor define was meant to be used to conditionally include VCSVersion.inc. However, the define was always set, and it was the content of the header that was conditionally generated. Therefore HAVE_VCS_VERSION_INC should be cleaned up.

Reviewed By: gribozavr2, MaskRay

Differential Revision: https://reviews.llvm.org/D84623
2020-10-29 13:09:05 -07:00
Jan Kratochvil 41f2bb232c [nfc] [lldb] Remove excessive parentheses in SymbolFileDWARF::GetUID 2020-10-29 18:01:37 +01:00
Pavel Labath 8cc49bec2e [lldb] Use reverse connection method for lldb-server tests
This fixes an flakyness is all gdb-remote tests. These tests have been
(mildly) flaky since we started using "localhost" instead of 127.0.0.1
in the test suite. The reason is that lldb-server needs to create two
sockets (v4 and v6) to listen for localhost connections. The algorithm
it uses first tries to select a random port (bind(localhost:0)) for the
first address, and then bind the same port for the second one.

The creating of the second socket can fail as there's no guarantee that
port will be available -- it seems that the (linux) kernel tries to
choose an unused port for the first socket (I've had to create thousands
of sockets to reproduce this reliably), but this can apparantly fail
when the system is under load (and our test suite creates a _lot_ of
sockets).

The socket creationg operation is considered successful if it creates at
least one socket is created, but the test harness has no way of knowing
which one it is, so it can end up connecting to the wrong address.

I'm not aware of a way to atomically create two sockets bound to the
same port. One way to fix this would be to make lldb-server report the
address is it listening on instead of just the port. However, this would
be a breaking change and it's not clear to me that's worth it (the
algorithm works pretty well under normal circumstances).

Instead, this patch sidesteps that problem by using "reverse"
connections. This way, the test harness is responsible for creating the
listening socket so it can pass the address that it has managed to open.
It also results in much simpler code overall.

To preserve test coverage for the named pipe method, I've moved the
relevant code to a dedicated test. To avoid original problem, this test
passes raw addresses (as obtained by getaddrinfo(localhost)) instead of
"localhost".

Differential Revision: https://reviews.llvm.org/D90313
2020-10-29 13:49:51 +01:00
David Spickett 749f13e763 [lldb] Correct --help output for qemu rootfs script
It was printing "Usage:" twice.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D90225
2020-10-29 09:57:32 +00:00
David Zarzycki 075f661d01 [lldb] Unbreak the build after a recent PowerPC change
40dd4d5233 introduced two new types.
2020-10-29 05:56:38 -04:00
Jonas Devlieghere 49c84fd5a4 Revert "[AppleObjCRuntimeV2] Force lazily allocated class names to be resolved."
We're no longer convinced that this is needed and we have no test
coverage to disprove that. Backing out of this change until we're
convinced otherwise.
2020-10-28 16:53:02 -07:00
Vedant Kumar 158f336043 [lldb] Delete lldb/utils/test
These utilities aren't useful any more -- delete them as a cleanup.

Discussion:
http://lists.llvm.org/pipermail/lldb-dev/2020-October/016536.html
2020-10-28 12:06:02 -07:00
Jonas Devlieghere 00bb397b0d [lldb] Support Python imports relative the to the current file being sourced
Make it possible to use a relative path in command script import to the
location of the file being sourced. This allows the user to put Python
scripts next to LLDB command files and importing them without having to
specify an absolute path.

To enable this behavior pass `-c` to `command script import`. The
argument can only be used when sourcing the command from a file.

rdar://68310384

Differential revision: https://reviews.llvm.org/D89334
2020-10-27 09:20:45 -07:00
Raphael Isemann 45c3fc97a2 [lldb][NFC] Make GetResumeCountForLaunchInfo return an unsigned.
The number of resumes should always be positive to let's make this an
unsigned everywhere. Also remove the unused 'localhost' parameter from
ConvertArgumentsForLaunchingInShell.
2020-10-27 16:25:01 +01:00
Raphael Isemann d43c70a202 [lldb] Add llvm-pdbutil to lldb test dependencies
Since D89812 we use llvm-pdbutil in the LLDB tests but we didn't add it to
the test dependencies.
2020-10-27 15:46:25 +01:00
Michał Górny 4ba8ea4cb0 [lldb] [Process/FreeBSD] Fix missing namespace qualifier
Fixes e4cc6e9bcd
2020-10-27 15:38:00 +01:00
Michał Górny 8e7ea99c38 [lldb] [Process/FreeBSDRemote] Enable watchpoint support
Replace the inline x86 watchpoint handling code with the reusable
NativeRegisterContextWatchpoint_x86.  Implement watchpoint support
in NativeThreadFreeBSD and SIGTRAP handling for watchpoints.

Un-skip all concurrent_events tests as they pass with the new plugin.

Differential Revision: https://reviews.llvm.org/D90102
2020-10-27 15:38:00 +01:00
David Spickett f8a3b9b06c [lldb] Correct vFile:pread/pwrite packet docs
The statement that lldb-server can handle
decimal and hex numbers is misleading.
(it can only handle hex with 0x prefix)

Mentioning non decimal numbers at all
is just creating more confusion for anyone
who tries to use them with lldb-server.

Differential Revision: https://reviews.llvm.org/D89383
2020-10-27 11:47:35 +00:00
Raphael Isemann 1f933ff999 [lldb][NFC] Rewrite TestQuoting
TestQuoting's different test methods all build their own test binaries but
we can just reuse the same test binary by merging all asserts into one method.
This reduces the test runtime from 8 seconds to 4 seconds on my machine.
This also removes the ability to have partial failures in this test, but given
how rarely this code is touched this seems like a fair tradeoff (and we will be
able to re-add this feature once we updated our test framework).

Some other small changes:
  * Fixed that we cleanup "stdout.txt" instead of "output.txt" in the cleanup.
  * Fixed some formatting issues.
  * Call `build` instead of directly calling `buildDefault`.
2020-10-27 11:12:17 +01:00
Zequan Wu 779deb9750 [lldb][NativePDB] fix test load-pdb.cpp 2020-10-26 17:12:51 -07:00
Jan Kratochvil 7611c5bb42 [nfc] [lldb] Refactor DWARFUnit::GetDIE
Reduce indentation of the code by early returns for failed code paths.
2020-10-26 23:18:19 +01:00
Sriraman Tallam 9aa7a721ce Test to check backtraces with machine function splitting.
clang supports option -fsplit-machine-functions and this test checks if the
backtraces are sane when functions are split.

With -fsplit-machine-functions, a function with profiles can get split into 2
parts, the original function containing hot code and a cold part as determined
by the profile info and the cold cutoff threshold.. The cold part gets the
".cold" suffix to disambiguate its symbol from the hot part and can be placed
arbitrarily in the address space.

This test checks if the back-trace looks correct when the cold part is executed.

Differential Revision: https://reviews.llvm.org/D90081
2020-10-26 14:08:42 -07:00
Zequan Wu 4b83747ab1 [lldb][NativePDB] fix test load-pdb.cpp 2020-10-26 11:38:12 -07:00
Zequan Wu 242e1e9910 [lldb][PDB] Add ObjectFile PDB plugin
To allow loading PDB file with `target symbols add` command.

Differential Revision: https://reviews.llvm.org/D89812
2020-10-26 10:28:48 -07:00
Andy Yankovsky 206e8d8905 Fix SBError::SetErrorToGenericError
`SBError::SetErrorToGenericError` should call `Status::SetErrorToGenericError`,
not `Status::SetErrorToErrno`.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D90151
2020-10-26 15:44:38 +01:00
Raphael Isemann d0ee1d8efe [lldb][NFC] Make GetShellSafeArgument simpler and faster
Escaping by inserting characters in the middle of a std::string isn't cheap.
It's much more verbose than just prepending a backslash in a loop.
2020-10-26 15:29:13 +01:00
Pavel Labath e4cc6e9bcd [lldb] Modernize PseudoTerminal::Fork 2020-10-26 12:01:20 +01:00
Pavel Labath 97ca9ca180 [lldb] Fix bitfield "frame var" for pointers (pr47743)
Displaying large packed bitfields did not work if one was accessing them
through a pointer, and he used the "->" notation ("[0]." notation is
fine). The reason for that is that implicit dereference in -> is plumbed
all the way down to ValueObjectChild::UpdateValue, where the process of
fetching the child value was forked for this flag. The bitfield
"sliding" code was implemented only for the branch which did not require
dereferencing.

This patch restructures the function to avoid this mistake. Processing
now happens in two stages.
- first the parent is dereferenced (if needed)
- then the child value is computed (this step includes sliding and is
  common for both branches)

Differential Revision: https://reviews.llvm.org/D89236
2020-10-26 12:01:20 +01:00
Michał Górny f5ca27569e [lldb] [Process/Linux] Reuse NativeRegisterContextWatchpoint_x86
Differential Revision: https://reviews.llvm.org/D90119
2020-10-26 11:55:22 +01:00
Michał Górny a890237665 [lldb] [Process/NetBSD] Set xs_xstate_bv correctly when setting regs
Ensure that xs_xstate_bv is set correctly before calling
WriteRegisterSet().  The bit can be clear if the relevant registers
were at their initial state when they were read, and it needs to be set
in order to apply changes from the XState structure.

Differential Revision: https://reviews.llvm.org/D90105
2020-10-26 11:54:40 +01:00
Michał Górny 37d4d3bb4d [lldb] [test/Register] Use initial state for write tests
Reset registers to their 'initial' state instead of a semi-random
pattern in write tests.  While the latter might have been helpful
while debugging failures (i.e. to distinguish unmodified registers
from mistakenly written zeroes), the former makes it possible to test
whether xstate_bv field is written correctly when using XSAVE.

With this change, the four relevant tests start failing on NetBSD
without D90105.

Differential Revision: https://reviews.llvm.org/D90114
2020-10-26 11:54:00 +01:00
Michał Górny 7acf2e2e1e [lldb] [Process/FreeBSDRemote] Fix #include for i386 compat
Include <x86/fpu.h> rather than <machine/fpu.h>, as the latter is not
present on i386.

Differential Revision: https://reviews.llvm.org/D90128
2020-10-26 11:53:26 +01:00
Michał Górny d96cb52830 [lldb] [Process/NetBSD] Use XStateRegSet for all FPU registers
Unify the x86 regset API to use XStateRegSet for all FPU registers,
therefore eliminating the legacy API based on FPRegSet.  This makes
the code a little bit simpler but most notably, it provides future
compatibility for register caching.

Since the NetBSD kernel takes care of providing compatibility with
pre-XSAVE processors, PT_{G,S}ETXSTATE can be used on systems supporting
only FXSAVE or even plain FSAVE (and unlike PT_{G,S}ETXMMREGS, it
clearly indicates that XMM registers are not supported).

Differential Revision: https://reviews.llvm.org/D90034
2020-10-24 09:17:53 +02:00
Martin Storsjö 84ce6b9991 [lldb] Fix building with GCC 7. NFC. 2020-10-24 09:33:01 +03:00
David Blaikie 0b05732045 fix lldb for recent libDebugInfoDWARF API change 2020-10-23 19:20:38 -07:00
Walter Erquinigo 48d8af9825 [intel-pt] Disable/Enable tracing to guarantee the trace is correct
As mentioned in the comment inside the code, the Intel documentation
states that the internal CPU buffer is flushed out to RAM only when tracing is
disabled. Otherwise, the buffer on RAM might be stale.

This diff disables tracing when the trace buffer is going to be read. This is a
quite safe operation, as the reading is done when the inferior is paused at a
breakpoint, so we are not losing any packets because there's no code being
executed.

After the reading is finished, tracing is enabled back.

It's a bit hard to write a test for this now, but Greg Clayton and I will
refactor the PT support and writing tests for it will be easier. However
I tested it manually by doing a script that automates
the following flow

```
(lldb) b main
Breakpoint 1: where = a.out`main + 15 at main.cpp:4:7, address = 0x000000000040050f
(lldb) r
Process 3078226 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x000000000040050f a.out`main at main.cpp:4:7
(lldb) processor-trace start
(lldb) b 5
Breakpoint 2: where = a.out`main + 22 at main.cpp:5:12, address = 0x0000000000400516
(lldb) c
Process 3078226 resuming
Process 3078226 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 2.1
frame #0: 0x0000000000400516 a.out`main at main.cpp:5:12
(lldb) processor-trace show-instr-log
thread #1: tid=3078226
0x40050f <+15>: movl $0x0, -0x8(%rbp)

>>> Before, some runs of the script up to this point lead to empty traces

(lldb) b 6
Breakpoint 3: where = a.out`main + 42 at main.cpp:6:14, address = 0x000000000040052a
(lldb) c
Process 3092991 resuming
Process 3092991 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 3.1
frame #0: 0x000000000040052a a.out`main at main.cpp:6:14
(lldb) processor-trace show-instr-log thread #1: tid=3092991
0x40050f <+15>: movl $0x0, -0x8(%rbp)
0x400516 <+22>: movl $0x0, -0xc(%rbp)
0x40051d <+29>: cmpl $0x2710, -0xc(%rbp) ; imm = 0x2710
0x400524 <+36>: jge 0x400546 ; <+70> at main.cpp
0x400524 <+36>: jge 0x400546 ; <+70> at main.cpp

>>> The trace was re-enabled correctly and includes the instruction of the
first reading.
```
Those instructions correspond to these lines
```
3 int main() {
4 int z = 0;
5 for (int i = 0; i < 10000; i++) {
6 z += fun(z)
...
```

Differential Revision: https://reviews.llvm.org/D85241
2020-10-23 16:36:42 -07:00
Jonas Devlieghere 73811d32c7 [lldb] Move copying of files into reproducer out of process
For performance reasons the reproducers don't copy the files captured by
the file collector eagerly, but wait until the reproducer needs to be
generated.

This is a problematic when LLDB crashes and we have to do all this
signal-unsafe work in the signal handler. This patch uses a similar
trick to clang, which has the driver invoke a new cc1 instance to do all
this work out-of-process.

This patch moves the writing of the mapping file as well as copying over
the reproducers into a separate process spawned when lldb crashes.

Differential revision: https://reviews.llvm.org/D89600
2020-10-23 12:33:54 -07:00
Jonas Devlieghere a4459feca4 [lldb] Fix use of undefined type 'lldb_private::UtilityFunction'
We were returning the default constructed unique_pointer from
TypeSystem.h for which the compiler does not have a definition. Move the
implementation into the cpp file.
2020-10-23 11:48:11 -07:00
Jonas Devlieghere de346cf2ac [lldb] Redesign Target::GetUtilityFunctionForLanguage API
This patch redesigns the Target::GetUtilityFunctionForLanguage API:

 - Use a unique_ptr instead of a raw pointer for the return type.
 - Wrap the result in an llvm::Expected instead of using a Status object as an I/O parameter.
 - Combine the action of "getting" and "installing" the UtilityFunction as they always get called together.
 - Pass std::strings instead of const char* and std::move them where appropriate.

There's more room for improvement but I think this tackles the most
prevalent issues with the current API.

Differential revision: https://reviews.llvm.org/D90011
2020-10-23 10:00:23 -07:00
Michał Górny dae7b10034 [lldb] Split out NetBSD/x86 watchpoint impl for unification
Split the current NetBSD watchpoint implementation for x86 into Utility,
and revamp it to improve readability.  This code is meant to be used
as a common class for all x86 watchpoint implementation, particularly
these on FreeBSD and Linux.

The code uses global watchpoint enable bits, as required by the NetBSD
kernel.  If it ever becomes necessary for any platform to use local
enable bits instead, this can be trivially abstracted out.

The code also postpones clearing DR6 until a new different watchpoint
is being set in place of the old one.  This is necessary since LLDB
repeatedly reenables watchpoints on all threads, by clearing
and restoring them.  When DR6 is cleared as a part of that, then pending
events on other threads can no longer be associated with watchpoints
correctly.

Differential Revision: https://reviews.llvm.org/D89874
2020-10-23 12:20:15 +02:00
Jonas Devlieghere 3590a8319a [lldb] Fix bug instroduced by a00acbab45
g_expression_prefix, as the name implies, must be perfixed, not
suffixed.
2020-10-22 22:17:11 -07:00
Jonas Devlieghere a00acbab45 [lldb] Fix missing initialization in UtilityFunction ctor (NFC)
The UtilityFunction ctor was dropping the text argument. Probably for
that reason ClangUtilityFunction was setting the parent's member
directly instead of deferring to the parent ctor. Also change the
signatures to take strings which are std::moved in place.
2020-10-22 21:12:27 -07:00
Raphael Isemann 5dc70332d5 Revert "[lldb] Explicitly use the configuration architecture when building test executables"
This reverts commit 41185226f6.

Causes TestQuoting to fail on Windows.
2020-10-22 18:42:19 +02:00
Med Ismail Bennani efe62b637d [lldb/DWARF] Add support for DW_OP_implicit_value
This patch completes https://reviews.llvm.org/D83560. Now that the
compiler can emit `DW_OP_implicit_value` into DWARF expressions, lldb
needed to learn reading these opcodes for variable inspection and
expression evaluation.

This implicit location descriptor specifies an immediate value with two
operands: the length (ULEB128) followed by a block representing the value
in the target memory representation.

rdar://67406091

Differential revision: https://reviews.llvm.org/D89842

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-10-22 18:02:44 +02:00
Jonas Devlieghere 826997c462 [lldb] Fix a regression introduced by D75730
In a new Range class was introduced to simplify and the Disassembler API
and reduce duplication. It unintentionally broke the
SBFrame::Disassemble functionality because it unconditionally converts
the number of instructions to a Range{Limit::Instructions,
num_instructions}. This is subtly different from the previous behavior,
where now we're passing a Range and assume it's valid in the callee, the
original code would propagate num_instructions and the callee would
compare the value and decided between disassembling instructions or
bytes.

Unfortunately the existing tests was not particularly strict:

  disassembly = frame.Disassemble()
  self.assertNotEqual(len(disassembly), 0, "Disassembly was empty.")

This would pass because without this patch we'd disassemble zero
instructions, resulting in an error:

  (lldb) script print(lldb.frame.Disassemble())
  error: error reading data from section __text

Differential revision: https://reviews.llvm.org/D89925
2020-10-22 08:38:03 -07:00
Raphael Isemann 30d5590d17 [lldb] Fix TestTargetAPI.py on Apple simulators
This test checks that the output of `SBTarget.GetDescription()` contains the
substrings `'a.out', 'Target', 'Module', 'Breakpoint'` in that order. This test
is currently failing on Apple simulators as apparently 'Module' can't be found
in the output after 'Target".

The reason for that is that the actual output of `SBTarget.GetDescription()` looks like this:
```
Target
  Module /build/path/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_description_dwarf/a.out
0x7ff2b6d3f990:     ObjectFileMachO64, file = /build/path/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_description
[...]
0x7ff307150000:   BreakpointList with 0 Breakpoints:
<LLDB module output repeats for each loaded module>
```

Clearly the string order should be `'Target', 'Module', 'a.out', 'Breakpoint'`.
However, LLDB is also a bunch of system shared libraries (libxpc.dylib,
libobjc.A.dylib, etc.) when *not* running against a simulator, we end up
unintentionally finding the `'Target', 'Module', 'Breakpoint'` substrings in the
trailing descriptions of the system modules. When running against a simulator we
however don't load shared system libraries.

This patch just moves the substrings in the correct order to make this test pass
without having any shared library modules in the description output.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D89698
2020-10-22 16:41:54 +02:00
Raphael Isemann 41185226f6 [lldb] Explicitly use the configuration architecture when building test executables
The Darwin builder currently assumes in `getArchCFlags` that the passed `arch`
value is an actual string it can string.join with vendor/os/version/env strings:

```
   triple = '-'.join([arch, vendor, os, version, env])
```

However this is not true for most tests as we just pass down the `arch=None`
default value from `TestBase.build`. This causes that if we actually end up in
this function we just error out when concatenating `None` with the other actual
strings of vendor/os/version/env. What we should do instead is check that if
there is no test-specific architecture that we fall back to the configuration's
architecture value.

It seems we already worked around this in `builder.getArchSpec` by explicitly
falling back to the architecture specified in the configuration.

This patch just moves this fallback logic to the top `build` function so that it
affects all functions called from `TestBase.build`.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D89056
2020-10-22 15:30:25 +02:00
Raphael Isemann bb1d702e25 [lldb][NFC] Make GetShellSafeArgument return std::string and unittest it. 2020-10-22 14:47:10 +02:00
Pavel Labath d900b755ed [lldb] Fix windows build for fa5fa63fd1 2020-10-21 17:51:11 +02:00
Christopher Tetreault 26459e6d8e Fix "Unknown arguments specified" to if in lldb
Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D89807
2020-10-21 07:24:53 -07:00
Pavel Labath fa5fa63fd1 [lldb] Port lldb gdb-server to libOption
The existing help text was very terse and was missing several important
options. In the new version, I add a short description of each option
and a slightly longer description of the tool as a whole.

The new option list does not include undocumented no-op options:
--debug and --verbose. It also does not include undocumented short
aliases for long options, with two exceptions: -h, because it's
well-known; and -S (--setsid), as it's used in one test. Using these
options will now produce an error. I believe that is acceptable as users
aren't generally invoking lldb-server directly, and the only way to
learn about the short aliases was by looking at the source.

Differential Revision: https://reviews.llvm.org/D89477
2020-10-21 16:16:18 +02:00
Sylvestre Ledru 0784e17f1b Remove .svn from exclude list as we moved to git
Reviewed By: emaste

Differential Revision: https://reviews.llvm.org/D89859
2020-10-21 16:09:21 +02:00
Jan Kratochvil 7bf066a20f [nfc] [lldb] Fix harmless slicing of DWARFDIE
Differential Revision: https://reviews.llvm.org/D89875
2020-10-21 15:49:53 +02:00
Jonas Devlieghere c565f09f4b [lldb] Don't strip LLDB.framework on install
The framework build will run dsymutil after LLDB.framework is installed.
2020-10-20 18:16:36 -07:00
Jonas Devlieghere de6f3d1c71 [lldb] Add a page to the docs with (external) links on how to use LLDB
In a discussion with Jim last week we came to the realization that often
we get asked about things that might not be documented on the website,
but that have been pretty well explained elsewhere. In those situations
it's often easier to quickly answer the question than searching for that
presentation you gave 3 years ago if you remember at all.

This often results in us having to answer the same questions over and
over again. We could add the questions and their answer to the website,
but that means we (1) have to duplicate the work and (2) now have to
maintain it.

A more efficient solution is to add a page with external resources with
the caveat that they might be outdated. That's exactly the purpose of
this patch.

I've added a few links that came to mind, but I don't want to be the
arbiter of what should and should not be included. I'd hope that over
time the community can crowd-source the best resources.

Differential revision: https://reviews.llvm.org/D89215
2020-10-20 11:43:31 -07:00
Duncan P. N. Exon Smith b333d6e129 lldb: Migrate to MemoryBufferRef for createFileID (after 51d1d585e5)
I missed these two lldb users before deleting the `UnownedTag` API for
`createFileID` in 51d1d585e5. This should
fix the build.
2020-10-20 13:52:39 -04:00
Jason Molenda c932266c8d Add a nul byte to packet str before logging, increase default size.
Add a nul byte to the stream in CommunicationKDP::CheckForPacket
before we send the GetData() to a Log::Printf as a c-str.  Avoids
a crash when logging kdp communications and memory layout isn't
in your favor.
2020-10-20 01:43:31 -07:00
Duncan P. N. Exon Smith f96e16bc15 lldb: Update for change in `clang::Lexer`'s constructor
b3eff6b7bb updated `Lexer::Lexer` to take
`clang::MemoryBufferRef` instead of `clang::MemoryBuffer*`. Update LLDB
to fix the bots.
2020-10-19 20:09:27 -04:00
Walter Erquinigo 8a203bb22d [trace] rename ThreadIntelPT into TraceTrace
Renamed ThreadIntelPT to TreaceThread, making it a top-level class. I noticed that this class can and shuld work for any trace plugin and there's nothing intel-pt specific in it.
With that TraceThread change, I was able to move most of the json file parsing logic to the base class TraceSessionFileParser, which makes adding new plug-ins easier.

This originally was part of https://reviews.llvm.org/D89283

Differential Revision: https://reviews.llvm.org/D89408
2020-10-19 15:15:02 -07:00
Alexandre Ganea 89b72209ad [LLDB][TestSuite] Improve skipIfWindowsAndNonEnglish in decorators.py
Differential Revision: https://reviews.llvm.org/D89716
2020-10-19 14:28:08 -04:00
Jan Kratochvil 0e5248be86 [nfc] [lldb] Move LookupAddress to DWARFCompileUnit
LookupAddress makes no sense for DWARFTypeUnit.
Also make GetNonSkeletonUnit to preserve the called type.

Differential Revision: https://reviews.llvm.org/D89646
2020-10-19 12:44:33 +02:00
Pavel Labath dfb2266328 [lldb] Make DW_AT_declaration-with-children.s test more realistic
(Re)add DW_AT_specification and DW_AT_object_pointer attributes. These
were removed in fa89f641c, as they were bogus due to bad test case
reduction.
2020-10-19 10:34:13 +02:00
Jan Kratochvil fa89f641cf [nfc] [lldb] [testsuite] Fix DW_FORM_ref* in DW_AT_declaration-with-children.s .
There were invalid DIE references which nobody used. If LLDB starts to
report invalid DIE references it would lock up (mutex lock).

These invalid DIE references are there since initial check-in by:
  https://reviews.llvm.org/D83302
2020-10-18 16:57:27 +02:00
Jan Kratochvil 224caaf69b [nfc] [lldb] Delete an empty trailing line.
A patchset being prepared shows needless diffs.
2020-10-18 10:16:00 +02:00
Dave Lee ae4fe1984f [lldb] Enable cmake policy CMP0077 for option()
In lldb, explicitly set the "option() honors normal variables" CMake policy. This applies for
standalone lldb builds and matches what llvm, clang, etc do. This prevents potentially unwanted
clearing of variables like `LLVM_ENABLE_WARNINGS`, and also prevents unnecessary build warnings.

See: https://cmake.org/cmake/help/latest/policy/CMP0077.html

Differential Revision: https://reviews.llvm.org/D89614
2020-10-17 00:16:24 -07:00
Jason Molenda 32021eeff0 Un-indent the section on 'Writing Target Stop-Hooks in Python'
it was ending up in a code block from the previous section,
instead of being its own section.
2020-10-16 23:23:25 -07:00
Sriraman Tallam 2e5b701d93 This test includes a source that will produce basic blocks and hence sections with -fbasic-block-sections=all.
The test reorders the basic blocks to be dis-contiguous in the address space and checks if the back trace contains the right symbol.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D89179
2020-10-16 21:31:42 -07:00
Dave Lee f16cecf375 [lldb] Implement ObjCExceptionThrowFrameRecognizer::GetName()
Implement `GetName` for `ObjCExceptionThrowFrameRecognizer`. Otherwise, `frame recognizer list` shows "(internal)" for the name.

Differential Revision: https://reviews.llvm.org/D89589
2020-10-16 14:24:03 -07:00
Adrian Prantl cf24508651 Add support for more OS types to AddClangModuleCompilationOptionsForSDKType()
This patch also avoids hardcoding the clang options, which makes it
less likely for them to become out-of-date.

rdar://problem/63791367+66927829

Differential Revision: https://reviews.llvm.org/D89428
2020-10-16 11:43:22 -07:00
Joseph Tremoulet d30797b404 [lldb] Minidump: check for .text hash match with directory
When opening a minidump, we might discover that it reports a UUID for a
module that doesn't match the build ID, but rather a hash of the .text
section (according to either of two different hash functions, used by
breakpad and Facebook respectively).  The current logic searches for a
module by filename only to check the hash; this change updates it to
first search by directory+filename.  This is important when the
directory specified in the minidump must be interpreted relative to a
user-provided sysoort, as the leaf directory won't be in the search path
in that case.

Also add a regression test; without this change, module validation fails
because we have just the placeholder module which reports as its path
the platform path in the minidump.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D89155
2020-10-16 09:32:08 -04:00
Pavel Labath daae4a8482 [lldb] Modernize PseudoTerminal::OpenSecondary 2020-10-16 15:22:55 +02:00
Pavel Labath e338ca7bce [lldb] Fix FreeBSD build for ea3a547 2020-10-16 13:50:53 +02:00
Jim Ingham 6754caa9bf Add an SB API to get the SBTarget from an SBBreakpoint
Differential Revision: https://reviews.llvm.org/D89358
2020-10-15 14:28:44 -07:00
Michał Górny 87d38831d9 [lldb] [Process/FreeBSDRemote] Initial multithreading support
Implement initial support for watching thread creation and termination.
Update ptrace() calls to correctly indicate requested thread.
Watchpoints are not supported yet.

This patch fixes at least multithreaded register tests.

Differential Revision: https://reviews.llvm.org/D89413
2020-10-15 17:37:37 +02:00
Raphael Isemann 82ed18601d [lldb] Explicitly test the template argument SB API 2020-10-15 11:17:43 +02:00
Jason Molenda af5504edd6 Increase timeout to find a dSYM in macos DownloadObjectAndSymbolFile
With a large dSYM over a slow home connection, the two minute timeout
would sometimes be exceeded, and we haven't seen instances of a
long timeout causing people any problems, so we're bumping it up.

640 seconds ought to be enough for anyone.

<rdar://problem/67759526>
2020-10-15 00:57:23 -07:00
Jason Molenda b19856881c Fix typeo in attach failed error message.
<rdar://problem/70296751>
2020-10-14 23:31:24 -07:00
Pavel Labath a1ab2b773b [lldb] More memory allocation test fixes
XFAIL nodefaultlib.cpp on darwin - the test does not pass there

XFAIL TestGdbRemoteMemoryAllocation on windows - memory is allocated
with incorrect permissions
2020-10-14 20:43:47 +02:00
Michał Górny ff30bff136 [lldb] [Process/FreeBSDRemote] Support YMM reg via PT_*XSTATE
Add a framework for reading/writing extended register sets via
PT_GETXSTATE/PT_GETXSTATE_INFO/PT_SETXSTATE, and use it to support
YMM0..YMM15.  The code is prepared to handle arbitrary XSAVE extensions,
including correct offset handling.

This fixes Shell/Register/*ymm* tests.

Differential Revision: https://reviews.llvm.org/D89193
2020-10-14 19:56:46 +02:00
Pavel Labath 36f22cd28d [lldb] Fix TestGdbRemoteMemoryAllocation on windows
It appears that memory allocation actually works on windows (but it was
not fully wired up before 2c4226f8).
2020-10-14 16:46:10 +02:00
Pavel Labath ea3a547f0b [lldb] Remove bogus ProcessMonitor forward-decls
This class is not used in those files.
2020-10-14 16:43:45 +02:00
Pavel Labath 2c4226f8ac [lldb-server][linux] Add ability to allocate memory
This patch adds support for the _M and _m gdb-remote packets, which
(de)allocate memory in the inferior. This works by "injecting" a
m(un)map syscall into the inferior. This consists of:
- finding an executable page of memory
- writing the syscall opcode to it
- setting up registers according to the os syscall convention
- single stepping over the syscall

The advantage of this approach over calling the mmap function is that
this works even in case the mmap function is buggy or unavailable. The
disadvantage is it is more platform-dependent, which is why this patch
only works on X86 (_32 and _64) right now. Adding support for other
linux architectures should be easy and consist of defining the
appropriate syscall constants. Adding support for other OSes depends on
the its ability to do a similar trick.

Differential Revision: https://reviews.llvm.org/D89124
2020-10-14 15:02:09 +02:00
Pavel Labath 6bb123b819 [lldb] Modernize PseudoTerminal::OpenFirstAvailablePrimary
replace char*+length combo with llvm::Error
2020-10-14 14:55:03 +02:00
Michał Górny caedbc317a [lldb] [test/Register] Add read/write tests for multithreaded process
Add a test to verify that 'register read' and 'register write' commands
work correctly in a multithreaded program, in particular that they read
or write registers for the correct thread.  The tests use locking
to ensure that events are serialized and the test can execute reliably.

Differential Revision: https://reviews.llvm.org/D89248
2020-10-14 11:08:36 +02:00
Raphael Isemann cb81e662a5 [lldb] Reject redefinitions of persistent variables
Currently one can redefine a persistent variable and LLDB will just silently
ignore the second definition:

```
(lldb) expr int $i = 1
(lldb) expr int $i = 2
(lldb) expr $i
(int) $i = 1
```

This patch makes this an error and rejects the expression with the second
definition.

A nice follow up would be to refactor LLDB's persistent variables to not just be
a pair of type and name, but also contain some way to obtain the original
declaration and source code that declared the variable. That way we could
actually make a full diagnostic as we would get from redefining a variable twice
in the same expression.

Reviewed By: labath, shafik, JDevlieghere

Differential Revision: https://reviews.llvm.org/D89310
2020-10-14 10:24:35 +02:00
Jonas Devlieghere 3b33b41604 [lldb] Remove lexical block and fix formatting LoadScriptingModule (NFC) 2020-10-13 23:50:57 -07:00
Jonas Devlieghere 1197ee35b8 [lldb] Unconditionally strip the `.py(c)` extension when loading a module
Currently we only strip the Python extension when the file exists on
disk because we assumed that if it didn't exist it was a module.
However, with the change from D89334 this is no longer the case as we
want to be able to import a relative path to a .py as a module. Since we
always import a scripting module as a "python module" we should always
strip the extension if present.

Differential revision: https://reviews.llvm.org/D89352
2020-10-13 23:50:57 -07:00
Adrian Prantl f9586a3b3c Replace bool constants with named constants for improved readibility (NFC) 2020-10-13 17:41:26 -07:00
Adrian Prantl 9b1c06c0e8 Move initialization of Variable::m_loc_is_const_data into constructor (NFC)
This makes it symmetric with all other flags and makes it easier to
not forget to initialize it.

https://reviews.llvm.org/D89351
2020-10-13 17:01:28 -07:00
Jason Molenda 7d67c06391 Remove unused build configurations from debugserver xcode project
the xcode project file for debugserver exists only to make my
life easier when I'm working only on debugserver and don't need
to build the rest of llvm/lldb.  It had many build configurations
to reflect our old lldb xcode project file, which is long gone.
Removing them to simplify the configurations.

Specifically dropping CustomSwift-Debug, DebugClang, DebugPresubmission,
CustomSwift-Release, BuildAndIntegration.  Keeping Debug & Release.
2020-10-13 16:39:30 -07:00
Jason Molenda e763709d14 Add a new launch flag option for watchos, WatchComplicationLaunch.
Link against CarouselServices on watchos, recognize the
WatchComplicationLaunch launch flag option when that framework
is available.

<rdar://problem/62473967>, <rdar://problem/61230088>
2020-10-13 16:28:16 -07:00
Raphael Isemann 6733b25447 [lldb][cmake] Remove custom logic for finding VCS file to fix LLDB's VCSVersion.inc generation
We are still implementing our own logic for this that looks for a VCS file in
the place where it was before the monorepo migration. This removes this logic
and just uses the CMake function that LLVM/Clang are using.

Reviewed By: JDevlieghere, kastiglione

Differential Revision: https://reviews.llvm.org/D88950
2020-10-13 17:14:43 +02:00
Raphael Isemann 02114e15da [lldb] Allow limiting the number of error diagnostics when parsing an expression
While debugging another bug I found out that we currently don't set any limit
for the number of diagnostics Clang emits. If a user does something that
generates a lot of errors (like including some long header file from within the
expression function), then we currently spam the LLDB output with potentially
thousands of Clang error diagnostics.

Clang sets a default limit of 20 errors, but given that LLDB is often used
interactively for small expressions I would say a limit of 5 is enough. The
limit is implemented as a setting, so if a user cares about seeing having a
million errors printed to their terminal then they can just increase the
settings value.

Reviewed By: shafik, mib

Differential Revision: https://reviews.llvm.org/D88889
2020-10-13 17:12:43 +02:00
Raphael Isemann 24e07570cc [lldb] Remove all the RegisterInfo name constification code
RegisterInfo's `reg_name`/`reg_alt_name` fields are C-Strings and are supposed
to only be generated from a ConstString. The reason for that is that
`DynamicRegisterInfo::GetRegisterInfo` and
`RegInfoBasedABI::GetRegisterInfoByName` try to optimise finding registers by
name by only comparing the C string pointer values instead of the underlying
strings. This only works if both C strings involved in the comparison come from
a ConstString. If one of the two C strings doesn't come from a ConstString the
comparison won't work (and most likely will silently fail).

I added an assert in b0060c3a78 which checks that
both strings come from a ConstString. Apparently not all ABI plugins are
generating their register names via ConstString, so this code is now not just
silently failing but also asserting.

In D88375 we did a shady fix for the MIPS plugins by just copying the
ConstString setup code to that plugin, but we still need to fix ABISysV_arc,
ABISysV_ppc and ABISysV_ppc64 plugins.

I would say we just fix the remaining plugins by removing the whole requirement
to have the register names coming from ConstStrings. I really doubt that we
actually save any time with the whole ConstString search trick (searching ~50
strings that have <4 characters doesn't sound more expensive than calling the
really expensive ConstString constructor + comparing the same amount of pointer
values). Also whatever small percentage of LLDB's runtime is actually spend in
this function is anyway not worth the complexity of this approach.

This patch just removes all this and just does a normal string comparison.

Reviewed By: JDevlieghere, labath

Differential Revision: https://reviews.llvm.org/D88490
2020-10-13 17:10:29 +02:00