Commit Graph

22372 Commits

Author SHA1 Message Date
Walter Erquinigo 576105c322 [lldb-vscode] stop read loop after termination
Summary:
On Linux, when executing lldb-vscode on a remote machine, lldb-vscode doesn't die after the debug session ends. It keeps trying to read JSON input to no avail.
This diff indicates lldb-vscode to stop reading after a termination event has been processed.

Reviewers: clayborg, aadsm, kusmour

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76314
2020-03-20 14:38:49 -07:00
Davide Italiano 696ae6f7d8 [StopHook] Use wildcard matching. Pointed out by Jim Ingham. 2020-03-20 13:57:40 -07:00
Davide Italiano 6385c2ab8f [AppleObjCRuntimeV2] Force lazily allocated class names to be resolved.
Fixes a couple of tests on new versions of the Obj-C runtime.
2020-03-20 13:43:08 -07:00
Sterling Augustine 5de4ba1770 Cleanup the plumbing for DILineInfoSpecifier. [NFC - Try 2] 2020-03-20 10:29:57 -07:00
Anton Kolesov 0b18b568e9 [lldb-vscode] Don't use SBLaunchInfo in request_attach
If LLDB attaches to an already running target, then structure SBAttachInfo is
used instead of SBLaunchInfo. lldb-vscode function request_attach sets some
values to g_vsc.launch_info, however this field is then not passed anywhere, so
this action has no effect. This commit removes invocation of
SBLaunchInfo::SetDetachOnError, which has no equivalent in SBAttachInfo.

File package.json doesn't describe detachOnError property for "attach" request
type, therefore it is not needed to update it.

Differential Revision: https://reviews.llvm.org/D76351
2020-03-20 20:15:23 +03:00
Jaroslav Sevcik 089cfe113d Improve step over performance
Summary:
This patch improves step over performance for the case when we are
stepping over a call with a next-branch-breakpoint (see
https://reviews.llvm.org/D58678), and we encounter a stop during the
call. Currently, this causes the thread plan to step-out //each frame//
until it reaches the step-over range. This is a regression introduced by
https://reviews.llvm.org/D58678 (which did improve other things!). Prior
to that change, the step-over plan would always step-out just once.

With this patch, if we find ourselves stopped in a deeper stack frame
and we already have a next branch breakpoint, we simply return from the
step-over plan's ShouldStop handler without pushing the step out plan.

In my experiments this improved the time of stepping over a call that
loads 12 dlls from 14s to 5s. This was in remote debugging scenario with
10ms RTT, the call in question was Vulkan initialization
(vkCreateInstance), which loads various driver dlls. Loading those dlls
must stop on the rendezvous breakpoint, causing the perf problem
described above.

Reviewers: clayborg, labath, jingham

Reviewed By: jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76216
2020-03-20 11:41:56 +01:00
Raphael Isemann 467c4902a1 [lldb] Enable now passing part of TestDataFormatterStdString.py
This was fixed by 7b2442584e .
2020-03-20 11:35:15 +01:00
Jonas Devlieghere 90308a4da1 [debugserver] Implement hardware breakpoints for ARM64
Add support for hardware breakpoints on ARM64.

Differential revision: https://reviews.llvm.org/D76411
2020-03-19 11:55:48 -07:00
Raphael Isemann 7b2442584e Reland [lldb] Fix string summary of an empty NSPathStore2
(This is D68010 but I also set the new parameter in LibStdcpp.cpp to fix
the Debian tests).

Summary:
Printing a summary for an empty NSPathStore2 string currently prints random bytes behind the empty string pointer from memory (rdar://55575888).

It seems the reason for this is that the SourceSize parameter in the `ReadStringAndDumpToStreamOptions` - which is supposed to contain the string
length - actually uses the length 0 as a magic value for saying "read as much as possible from the buffer" which is clearly wrong for empty strings.

This patch adds another flag that indicates if we have know the string length or not and makes this behaviour dependent on that (which seemingly
was the original purpose of this magic value).

Reviewers: aprantl, JDevlieghere, shafik

Reviewed By: aprantl

Subscribers: christof, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68010
2020-03-19 18:50:26 +01:00
Raphael Isemann 50f1985353 [lldb][NFC] Delete the original UserExpression before trying to reparse it with FixIts.
Currently when an expression fails to parse and we have a FixIt, we keep
the failed UserExpression around while trying to parse the expression with
applied fixits. This means that we have this rather confusing control flow:

1. Original expression created and parsing attempted.
2. Expression with applied FixIts is created and parsing attempted.
3. Original expression is destroyed and parser deconstructed.
4. Expression with applied FixIts is destroyed and parser deconstructed.

This patch just deletes the original expression so that step 2 and 3 are
swapped and the whole process looks more like just sequentially parsing two
expressions (which is what we actually do here).

Doesn't fix anything just makes the code less fragile.
2020-03-19 18:10:57 +01:00
Fred Riss 76a5451a52 [lldb/testsuite] un-XFail TestInlineStepping.py on linux and windows
It looks like my tweak in ecc6c42697 made the test pass on windows
and the linux aarch64 bot.
2020-03-19 09:24:11 -07:00
Jonas Devlieghere 99a0cbb423 [lldb/Test] Remove debug print in supports_hw_breakpoints. 2020-03-19 08:35:22 -07:00
Fred Riss 8758d02074 [lldb/testsuite] Skip part of TestProcessCrashInfo.py on Darwin embedded
See https://reviews.llvm.org/D76407 for discussion.
2020-03-19 08:26:00 -07:00
Fred Riss ecc6c42697 [lldb/testsuite] Fix TestInlineStepping on arm64 with newer compilers
Summary:
TestInlineStepping tests LLDB's ability to step in the presence of
inline frames. The testcase source has a number of functions and some
of them are marked `always_inline`.

The test is built around the assumption that the inline function will
be fully represented once inlined, but this is not true with the
current arm64 code generation. For example:

void caller() {
     always_inline_function(); // Step here
}

When stppeing into `caller()` above, you might immediatly end up in
the inlines frame for `always_inline_function()`, because there might
literally be no code associated with `caller()` itself.

This patch hacks around the issue by adding an `asm volatile("nop")`
on some lines with inlined calls where we expect to be able to
step. Like so:

void caller() {
     asm volatile("nop"); always_inline_function(); // Step here
}

This guarantees there is always going to be one instruction for this
line in the caller.

Reviewers: labath, jingham

Subscribers: kristof.beyls, danielkiss, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76406
2020-03-19 08:25:59 -07:00
Fred Riss e154cbb124 [lldb/testsuite] XFail TestBuiltinTrap.py not only on linux
Summary:
TestBuiltinTrap fail on darwin embedded because the `__builin_trap`
builtin doesn't get any line info attached to it by clang when
building for arm64.

The test was already XFailed for linux arm(64), I presume for the same
reasons. This patch just XFails it independently of the platform.

Reviewers: labath

Subscribers: kristof.beyls, danielkiss, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76408
2020-03-19 08:25:59 -07:00
Konrad Kleine 44361782e2 [lldb] fix typo in comment for lldbtest.py 2020-03-19 10:08:11 -04:00
Djordje Todorovic d9b9621009 Reland D73534: [DebugInfo] Enable the debug entry values feature by default
The issue that was causing the build failures was fixed with the D76164.
2020-03-19 13:57:30 +01:00
Raphael Isemann 718d94187d Revert "[lldb] Fix string summary of an empty NSPathStore2"
This reverts commit 939ca455e7.

This failed on the debian bot for some reason:
  File "/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py", line 67, in test_with_run_command
    "s summary wrong")
AssertionError: 'L"hello world! מזל טוב!\\0!\\0!!!!\\0\\0A\\0\\U0000fffd\\U0000fffd\\U0000fffd\\ [truncated]... != 'L"hello world! מזל טוב!"'
Diff is 2156 characters long. Set self.maxDiff to None to see it. : s summary wrong
2020-03-19 13:08:39 +01:00
Raphael Isemann 939ca455e7 [lldb] Fix string summary of an empty NSPathStore2
Summary:
Printing a summary for an empty NSPathStore2 string currently prints random bytes behind the empty string pointer from memory (rdar://55575888).

It seems the reason for this is that the SourceSize parameter in the `ReadStringAndDumpToStreamOptions` - which is supposed to contain the string
length - actually uses the length 0 as a magic value for saying "read as much as possible from the buffer" which is clearly wrong for empty strings.

This patch adds another flag that indicates if we have know the string length or not and makes this behaviour dependent on that (which seemingly
was the original purpose of this magic value).

Reviewers: aprantl, JDevlieghere, shafik

Reviewed By: aprantl

Subscribers: christof, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68010
2020-03-19 12:20:35 +01:00
Jason Molenda 5d881dd8a8 Update so debugserver can be built on macos again with xcodebuild. 2020-03-18 21:46:20 -07:00
Fred Riss 59918d3793 [lldb/testsuite] Make TestObjCIvarStripped.py working with codesigning
This test was stripping a binary generated by Makefile.rules which is
potentially codesigned. Stripping invalidates the code signature, so
we might need to re-sign after stripping.
2020-03-18 20:52:28 -07:00
Fred Riss acd641c19d [lldb/testsuite] Slightly rework TestHiddenIvars.py
The test was stripping the binaries from the Python
code. Unfortunately, if running on darwin embedded in a context that
requires code signing, the stripping was invalidating the signature,
thus breaking the test.

This patch moves the stripping to the Makefile and resigns the
stripped binaries if required.
2020-03-18 20:52:28 -07:00
Fred Riss 71db787c45 [lldb/testsuite] Rewrite TestThreadLocal.py
It was an inline test before. Clang stopped emitting line information
for the TLS initialization and the inline test didn't have a way to
break before it anymore.

This rewrites the test as a full-fldeged python test and improves the
checking of the error case to verify that the failure we are looking
for is related to the TLS setup not being complete.
2020-03-18 20:52:28 -07:00
Fred Riss 127b9d9d77 [lldb/testsuite] Apply @skipIfDarwinEmbedded to part of TestHWBreakMultiThread
The comment in the test wrongfully claimed that we support hardware
breakpoints on darwin for arm64, but we never did.
2020-03-18 20:52:28 -07:00
Fred Riss c182be211a [lldb/testsuite] Tweak TestBreakpointLocations.py to pass for arm64
The test checks that we correctly set the right number of breakpoints
when breaking into an `always_inline` function. The line of this
funstion selected for this test was the return statement, but with
recent compiler, this return statement doesn't necessarily exist after
inlining, even at O0.

Switch the breakpoint to a different line of the inline function.
2020-03-18 20:52:28 -07:00
Fred Riss 52b2bae777 [lldb/testsuite] Skip TestEmptyStdModule.py if using a remote platform
The test runs `platform select host`, so it make no sense to run it
when remote debugging.
2020-03-18 20:52:28 -07:00
Davide Italiano f0ca0a2538 [AppleObjCRuntimeV2] Rewrite GetClassDescriptor, reducing indentation.
I'm going to modify this function to account for lazily allocated
class names in the Obj-C runtime, but first I need to understand
what it does.
2020-03-18 19:23:58 -07:00
Jonas Devlieghere 5ffb30fd6c [lldb/PlatformDarwin] Expose current toolchain and CL tools directory
Expose two methods to find the current toolchain and the current command
line tools directory. These are used by Swift to find the resource
directory.
2020-03-18 15:08:24 -07:00
Jonas Devlieghere 14970669dd [lldb/Test] Add unittest for FileSpec::operator bool() 2020-03-18 15:08:23 -07:00
Davide Italiano 85bd436961 [Host] Remove some code that's not needed anymore.
Discussed offline with Jason.
2020-03-18 14:44:53 -07:00
Fred Riss b40ee7ff1b [lldb/MemoryHistoryAsan] Fix address resolution for recorded backtraces
Summary:
The memory history plugin for Asan creates a HistoryThread with the
recorded PC values provided by the Asan runtime. In other cases,
thoses PCs are gathered by LLDB directly.

The PCs returned by the Asan runtime are the PCs of the calls in the
backtrace, not the return addresses you would normally get when
unwinding the stack (look for a call to GetPreviousIntructionPc in
AsanGetStack).

When the above addresses are passed to the unwinder, it will subtract
1 from each address of the non zero frames because it treats them as
return addresses. This can lead to the final report referencing the
wrong line.

This patch fixes this issue by threading a flag through HistoryThread
and HistoryUnwinder that tells them to treat every frame like the
first one. The Asan MemoryHistory plugin can then use this flag.

This fixes running TestMemoryHistory on arm64 devices, although it's
hard to guarantee that the test will continue to exhibit the boundary
condition that triggers this bug.

Reviewers: jasonmolenda, kubamracek

Subscribers: kristof.beyls, danielkiss, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76341
2020-03-18 13:18:02 -07:00
Jan Kratochvil 3481062bc6 [lldb] [testsuite] Enable forgotten -gsplit-dwarf for 2 testfiles
D63643 added these testfiles but some of the %t4dwo and %t5dwo builds
are the same as corresponding %t4 and %t5 builds. Fortunately the
testcases do PASS.

After just adding -gsplit-dwarf these both skeleton files:
  tools/lldb/test/SymbolFile/DWARF/Output/debug-types-expressions.test.tmp4dwo
  tools/lldb/test/SymbolFile/DWARF/Output/debug-types-expressions.test.tmp5dwo

were referencing to this one non-skeleton file:
  tools/lldb/test/SymbolFile/DWARF/debug-types-expressions.dwo

Surprisingly it does not affect the other test debug-types-basic.test
probably because it compiles to .o and then links it. While
debug-types-expressions.test compiles directly to an executable.

So fixed that while keeping the direct executable compilation.

Differential Revision: https://reviews.llvm.org/D76316
2020-03-18 15:49:24 +01:00
Med Ismail Bennani db31e2e1e6
[lldb/Target] Support more than 2 symbols in StackFrameRecognizer
This patch changes the way the StackFrame Recognizers match a certain
frame.

Until now, recognizers could be registered with a function
name but also an alternate symbol.
This change is motivated by a test failure for the Assert frame
recognizer on Linux. Depending the version of the libc, the abort
function (triggered by an assertion), could have more than two
signatures (i.e. `raise`, `__GI_raise` and `gsignal`).

Instead of only checking the default symbol name and the alternate one,
lldb will iterate over a list of symbols to match against.

rdar://60386577

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-03-18 14:15:58 +01:00
Jonas Devlieghere a11b330418 [lldb/Bindings] Check that process isn't None before calling is_alive.
Make sure that `process` is not None before calling is_alive. Otherwise
this might result in an AttributeError: 'NoneType' object has no
attribute 'is_alive'.

Although lldb.process and friends could already be None in the past, for
example after leaving an interactive scripting session, the issue became
more prevalent after `fc1fd6bf9fcfac412b10b4193805ec5de0e8df57`.

I audited the other interface files for usages of target, process,
thread and frame, but this seems the only place where a global is used
from an SB class.
2020-03-17 17:06:04 -07:00
Jonas Devlieghere 3829d85cc6 [lldb/PlatformDarwin] Return POSIX path from FindXcodeContentsDirectoryInPath
Always return a POSIX-style path from FindXcodeContentsDirectoryInPath
so that the output is identical on all host platforms.
2020-03-17 15:57:34 -07:00
Jonas Devlieghere 7aa28995e8 [lldb/PlatformDarwin] Be more robust in computing the SDK path with xcrun
The current implementation isn't very resilient when it comes to the
output of xcrun. Currently it cannot deal with:

 - Trailing newlines.
 - Leading newlines and errors/warnings before the Xcode path.
 - Xcode not being named Xcode.app.

This extract the logic into a helper in PlatformDarwin and fixes those
issues. It's also the first step towards removing code duplication
between the different platforms and downstream Swift.

Differential revision: https://reviews.llvm.org/D76261
2020-03-17 14:41:45 -07:00
shafik 9e2715aaac [lldb] Remove template parameters from FunctionTemplateDecl names
Fix to get the AST we generate for function templates closer to what clang generates and expects.
We fix which FuntionDecl we are passing to CreateFunctionTemplateSpecializationInfo and we strip
template parameters from the name when creating the FunctionDecl and FunctionTemplateDecl.

These two fixes together fix asserts and ambiguous lookup issues for several cases which are added to the already existing small function template test.
This fixes issues with overloads, overloads and ADL, variadic function templates and templated operator overloads.

Differential Revision: https://reviews.llvm.org/D75761
2020-03-17 11:00:23 -07:00
Raphael Isemann f95541839c [lldb] Tighten checks in TestStats.py
Just adding trailing newlines that "...: 1" doesn't match "...: 10".
2020-03-17 14:12:13 +01:00
Raphael Isemann 7c6e52ac0c [lldb] Ptrs->refs in CommandObjectExpression::EvaluateExpression parameters
The error_stream and result parameter were inconsistently checked for
being null, so we might as well make them references instead of crashing
in case someone passes a nullptr and hits one of the code paths that are
currently not doing a nullptr check on those parameters. Also change
output_stream for consistency.
2020-03-17 13:23:16 +01:00
Ayke van Laethem 0818e6cf1d
[LLDB] Add support for AVR breakpoints
I believe the actual opcode does not matter because the AVR architecture
is a Harvard architecture that does not support writing to program
memory. Therefore, debuggers and emulators provide hardware breakpoints.
But for some reason, this opcode must be defined or else LLDB will crash
with an assertion error.

Differential Revision: https://reviews.llvm.org/D74255
2020-03-17 13:17:48 +01:00
Raphael Isemann f5e0f8b10a [lldb] Add test for importing ObjC modules in a non-ObjC target
This was previously crashing due to a missing nullptr check (see
e2d8aa6bf7 ). This just adds a test that should
make sure this doesn't crash in case a user ends up in this strange setup.
2020-03-17 12:49:48 +01:00
Michał Górny 06489eaa92 [lldb] [Host/NetBSD] Rename Host.cpp to HostNetBSD.cpp
Rename NetBSD-specific Host.cpp to HostNetBSD.cpp to avoid basename
conflict with common/Host.cpp.
2020-03-17 11:42:39 +01:00
Jason Molenda 8aa07f81b8 Remove the old SecTaskAccess entry from debugserver's plist
<rdar://problem/60230324>
2020-03-16 21:54:32 -07:00
Adrian Prantl 90a2fbdb04 Switch to TypeSystemClang over to CreateDeserialized() (NFC)
which is the more appropriate API for its use-case.

Differential Revision: https://reviews.llvm.org/D75715
2020-03-16 18:11:36 -07:00
Jonas Devlieghere 88fbd8f9e7 [lldb/Reproducers] Decode run-length encoding in GDB replay server.
The GDB replay server sanity-checks that every packet it receives
matches what it expects from the serialized packet log. This mechanism
tripped for TestReproducerAttach.py on Linux, because one of the packets
(jModulesInfo) uses run-length encoding. The replay server was comparing
the expanded incoming packet with the unexpanded packet in the log. As a
result, it claimed to have received an unexpected packet, which caused
the test to fail.

This patch addresses that issue by expanding the run-length encoding
before comparing the packets.

Differential revision: https://reviews.llvm.org/D76163
2020-03-16 08:47:39 -07:00
Raphael Isemann e2d8aa6bf7 [lldb] Re-add nullptr check to IRForTarget::RewriteObjCConstString log statement
The nullptr check here was removed in 4ef50a33b1
when I replaced (nearly) all log->Print to LLDB_LOG calls (which automatically
check for this stuff). But it seems this one call escaped my sed call.

Currently working on a test that can cover this code path but we can revert
this until I have found one.
2020-03-16 16:28:36 +01:00
Tatyana Krasnukha 332edcc6bd [lldb] Remove unimplemented StackFrame::BehavesLikeZerothFrame
Commit [1] added a declaration of function-member
StackFrame::BehavesLikeZerothFrame but hasn't added an implementation
for the function. This commit removes this declation, because the
function is not used anywhere.

[1] 31e6dbe1c6 Fix PC adjustment in StackFrame::GetSymbolContext

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

Patch by Anton Kolesov <Anton.Kolesov@synopsys.com>
2020-03-16 16:20:12 +03:00
Tatyana Krasnukha 0a840ef800 [lldb] Copy m_behaves_like_zeroth_frame on stack frame update
Fix to code from https://reviews.llvm.org/D64993.

Field StackFrame::m_behaves_like_zeroth_frame was introduced in commit
[1], however that commit hasn't added a copying of the field to
UpdatePreviousFrameFromCurrentFrame, therefore the value wouldn't change
when updating frames to reflect the current situation.

The particular scenario, where this matters is following. Assume we have
function main that invokes function func1. We set breakpoint at
func1 entry and in main after the func1 call, and do not stop at
the main entry. Therefore, when debugger stops for the first time,
func1 is frame#0, while main is frame#1, thus
m_behaves_like_zeroth_frame is set to 0 for main frame. Execution is
resumed, and stops now in main, where it is now frame#0. However while
updating the frame object, m_behaves_like_zeroth_frame remains false.
This field plays an important role when calculating line information for
backtrace: for frame#0, PC is the current line, therefore line
information is retrieved for PC, however for all other frames this is
not the case - calculated PC is a return-PC, i.e. instruction after the
function call line, therefore for those frames LLDB needs to step back
by one instruction. Initial implementation did this strictly for frames
that have index != 0 (and index is updated properly in
UpdatePreviousFrameFromCurrentFrame), but m_behaves_like_zeroth_frame
added a capability for middle-of-stack frames to behave in a similar
manner. But because current code now doesn't check frame idx,
m_behaves_like_zeroth_frame must be set to true for frames with 0 index,
not only for frame that behave like one. In the described test case,
after stopping in main, LLDB would still consider frame#0 as
non-zeroth, and would subtract instruction from the PC, and would report
previous like as current line.

The error doesn't manifest itself in LLDB interpreter though - it can be
reproduced through LLDB-MI and when using SB API, but not when we
interpreter command "continue" is executed. Honestly, I didn't fully
understand why it works in interpreter, I did found that bug "fixes"
itself if I enable DEBUG_STACK_FRAMES in StackFrameList.cpp, because
that calls StackFrame::Dump and that calls
GetSymbolContext(eSymbolContextEverything), which fills the context of
frame on the first breakpoint, therefore it doesn't have to be
recalculated (improperly) on a second frame. However, on first
breakpoint symbol context is calculated for the "call" line, not the
next one, therefore it should be recalculated anyway on a second
breakpoint, and it is done correctly, even though
m_behaves_like_zeroth_frame is still incorrect, as long as
GetSymbolContext(eSymbolContextEverything) has been called.

[1] 31e6dbe1c6 Fix PC adjustment in StackFrame::GetSymbolContext

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

Patch by Anton Kolesov <Anton.Kolesov@synopsys.com>
2020-03-16 16:20:11 +03:00
Pavel Labath c5ff3df839 [lldb] Hardcode target in dwo-type-in-main-file.s test 2020-03-16 13:25:10 +01:00
Pavel Labath 5abfa3226d [lldb/DWARF] Fix crash when a dwo compile unit refers to a non-dwo type
In this case dwo_num can be None => stop assuming it can't.
2020-03-16 12:12:59 +01:00
Jonas Devlieghere 4c90a5297d [lldb/Process] Include Unwind.h in FreeBSDThread
Fixes member access into incomplete type 'lldb_private::Unwind'. Thank
you to Paulf for pointing this out.
2020-03-15 20:38:40 -07:00
Jonas Devlieghere bfedb663cc [lldb/Host] s/FindProcesses/FindProcessesImpl/ in freebsd/Host.cpp
Fix the FreeBSD build. Thank you to Paulf for pointing this out.
2020-03-15 20:36:40 -07:00
Jonas Devlieghere 2059d28bfd [lldb/Utils] Use PYTHON_EXECUTABLE to configure lldb-dotest's shebang
Ideally we'd want all shebangs to be configurable, but that's not a
viable solution. Given that lldb-dotest is already configured, we might
as well make sure it uses the correct interpreter.

Differential revision: https://reviews.llvm.org/D76167
2020-03-15 20:34:17 -07:00
Nico Weber f82b32a51e Revert "Reland "[DebugInfo] Enable the debug entry values feature by default""
This reverts commit 5aa5c943f7.
Causes clang to assert, see
https://bugs.chromium.org/p/chromium/issues/detail?id=1061533#c4
for a repro.
2020-03-13 15:37:44 -04:00
Jonas Devlieghere 20e36f31df [lldb/Host] s/FindProcesses/FindProcessesImpl/ in windows/Host.cpp
Fix the Windows build.
2020-03-13 10:07:15 -07:00
Jonas Devlieghere 01387c44d0 [lldb/Test] Temporarily skip TestReproducerAttach on Linux
The test is failing with an unexpected packet during replay. Temporarily
disabling the test while I setup and environment to investigate.
2020-03-13 10:07:15 -07:00
Jonas Devlieghere 17bdb7a179 [lldb/Test] Convert stdout to str by calling decode('utf-8') on it.
Make sure both arguments to assertIn are of type str. This should fix
the following error:

TypeError: a bytes-like object is required, not 'str'.
2020-03-13 09:50:41 -07:00
Jonas Devlieghere 2451cbf07b [lldb/Reproducers] Intercept the FindProcesses API
This patch extends the reproducers to intercept calls to FindProcesses.
During capture it serializes the ProcessInstanceInfoList returned by the
API. During replay, it returns the serialized data instead of querying
the host.

The motivation for this patch is supporting the process attach workflow
during replay. Without this change it would incorrectly look for the
inferior on the host during replay and failing if no matching process
was found.

Differential revision: https://reviews.llvm.org/D75877
2020-03-13 09:31:35 -07:00
Adrian Prantl 57da8f720c Add support for XFAILing a test based on a setting.
This is analogous to the skipping mechanism introduced in
https://reviews.llvm.org/D75864
2020-03-12 19:26:24 -07:00
Adrian Prantl a9682ccb7e Convert settings list into a tuple so it can be matched by the decorator. 2020-03-12 17:51:15 -07:00
Raphael Isemann af7fc8c1bb [lldb] Remove unused and too strict error_msg parameter from expect_expr
Directly matching the error message is nearly never useful. We can re-add
error-checking once we have a plan to properly implement this.
2020-03-13 00:45:43 +01:00
Jonas Devlieghere 2411f56bfd [lldb/Host] Fix the Windows build
Update use of ProcessInstanceInfoList which is now a std::vector.
2020-03-12 15:31:09 -07:00
Jonas Devlieghere 0ce3b710b4 [lldb] Add YAML traits for ArchSpec and ProcessInstanceInfo
Add YAML traits for ArchSpec and ProcessInstanceInfo so they can be
serialized for the reproducers.

Differential revision: https://reviews.llvm.org/D76004
2020-03-12 14:38:37 -07:00
Jonas Devlieghere 638b06cf29 [lldb/Utility] Replace ProcessInstanceInfoList with std::vector. (NFCI)
Replace ProcessInstanceInfoList with std::vector<ProcessInstanceInfo>
and update the call sites.
2020-03-12 14:10:25 -07:00
Tatyana Krasnukha fe74df01a9 [lldb] Specify default value for platform.module-cache-directory
In addition to the commit rG352f16db87f583ec7f55f8028647b5fd8616111f,
this one fixes settings behavior on clearing - the setting should be
reverted to their default value, not an empty one.
2020-03-12 22:08:12 +03:00
Jonas Devlieghere bc9b6b33a0 [lldb/Utility] Add YAML traits for ConstString and FileSpec.
Add YAML traits for the ConstString and FileSpec classes so they can be
serialized as part of ProcessInfo. The latter needs to be serializable
for the reproducers.

Differential revision: https://reviews.llvm.org/D76002
2020-03-12 10:28:21 -07:00
Raphael Isemann 352f16db87 [lldb] Let OptionValueRegex::Clear set to value to the default and not an empty regex
Since D75537 the test suite clears all settings before a test. This caused
two tests to fail:
    lldb-api :: functionalities/inline-stepping/TestInlineStepping.py
    lldb-api :: lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py
The reason for that is that OptionValueRegex::Clear was setting the regex
to empty instead of the default value that was passed initially. This caused
that the target.process.thread.step-avoid-regexp setting which is used in the
tests was set to "" instead of "^std::".

This patch is just a quick fix that sets the regex back to the original value
to make the tests pass.

In total these 3 setting values have changed with D75537 and also need to be
fixed (even though they don't seem to break any tests).
  target.process.thread.step-avoid-regexp (regex) -> from '^std::' to empty string
  platform.module-cache-directory (file) -> from "~/.lldb/module_cache" to empty string
  script-lang (enum) -> from 'default' to 'python'
2020-03-12 16:12:14 +01:00
Raphael Isemann e3fc6b3c34 [lldb][NFC] Fix unsigned/signed comparison warning in SymbolFileDWARFTest.cpp
offset_t is unsigned, so if the RHS is signed we get a warning from clang:
    warning: comparison of integers of different signs: 'const unsigned long long' and 'const int'
2020-03-12 15:30:11 +01:00
Tatyana Krasnukha df90a15b1a [lldb] Clear all settings during a test's setUp
Global properties are shared between debugger instances and
if a test doesn't clear changes in settings it made,
this leads to side effects in other tests.

Differential Revision: https://reviews.llvm.org/D75537
2020-03-12 16:30:26 +03:00
Luke Drummond 0fa3320931 [lldb] reject `.debug_arange` sections with nonzero segment size
If a producer emits a nonzero segment size, `lldb` will silently read
incorrect values and crash, or do something worse later as the tuple
size is expected to be 2, rather than 3.

Neither LLVM, nor GCC produce segmented aranges, but this dangerous case
should still be checked and handled.

Reviewed by: clayborg, labath
Differential Revision: https://reviews.llvm.org/D75925
Subscribers: lldb-commits
Tags: #lldb
2020-03-12 12:22:50 +00:00
Adrian Prantl 5161194fad Revert "Update debugserver test for new ostype names"
I accidentally commited this while cherry-picking commits out of my
reflog.

This reverts commit ae73ab64b6.
2020-03-11 21:32:12 -07:00
Adrian Prantl cd4c1adabe Add newly-missing include 2020-03-11 19:30:53 -07:00
Adrian Prantl ae73ab64b6 Update debugserver test for new ostype names 2020-03-11 15:50:03 -07:00
Reid Kleckner 213aea4c58 Remove unused Endian.h includes, NFC
Mainly avoids including Host.h everywhere:

$ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
    | grep '^[-+] ' | sort | uniq -c | sort -nr
   3141 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Host.h
2020-03-11 15:45:34 -07:00
Reid Kleckner e08464fb45 Avoid including FileManager.h from SourceManager.h
Most clients of SourceManager.h need to do things like turning source
locations into file & line number pairs, but this doesn't require
bringing in FileManager.h and LLVM's FS headers.

The main code change here is to sink SM::createFileID into the cpp file.
I reason that this is not performance critical because it doesn't happen
on the diagnostic path, it happens along the paths of macro expansion
(could be hot) and new includes (less hot).

Saves some includes:
    309 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileManager.h
    272 -    /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileSystemOptions.h
    271 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/VirtualFileSystem.h
    267 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/FileSystem.h
    266 -    /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Chrono.h

Differential Revision: https://reviews.llvm.org/D75406
2020-03-11 13:53:12 -07:00
Reid Kleckner c915cb957d Avoid including Module.h from ExternalASTSource.h
Module.h takes 86ms to parse, mostly parsing the class itself. Avoid it
if possible. ASTContext.h depends on ExternalASTSource.h.

A few NFC changes were needed to make this possible:

- Move ASTSourceDescriptor to Module.h. This needs Module to be
  complete, and seems more related to modules and AST files than
  external AST sources.
- Move "import complete" bit from Module* pointer int pair to
  NextLocalImport pointer. Required because PointerIntPair<Module*,...>
  requires Module to be complete, and now it may not be.

Reviewed By: aaron.ballman, hans

Differential Revision: https://reviews.llvm.org/D75784
2020-03-11 13:37:41 -07:00
Adrian Prantl ea96037186 Add a verification mechanism to CompilerType.
Badly-written code can combine an unrelated TypeSystem and opaque type
pointer into a CompilerType. This is particularly an issue in
swift-lldb. This patch adds an assertion mechanism that catches these
kinds of mistakes early. Because this is an assertion-only code path
there is not cost for release builds.

Differential Revision: https://reviews.llvm.org/D76011
2020-03-11 12:43:32 -07:00
Adrian Prantl 0396aa4c05 Add a decorator option to skip tests based on a default setting.
This patch allows skipping a test based on a default setting, which is
useful when running the testsuite in different "modes" based on a
default setting. This is a feature I need for the Swift testsuite, but
I think it's generally useful.

Differential Revision: https://reviews.llvm.org/D75864
2020-03-11 10:00:36 -07:00
Jonas Devlieghere 4016c6b07f [lldb/Reproducer] Prevent crash when GDB multi-loader can't be created.
Check that the multi loader isn't null and print an error otherwise.
This patch also extends the test to cover these error paths.
2020-03-10 23:16:55 -07:00
Pavel Labath 6b37c476a2 [lldb] Improve test failure messages in vscode tests
A couple of tests sporadically fail on these assertions, but the error
messages do not give a clue as to what has actually happened.

Improve them so that we can better understand what is going wrong.
2020-03-10 14:32:45 +01:00
Pavel Labath 1ca1e08e75 [lldb] Break up CommandObjectDisassemble::DoExecute
The function consisted of a complicated set of conditions to compute the
address ranges which are to be disassembled (depending on the mode
selected by command line switches). This patch creates a separate
function for each mode, so that DoExecute is only left with the task of
figuring out how to dump the relevant ranges.

This is NFC-ish, except for one change in the error message, which is
actually an improvement.
2020-03-10 14:03:16 +01:00
Pavel Labath d00dff88b4 [lldb] Make UnwindLLDB a non-plugin
Summary:
This is the only real unwinder, and things have been this way for quite
a long time. At this point, the class has accumulated so many features
it is unlikely that anyone will want to reimplement the whole thing.

The class is also fairly closely coupled (through UnwindPlans and
FuncUnwinders) with a lot of other lldb components that it is hard to
imagine a different unwinder implementation being substantially
different without reimplementing all of those.

The existing unwinding functionality is nonetheless fairly complex and
there is space for adding more structure to it, but I believe a more
worthwhile effort would be to take the existing UnwindLLDB class and try
to break it down and introduce extension/customization points, instead
of writing a brand new Unwind implementation.

Reviewers: jasonmolenda, JDevlieghere, xiaobai

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75848
2020-03-10 13:56:15 +01:00
Djordje Todorovic 5aa5c943f7 Reland "[DebugInfo] Enable the debug entry values feature by default"
Differential Revision: https://reviews.llvm.org/D73534
2020-03-10 09:15:06 +01:00
Davide Italiano 9d389f7858 [AppleObjCRuntimeV2] Fix a typo. Evalulate -> evaluate. 2020-03-09 15:40:09 -07:00
Davide Italiano a3c4e6b44a [AppleObjC2RuntimeV2] Remove dead code. NFC. 2020-03-09 15:37:12 -07:00
Davide Italiano 3cabd173a1 [ObjC] Dynamic type resolution logging should go to the types log. 2020-03-09 15:35:51 -07:00
Fangrui Song 71269a1f17 [lldb] Add .clang-tidy with customization to disable readability-identifier-naming
Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D75810
2020-03-09 12:50:28 -07:00
Jonas Devlieghere 12ba989eef [lldb/Process] Update ThreadKDP for API change
GetUnwinder now returns a reference instead of a pointer.
2020-03-09 10:01:53 -07:00
Muhammad Omair Javaid 2b6ad82f8d [lldb/test] Fix arch arm for 32-bit armv7l/armv8l
This patch forces architecture "arm" if underlying os reports core
armv7l or armv8l. On linux systems 32 bit sysroot running on 64bit
AArch64 hardware reports armv7l or armv8l which is essently arm
32bit mode. This fixes 5 testcases on 32bit arm.
2020-03-09 20:32:18 +05:00
Pavel Labath 34d7143b03 [lldb] Fix windows build, second attempt 2020-03-09 16:24:34 +01:00
Pavel Labath 24b1831ebf [lldb] Fix windows&freebsd builds for c0b1af68 2020-03-09 14:55:43 +01:00
Pavel Labath c0b1af6878 [lldb] Return Unwinder& from Thread::GetUnwinder
The function always returns a valid object. Let the return type reflect
that, and remove some null checks.
2020-03-09 14:13:22 +01:00
Pavel Labath af3db4e9aa [lldb] Reduce duplication in the Disassembler class
Summary:
The class has two pairs of functions whose functionalities differ in
only how one specifies how much he wants to disasseble. One limits the
process by the size of the input memory region. The other based on the
total amount of instructions disassembled. They also differ in various
features (like error reporting) that were only added to one of the
versions.

There are various ways in which this could be addressed. This patch
does it by introducing a helper struct called "Limit", which is
effectively a pair specifying the value that you want to limit, and the
actual limit itself.

Reviewers: JDevlieghere

Subscribers: sdardis, jrtc27, atanasyan, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75730
2020-03-09 13:41:43 +01:00
Muhammad Omair Javaid ee4dc980c0 [lldb/test] Remove skip arm/aarch64 decorator from instruction counting tests
This patch removes skipIf decorator from instruction counting tests.
We now use inline intruction in testing inferior to make sure that
number of instructions stays fixed. This was tested on aarch64 linux.
2020-03-09 12:54:42 +05:00
Yaxun (Sam) Liu fe73d36f23 Fix lldb build failure due to clang mangler change 2020-03-08 00:38:30 -05:00
Michał Górny 172d564c73 [lldb] Un-XFAIL two tests on NetBSD 2020-03-07 18:35:22 +01:00
Raphael Isemann 6bbdecc5cf [lldb][NFC] Make TestStats.py not an inline test
There is still the bug that empty lines seem to skip any following expressions
and it makes it harder to commend between all the comments. Let's make this
a normal test instead which is just slightly more verbose but can be properly
formatted.
2020-03-06 18:47:59 -08:00
Raphael Isemann 8f7c911b58 [lldb][NFC] Refactor our option generation out of EvaluateExpression 2020-03-06 18:32:16 -08:00
Raphael Isemann 4e7c686e46 [lldb] Never compile the debugserver with Clang module flags
Summary:
Compiling ObjC++ with Clang modules is usually not working well and compiling
the small debugserver with modules is not worth the trouble.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: mgorny, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74891
2020-03-06 17:26:39 -08:00
Raphael Isemann ce1bc00f37 [lldb][cmake] Move remove_module_flags macro to AddLLDB.cmake
Summary: This is currently hidden in the Host CMakeLists but we should also use this macro in other parts of LLDB where we have ObjC++ sources (see D74891)

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75164
2020-03-06 17:21:24 -08:00
Raphael Isemann 2bba1c22e7 tab completion for process signal
Summary: Provide a list of Unix signals for the tap completion for command "process signal".

Reviewers: teemperor

Subscribers: labath, jingham, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75418
2020-03-06 17:05:25 -08:00
Raphael Isemann 53b135eeb4 [lldb][NFC] Refactor TestSafeFuncCalls.py
Summary:
This patch inlines all the single-line functions that we only use once in the test
and replaces the assertTrue with an assertEquals to improve the error message
when this test fails.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75497
2020-03-06 15:46:36 -08:00
Adrian Prantl 33b696b57a Fix test broken by simulator triple changes. 2020-03-06 11:28:31 -08:00
Raphael Isemann 3b2c4e7178 [lldb] Remove some #ifdef LLDB_CONFIGURATION_DEBUG around asserts
Summary:
Otherwise this code won't run on the Release+Asserts builds we have on the CI.

Fixes rdar://problem/59867885 (partly)

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75493
2020-03-06 11:21:00 -08:00
Gongyu Deng ec31255c00 [lldb] Update the current execution context at the beginning of tab completions
Summary: Fix a bug that tab completions won't synchronous the current execution context. ( Thanks for Jim's explanation! )

Reviewers: teemperor, labath, jingham

Reviewed By: jingham

Subscribers: jingham, labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75597
2020-03-06 10:44:00 -08:00
Adrian Prantl 000847f8be Correctly identify iOS simulator processes in debugserver.
Starting with iOS 13 simulator binaries are identified with an
explicit platform in the new LC_BUILD_VERSION load command.

On older deployment targets using the LC_VERSION_MIN load commands,
this patch detects when an ios process runs on a macOS host and
updates the target triple with the "simulator" environment
accordingly.

(Patch re-applied with bugfix this time).

This is part of https://bugs.swift.org/browse/SR-11971

rdar://problem/58438125

Differential Revision: https://reviews.llvm.org/D75696
2020-03-06 10:16:47 -08:00
Adrian Prantl 4ebe9b498d Revert "Correctly identify iOS simulator processes in debugserver."
This reverts commit 59d816d884.

It broke TestGDBRemoteClient.
2020-03-06 10:16:47 -08:00
Adrian Prantl 3ed02340ea Increase default timeout in lldbutil.expect_state_changes() 2020-03-06 10:00:47 -08:00
Adrian Prantl 58c506d8e8 Correctly identify iOS simulator processes in debugserver.
Starting with iOS 13 simulator binaries are identified with an
explicit platform in the new LC_BUILD_VERSION load command.

On older deployment targets using the LC_VERSION_MIN load commands,
this patch detects when an ios process runs on a macOS host and
updates the target triple with the "simulator" environment
accordingly.

(Patch re-applied without modifications, the bot failure was unrelated).

This is part of https://bugs.swift.org/browse/SR-11971

rdar://problem/58438125

Differential Revision: https://reviews.llvm.org/D75696
2020-03-06 09:59:30 -08:00
Adrian Prantl 66a6fa631e Revert "Correctly identify iOS simulator processes in debugserver."
This reverts commit 59d816d884.

It broke TestGDBRemoteClient.
2020-03-06 09:52:20 -08:00
Adrian Prantl 59d816d884 Correctly identify iOS simulator processes in debugserver.
Starting with iOS 13 simulator binaries are identified with an
explicit platform in the new LC_BUILD_VERSION load command.

On older deployment targets using the LC_VERSION_MIN load commands,
this patch detects when an ios process runs on a macOS host and
updates the target triple with the "simulator" environment
accordingly.

This is part of https://bugs.swift.org/browse/SR-11971

rdar://problem/58438125

Differential Revision: https://reviews.llvm.org/D75696
2020-03-06 09:42:05 -08:00
Pavel Labath 92c0cda928 [lldb/Disassembler] Move address resolution into the ParseInstructions function
The static Disassembler can be thought of as shorthands for three
operations:
- fetch an appropriate disassembler instance (FindPluginForTarget)
- ask it to dissassemble some bytes (ParseInstructions)
- ask it to dump the disassembled instructions (PrintInstructions)

The only thing that's standing in the way of this interpretation is that
the Disassemble function also does some address resolution before
calling ParseInstructions. This patch moves this functionality into
ParseInstructions so that it is available to users who call
ParseInstructions directly.
2020-03-06 11:23:41 +01:00
Pavel Labath aa73ee052f [lldb/test] Use inline assembly for instruction counting tests
We have a test which checks that instruction-step really steps one
instruction, but the way it checks this makes it very susceptible to
codegen changes. This rewrites the test inferior to use inline assembly,
which guarantees a known sequence of instructions that the test can
check. This does mean we have to write separate assembly for each
architecture, but that is no better than having architecture-specific
assertions, which the test was already starting to accumulate.
2020-03-06 11:05:07 +01:00
Muhammad Omair Javaid eaddbc238d LLDB AArch64 skip single_step_only_steps_one_instruction* tests
This patch makes sure that LLDB AArch64/Linux testsuite skips
single_step_only_steps_one_instruction* tests. There is no possible
gaurantee for this test to pass and there already exists a bug report
against this bug.
2020-03-06 14:26:11 +05:00
Pavel Labath 71c1c18474 [lldb] Delete UnwindMacOSXFrameBackchain
Summary:
It isn't used anywhere (except on imaginary triples like
sparc-apple-ios) and it also violates plugin separation.

This patch deletes it and declares UnwindLLDB to be _the_ lldb unwinder.

Reviewers: jasonmolenda, JDevlieghere, xiaobai

Subscribers: jyknight, mgorny, krytarowski, fedor.sergeev, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75680
2020-03-06 08:27:13 +01:00
Jonas Devlieghere 621d969a96 [lldb/DWARF] Fix 80 col formatting (NFC)
Forgot to run git clang-format before landing my previous commit
(226d52b1fa).
2020-03-05 21:28:23 -08:00
Jonas Devlieghere 226d52b1fa [lldb/DWARF] Replace C style casts with static_cast<> (NFC)
Using static_cast instead of C style casts better conveys the code's
intent, is a tad more safe and stands out more.
2020-03-05 21:24:51 -08:00
Shu Anzai 467969161d [lldb/Core] Minor code cleanup in Editline.cpp (NFC)
Simplify the code a bit.

Differential revision: https://reviews.llvm.org/D75294
2020-03-05 16:15:26 -08:00
Raphael Isemann d0e8abc438 [lldb] Fix more typos in log statements in ClangASTSource
The indexes need to start at 0 but in D74951 I removed the first parameter
and didn't decrement all the indexes. This patch at least makes sure that
LLDB logging no longer crashes (but it still deadlocks).
2020-03-05 14:13:09 -08:00
Pavel Labath 04592d5b23 [lldb] s/ExecutionContext/Target in Disassembler
Some functions in this file only use the "target" component of an
execution context. Adjust the argument lists to reflect that.

This avoids some defensive null checks and simplifies most of the
callers.
2020-03-05 14:46:39 +01:00
Tatyana Krasnukha ef38283a09 [lldb][test] Temporarily X-fail TestPtrRefs.py and TestPtrRefsObjC.py
Bugzilla issue: llvm.org/pr45112
2020-03-05 14:38:44 +03:00
Pavel Labath ea68462ed1 [lldb] Make Disassembler::PrintInstructions a method
the previously static member function took a Disassembler* argument
anyway. This renames the argument to "this". The function also always
succeeds (returns true), so I change the return type to void.
2020-03-05 12:07:49 +01:00
Pavel Labath c6a38957a7 [lldb] Delete two overloads of Disassembler::Disassemble
by "inlining" them into their single caller (CommandObjectDisassemble).
The functions mainly consist of long argument lists and defensive
checks. These become unnecessary after inlining, so the end result is
less code. Additionally, this makes the implementation of
CommandObjectDisassemble more uniform (first figure out what you're
going to disassemble, then actually do it), which enables further
cleanups.
2020-03-05 11:00:37 +01:00
Tatyana Krasnukha aafd65ad9f [lldb][test] Replace HandleCommand with runCmd to check that a command succeeded 2020-03-05 12:37:08 +03:00
Tatyana Krasnukha d2e397f156 [lldb][test] These tests don't fail on Windows anymore 2020-03-05 12:37:08 +03:00
Tatyana Krasnukha 7a11cc06a4 [lldb][test] TestFileHandle: flush the output after write 2020-03-05 11:45:28 +03:00
Tatyana Krasnukha eecef3af2c [lldb][test] Enable fix-its for the test case that expects them enabled
Fix-its were intentionally disabled by TestBase.setUp so that incorrect expressions in tests
don't pass just because Clang thinks it has a fix-it.
2020-03-05 10:31:07 +03:00
Tatyana Krasnukha a31130f6fc [lldb][testsuite] Create a SBDebugger instance for each test
Some tests set settings and don't clean them up, this leads to side effects in other tests.
The patch removes a global debugger instance with a per-test debugger to avoid such effects.

From what I see, lldb.DBG was needed to determine the platform before a test is run,
lldb.selected_platform is used for this purpose now. Though, this required adding a new function
to the SBPlatform interface.

Differential Revision: https://reviews.llvm.org/D74903
2020-03-05 10:12:54 +03:00
Raphael Isemann 70b8f95813 [lldb][NFC] Use C++11 for loop in ClangASTSource::FindExternalLexicalDecls 2020-03-04 12:57:05 -08:00
Raphael Isemann 4ab2ea9fc0 [lldb] Fix typo in ClangASTSource logging statement 2020-03-04 11:05:48 -08:00
Raphael Isemann e98ef0af2c [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp 2020-03-04 10:32:50 -08:00
Raphael Isemann 0ab109d43d [lldb][NFC] Modernize logging UserExpression 2020-03-04 09:04:54 -08:00
Tatyana Krasnukha b1324e74da [lldb][NFC] Move local variables near to their usage 2020-03-04 16:56:51 +03:00
Tatyana Krasnukha 6c17cc531f [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint
This prevents calling Breakpoint::shared_from_this of an object that is not owned by any shared_ptr.

Differential Revision: https://reviews.llvm.org/D74557
2020-03-04 16:56:50 +03:00
Pavel Labath 3245dd59b1 [lldb] Reduce duplication in CommandObjectDisassemble
This command had nearly identical code for the "then" and "else"
branches of the "if (m_options.num_instructions != 0)" condition.

This patch factors out the common parts of the two blocks to reduce
duplication.
2020-03-04 13:47:35 +01:00
Adrian Prantl a7fa8b022f Doxygenify CompilerType.h (NFC) 2020-03-03 13:43:25 -08:00
Alex Langford e566dd733d [lldb] Delete some commented out code in ClangASTSource.cpp 2020-03-03 13:17:21 -08:00
Stefan Stipanovic 13fd50cc26 Revert "Revert "[lldb/Docs] Mark both Python 3.6 and 3.8 as supported on Windows""
This reverts commit 78a734e279.
2020-03-03 20:43:16 +01:00
Stefan Stipanovic 78a734e279 Revert "[lldb/Docs] Mark both Python 3.6 and 3.8 as supported on Windows"
This reverts commit 3270ea9042.
2020-03-03 20:41:18 +01:00
Jonas Devlieghere 3270ea9042 [lldb/Docs] Mark both Python 3.6 and 3.8 as supported on Windows
Haibo told me he didn't have any issues with Python 3.8 and I was able
to confirm that. Even though we don't have bot running with 3.8, I think
it safe to mark it as supported in the docs.
2020-03-03 11:26:00 -08:00
Raphael Isemann 531515198e [lldb][NFC] Remove some commented out code in TypeSystemClang
Summary: I don't see why we want to keep that code around.

Reviewers: #lldb, JDevlieghere

Reviewed By: #lldb, JDevlieghere

Subscribers: davide

Differential Revision: https://reviews.llvm.org/D75496
2020-03-03 10:50:48 -08:00
Pavel Labath 573e077699 [lldb] Add detailed tests for the "disassemble" command
While we have some tests for this command already, they are very vague.
This is not surprising -- it's hard to make strict assertions about the
assembly if your input is a c++ source file. This means that the tests
can more-or-less only detect when the command breaks completely, and not
when there is a subtle change in meaning due to e.g. a code refactor --
which is something that I am getting ready to do.

This tests in this patch create binaries with well known data (via assembler
and yaml2obj). This means that we are able to make precise assertions
about the text that lldb is supposed to print. As some of the features
of this command are only available with a real process, I use a minidump
core file to create a sufficiently realistic process object.
2020-03-03 16:40:27 +01:00
Pavel Labath 1d6fa41f40 [lldb] Have Disassembler::ParseInstructions take a Target&
Instead of a ExecutionContext*. All it needs is the target so it can
read the memory.

This removes some defensive checks from the function. I've added
equivalent checks to the callers in cases where a non-null target
pointer was not guaranteed to be available.
2020-03-03 13:58:56 +01:00
Pavel Labath 221641be02 [lldb] Add lldbTarget -> llvmMC dependency
The ABI class uses llvm::MCRegisterInfo.
2020-03-03 13:10:44 +01:00
Unnar Freyr Erlendsson 6304368818 [lldb] Treat RangeDataVector as an augmented binary search tree
Summary:
Since RangeDataVector is assumed to always be sorted we can treat it as
an flattened BST and augment it with additional information about the
ranges belonging to each "subtree". By storing the maximum endpoint in
every subtree we can query for intervals in O(log n) time.

Reviewers: labath, teemperor

Reviewed By: labath

Subscribers: jarin, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74759
2020-03-03 11:28:16 +01:00
Pavel Labath 4deea65249 [lldb] Make sure we don't drop asynchronous output when sourcing files
Summary:
If a command from a sourced file produces asynchronous output, this
output often does not make its way to the user. This happens because the
asynchronous output machinery relies on the iohandler stack to ensure
the output does not interfere with the things the iohandler is doing.

However, if this happens near the end of the command stream then by the
time the asynchronous output is produced we may already have already
started tearing down the sourcing session. Specifically, we may already
pop the relevant iohandler, leaving the stack empty.

This patch makes sure this kind of output gets printed by adding a
fallback to IOHandlerStack::PrintAsync to print the output directly if
the stack is empty. This is safe because if we have no iohandlers then
there is nothing to synchronize.

Reviewers: JDevlieghere, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75454
2020-03-03 11:18:41 +01:00
Hans Wennborg 916be8fd6a Revert abb00753 "build: reduce CMake handling for zlib" (PR44780)
and follow-ups:
a2ca1c2d "build: disable zlib by default on Windows"
2181bf40 "[CMake] Link against ZLIB::ZLIB"
1079c68a "Attempt to fix ZLIB CMake logic on Windows"

This changed the output of llvm-config --system-libs, and more
importantly it broke stand-alone builds. Instead of piling on more fix
attempts, let's revert this to reduce the risk of more breakages.
2020-03-03 11:03:09 +01:00
Fred Riss 138c7ac5b6 [lldb/GDBRemote] Fix obvious typo in error message.
It's unlikely that `errno` is the value the user wants to see in this
error message.
2020-03-02 17:53:39 -08:00
Fred Riss 20ce8affce [lldb/API] NFC: Reformat and simplify SBThread::GetStopDescription()
Summary:
This gets rid of some nesting and of the raw char* variable that caused
the memory management bug we hit recently.

This commit also removes the fallback code which should trigger when
the StopInfo provides no stop description. All currently implemented
StopInfos have a `GetDescription()` method that shouldn't return an
empty description.

Reviewers: JDevlieghere, labath, mib

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74157
2020-03-02 17:43:35 -08:00
Jonas Devlieghere 7ad30f4249 [lldb/Utility] Use emplace_back instead of push_back (NFC)
Use emplace_back to allow for in-place construction of the
BroadcastEventSpec instead of copying it.
2020-03-02 15:54:00 -08:00