Commit Graph

22631 Commits

Author SHA1 Message Date
Konrad Kleine 107200ae0a [lldb][nfc] early exit/continue
Summary:
This commit just tries to invert some `if`'s logic to
`return`/`continue` early.

Reviewers: jankratochvil, teemperor

Reviewed By: jankratochvil, teemperor

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77377
2020-04-03 14:50:08 +02:00
Igor Kudrin f13ce15d44 [DebugInfo] Rename getOffset() to getContribution(). NFC.
The old name was a bit misleading because the functions actually return
contributions to the corresponding sections.

Differential revision: https://reviews.llvm.org/D77302
2020-04-03 14:15:53 +07:00
Greg Clayton 5998aceda9 Have lldb-vscode update the currently selecte thread and frame when it receives a "scopes" request.
Summary: The IDE has no packets that are sent to lldb-vscode that say which thread and frame are selected. The only way we know is we get a request for variables for a stack frame via a "scopes" request. When we receive this packet we make that thread and frame the selected thread and frame in lldb. This way when people execute lldb commands in the debug console by prefixing the expression with the backtick character, we will have the right thread and frame selected. Previously this was not updated as new stack frames were selected.

Reviewers: labath, aadsm, wallace, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77347
2020-04-02 18:35:17 -07:00
Walter Erquinigo b78157c88b [intel-pt] Implement a basic test case
* This is a reattempted commit due to a previous builtbot failure

- Now using a env var to determine whether to run the test, as
someone might have built liblldbIntelFeatures.so without intelPT
support, which would make this test fail.

Summary:
Depends on D76872.

There was no test for the Intel PT support on LLDB, so I'm creating one, which
will help making progress on solid grounds.

The test is skipped if the Intel PT plugin library is not built.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77107
2020-04-02 11:36:05 -07:00
Shivam Mittal 51b3874629 Convert for loops to entry-based iteration
Summary: Convert index-based loops marked TODO in CommandObjectSettings and CommandObjectTarget to entry-based.

Reviewers: labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76729
2020-04-02 18:56:29 +02:00
scentini 183fba635d Add OMPIterator case in switch statement to silence warnings 2020-04-02 16:16:11 +02:00
Ed Maste 55e32e92cd [lldb] update eArgTypeScriptLang description to mention lua
--script-language python and --script-language lua are both valid now.

Reviewed by:	JDevlieghere

Differential Revision:	https://reviews.llvm.org/D77241
2020-04-02 09:43:01 -04:00
Pavel Labath 451741a9d7 [lldb] Change Communication::SetConnection to take a unique_ptr
The function takes ownership of the object. This makes that explicit,
and avoids unowned pointers floating around.
2020-04-02 14:42:25 +02:00
Pavel Labath 62be83463a Recommit "[lldb] Fix TestSettings.test_pass_host_env_vars on windows"
This patch was reverted because it introduced a failure in
TestHelloWorld.py. The reason for that was running "ls" shell command
failed as it was evaluated in an environment with an empty path. This
has now been fixed with D77123, which ensures that all shell commands
inherit the host environment, so this patch should be safe to recommit.

The original commit message was:

A defensive check in ProcessLauncherWindows meant that we would never
attempt to launch a process with a completely empty environment -- the
host environment would be used instead. Instead, I make the function add
an extra null wchar_t at the end of an empty environment. The
documentation on this is a bit fuzzy, but it seems to be what is needed
to make windows accept these kinds of environments.

Reviewers: amccarth, friss

Differential Revision: https://reviews.llvm.org/D76835
2020-04-02 11:52:56 +02:00
Ed Maste af1b7d06d9 Correct copy-pasteo in lua script language description 2020-04-02 00:12:24 -04:00
Adrian Prantl 32672b877d Revert "Preserve the owning module information from DWARF in the synthesized AST"
This reverts commit 4354dfbdf5 while investigating bot fallout.
2020-04-01 18:58:11 -07:00
Adrian Prantl 4354dfbdf5 Preserve the owning module information from DWARF in the synthesized AST
Types that came from a Clang module are nested in DW_TAG_module tags
in DWARF. This patch recreates the Clang module hierarchy in LLDB and
sets the owning module information accordingly. My primary motivation
is to facilitate looking up per-module APINotes for individual
declarations, but this likely also has other applications.

rdar://problem/59634380

Differential Revision: https://reviews.llvm.org/D75488
2020-04-01 17:46:02 -07:00
Vedant Kumar f203100ebe Reapply: [Host.mm] Check for the right macro instead of inlining it
Previously, this was reverted in bf65f19b becuase it checked whether
TARGET_OS_EMBEDDED is defined, but that macro is always defined.

Update the condition to check that TARGET_OS_OSX is true.
2020-04-01 15:23:07 -07:00
Walter Erquinigo 064c634ef3 Revert "[intel-pt] Implement a basic test case"
This reverts commit c911cc6c49.
2020-04-01 14:08:19 -07:00
Walter Erquinigo c911cc6c49 [intel-pt] Implement a basic test case
Summary:
Depends on D76872.

There was no test for the Intel PT support on LLDB, so I'm creating one, which
will help making progress on solid grounds.

The test is skipped if the Intel PT plugin library is not built.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77107
2020-04-01 13:44:03 -07:00
Walter Erquinigo 8ba8a4a14d Revert "[intel-pt] Implement a basic test case"
This reverts commit f1242ec543.
2020-04-01 13:27:30 -07:00
Walter Erquinigo f1242ec543 [intel-pt] Implement a basic test case
Summary:
Depends on D76872.

There was no test for the Intel PT support on LLDB, so I'm creating one, which
will help making progress on solid grounds.

The test is skipped if the Intel PT plugin library is not built.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77107
2020-04-01 13:19:15 -07:00
Walter Erquinigo 30350c2541 [source maps] Ensure all valid source maps are added instead of failing with the first invalid one
Summary:
Several lldb-vscode users have noticed that when a source map rule is invalid (because a folder doesn't exist anymore), the rest of the source maps from their configurations are not applied.
This happens because lldb-vscode executes a single "settings set target.source-map" command with all the source maps and LLDB processes them one by one until one fails.

Instead of doing this, we can process in LLDB all the source map rules and apply the valid ones instead of failing fast.

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77186
2020-04-01 13:01:40 -07:00
Muhammad Omair Javaid c9d1588054 Silent failing TestWatchpointCount.py aarch64/linux
Skip TestWatchpointCount.py for aarch64-linux to fix lldb aarch64 linux buildbot.

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/
2020-04-01 16:31:37 +05:00
Raphael Isemann 9beba4245a [lldb][NFC] Modernize TestExprChar 2020-04-01 13:24:21 +02:00
Martin Storsjö aa786b881f [lldb] [PECOFF] Only use PECallFrameInfo on the one supported architecture
The RuntimeFunction struct, which PECallFrameInfo interprets, has a
different layout and differnet semantics on all architectures.

Differential Revision: https://reviews.llvm.org/D77000
2020-04-01 12:39:21 +03:00
Pavel Labath 0ec88d031a [lldb] Inherit host environment when running shell commands
Summary:
On most hosts we were running shell commands with an empty environment.
The only exception was windows, which was inheriting the host enviroment
mostly by accident.

Running the commands in an empty environment does not sound like a
sensible default, so this patch changes Host::RunShellCommand to inherit
the host environment.  This impacts both commands run via
SBPlatform::Run (in case of host platforms), as well as the "platform
shell" CLI command.

Reviewers: jingham, friss

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77123
2020-04-01 11:20:13 +02:00
Raphael Isemann 48a5bdafba [lldb][NFC] Modernize TestXValuePrinting 2020-04-01 10:20:52 +02:00
Raphael Isemann edb0efca1e [lldb][NFC] Modernize call-function tests 2020-04-01 10:17:42 +02:00
Raphael Isemann fa1b602ee6 [lldb][NFC] Modernize TestCallUserAnonTypedef 2020-04-01 10:06:59 +02:00
Raphael Isemann 15f34ff2d8 [lldb] Allow expect_expr without a running target
Summary:
If we don't have a current frame then we can still run many expressions
as long as we have an active target. With this patch `expect_expr` directly
calls the target's EvaluateExpression function when there is no current frame.

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D77197
2020-04-01 09:39:24 +02:00
Davide Italiano 64799fbebd [debugserver/ARM64] Make sure watchpoints hit are attributed correctly.
This didn't happen for arm64 if you have watches for variables
that are contigous in memory.

<rdar://problem/55135006>
2020-03-31 15:56:20 -07:00
Adrian Prantl ec11c5615a Replace uint32_t with typedef (NFC) 2020-03-31 14:58:25 -07:00
Adrian Prantl 00efcd6fff Add a Type::Payload typedef. (NFC)
This addresses review feedback from Raphael that I missed before
landing the change that introduced the payload field.
2020-03-31 14:32:53 -07:00
Jonas Devlieghere 015c6cd475 Re-land "[lldb/Reproducers] Always collect the whole dSYM in the reproducer"
The FileCollector in LLDB collects every files that's used during a
debug session when capture is enabled. This ensures that the reproducer
only contains the files necessary to reproduce. This approach is not a
good fit for the dSYM bundle, which is a directory on disk, but should
be treated as a single unit.

On macOS LLDB have automatically find the matching dSYM for a binary by
its UUID. Having a incomplete dSYM in a reproducer can break debugging
even when reproducers are disabled.

This patch adds a was to specify a directory of interest to the
reproducers. It is called from SymbolVendorMacOSX with the path of the
dSYMs used by LLDB.

Differential revision: https://reviews.llvm.org/D76672
2020-03-31 12:47:12 -07:00
Benjamin Kramer e8f13f4f62 Replace std::string::find == 0 with StringRef::startswith
This is both more readable and faster. Found by clang-tidy's
abseil-string-find-startswith.
2020-03-31 21:01:09 +02:00
Walter Erquinigo 128c0d037d [intel-pt] Fix existing support in LLDB
Summary:
//reviews.llvm.org/D33035 added in 2017 basic support for intel-pt. I
plan to improve it and use it to support reverse debugging.

I fixed a couple of issues and now this plugin works again:
1. pythonlib needed to be linked against it for the SB framework.
Linking was failing because of this
2. the decoding functionality was broken because it lacked handling for
instruction events. It seems old versions of libipt, the actual decoding
library, didn't require these, but modern version require it (you can
read more here
https://github.com/intel/libipt/blob/master/doc/howto_libipt.md). These
events signal overflows of the internal PT buffer in the CPU,
enable/disable events of tracing, async cpu events, interrupts, etc.

I ended up refactoring a little bit the code to reduce code duplication.

In another diff I'll implement some basic tests.

This is a simple execution of the library:

(lldb) target create "/data/users/wallace/rr-project/a.out"
Current executable set to '/data/users/wallace/rr-project/a.out' (x86_64).
(lldb) plugin load liblldbIntelFeatures.so
(lldb) b main
Breakpoint 1: where = a.out`main + 8 at test.cpp:10, address = 0x00000000004007fa
(lldb) b test.cpp:14
Breakpoint 2: where = a.out`main + 50 at test.cpp:14, address = 0x0000000000400824
(lldb) r
Process 902754 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004007fa a.out`main at test.cpp:10
   7    }
   8
   9    int main() {
-> 10     int z = 0;
   11     for(int i = 0; i < 10000; i++)
   12       z += fun(z);
   13

Process 902754 launched: '/data/users/wallace/rr-project/a.out' (x86_64)
(lldb) processor-trace start all
(lldb) c
Process 902754 resuming
Process 902754 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 2.1
    frame #0: 0x0000000000400824 a.out`main at test.cpp:14
   11     for(int i = 0; i < 10000; i++)
   12       z += fun(z);
   13
-> 14     cout << z<< endl;
   15     return 0;
   16   }

(lldb) processor-trace show-instr-log
thread #1: tid=902754
    0x7ffff72299b9 <+9>: addq   $0x8, %rsp
    0x7ffff72299bd <+13>: retq
    0x4007ed <+16>: addl   $0x1, %eax
    0x4007f0 <+19>: leave
    0x4007f1 <+20>: retq
    0x400814 <+34>: addl   %eax, -0x4(%rbp)
    0x400817 <+37>: addl   $0x1, -0x8(%rbp)
    0x40081b <+41>: cmpl   $0x270f, -0x8(%rbp)       ; imm = 0x270F
    0x400822 <+48>: jle    0x40080a                  ; <+24> at test.cpp:12
    0x400822 <+48>: jle    0x40080a                  ; <+24> at test.cpp:12
```

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76872
2020-03-31 11:32:34 -07:00
Adrian Prantl 7b06cb4523 Add an opque payload field to lldb::Type (NFC).
Differential Revision: https://reviews.llvm.org/D75562
2020-03-31 11:14:12 -07:00
Davide Italiano 75cfd38220 Revert "[lldb/Reproducers] Always collect the whole dSYM in the reproducer"
This reverts commit 38ddb49e52 as it
breaks the macOS bots.
2020-03-31 10:56:02 -07:00
Jonas Devlieghere 5c2bf577dc [lldb/API] Add missing reproducer instrumentation to GetHostPlatform.
SBPlatform::GetHostPlatform was missing the reproducer instrumentation
macros. Fixed by running lldb-instr on SBPlatform.cpp:

$ ./bin/lldb-instr ../llvm-project/lldb/source/API/SBPlatform.cpp
2020-03-31 10:45:25 -07:00
Med Ismail Bennani f3a7d790df
[lldb/DWARF] Fix evaluator crash when accessing empty stack.
This patch fixes a crash that happens on the DWARF expression evaluator
when trying to access the top of the stack while it's empty.

rdar://60512489

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-03-31 17:44:57 +02:00
Med Ismail Bennani e4a778052e Revert "[lldb/DWARF] Fix evaluator crash when accessing empty stack."
This reverts commit e26eece1e2.
2020-03-31 17:44:17 +02:00
Med Ismail Bennani e26eece1e2 [lldb/DWARF] Fix evaluator crash when accessing empty stack.
This patch fixes a crash that happens on the DWARF expression evaluator
when trying to access the top of the stack while it's empty.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-03-31 17:28:15 +02:00
Shivam Mittal d30e9ad345 Correct the duplicate pragma marks in CommandObjectTarget.cpp
Summary: Resolve the two duplicated pragma marks in lldb/source/Commands/CommandObjectTarget.cpp

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: teemperor, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77096
2020-03-31 11:16:40 +02:00
Kai Wang 581ba35291 [RISCV] ELF attribute section for RISC-V.
Leverage ARM ELF build attribute section to create ELF attribute section
for RISC-V. Extract the common part of parsing logic for this section
into ELFAttributeParser.[cpp|h] and ELFAttributes.[cpp|h].

Differential Revision: https://reviews.llvm.org/D74023
2020-03-31 16:16:19 +08:00
Jonas Devlieghere 38ddb49e52 [lldb/Reproducers] Always collect the whole dSYM in the reproducer
The FileCollector in LLDB collects every files that's used during a
debug session when capture is enabled. This ensures that the reproducer
only contains the files necessary to reproduce. This approach is not a
good fit for the dSYM bundle, which is a directory on disk, but should
be treated as a single unit.

On macOS LLDB have automatically find the matching dSYM for a binary by
its UUID. Having a incomplete dSYM in a reproducer can break debugging
even when reproducers are disabled.

This patch adds a was to specify a directory of interest to the
reproducers. It is called from SymbolVendorMacOSX with the path of the
dSYMs used by LLDB.

Differential revision: https://reviews.llvm.org/D76672
2020-03-30 15:16:50 -07:00
Davide Italiano 06bb7df81c Recommit "[lldb] Make Fix-Its also apply to top-level expressions""
This reverts commit fe5cb1c25f as it
 was not responsible for breaking the bots. Sorry.
2020-03-30 14:24:06 -07:00
Davide Italiano 075b610403 Recommit "[lldb] Make TestExprDiagnostics.py pass again after enabling Fix-Its in test"
This reverts commit 55ed09d32e as
it was not responsible for breaking the bots. Sorry.
2020-03-30 14:24:06 -07:00
Davide Italiano 50f7153ddb Revert "[lldb][NFC] Refactor Fix-It filter for warnings"
This reverts commit 11a5caee2a as
it broke the bots.
2020-03-30 14:12:11 -07:00
Davide Italiano 55ed09d32e Revert "[lldb] Make TestExprDiagnostics.py pass again after enabling Fix-Its in test"
This reverts commit 502a06fcda as it
breaks the macOS bots. Raph will take a look and re-commit.
2020-03-30 13:58:18 -07:00
Davide Italiano 10f633db86 [TypeSystemClang] Add missing case in a switch. NFC'ish. 2020-03-30 13:53:53 -07:00
Davide Italiano fe5cb1c25f Revert "[lldb] Make Fix-Its also apply to top-level expressions"
This reverts commit 83c81c0a46 as
it broke the macOS lldb bots.
2020-03-30 13:23:58 -07:00
Jonas Devlieghere 63aaecd5be [lldb/CMake] Make check-lldb-* work for the standalone build.
In order to run check-lldb-* we need the correct map_config directives
in llvm-lit. For the standalone build, LLVM doesn't know about LLDB, and
the lldb mappings are missing. In that case we build our own llvm-lit,
and tell LLVM to use the llvm-lit in the lldb build directory.

Differential revision: https://reviews.llvm.org/D76945
2020-03-30 11:38:37 -07:00
Pavel Labath 37889786b0 Revert "[lldb] Fix TestSettings.test_pass_host_env_vars on windows"
This reverts commit because of test failures in TestHelloWorld.

It seems that this test (specifically running "ls" as a platform shell
command) depended on the implicit passing of the host environment.

The fix should be fairly simple (inherit the environment explicitly),
but it may take me a while to figure where exactly to do that. Revert
while I am figuring that out.
2020-03-30 17:32:42 +02:00
Benjamin Kramer 3806b38045 [LLDB] Initialize temporary token
Found by msan.
2020-03-30 16:12:50 +02:00
Pavel Labath 908f78f3c1 [lldb] Fix TestSettings.test_pass_host_env_vars on windows
Summary:
A defensive check in ProcessLauncherWindows meant that we would never
attempt to launch a process with a completely empty environment -- the
host environment would be used instead. Instead, I make the function add
an extra null wchar_t at the end of an empty environment. The
documentation on this is a bit fuzzy, but it seems to be what is needed
to make windows accept these kinds of environments.

Reviewers: amccarth, friss

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76835
2020-03-30 16:06:52 +02:00
Pavel Labath 7b00eeb53d [lldb] Fix another crash in covariant type handling
Summary:
D73024 seems to have fixed one set crash, but it introduced another.
Namely, if a class contains a covariant method returning itself, the
logic in MaybeCompleteReturnType could cause us to attempt a recursive
import, which would result in an assertion failure in
clang::DeclContext::removeDecl.

For some reason, this only manifested itself if the class contained at
least two member variables, and the class itself was imported as a
result of a recursive covariant import.

This patch fixes the crash by not attempting to import classes which are
already completed in MaybeCompleteReturnType. However, it's not clear to
me if this is the right fix, or if this should be handled automatically
by functions lower in the stack.

Reviewers: teemperor, shafik

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76840
2020-03-30 16:00:21 +02:00
Raphael Isemann 11a5caee2a [lldb][NFC] Refactor Fix-It filter for warnings
LLDB only automatically applies Fix-Its from errors, but not from warnings.

Currently we only store Fix-Its from errors and then later apply all Fix-Its
we stored. This moves the filter to the application phase, so that we now
store *all* Fix-Its but only apply Fix-Its from errors later on.

This is NFC preparation for an upcoming patch.
2020-03-30 14:01:16 +02:00
Raphael Isemann 502a06fcda [lldb] Make TestExprDiagnostics.py pass again after enabling Fix-Its in test
Commit 83c81c0a46 enabled Fix-Its for top-level
expressions which change the error message of this test here as Clang comes
up with a strange Fix-It for this expression. This patch just changes the
test to declare a void variable so that Clang doesn't see a way to
recover with a Fix-It and change the error message.
2020-03-30 13:52:09 +02:00
Raphael Isemann 83c81c0a46 [lldb] Make Fix-Its also apply to top-level expressions
Summary:
Currently top-level expressions won't automatically get Fix-Its applied. The reason
for that is that we only set the `m_fixed_text` member if we have a wrapping
source code (I.e. `m_source_code` is not zero and is wrapping some expressions).

This patch just always sets `m_fixed_text` to get this working.

Reviewers: labath, jingham

Reviewed By: labath

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D77042
2020-03-30 11:50:57 +02:00
Raphael Isemann 767a97b223 [lldb][NFC] Cleanup Fix-It code 2020-03-30 11:02:44 +02:00
Raphael Isemann 064ab22fb2 [lldb] Run TestFixIts on non-Darwin platforms
This test also passes on my Linux machine, so this seems too strict.
2020-03-30 09:53:51 +02:00
Raphael Isemann 53e7c8fdfa [lldb][NFC] Cleanup TestFixIts.py 2020-03-30 09:40:03 +02:00
Raphael Isemann 14db82c929 [lldb][NFC] Fix typo in TestInvalidArgsLog 2020-03-28 16:16:08 +01:00
Jason Molenda f0a5af906b Merge in symbols from Mach-O dyld trie to the symbol table
In ObjectFileMachO we construct the symbol table from multiple
sources -- primarily the binary's nlist records, but when the nlist
symbols have been stripped, we would augment those with function
start address from the LC_FUNCTION_STARTS or eh_frame.  This patch
adds another source of symbols - the exported symbols that the
dynamic linker, dyld, uses at runtime from its trie structure.  This
provides us names and addresses for these functions/data.

This patch removes the code from ParseSymtab that would reject an
empty symbol table / nlist source.  It adds a new symbols_added
set which tracks the address of every symbol we've added to the
symtab.  We add symbols in most-information-ful order, and before
adding a symbol from less-informational-ful source (e.g.
LC_FUNCTION_STARTS with no function name), we check if that symbol
has already been added.

On targets with thumb code generation, instead of using the 0th bit
in these addresses in FunctionStarts (or now the trie entries), we
use the data field of FunctionStarts (formerly used to track if the
func_start should be added) and a flag for the trie entries to
encode this, and only store the actual addresses in the symbols_seen
and these vectors.

<rdar://problem/50791451>

Differential revision: https://reviews.llvm.org/D76758
2020-03-27 22:53:15 -07:00
Jonas Devlieghere 823dbb4c74 [lldb/CMake] Only CMAKE_CFG_INTDIR if it's not '.'
Thanks to Brooks Davis for spotting this and finding a solution.
2020-03-27 17:49:00 -07:00
shafik 8016d61e3c [LLDB] CPlusPlusNameParser does not handles templated operator< properly
CPlusPlusNameParser is used in several places on of them is during IR execution and setting breakpoints to pull information C++ like the basename, the context and arguments.

Currently it does not handle templated operator< properly, because of idiosyncrasy is how clang generates debug info for these cases.

It uses clang::Lexer which will tokenize operator<<A::B> into:

tok::kw_operator
tok::lessless
tok::raw_identifier

Later on the parser in ConsumeOperator() does not handle this case properly and we end up failing to parse.

Differential Revision: https://reviews.llvm.org/D76168
2020-03-27 14:46:39 -07:00
Adrian Prantl 974fbd9b81 Unbreak LLDB tests after 96023917e6f
by teaching LLDB to apply DW_AT_comp_dir to the DW_AT_LLVM_include path.
2020-03-27 14:23:30 -07:00
Jonas Devlieghere 457eb05db6 [lldb/PlatformMacOSX] Re-implement GetDeveloperDirectory
GetDeveloperDirectory returns a const char* which is NULL when we cannot
find the developer directory. This crashes in
PlatformDarwinKernel::CollectKextAndKernelDirectories because we're
unconditionally assigning it to a std::string. Coincidentally I just
refactored a bunch of code in PlatformMacOSX so instead of a ad-hoc fix
I've reimplemented the method based on GetXcodeContentsDirectory.

The change is mostly NFC. Obviously it fixes the crash, but it also
removes support for finding the Xcode directory through he legacy
$XCODE_SELECT_PREFIX_DIR/usr/share/xcode-select/xcode_dir_path.

Differential revision: https://reviews.llvm.org/D76938
2020-03-27 12:36:56 -07:00
shafik 00c8120acb [LLDB] Fix handling of bit-fields when there is a base class when parsing DWARF
When parsing DWARF and laying out bit-fields we currently don't take into account whether we have a base class or not.
Currently if the first field is a bit-field but the bit offset is due a field we inherit from a base class we currently
treat it as an unnamed bit-field and therefore add an extra field.

This fix will not check if we have a base class and assume that this offset is due to members we are inheriting from the base.
We are currently seeing asserts during codegen when debugging clang::DiagnosticOptions.

This assumption will fail in the case where the first field in the derived class in an unnamed bit-field. Fixing the first field
being an unnamed bit-field looks like it will require a larger change since we will need a way to track or discover the last field offset of the bases(s).

Differential Revision: https://reviews.llvm.org/D76808
2020-03-27 11:28:07 -07:00
Walter Erquinigo a515fd01a4 [lldb-vscode] fix breakpoint result ordering
Summary:
The DAP specifies the following for the SetBreakpoints request:

  The breakpoints returned are in the same order as the elements of the 'breakpoints' arguments

This was not followed, as lldb-vscode was returning the breakpoints in a different order, because they were first stored into a map, and then traversed. Of course, maps normally don't preserve ordering.

See this log I captured:

  -->
  {"command":"setBreakpoints",
   "arguments":{
     "source":{
       "name":"main.cpp",
       "path":"/Users/wallace/fbsource/xplat/sand/test-projects/buck-cpp/main.cpp"
     },
     "lines":[6,10,11],
     "breakpoints":[{"line":6},{"line":10},{"line":11}],
     "sourceModified":false
   },
   "type":"request",
   "seq":3
  }

  <--
  {"body":{
     "breakpoints":[
       {"id":1, "line":11,"source":{"name":"main.cpp","path":"xplat/sand/test-projects/buck-cpp/main.cpp"},"verified":true},
       {"id":2,"line":6,"source":{"name":"main.cpp","path":"xplat/sand/test-projects/buck-cpp/main.cpp"},"verified":true},
       {"id":3,"line":10,"source":{"name":"main.cpp","path":"xplat/sand/test-projects/buck-cpp/main.cpp"},"verified":true}]},
     "command":"setBreakpoints",
     "request_seq":3,
     "seq":0,
     "success":true,
     "type":"response"
  }

As you can see, the order was not respected. This was causing the IDE not to be able to disable/enable breakpoints by clicking on them in the breakpoint view in the lower corner of the Debug tab.

This diff fixes the ordering problem. The traversal + querying was done very fast in O(nlogn) time. I'm keeping the same complexity.

I also updated a couple of tests to account for the ordering.

Reviewers: clayborg, aadsm, kusmour, labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76891
2020-03-27 08:42:58 -07:00
Jonas Devlieghere 17e4c38739 [lldb/CMake] Fix `install` for multi-configuration generators.
For multi-generator builds like MSVC and Xcode, the install source and
destination of the lldb-python-scripts target contains configuration
dependent paths and therefore need to be substituted.

Differential revision: https://reviews.llvm.org/D76827
2020-03-26 09:51:29 -07:00
Anton Kolesov a92673fe9a [lldb-vscode] Convert launch_info and attach_info to local variables
Those fields inside of the global variable can be local variables because
they are used in only inside of one function: request_launch for launch_info
and request_attach for attach_info.

To avoid confusion an already existing local variable attach_info of
request_attach has been renamed to better reflect its purpose.

Differential Revision: https://reviews.llvm.org/D76593
2020-03-26 18:48:40 +03:00
Pavel Labath e22f0dabcf [lldb/breakpad] Fix register resolution on arm
In breakpad, only x86 (and mips) registers have a leading '$' in their
names. Arm architectures use plain register names.

Previously, lldb was assuming all registers have a '$'. Fix the code to
match the (unfortunately, inconsistent) reality.
2020-03-26 13:51:27 +01:00
Tatyana Krasnukha 2bfe2b878a [lldb][testsuite] Check that process is launched successfully in inline tests 2020-03-26 15:05:30 +03:00
Tatyana Krasnukha ccf1c30cde [lldb][testsuite] Add lldb-server category 2020-03-26 15:05:30 +03:00
Emre Kultursay 57be22fa17 [LLDB] Fix parsing of IPv6 host:port inside brackets
Summary:
When using IPv6 host:port pairs, typically the host is put inside
brackets, such as [2601🔢...:0213]:5555, and the UriParser
can handle this format.

However, the Android infrastructure in LLDB assumes an additional
brackets around the host:port pair, such that the entire host:port
string can be treated as the host (which is used as an Android Serial
Number), and UriParser cannot handle multiple brackets. Parsing
inputs with such extra backets requires searching the closing bracket
from the right.

Test: BracketedHostnameWithPortIPv6 covers the case mentioned above

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: kwk, shafik, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76736
2020-03-26 11:35:54 +01:00
Shivam Mittal daed98e5b5 Convert CommandObjectCommands functions to return StringRefs
Reviewers: jingham, aprantl, labath, jankratochvil

Reviewed By: labath, jankratochvil

Subscribers: labath, jankratochvil, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76569
2020-03-26 11:20:38 +01:00
Pavel Labath 703a856a10 [lldb] Fix TestVSCode_completions for clang 159a9f7
Printing of types has changed slightly.

Also improve the error messages the test gives when it fails.
2020-03-26 10:24:33 +01:00
Pavel Labath c72675394a [lldb] add lit.local.cfg for breakpad tests
The reason is to add .yaml as a valid test suffix. The test folder
contains one yaml file, which wasn't being run because of that.

Unsurprisingly the test fails, but this was not because the underlying
functionality was broken, but rather because the test was setup
incorrectly (most likely due to overly aggressive simplification of the
test data on my part).

Therefore this patch also tweaks the test inputs in order to test what
they are supposed to test, and also updates some other breakpad tests
(because they depend on the same inputs as this one) to be more
realistic -- specifically it avoids putting symbols to the first page of
the module, as that's where normally the COFF header would reside.
2020-03-25 17:00:46 +01:00
Raphael Isemann 7754b652b3 [lldb][NFC] lldb_assert->lldbassert in ClangExpressionParser
lldbassert is the macro that takes care of passing along line/file/function
to the lldb_assert function. Let's call that instead of manually calling the
function.
2020-03-25 14:10:48 +01:00
Davide Italiano 3e11d84d9f [Darwin] Add another hint to find the kernel. NFC. 2020-03-24 13:04:36 -07:00
Vedant Kumar 03e29e2c19 [lldb/DWARF] Reland: Use DW_AT_call_pc to determine artificial frame address
Reland with changes: the test modified in this change originally failed
on a Debian/x86_64 builder, and I suspect the cause was that lldb looked
up the line location for an artificial frame by subtracting 1 from the
frame's address. For artificial frames, the subtraction must not happen
because the address is already exact.

---

lldb currently guesses the address to use when creating an artificial
frame (i.e., a frame constructed by determining the sequence of (tail)
calls which must have happened).

Guessing the address creates problems -- use the actual address provided
by the DW_AT_call_pc attribute instead.

Depends on D76336.

rdar://60307600

Differential Revision: https://reviews.llvm.org/D76337
2020-03-24 12:54:40 -07:00
Raphael Isemann 0ccc4de42e [lldb] Always log if acquiring packet sequence mutex fails
Summary:
Currently we only log in debug builds but I don't see why we would do this as this is neither
expensive and seems useful.

I looked into the git history of this code and it seems originally there was also an assert here
and the logging here was the #else branch branch for non-Debug builds.

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D76698
2020-03-24 20:24:50 +01:00
Vedant Kumar 0a9b91c390 Revert "[lldb/DWARF] Use DW_AT_call_pc to determine artificial frame address"
This reverts commit 6905394d15. The
changed test is failing on Debian/x86_64, possibly because lldb is
subtracting an offset from the DW_AT_call_pc address used for the
artificial frame:

http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/7171/steps/test/logs/stdio

/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/tail_call_frames/unambiguous_sequence/main.cpp:6:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: frame #1: 0x{{[0-9a-f]+}} a.out`func3() at main.cpp:14:3 [opt] [artificial]
                ^
<stdin>:3:2: note: scanning from here
 frame #1: 0x0000000000401127 a.out`func3() at main.cpp:13:4 [opt] [artificial]
2020-03-24 12:22:12 -07:00
Raphael Isemann 6b6a779ca8 [lldb][NFC] Always update m_cache_{hits/misses} in FormatCache
Summary:
These two variables are only incremented under LLDB_CONFIGURATION_DEBUG but their
value is always logged when verbose lldb formatter logging is enabled, which causes that our
cache hit/miss log looks like this in non-Debug builds:

```
Cache hits: 0 - Cache Misses: 0
...
Cache hits: 0 - Cache Misses: 0
...
Cache hits: 0 - Cache Misses: 0
```

This just always increments those two counters independent of build mode.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D76687
2020-03-24 20:16:43 +01:00
Raphael Isemann aef982e35a [lldb] Don't dump the frame in SBTarget::EvaluateExpression in LLDB_CONFIGURATION_DEBUG
Summary:
Dumping the frame using the user-set format could cause that a debug LLDB doesn't behave as a release LLDB,
which could potentially break replaying a reproducer.

Also it's kinda strange that the frame format set by the user is used in the internal log output.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D76685
2020-03-24 20:16:09 +01:00
Vedant Kumar 6905394d15 [lldb/DWARF] Use DW_AT_call_pc to determine artificial frame address
lldb currently guesses the address to use when creating an artificial
frame (i.e., a frame constructed by determining the sequence of (tail)
calls which must have happened).

Guessing the address creates problems -- use the actual address provided
by the DW_AT_call_pc attribute instead.

Depends on D76336.

rdar://60307600

Differential Revision: https://reviews.llvm.org/D76337
2020-03-24 12:02:03 -07:00
Raphael Isemann b8dab9b3d5 [lldb] Remove some debugging printfs from ITSession code
Summary:
This seems only useful for debugging and it's just plainly printf'ing to the console instead
of some log, so let's remove this.

Reviewers: #lldb, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D76699
2020-03-24 18:09:27 +01:00
Jonas Devlieghere 1f80e51546 [lldb/Reproducers] Collect files imported by command script import
Files imported by the script interpreter aren't opened by LLDB so they
don't end up in the reproducer. The solution is to explicitly add them
to the FileCollector.

Differential revision: https://reviews.llvm.org/D76626
2020-03-24 08:54:26 -07:00
Jaroslav Sevcik 177dd63c8d Data formatters: fix detection of C strings
Summary:
Detection of C strings does not work well for pointers. If the value object holding a (char*) pointer does not have an address (e.g., if it is a temp), the value is not considered a C string and its formatting is left to DumpDataExtractor rather than the special handling in  ValueObject::DumpPrintableRepresentation. This leads to inconsistent outputs, e.g., in escaping non-ASCII characters. See the test for an example; the second test expectation is not met (without this patch). With this patch, the C string detection only insists that the pointer value is valid. The patch makes the code consistent with how the pointer is obtained in ValueObject::ReadPointedString.

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76650
2020-03-24 14:25:59 +01:00
Raphael Isemann 68687e75e7 [lldb][NFC] Mark GetNextPersistentVariableName as overriden to silence warning
This was triggering -Winconsistent-missing-override warnings.
2020-03-24 12:30:03 +01:00
Walter Erquinigo e0279d720a [lldb-vscode] Add missing launchCommands entry in the package.json 2020-03-23 23:21:30 -07:00
Walter Erquinigo ca69be218c Create basic SBEnvironment class 2020-03-23 19:23:33 -07:00
Walter Erquinigo 318a0caf9a Revert "Create basic SBEnvironment class"
This reverts commit fd868f517d.
2020-03-23 18:20:10 -07:00
Walter Erquinigo fd868f517d Create basic SBEnvironment class 2020-03-23 17:59:06 -07:00
Fred Riss b6ae8937e0 [lldb/PlatformDarwin] Always delete destination file first in PutFile
Summary:
The default behavior of Platform::PutFile is to open the file and
truncate it if it already exists. This works fine and is a sensible
default, but it interacts badly with code-signing on iOS, as doing so
invalidates the signature of the file (even if the new content has a
valid code signature).

We have a couple tests which on purpose reload a different binary with
the same name. Those tests are currently broken because of the above
interaction.

This patch simply makes the Darwin platform unconditionally delete the
destination file before sending the new one to work around this issue.

Reviewers: jasonmolenda

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76450
2020-03-23 14:34:17 -07:00
Jim Ingham 67d67ebe8f Internal expressions shouldn't increment the result variable numbering.
There an option: EvaluateExpressionOptions::SetResultIsInternal to indicate
whether the result number should be returned to the pool or not.  It
got broken when the PersistentExpressionState was refactored.

This fixes the issue and provides a test of the behavior.

Differential Revision: https://reviews.llvm.org/D76532
2020-03-23 13:30:37 -07:00
shafik a567d6809e [DataFormatters] Add formatter for libc++ std::unique_ptr
This adds a formatter for libc++ std::unique_ptr.

I also refactored GetValueOfCompressedPair(...) out of LibCxxList.cpp since I need the same functionality and it made sense to share it.

Differential Revision: https://reviews.llvm.org/D76476
2020-03-23 11:48:20 -07:00
Jonas Devlieghere ae37e2285d [lldb/Reproducers] Mark reproducer test directory as unsupported on Windows
Reproducers are unsupported on Windows. Rather than having a UNSUPPORTED
line in every test, just skip the whole subdirectory.
2020-03-23 09:54:11 -07:00
Fred Riss 7e10581e8c [lldb/testsuite] Skip part of TestSettings.py on windows
The newly introduced tests for unsetting environment variables
is failing on Windows. Skip the test there to allow investigation.

It seems like setting inherit-env to false was never tested
before. Could it be that the Windows process launcher doesn't
honor this setting?
2020-03-23 09:15:16 -07:00
Fred Riss b4a6e63ea1 [lldb/Target] Rework the way the inferior environment is created
Summary:
The interactions between the environment settings (`target.env-vars`,
`target.inherit-env`) and the inferior life-cycle are non-obvious
today. For example, if `target.inherit-env` is set, the `target.env-vars`
setting will be augmented with the contents of the host environment
the first time the launch environment is queried (usually at
launch). After that point, toggling `target.inherit-env` will have no
effect as there's no tracking of what comes from the host and what is
a user setting.

This patch computes the environment every time it is queried rather
than updating the contents of the `target.env-vars` property. This
means that toggling the `target.inherit-env` property later will now
have the intended effect.

This patch also adds a `target.unset-env-vars` settings that one can
use to remove variables from the launch environment. Using this, you
can inherit all but a few of the host environment.

The way the launch environment is constructed is:
  1/ if `target.inherit-env` is set, then read the host environment
  into the launch environment.
  2/ Remove for the environment the variables listed in
  `target.unset-env`.
  3/ Augment the launch environment with the contents of
  `target.env-vars`. This overrides any common values with the host
  environment.

The one functional difference here that could be seen as a regression
is that `target.env-vars` will not contain the inferior environment
after launch. The patch implements a better alternative in the
`target show-launch-environment` command which will return the
environment computed through the above rules.

Reviewers: labath, jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76470
2020-03-23 07:58:34 -07:00
Fred Riss cd7b45057c [lldb/API] Make Launch(Simple) use args and env from target properties
Summary:
When no arguments or environment is provided to SBTarget::LaunchSimple,
make it use the values surrently set in the target properties. You can
get the current behavior back by passing an empty array instead.

It seems like using the target defaults is a much more intuitive
behavior for those APIs. It's unllikely that anyone passed NULL/None to
this API after having set properties in order to explicitely ignore them.

One direct application of this change is within the testsuite. We have
plenty of tests calling LaunchSimple and passing None as environment.
If you passed --inferior-env to dotest.py to, for example, set
(DY)LD_LIBRARY_PATH, it wouldn't be taken into account.

Reviewers: jingham, labath, #libc_abi!

Subscribers: libcxx-commits, lldb-commits

Tags: #lldb, #libc_abi

Differential Revision: https://reviews.llvm.org/D76045
2020-03-23 07:58:33 -07:00
Fred Riss 9228a9efc6 [lldb/Target] Initialize new targets environment variables from target.env-vars
Summary:
The TargetProperties constructor invokes a series of callbacks to
prime the properties from the default ones. The one callback in
charge of updating the inferior environment was commented out
because it crashed.

The reason for the crash is that TargetProperties is a parent class
of Target and the callbacks were invoked using a Target that was
not fully initialized. This patch moves the initial callback
invocations to a separate function that can be called at the end
the Target constructor, thus preventing the crash.

One existing test had to be modified, because the initialization of
the environment properties now take place at the time the target is
created, not at the first use of the environment (usually launch
time).

The added test checks that the LaunchInfo object returned by
the target has been primed with the values from the settings.

Reviewers: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76009
2020-03-23 07:58:33 -07:00
Raphael Isemann 6a4905ae2d [lldb] Mark expressions that couldn't be parsed or executed as failed expressions
Summary:
LLDB keeps statistics of how many expression evaluations are 'successful' and 'failed'
which are updated after each expression evaluation (assuming statistics are enabled).
From what I understand the idea is that this could be used to define how well LLDB's
expression evaluator is working.

Currently all expressions are considered successful unless the user passes an explicit
positive element counting to the expression command (with the `-Z` flag) and then passes
an expression that successfully evaluates to a type that doesn't support element counting.
Expressions that fail to parse, execute or any other outcome are considered successful
at the moment which means we nearly always have a 100% expression evaluation
success rate.

This patch makes that expressions that fail to parse or execute to count as failed
expressions.

We can't know whether the expression failed because of an user error
of because LLDB couldn't correctly parse/compile it, but I would argue that this is
still an improvement. Assuming that the percentage of valid user expressions stays
mostly constant over time (which seems like a reasonable assumption), then this
way we can still see if we are doing relatively better/worse from release to release.

Reviewers: davide, aprantl, JDevlieghere

Reviewed By: aprantl

Subscribers: abidh

Differential Revision: https://reviews.llvm.org/D76280
2020-03-23 15:28:17 +01:00
Walter Erquinigo 7ece7c0faa Revert "Create basic SBEnvironment class"
This reverts commit 34c0759f84.
2020-03-20 19:25:27 -07:00
Walter Erquinigo e292cdfb33 Revert "[lldb-vscode] Add missing launchCommands entry in the package.json"
This reverts commit a8c22ba416.
2020-03-20 19:25:12 -07:00
Walter Erquinigo c85bf7cfa8 Revert "[lldb-vscode] Add inheritEnvironment option"
This reverts commit 4ec6ebabfc.
2020-03-20 19:24:51 -07:00
Walter Erquinigo 34c0759f84 Create basic SBEnvironment class
Summary: Inspired by https://reviews.llvm.org/D74636, I'm introducing a basic version of Environment in the API. More functionalities can be added as needed.

Reviewers: labath, clayborg

Subscribers: mgorny, lldb-commits, diazhector98

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76111
2020-03-20 18:51:25 -07:00
Hector Diaz 4ec6ebabfc [lldb-vscode] Add inheritEnvironment option
Summary:
If no custom launching is used, lldb-vscode launches a program with an empty environment by default. In some scenarios, the user might want to simply use the same environment as the IDE to have a set of working environment variables (e.g. PATH wouldn't be empty). In fact, most DAPs in VSCode have this behavior by default. In other cases the user definitely needs to set their custom environment, which is already supported. To make the first case easier for the user (e.g. not having to copy the PATH to the launch.json every time they want to debug simple programs that rely on PATH), a new option is now offered. inheritEnvironment will launch the program copying its own environment, and it's just a boolean flag.

{F11347695}

Reviewers: clayborg, aadsm, diazhector98, kusmour

Subscribers: labath, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74636
2020-03-20 18:51:25 -07:00
Walter Erquinigo a8c22ba416 [lldb-vscode] Add missing launchCommands entry in the package.json
Summary:
https://reviews.llvm.org/D65363 introduced the launchCommands argument. However, it did not add
a corresponding definition in the package.json

Reviewers: clayborg, labath, kusmour, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76529
2020-03-20 18:51:25 -07:00
Jonas Devlieghere 09c8845adf [lldb]/Tablegen] Use ElementType instead of DefaultValueUnsinged
The fourth field in the property struct is the default unsigned or enum
value for all types, except for Array and Dictionary types. For those,
it is the element type. During the tablegen conversion, this was
incorrectly translated to DefaultValueUnsigned with a value
corresponding to the OptionValue: enum type. So for
OptionValue::eTypeString this became DefaultUnsignedValue<16>. This
patch extends the tablegen backend to understand ElementType to express
this as ElementType<"String">.

Differential revision: https://reviews.llvm.org/D76535
2020-03-20 18:35:13 -07:00
Adrian Prantl 0a5fbf3093 Temporarily Revert "Create basic SBEnvironment class"
while investigating bot breakage.

This reverts commit 2dec82652e.
2020-03-20 16:47:50 -07:00
Walter Erquinigo 2dec82652e Create basic SBEnvironment class
Summary: Inspired by https://reviews.llvm.org/D74636, I'm introducing a basic version of Environment in the API. More functionalities can be added as needed.

Reviewers: labath, clayborg

Subscribers: mgorny, lldb-commits, diazhector98

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76111
2020-03-20 14:38:50 -07:00
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
Raphael Isemann b6b3fcdcb8 [lldb] Don't iterate over a std::set<Type*> in SymbolFileDWARF::GetTypes to make it deterministic
Summary:
Currently `SymbolFileDWARF::TypeSet` is a typedef to a `std::set<Type *>`.
In `SymbolFileDWARF::GetTypes` we iterate over a TypeSet variable when finding
types so that logic is non-deterministic as it depends on the actual pointer address values.

This patch changes the `TypeSet` to a `llvm::UniqueVector` which always iterates in
the order in which we inserted the types into the list.

Reviewers: JDevlieghere, aprantl

Reviewed By: JDevlieghere

Subscribers: mgrang, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75481
2020-03-02 15:03:45 -08:00
Davide Italiano eddf59ae71 [docs] Use 0 as version placeholder instead of a made up number.
While here, explain that this is not really used. Probably NFC.
2020-03-02 14:55:05 -08:00
Jonas Devlieghere c77fc00eec [lldb/Docs] Remove the version from the home page 2020-03-02 14:23:05 -08:00
Raphael Isemann 69d2b67556 [lldb] Remove checks behind LLDB_CONFIGURATION_DEBUG from TypeSystemClang
Summary:
This function is (supposed) to be a list of asserts that just do a generic sanity check
on declarations we return. Right now this function is hidden behind the
LLDB_CONFIGURATION_DEBUG macro which means it will *only* be run in
debug builds (but not Release+assert builds and so on).

As we have not a single CI running in Debug build, failures in VerifyDecl are hidden
from us until someone by accident executes the tests in Debug mode on their own machine.

This patch removes the `ifdef`'s for LLDB_CONFIGURATION_DEBUG and puts
the `getAccess()` call in `VerifyDecl` behind a `#ifndef NDEBUG` to make sure
that this function is just an empty function with internal linkage when NDEBUG
is defined (so compilers should just optimize away the calls to it).

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: shafik, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75330
2020-03-02 10:57:56 -08:00
Pavel Labath 7369ad38f8 [lldb] Use llvm MC as the source of dwarf/eh register numbers for X86 ABIs
x86_64 ABIs were converted with 07355c1c0. This does the same with i386.
2020-02-28 10:49:08 +01:00
Reid Kleckner e3a9b0f359 [Support] Remove byte swapping from MathExtras.h
MathExtras.h was just wrapping SwapByteOrder.h functionality, so have
the callers use it directly.  Use the MathExtras.h name (ByteSwap_NN) as
the standard naming, since it appears to be the most popular.
2020-02-27 17:23:48 -08:00
Reid Kleckner 4c2a6567bb Avoid ASTContext.h -> TargetInfo.h dep
This has been done before in 2008: ab13857072
But these things regress easily.
Move some things out of line.

Saves 316 includes + transitive stuff:
    316 -    ../clang/include/clang/Basic/TargetOptions.h
    316 -    ../clang/include/clang/Basic/TargetInfo.h
    316 -    ../clang/include/clang/Basic/TargetCXXABI.h
    316 -    ../clang/include/clang/Basic/OpenCLOptions.h
    316 -    ../clang/include/clang/Basic/OpenCLExtensions.def
    302 -    ../llvm/include/llvm/Target/TargetOptions.h
    302 -    ../llvm/include/llvm/Support/CodeGen.h
    302 -    ../llvm/include/llvm/MC/MCTargetOptions.h
    302 -    ../llvm/include/llvm/ADT/FloatingPointMode.h
    302 -    ../clang/include/clang/Basic/XRayInstr.h
    302 -    ../clang/include/clang/Basic/DebugInfoOptions.h
    302 -    ../clang/include/clang/Basic/CodeGenOptions.h
    302 -    ../clang/include/clang/Basic/CodeGenOptions.def
    257 -    ../llvm/include/llvm/Support/Regex.h
     79 -    ../llvm/include/llvm/ADT/SmallSet.h
     68 -    MSVCSTL/include/set
     66 -    ../llvm/include/llvm/ADT/SmallPtrSet.h
     62 -    ../llvm/include/llvm/ADT/StringSwitch.h
2020-02-27 14:35:00 -08:00
Reid Kleckner 86565c1309 Avoid SourceManager.h include in RawCommentList.h, add missing incs
SourceManager.h includes FileManager.h, which is expensive due to
dependencies on LLVM FS headers.

Remove dead BeforeThanCompare specialization.

Sink ASTContext::addComment to cpp file.

This reduces the time to compile a file that does nothing but include
ASTContext.h from ~3.4s to ~2.8s for me.

Saves these includes:
    219 -    ../clang/include/clang/Basic/SourceManager.h
    204 -    ../clang/include/clang/Basic/FileSystemOptions.h
    204 -    ../clang/include/clang/Basic/FileManager.h
    165 -    ../llvm/include/llvm/Support/VirtualFileSystem.h
    164 -    ../llvm/include/llvm/Support/SourceMgr.h
    164 -    ../llvm/include/llvm/Support/SMLoc.h
    161 -    ../llvm/include/llvm/Support/Path.h
    141 -    ../llvm/include/llvm/ADT/BitVector.h
    128 -    ../llvm/include/llvm/Support/MemoryBuffer.h
    124 -    ../llvm/include/llvm/Support/FileSystem.h
    124 -    ../llvm/include/llvm/Support/Chrono.h
    124 -    .../MSVCSTL/include/stack
    122 -    ../llvm/include/llvm-c/Types.h
    122 -    ../llvm/include/llvm/Support/NativeFormatting.h
    122 -    ../llvm/include/llvm/Support/FormatProviders.h
    122 -    ../llvm/include/llvm/Support/CBindingWrapping.h
    122 -    .../MSVCSTL/include/xtimec.h
    122 -    .../MSVCSTL/include/ratio
    122 -    .../MSVCSTL/include/chrono
    121 -    ../llvm/include/llvm/Support/FormatVariadicDetails.h
    118 -    ../llvm/include/llvm/Support/MD5.h
    109 -    .../MSVCSTL/include/deque
    105 -    ../llvm/include/llvm/Support/Host.h
    105 -    ../llvm/include/llvm/Support/Endian.h

Reviewed By: aaron.ballman, hans

Differential Revision: https://reviews.llvm.org/D75279
2020-02-27 13:49:40 -08:00
Jonas Devlieghere 04a91deebb [lldb/CMake] Use PYTHON_HOME as a hint to find Python 3.
http://lists.llvm.org/pipermail/lldb-dev/2020-February/015998.html

Differential revision: https://reviews.llvm.org/D75275
2020-02-27 13:17:49 -08:00
Paolo Severini 256e61699b [LLDB] Fix AddressSanitizer failure in MemoryCache
The lldb sanitizer bot is flagging a container-overflow error after we
introduced test TestWasm.py. MemoryCache::Read didn't behave correctly
in case of partial reads that can happen with object files whose size is
smaller that the cache size. It should return the actual number of bytes
read and not try to fill the buffer with random memory.
Module::GetMemoryObjectFile needs to be modified accordingly, to resize
its buffer to only the size that was read.

Differential Revision: https://reviews.llvm.org/D75200
2020-02-27 11:17:10 -08:00
Raphael Isemann 4bb3cb2bcb [lldb] Show the actual error when 'watchpoint set expression' failed
Currently we only show the user that the expression failed but not
what is actually wrong with it. This just dumps the error we get
back alongside the other output to the error stream.

This should also help with finding out with why sometimees the
TestWatchLocationWithWatchSet.py test fails here on the LLDB
incremental bot on Green Dragon.
2020-02-27 12:06:51 +01:00
Raphael Isemann 2affdcee61 [lldb][NFC] Fix several -Wdocumentation warnings
The GetOffset documentation was copied from the function above
so I completely deleted that one. The rest was just outdated
documentation that didn't keep up with renamed or changed
function parameters/return types.
2020-02-27 11:17:16 +01:00
Raphael Isemann 56b03c35dd [lldb] Skip TestWasm.py on sanitized builds until D75200 has landed 2020-02-27 10:45:42 +01:00
Davide Italiano 34ee941f6d [ObjectFileMachO] Fix a build error on embedded. 2020-02-26 14:31:48 -08:00
Reid Kleckner 34312ed24e Remove unneeded Compiler.h and DataTypes.h includes, NFC 2020-02-26 10:36:17 -08:00
Vedant Kumar 7822c8c03e [lldb/test] Skip running a test under ASan, it intentionally double-frees 2020-02-26 10:11:39 -08:00
Unnar Freyr Erlendsson 594130db0a Add unit tests for RangeDataVector::FindEntryIndexesThatContain
Summary: This adds unit tests for FindEntryIndexesThatContain, this is done in preparation for changing the logic of the function.

Reviewers: labath, teemperor

Reviewed By: labath

Subscribers: arphaman, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75180
2020-02-26 16:47:42 +01:00
Pavel Labath d4eca120ac [lldb/gdb-remote] Add support for the qOffsets packet
Summary:
This packet is necessary to make lldb work with the remote-gdb stub in
user mode qemu when running position-independent binaries. It reports
the relative position (load bias) of the loaded executable wrt. the
addresses in the file itself.

Lldb needs to know this information in order to correctly set the load
address of the executable. Normally, lldb would be able to find this out
on its own by following the breadcrumbs in the process auxiliary vector,
but we can't do this here because qemu does not support the
qXfer:auxv:read packet.

This patch does not implement full scope of the qOffsets packet (it only
supports packets with identical code, data and bss offsets), because it
is not fully clear how should the different offsets be handled and I am
not aware of a producer which would make use of this feature (qemu will
always
<https://github.com/qemu/qemu/blob/master/linux-user/elfload.c#L2436>
return the same value for code and data offsets). In fact, even gdb
ignores the offset for the bss sections, and uses the "data" offset
instead.  So, until the we need more of this packet, I think it's best
to stick to the simplest solution possible. This patch simply rejects
replies with non-uniform offsets.

Reviewers: clayborg, jasonmolenda

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74598
2020-02-26 10:18:58 +01:00
Jason Molenda 4b2b8b96db Re-land Unwind past an interrupt handler correctly on arm or at pc==0
Updated the patch to only fetch $pc on a Return Address-using
target only if we're in a trap frame *and* if there is a saved
location for $pc in the trap frame's unwind rules.  If not,
we fall back to fetching the Return Address register (eg $lr).

Original commit msg:

    Unwind past an interrupt handler correctly on arm or at pc==0

    Fix RegisterContextLLDB::InitializeNonZerothFrame so that it
    will fetch a FullUnwindPlan instead of falling back to the
    architectural default unwind plan -- GetFullUnwindPlan knows
    how to spot a jmp 0x0 that results in a fault, which may be
    the case when we see a trap handler on the stack.

    Fix RegisterContextLLDB::SavedLocationForRegister so that when
    the pc value is requested from a trap handler frame, where we
    have a complete register context available to us, don't provide
    the Return Address register (lr) instead of the pc.  We have
    an actual pc value here, and it's pointing to the instruction
    that faulted.

    Differential revision: https://reviews.llvm.org/D75007
    <rdar://problem/59416588>
2020-02-25 14:58:20 -08:00
Jim Ingham 3cd13c4624 Fix a race between lldb's packet timeout and the profile thread's usleep.
The debugserver profile thread used to suspend itself between samples with
a usleep.  When you detach or kill, MachProcess::Clear would delay replying
to the incoming packet until pthread_join of the profile thread returned.
If you are unlucky or the suspend delay is long, it could take longer than
the packet timeout for pthread_join to return.  Then you would get an error
about detach not succeeding from lldb - even though in fact the detach was
successful...

I replaced the usleep with PThreadEvents entity.  Then we just call a timed
WaitForEventBits, and when debugserver wants to stop the profile thread, it
can set the event bit, and the sleep will exit immediately.

Differential Revision: https://reviews.llvm.org/D75004
2020-02-25 11:17:08 -08:00
Ayke van Laethem ec1efe7113
[LLDB] Let DataExtractor deal with two-byte addresses
AVR usually uses two byte addresses. By making DataExtractor deal with
this, it is possible to load AVR binaries that don't have debug info
associated with them.

Differential Revision: https://reviews.llvm.org/D73969
2020-02-25 16:27:38 +01:00
Raphael Isemann bdb24faa2a [lldb][NFC] Move filling namespace map in ClangASTSource to own function 2020-02-25 13:59:21 +01:00
Raphael Isemann 93b6e19240 [lldb] Initialize NameSearchContext::m_namespace_map in constructor
This member is for some reason initialized in ClangASTSource::FindExternalVisibleDecls
so all other functions using this member dereference a nullptr unless we
call this function before that. Let's just initialize this in the constructor.

This should be NFC as the only side effect is that we don't reset the namespace map
when calling ClangASTSource::FindExternalVisibleDecls multiple times (and we never
call this function multiple times for one NameSearchContext from what I can see).
2020-02-25 13:20:54 +01:00
Raphael Isemann 2ad7b6fba0 [lldb][NFC] Make NameSearchContext::m_found members bools instead of bitfields
The size of NameSearchContext isn't important as we never store it and rarely
allocate more than a few. This way we also don't have to use the memset to
initialize these fields to zero.
2020-02-25 12:45:00 +01:00
Raphael Isemann defd0e24aa [lldb][NFC] Move NameSearchContext to own header/source files
The class is large enough to be in its own file. This patch also removes the cyclic
dependency between ClangASTSource <-> NameSearchContext.
2020-02-25 12:25:36 +01:00
Raphael Isemann fc0d11c904 [lldb][NFC] Modernize logging in ClangASTSource/ExpressionDeclMap 2020-02-25 12:08:09 +01:00
Raphael Isemann 05d174d301 [lldb][NFC] Move namespace lookup in ClangASTSource to own function.
Beside being cleaner we can probably reuse that logic elsewhere.
2020-02-25 10:27:47 +01:00
Pavel Labath eefbff0082 [lldb] s/CHECK-NEXT/CHECK-DAG in dwp-debug-types.s
These can come out nondeterministically for two reasons:
- sorting based on ConstStringified pointer values
- different relative speeds of the indexing threads

Making these nondeterministic without incurring performance penalties is
hard, so I just make the test expect them in any order (the order is not
important in this test anyway.
2020-02-25 10:04:09 +01:00
Raphael Isemann ea6b95dc2f [lldb][NFC] Make ArrayRef initialization more obvious in lldb-test.cpp
Seems like this code raised some alarm bells as it looks like an ArrayRef
to a temporary initializer list, but it's actually just calling the ArrayRef(T*, T*)
constructor. Let's clarify this and directly call the right ArrayRef constructor here.

Fixes rdar://problem/59176052
2020-02-25 09:48:17 +01:00
Raphael Isemann 55d4b0d7dd [lldb] Fix that a crashing test is marked as unsupported when it prints UNSUPPORTED before crashing
Summary:
I added an `abort()` call to some code and noticed that the test suite was still passing and it just marked my test as "UNSUPPORTED".

It seems the reason for that is that we expect failing tests to print "FAIL:" which doesn't happen when we crash. If we then also
have an unsupported because we skipped some debug information in the output, we just mark the test passing because it is unsupported
on the current platform.

This patch marks any test that has a non-zero exit code as failing even if it doesn't print "FAIL:" (e.g., because it crashed).

Reviewers: labath, JDevlieghere

Reviewed By: labath, JDevlieghere

Subscribers: aprantl, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75031
2020-02-25 08:46:37 +01:00
Pavel Labath c08a1c7071 [lldb] Mark ObjectFileBreakpad test inputs as non-text
These are technically text files, but the object file layer treats them
as binary, and the relevant tests verify the parsed contents byte for
byte. Git's crlf conversion can make those tests fail. Marking the files
as non-text disables that.
2020-02-25 08:29:41 +01:00
Jonas Devlieghere 35a0614535 [lldb/Utility] Fix unspecified behavior.
Order of evaluation of the operands of any C++ operator [...] is
unspecified. This patch fixes the issue in Stream::Indent by calling the
function consecutively.

On my Windows setup, TestSettings.py fails because the function prints
the value first, followed by the indentation.

Expected result:
  MY_FILE=this is a file name with spaces.txt

Actual result:
MY_FILE  =this is a file name with spaces.txt
2020-02-24 21:25:55 -08:00
Jason Molenda 4fdd2edbdb Revert "Unwind past an interrupt handler correctly on arm or at pc==0"
The aarcht64-ubuntu bot is showing a test failure in TestHandleAbort.py
with this patch.  Adding some logging to that file, it looks like
the saved register context above the trap handler does not have
save state for $pc, but it does have it for $lr on that platform.
I need to fall back to looking for $lr if the $pc cannot be retrieved.
I'll update the patch and re-commit once that's fixed.

This reverts commit edc4f4c9c9.
2020-02-24 19:03:22 -08:00
Jason Molenda d5a4fa0514 Revert "My prevous commit to RegisterContextLLDB is causing a test fail"
This reverts commit 082f1a3b15.
2020-02-24 19:03:22 -08:00
Jason Molenda 082f1a3b15 My prevous commit to RegisterContextLLDB is causing a test fail
on aarch64-ubuntu - collect a little information about what
is happening on this target before I revert my change; I don't
have access to this target.
2020-02-24 17:19:06 -08:00
Shoaib Meenai e34ddc09f4 [arcconfig] Delete subproject arcconfigs
From https://secure.phabricator.com/book/phabricator/article/arcanist_new_project/:

> An .arcconfig file is a JSON file which you check into your project's root.

I've done some experimentation, and it looks like the subproject
.arcconfigs just get ignored, as the documentation says. Given that
we're fully on the monorepo now, it's safe to remove them.

Differential Revision: https://reviews.llvm.org/D74996
2020-02-24 16:20:36 -08:00
Jason Molenda edc4f4c9c9 Unwind past an interrupt handler correctly on arm or at pc==0
Fix RegisterContextLLDB::InitializeNonZerothFrame so that it
will fetch a FullUnwindPlan instead of falling back to the
architectural default unwind plan -- GetFullUnwindPlan knows
how to spot a jmp 0x0 that results in a fault, which may be
the case when we see a trap handler on the stack.

Fix RegisterContextLLDB::SavedLocationForRegister so that when
the pc value is requested from a trap handler frame, where we
have a complete register context available to us, don't provide
the Return Address register (lr) instead of the pc.  We have
an actual pc value here, and it's pointing to the instruction
that faulted.

Differential revision: https://reviews.llvm.org/D75007
<rdar://problem/59416588>
2020-02-24 16:11:15 -08:00
Jonas Devlieghere 841be9854c [lldb] Color the line marker
Highlight the color marker similar to what we do for the column marker.
The default color matches the color of the current PC marker (->) in the
default disassembly format.

Differential revision: https://reviews.llvm.org/D75070
2020-02-24 15:40:31 -08:00
Med Ismail Bennani eefda18227 [lldb/Plugins] Move SBTarget::GetExtendedCrashInformation to SBProcess
This patch moves the SB API method GetExtendedCrashInformation from
SBTarget to SBProcess since it only makes sense to call this method on a
sane process which might not be the case on a SBTarget object.

It also addresses some feedbacks received after landing the first patch
for the 'crash-info' feature.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-24 23:37:04 +01:00
Jonas Devlieghere 7f9f027c62 [lldb/Test] Update TestDisassemblyFormat for new format 2020-02-24 14:08:16 -08:00
Jonas Devlieghere c4093db3da [lldb] Color the current PC marker
Differential revision: https://reviews.llvm.org/D75073
2020-02-24 12:51:01 -08:00