Commit Graph

23709 Commits

Author SHA1 Message Date
Jonas Devlieghere 254e0abf5b [lldb] Fix the last remaining tests not inheriting TCC permissions
After this patch all test should have the inferior inheriting the TCC
permissions from its parent.
2020-08-11 12:50:36 -07:00
Jonas Devlieghere 61afdf0ab4 [lldb] Enable inheriting TCC permissions in lldb-test
Like the rest of the test suite, also set the target.inherit-tcc option
to true in lldb-test.
2020-08-11 11:37:14 -07:00
Jonas Devlieghere 7adf5bd181 [lldb] Look beyond the first line to find the PID in TestAppleSimulatorOSType
The current code fails when the first stderr line doesn't match the
given regex to parse the PID. This patch changes the code to read the
first 10 lines before giving up. It also adds tracing for the simctl
commands.
2020-08-11 11:07:04 -07:00
Jonas Devlieghere c135744b1d [lldb/CMake] Separate CMake code for Lua and Python (NFC)
Separate the CMake logic for Lua and Python to clearly distinguish
between code specific to either scripting language and the code shared
by both.

What this patch does is:

 - Move Python specific code into the bindings/python subdirectory.
 - Move the Lua specific code into the bindings/lua subdirectory.
 - Add the _python suffix to Python specific functions/targets.
 - Fix a dependency issue that would check the binding instead of
   whether the scripting language is enabled.

Note that this patch also changes where the bindings are generated,
which might affect downstream projects that check them in.

Differential revision: https://reviews.llvm.org/D85708
2020-08-11 09:04:18 -07:00
Pavel Labath bb91c9fe7b [cmake] Make gtest macro definitions a part the library interface
These definitions are needed by any file which uses gtest. Previously we
were adding them in the add_unittest function, but over time we've
accumulated libraries (which don't go through add_unittest) building on
gtest and this has resulted in proliferation of the definitions.

Making this a part of the library interface enables them to be managed
centrally. This follows a patch for -Wno-suggest-override (D84554) which
took a similar approach.

Differential Revision: https://reviews.llvm.org/D84748
2020-08-11 15:22:44 +02:00
Raphael Isemann 950f1bf976 [lldb] Add SubstTemplateTypeParm to RemoveWrappingTypes
Like the other type sugar removed by RemoveWrappingTypes, SubstTemplateTypeParm
is just pure sugar that should be ignored. If we don't ignore it (as we do now),
LLDB will fail to read values from record fields that have a
SubstTemplateTypeParm type.

Only way to produce such a type in LLDB is to either use the `import-std-module`
setting to get a template into the expression parser or just create your own
template directly in the expression parser which is what we do in the test.

Reviewed By: jarin

Differential Revision: https://reviews.llvm.org/D85132
2020-08-11 14:31:47 +02:00
Gongyu Deng 4f3559db1f [lldb] watchpoint ID common completion for commands `watchpoint delete/enable/disable/modify/ignore`
1. Added a common completion WatchPointIDs to complete with a list of the IDs of the current watchpoints;
2. Applied the completion to these commands: watchpoint delete/enable/disable/modify/ignore;
3. Added a correlated test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84104
2020-08-11 14:25:09 +02:00
Gongyu Deng a952fe236f [lldb] thread index common completion for commands like `thread select/step-over`
1. Added a common completion completing with a list of the threads of the current process;
2. Apply the common completion above to these commands: thread
   continue/info/exception/select/step-in/step-inst/step-inst-over/step-out/step-over/step-script​
3. Correlated test case test_common_completion_thread_index.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84088
2020-08-11 13:27:13 +02:00
Gongyu Deng b2b7dbb47a [lldb] stop-hook ID common completion for commands `target stop-hook enable/disable/delete'
1. Added a common completion StopHookIDs to provide completion with a list of stop hook ids;
2. Applied the common completion to commands: `target stop-hook delete/enable/disable';
3. Added an related test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84123
2020-08-11 13:14:27 +02:00
Raphael Isemann 33d0031edb [lldb] Fix unhandled switch case for GOFF in GDBRemoteCommunicationClient
Just implementing the default case that emits an error to supress the compiler
warning.
2020-08-11 12:57:18 +02:00
Gongyu Deng 419f1be7b5 [lldb] tab completion for `target modules load -u`
1. Added a common completion ModuleUUIDs to provide a list of the UUIDs of modules for completion;
2. Added a new enumeration item eArgTypeModuleUUID to CommandArgumentType which is set as the option argument type of OptionGroupUUID;
3. Applied the module UUID completion to the argument of the type eArgTypeModuleUUID in lldb/source/Interpreter/CommandObject.cpp;
4. Added an related test case in lldb/test/API/functionalities/completion/TestCompletion.py.
2020-08-11 12:35:36 +02:00
Gongyu Deng 66fa73fa27 [lldb] move the frame index completion into a common completion and apply it to `thread backtrace -s`
Commands frame select and thread backtrace -s can be completed in the same way.
Moved the dedicated completion of frame select into a common completion and
apply it to the both commands, along with the test modified.
2020-08-11 12:25:39 +02:00
Gongyu Deng 24bc8afd4b [lldb] tab completion for `target modules search-paths insert​`
Dedicated completion for the command `target modules search-paths insert​` with a test case.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D83309
2020-08-11 11:58:14 +02:00
Gongyu Deng 3ce57e0121 [lldb] type language common completion
1. Added a new common completion TypeLanguages to provide a list of supporting languages;
2. Bound the completion to eArgTypeLanguage;
3. Added a related test case.
2020-08-11 11:07:19 +02:00
Gongyu Deng 31fd64ac57 [lldb] tab completion for 'command delete/unalias'
Provided dedicated tab completions for `command delete/unalias`.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D81128
2020-08-11 10:27:04 +02:00
Raphael Isemann df916062c8 [lldb][NFC] Fix warning in Thread::AutoCompleteThreadPlans 2020-08-11 10:26:01 +02:00
Gongyu Deng f99a18bbaa [lldb] tab completion for `thread plan discard`
Dedicated completion for the command `thread plan discard` with a corresponding
test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D83234
2020-08-11 10:08:16 +02:00
Raphael Isemann 51117e3c51 [lldb][NFC] Remove unused custom reimplementation of realpath for Windows
No one is calling this function it seems and according to
https://bugs.llvm.org/show_bug.cgi?id=47088 this can leak memory, so let's just
remove it:

Quote from the bug report:
> Before return on line 146, the memory allocated on line 130 is not freed.

Reviewed By: amccarth

Differential Revision: https://reviews.llvm.org/D85633
2020-08-11 10:04:42 +02:00
Gongyu Deng 8a5e296975 [lldb] tab completion for `disassemble -F`
1.Added a new common completion DisassemblyFlavors;

2. Bound DisassemblyFlavors to argument of type eArgTypeDisassemblyFlavor in
CommandObject.cpp;

3. Added a related test case.
2020-08-11 10:01:45 +02:00
Gongyu Deng 2e653327e3 [lldb] tab completion for `watchpoint set variable`
1. Applied the common completion `eVariablePathCompletion` to command
`watchpoint set variable`;

2. Added a related test case.

Reviewed By: teemperor, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84177
2020-08-11 09:51:55 +02:00
Jonas Devlieghere a22301ef98 [lldb] Remove redundant add_definitions() in CMake (NFC)
Remove the unused LLDB_CONFIGURATION_RELEASE and move LLDB_USE_OS_LOG
under debugserver which is the only one using it.
2020-08-10 22:45:33 -07:00
Jonas Devlieghere bca43666e7 [lldb] Use modern CMake to avoid repetition (NFC)
Use the target variants of include_directories and add_definitions to
avoid repetition.
2020-08-10 22:29:40 -07:00
Jonas Devlieghere c4701c9c62 [lldb] Add missings moves where appropiate (NFC)
Manually curated list of things found by clang-tidy's
performance-unnecessary-value-param.
2020-08-10 21:02:11 -07:00
Jonas Devlieghere b448eda406 [lldb] Fix typo in AppleDWARFIndex
apple_names_table_up appeared twice in the binary expression, while the
second instance was meant to check apple_namespaces_table_up.

Fixes PR47101
2020-08-10 19:22:52 -07:00
Gongyu Deng e3820570d4 [lldb] tab completion for `platform target-install`
1. Applied the common completion `eDiskFileCompletion` to the first argument of
the command `platform target-install`.
2. Added a related test case.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D84179
2020-08-10 20:14:46 +02:00
Jonas Devlieghere 3162c6aa45 [lldb] Skip TestSimulatorPlatform with out-of-tree debugserver 2020-08-10 10:00:45 -07:00
Jonas Devlieghere b8ff0daeac [lldb] Fix NSArray0 data formatter and add test
Fixes PR47089
2020-08-10 09:38:37 -07:00
Raphael Isemann 8119d6c146 [lldb][NFC] Remove dead code in BreakpointResolverAddress 2020-08-10 11:29:40 +02:00
Eric Christopher b529c5270c Add override to fix -Winconsistent-missing-override warning. 2020-08-09 22:12:10 -07:00
Petr Hosek a4d78d23c5 Revert "[CMake] Simplify CMake handling for zlib"
This reverts commit ccbc1485b5 which
is still failing on the Windows MLIR bots.
2020-08-08 17:08:23 -07:00
Petr Hosek ccbc1485b5 [CMake] Simplify CMake handling for zlib
Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219
2020-08-08 16:44:08 -07:00
Muhammad Omair Javaid c888694a8e [LLDB] Fix timeout value on expect_gdbremote_sequence
D83904 seems to have changed timeout value on expect_gdbremote_sequence which
was 120 previously. This seems to be causing intermittent failures on
lldb-aarch64-ubuntu buildbot.

This patch fixes the timeout value to see the impact on test suite.

Example:
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/7401/steps/test/logs/stdio

Differential Revision: https://reviews.llvm.org/D85514
2020-08-08 23:57:08 +05:00
Jonas Devlieghere a97dfdc30b [lldb] Assert the process has exited before we gets its output. 2020-08-07 15:06:38 -07:00
Jim Ingham d3dfd8cec4 Add a setting to force stepping to always run all threads.
Also allow ScriptedThreadPlans to set & get their StopOthers
state.

<rdar://problem/64229484>

Differential Revision: https://reviews.llvm.org/D85265
2020-08-07 14:47:31 -07:00
Adrian Prantl 38b419eb93 Factor out reference-counting code from PlatformApple*
into PlatformAppleSimulator. This is legal because that is the only
entry point for the Terminate/Initialize functions.
2020-08-07 14:25:32 -07:00
Adrian Prantl 968cba8e89 lldbutil: add a retry mechanism for the ios simulator
We've been seeing this failure on green dragon when the system is
under high load. Unfortunately this is outside of LLDB's control.

Differential Revision: https://reviews.llvm.org/D85542
2020-08-07 13:28:46 -07:00
Jonas Devlieghere e3eb3cf550 [lldb] Only check for --apple-sdk argument on Darwin 2020-08-07 13:05:42 -07:00
Jonas Devlieghere f1d525734f [lldb] Store the Apple SDK in dotest's configuration.
This patch stores the --apple-sdk argument in the dotest configuration.
When it's set, use it instead of the triple to determine the current
platform.

Differential revision: https://reviews.llvm.org/D85537
2020-08-07 11:13:18 -07:00
Christian Kühnel f3cc4df51d Revert "[CMake] Simplify CMake handling for zlib"
This reverts commit 1adc494bce.
This patch broke the Windows compilation on buildbot and pre-merge testing:
http://lab.llvm.org:8011/builders/mlir-windows/builds/5945
https://buildkite.com/llvm-project/llvm-master-build/builds/780
2020-08-07 09:36:49 +02:00
Jonas Devlieghere dbf44b8330 [LLDB] Mark test_launch_simple as a no-debug-info test
No need to run this test with the multiple variants.
2020-08-06 23:18:37 -07:00
Adrian Prantl 243903f326 Factor out common code from the iPhone/AppleTV/WatchOS simulator platform plugins. (NFC)
The implementation of these classes was copied & pasted from the
iPhone simulator plugin with only a handful of configuration
parameters substituted. This patch moves the redundant implementations
into the base class PlatformAppleSimulator.

Differential Revision: https://reviews.llvm.org/D85243
2020-08-06 16:36:58 -07:00
Adrian Prantl 0fa520af67 Unify the code that updates the ArchSpec after finding a fat binary
with how it is done for a lean binary

In particular this affects how target create --arch is handled — it
allowed us to override the deployment target (a useful feature for the
expression evaluator), but the fat binary case didn't.

rdar://problem/66024437

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

(cherry picked from commit 470bdd3caaab0b6e0ffed4da304244be40b78668)
2020-08-06 13:30:17 -07:00
Adrian Prantl f406a90a08 Add missing override to Makefile 2020-08-06 13:07:16 -07:00
Jonas Devlieghere ba37b144e6 [LLDB] Skip test_launch_simple from TestTargetAPI.py when remote 2020-08-06 13:03:18 -07:00
Adrian Prantl 05df9cc703 Correctly detect legacy iOS simulator Mach-O objectfiles
The code in ObjectFileMachO didn't disambiguate between ios and
ios-simulator object files for Mach-O objects using the legacy
ambiguous LC_VERSION_MIN load commands. This used to not matter before
taught ArchSpec that ios and ios-simulator are no longer compatible.

rdar://problem/66545307

Differential Revision: https://reviews.llvm.org/D85358
2020-08-06 12:40:45 -07:00
Jonas Devlieghere 86aa8e6363 [lldb] Use target.GetLaunchInfo() instead of creating an empty one.
Update tests that were creating an empty LaunchInfo instead of using the
one coming from the target. This ensures target properties are honored.
2020-08-06 11:51:26 -07:00
Fred Riss 99298c7fc5 [lldb/testsuite] Change get_debugserver_exe to support Rosetta
In order to be able to run the debugserver tests against the Rosetta
debugserver, detect the Rosetta run configuration and return the
system Rosetta debugserver.
2020-08-06 10:38:30 -07:00
Sterling Augustine 9dbdaea9a0 Remove unused variable "saved_opts".
wattr_get is a macro, and the documentation states:
"The parameter opts is reserved for  future use,
applications must supply a null pointer."

In practice, passing a variable there is harmless, except
that it is unused inside the macro, which causes unused
variable warnings.

The various places where
2020-08-06 10:20:21 -07:00
Raphael Isemann f6913e7440 [lldb][NFC] Document and encapsulate OriginMap in ASTContextMetadata
Just adds the respective accessor functions to ASTContextMetadata instead
of directly exposing the OriginMap to the whole world.
2020-08-06 17:37:29 +02:00
Fangrui Song a6db64ef4a [ELF] Allow sections after a non-SHF_ALLOC section to be covered by PT_LOAD
GNU ld allows sections after a non-SHF_ALLOC section to be covered by PT_LOAD
(PR37607) and assigns addresses to non-SHF_ALLOC output sections (similar to
SHF_ALLOC NOBITS sections. The location counter is not advanced).

This patch tries to fix PR37607 (remove a special case in
`Writer<ELFT>::createPhdrs`). To make the created PT_LOAD meaningful, we cannot
reset dot to 0 for a middle non-SHF_ALLOC output section. This results in
removal of two special cases in LinkerScript::assignOffsets. Non-SHF_ALLOC
non-orphan sections can have non-zero addresses like in GNU ld.

The zero address rule for non-SHF_ALLOC sections is weakened to apply to orphan
only. This results in a special case in createSection and findOrphanPos, respectively.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D85100
2020-08-06 08:27:15 -07:00
David Spickett e82866d5d9 [lldb][AArch64] Correct compile options for Neon corefile
SVE is not required, it has its own test. Note that
there is no "+neon" so "+simd" is used instead.

Also rename the file to match the name of the corefile
it produces.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D85134
2020-08-06 13:39:09 +01:00
Muhammad Omair Javaid 94a5919946 [LLDB] Skip test_launch_simple from TestTargetAPI.py on Arm/AArch64 Linux
Recently added TestTargetAPI.py test "test_launch_simple" is failing on
Arm/AArch64 Linux targets. Putting them to skip until fixed.

Differential Revision: https://reviews.llvm.org/D85235
2020-08-06 17:38:20 +05:00
Raphael Isemann d40c44e89e [lldb] Fix LLDB compilation with ncurses 6.2 due to wattr_set/get being a macro
My ncurses 6.2 arch defines those two functions as macros, so the scope operator
doesn't work here.
2020-08-06 10:52:57 +02:00
Luboš Luňák 4a8e4b5c74 [lldb][gui] use names for color pairs, instead of magic numbers
Differential Revision: https://reviews.llvm.org/D85286
2020-08-06 08:58:29 +02:00
Luboš Luňák 14406ca01f [lldb][gui] use syntax highlighting also in gui mode
Use the same functionality as the non-gui mode, the colors just
need translating to curses colors.

Differential Revision: https://reviews.llvm.org/D85145
2020-08-06 08:57:53 +02:00
Luboš Luňák fc0e8fb787 [lldb][gui] truncate long lines/names if needed
Without this, sources with long lines or variable names may overwrite
panel frames, or even overrun to the following line. There's currently
no way to scroll left/right in the views, so that should be added
to handle these cases.
This commit includes fixing constness of some Window functions,
and also makes PutCStringTruncated() consistent with the added
printf-like variant to take the padding as the first argument (can't
add it after the format to the printf-like function).

Differential Revision: https://reviews.llvm.org/D85123
2020-08-06 08:40:42 +02:00
Jonas Devlieghere 9097ef84ce [lldb] Remove pointless assign to found_suffix (NFC) 2020-08-05 22:54:03 -07:00
Jonas Devlieghere 4fccdd5c85 [lldb] Fix bug in skipIfRosetta decorator
Currently, the skipIfRosetta decorator will skip tests with the message
"not on macOS" on all platforms that are not `darwin` or `macosx`.
Instead, it should only check the platform and architecture when running
on these platforms.

This triggers for example when running the test suite on device.

Differential revision: https://reviews.llvm.org/D85388
2020-08-05 20:51:07 -07:00
Jim Ingham 1c1ffa6a30 GetPath() returns a std::string temporary. You can't reference just the c_str.
Found by the static analyzer.
2020-08-05 19:12:15 -07:00
Jim Ingham 08063f85a7 "|" used when "||" was meant in SBTarget::FindFunctions 2020-08-05 19:02:00 -07:00
Jonas Devlieghere 3a538de653 [lldb] Make UBSan tests remote ready
Add missing call to registerSanitizerLibrariesWithTarget.
2020-08-05 18:31:43 -07:00
Petr Hosek 1adc494bce [CMake] Simplify CMake handling for zlib
Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219
2020-08-05 16:07:11 -07:00
Jonas Devlieghere 927afdffbb [lldb] Skip test_launch_simple on Windows
Because stdio manipulation unsupported on Windows.
2020-08-05 15:38:07 -07:00
Jonas Devlieghere 31137b87ef [lldb] Skip TestProcessConnect when running remotely
This test doesn't make much sense when already running remotely.
2020-08-05 15:27:34 -07:00
Jonas Devlieghere df46f174db [lldb] Modify the `skipIfRemote` decorator so we can skip all PExpect tests.
This patch modifies the skipIfRemote decorator so it can apply to a
whole class, which allows us to skip all PExpect tests as a whole.

Differential revision: https://reviews.llvm.org/D85365
2020-08-05 15:27:34 -07:00
Jordan Rupprecht 1dbac09dd6 [lldb/test] Support git commit version ids for clang.
`getCompilerVersion` assumes that `clang --version` prints out a string like `version [0-9\.]+`.
If clang is built from trunk, the version line might look like `clang version trunk (123abc)`.

Since there isn't any way of knowing by the commit id alone whether one commit is newer or older than another git commit (or clang version), assume that clang with a version id like this is very close to trunk. For example, any tests with `@skipIf(compiler="clang", compiler_version=['<', '8'])` should be run.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D85248
2020-08-05 13:16:01 -07:00
Jordan Rupprecht fcb0d8163a [lldb/test] Use realpath consistently for test root file paths.
LLDB tests assume that tests are in the test tree (the `LLDB_TEST_SRC` env variable, configured by `dotest.py`).
If this assertion doesn't hold, tests fail in strange ways. An early place this goes wrong is in `compute_mydir` which does a simple length-based substring to get the relative path. Later, we use that path to chdir to. If the test file and test tree don't agree in realpath-ness (and therefore length), this will be a cryptic error of chdir-ing to a directory that does not exist.

The actual discrepency is that the places we look for `use_lldb_suite.py` don't use a realpath, but `dotest.py` does (see initialization of `configuration.testdirs`).

It doesn't particularly matter whether we use realpath or abspath to canonicalize things, but many places end up with implicit dependencies on the canonicalized pwd being a realpath, so make them realpath consistently. Also, in the `compute_mydir` method mentioned, raise an error if the path types don't agree.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D85258
2020-08-05 11:35:37 -07:00
Jordan Rupprecht f425c0442c [lldb/test] Replace LLDB_TEST_SRC env variable with configuration
Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D85322
2020-08-05 10:19:21 -07:00
Jonas Devlieghere 249a1d4f1b [lldb] Add an option to inherit TCC permissions from parent.
Add an option that allows the user to decide to not make the inferior is
responsible for its own TCC permissions. If you don't make the inferior
responsible, it inherits the permissions of its parent. The motivation
is the scenario of running the LLDB test suite from an external hard
drive. If the inferior is responsible, every test needs to be granted
access to the external volume. When the permissions are inherited,
approval needs to be granted only once.

Differential revision: https://reviews.llvm.org/D85237
2020-08-05 10:08:28 -07:00
Jonas Devlieghere 882d8e60dd [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo
Currently SBTarget::LaunchSimple creates a new LaunchInfo which means it
ignores any target properties that have been set. Instead, it should
start from the target's LaunchInfo and populated the specified fields.

Differential revision: https://reviews.llvm.org/D85235
2020-08-05 10:08:28 -07:00
Ted Woodward 3169d920cc Remove special Hexagon packet traversal code
On Hexagon, breakpoints need to be on the first instruction of a packet.
When the LLVM disassembler for Hexagon returned 32 bit instructions, we
needed code to find the start of the current packet. Now that the LLVM
disassembler for Hexagon returns packets instead of instructions, we always
have the first instruction of the packet. Remove the packet traversal code
because it can cause problems when the next packet has more than one
instruction.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D84966
2020-08-05 12:05:42 -05:00
Hans Wennborg 3ab01550b6 Revert "[CMake] Simplify CMake handling for zlib"
This quietly disabled use of zlib on Windows even when building with
-DLLVM_ENABLE_ZLIB=FORCE_ON.

> Rather than handling zlib handling manually, use find_package from CMake
> to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
> HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
> set to YES, which requires the distributor to explicitly select whether
> zlib is enabled or not. This simplifies the CMake handling and usage in
> the rest of the tooling.
>
> This is a reland of abb0075 with all followup changes and fixes that
> should address issues that were reported in PR44780.
>
> Differential Revision: https://reviews.llvm.org/D79219

This reverts commit 10b1b4a231 and follow-ups
64d99cc6ab and
f9fec0447e.
2020-08-05 12:31:44 +02:00
Luboš Luňák 188187f062 [lldb] expect TestGuiBasicDebug.py failure on aarch64
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/7287/steps/test/logs/stdio
fails, and the output suggests that gui 'finish' (='thread step-out') is broken
on aarch64.
2020-08-05 12:21:05 +02:00
Luboš Luňák 138281904b Revert "[lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu"
This reverts commit 21f142ce1d.
2020-08-05 11:55:02 +02:00
Luboš Luňák 21f142ce1d [lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu 2020-08-05 11:54:14 +02:00
Tatyana Krasnukha bc056b3aa7 [lldb] Suppress MSVC warning C4065
MSVC reports "switch statement contains 'default' but no 'case' labels". Suppress,
as this was intended behavior.
2020-08-05 11:59:48 +03:00
Tatyana Krasnukha 75012a8044 [lldb] Use PyUnicode_GetLength instead of PyUnicode_GetSize
PyUnicode_GetSize is deprecated since Python version 3.3.
2020-08-05 11:59:47 +03:00
Tatyana Krasnukha cc68c122cd [lldb/TestingSupport] Manually disable GTEST_HAS_TR1_TUPLE
Gtest 1.8.0 uses tr1::tuple which is deprecated on MSVC. We have to force it off
to avoid the compiler warnings, which will become errors after switching on C++17
(https://devblogs.microsoft.com/cppblog/c17-feature-removals-and-deprecations).
2020-08-05 11:59:46 +03:00
Luboš Luňák db828aba55 [lldb][gui] add a test for 'b' (toggle breakpoint)
Differential Revision: https://reviews.llvm.org/D85107
2020-08-05 09:51:13 +02:00
Luboš Luňák c7be982c83 [lldb][gui] move TestGuiBasicDebug.py to lldb/test and update it
Between the time it was created and it was pushed upstream,
99451b4453 has moved the existing
gui gui tests to lldb/test, so move this one too.
And update it to contain TestGuiBasic.py changes since the time
when it was based on that test.

Differential Revision: https://reviews.llvm.org/D85106
2020-08-05 09:51:13 +02:00
Luboš Luňák d6868d9ca1 [lldb][gui] implement breakpoint removal on breakpoint toggling
It says it toggles breakpoints, so if one already exists
on the selected location, remove it instead of adding.

Differential Revision: https://reviews.llvm.org/D85098
2020-08-05 09:51:12 +02:00
Luboš Luňák 7a63dc534e [lldb][gui] implement shift+tab for going back in views
Also simplify the code for going forward.

Differential Revision: https://reviews.llvm.org/D85089
2020-08-05 09:51:12 +02:00
Luboš Luňák 2f1b24b70c [lldb][gui] implement TerminalSizeChanged()
Differential Revision: https://reviews.llvm.org/D85088
2020-08-05 09:51:12 +02:00
Luboš Luňák c952ec15d3 [lldb] fix building with panel.h being in /usr/include/ncurses/
My openSUSE 15.2 has /usr/include/curses.h as a symlink to
/usr/include/ncurses/curses.h , but there's no such symlink
for panel.h . Prefer using /usr/include/ncurses for the includes
if they are found there by the CMake check.

Differential Revision: https://reviews.llvm.org/D85219
2020-08-05 09:51:12 +02:00
Fred Riss 4c9ed3ed3d [lldb/testsuite] Skip 'frame diagnose' tests based on architecture
AFAICS, the feature only works on x86, skipping the tests has nothing to
do with the target being iOS or remote.
2020-08-04 17:45:55 -07:00
Adrian Prantl 7e9bab6ad5 Fix debugserver's qProcessInfo reporting of maccatalyst binaries
This patch is similar in spirit to https://reviews.llvm.org/D84480,
but does the maccatalyst/macosx disambiguation. I also took the
opportunity to factor out the gdb-remote packet log scanning used by
several testcases into lldbutil functions.

rdar://problem/66059257

Differential Revision: https://reviews.llvm.org/D84576
2020-08-04 16:42:14 -07:00
Jonas Devlieghere e8b7edafc3 [lldb/Test] Add @skipIfRemote decorator to TestProcessList.py
lldb-platform contains a very minimal support for the qfProcessInfo
packet, only allowing the simplest query to get most of the testsuite
running, and returning very little information about the matched
processes.
2020-08-04 14:40:07 -07:00
Jonas Devlieghere ba3d84d82b [lldb/Test] Skip tests that try to get the remote environment
We don't support getting the remote environment. The gdb remote protocol
has no packet for that.
2020-08-04 14:01:57 -07:00
Yifan Shen e7af98680a [lldb-vscode ]Add Syntax Highlighting to Disassembly View
When lldb cannot find source file thus IDE renders a disassembly view, add syntax highlighting for constants, registers and final line comments for better debugging experience.
The original plain disassembly view looks like:
{F12401687}
An ideal view is like the screenshot attached.
{F12401515}

In this diff, the mimeType is a kind of media type for formatting the content in the response to a source request. Elements in the disassembly view, like constants, registers and final line comments are colored for highlighting.
A built-in support in the VSCode IDE for syntax highlighting will identify the which mimeType to apply and render the disassembly view as expected.

Reviewed By: wallace, clayborg

Differential Revision: https://reviews.llvm.org/D84555
2020-08-04 13:31:44 -07:00
Jonas Devlieghere bb33f925a6 [lldb/Test] Add missing stdio.h includes
Fixes error: implicit declaration of function 'printf' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
2020-08-04 13:08:14 -07:00
Jordan Rupprecht 31ec6e969d [test] Fix another realpath->abspath.
This is a followup to 817b3a6fe3a4452eb61a2503c8beaa7267ca0351: in `builder_base` we should use abspath, not realpath, because the name is significant.
This is used by test cases that use `@skipIf(compiler="clang", compiler_version=['<', <version>])`
2020-08-04 11:06:31 -07:00
Jonas Devlieghere 041c7b84a4 [lldb/Host] Upstream macOS TCC code
Upstream the code for dealing with TCC introduced in macOS Mojave. This
will make the debuggee instead of the debugger responsible for the
privileges it needs.

Differential revision: https://reviews.llvm.org/D85217
2020-08-04 09:23:54 -07:00
Jordan Rupprecht 817b3a6fe3 [test] Use abspath instead of realpath sometimes
In these two cases, use of `os.path.realpath` is problematic:

- The name of the compiler is significant [1] . For testing purposes, we might
  provide a compiler called "clang" which is actually a symlink to some build
  script (which does some flag processing before invoking the real clang). The
  destination the symlink may not be called "clang", but we still want it to be
  treated as such.
- When using a build system that puts build artifacts in an arbitrary build
  location, and later creates a symlink for it (e.g. creates a
  "<lldb root>/lldbsuite/test/dotest.py" symlinks that points to
  "/build/artifact/<hash>/dotest.py"), looking at the realpath will not match
  the "test" convention required here.

[1] See `Makefile.rules` in the lldb tree, e.g. we use different flags if the compiler is named "clang"

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D85175
2020-08-04 08:20:50 -07:00
Luboš Luňák daa1c6d9d1 [lldb] fix typo 2020-08-04 12:05:57 +02:00
Jonas Devlieghere d6a5cce0e7 [lldb/Test] Fix skipTestIfFn for fucntions that return a value
Sometimes the decorator is used on a common function rather than the
test method, which can return a value. This fails with decorators that
use skipTestIfFn under the hood.
2020-08-03 19:56:12 -07:00
Jordan Rupprecht a06c28df3e Temporarily revert "[test] Exit with an error if no tests are run."
This reverts commit adb5c23f8c. It surprisingly fails on a windows build bot: http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/18009

Will reland after some investigation and/or after adding some extra logging to help debug the issue.
2020-08-03 18:37:50 -07:00
Jordan Rupprecht adb5c23f8c [test] Exit with an error if no tests are run.
If the test suite is misconfigured when it's run (a bad regexp, wrong test directory, etc.), the test suite may not discover any tests. When this happens, the test runner exits happily because no tests failed:

```
Ran 0 tests in 0.000s
RESULT: PASSED (0 passes, 0 failures, 0 errors, 0 skipped, 0 expected failures, 0 unexpected successes)
```

Change this to return an error so the misconfiguration can be more easily detected. Verified that `lldb-dotest -p TestDoesNotExist.py` successfully fails.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D85169
2020-08-03 16:32:12 -07:00
Tatyana Krasnukha e97c693bb0 [lldb/Process/Windows] Attempting to kill exited/detached process in not an error
The lldb test-suite on Windows reports a 'CLEANUP ERROR' when attempting to kill
an exited/detached process. This change makes ProcessWindows consistent with
the other processes which only log the error. After this change a number of
'CLEANUP ERROR' messages are now removed.

Differential Revision: https://reviews.llvm.org/D84957
2020-08-03 12:52:43 +03:00
Luboš Luňák 18d4069503 fix lldb test on lib64 systems
Differential revision: https://reviews.llvm.org/D85096
2020-08-03 11:19:07 +02:00
Raphael Isemann 8aeb212887 [debugserver] Fix that is_dot_app is producing unused warnings
Some build configurations don't use this static function.
2020-08-03 10:24:21 +02:00
Jan Kratochvil e6c2c9a7d1 [lldb] [test] Fix DW_TAG_GNU_call_site-DW_AT_low_pc.s relocation
I have made the DW_FORM_ref4 relative. One could also use relocated
DW_FORM_ref_addr instead.

Tested with:
        echo 'void f(){}'|clang -o 1.o -c -Wall -g -x c -;./bin/clang -o 1 1.o ../llvm-monorepo/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_GNU_call_site-DW_AT_low_pc.s;./bin/lldb --no-lldbinit ./1 -o r -o 'p p' -o exit
2020-08-02 22:41:02 +02:00
Adrian Prantl 5110fd0343 Convert to early exit (NFC) 2020-07-31 14:55:09 -07:00
Luboš Luňák 77d5a63c19 [lldb] report an error if a CLI option lacks an argument
Differential Revision: https://reviews.llvm.org/D84955
2020-07-31 22:02:40 +02:00
Luboš Luňák 8739445e32 [lldb] force full gui redraw on Ctrl+L
As is common with curses apps, this allows to redraw everything
in case something corrupts the screen. Apparently key modifiers
are difficult with curses (curses FAQ it "doesn't do that"),
thankfully Ctrl+key are simply control characters, so it's
(ascii & 037) => 12.

Differential Revision: https://reviews.llvm.org/D84972
2020-07-31 22:02:40 +02:00
Jonas Devlieghere 162e9f72ac [lldb/Test] Reduce code duplication by importing subprocess globally
Import the subprocess module once instead of doing it inline which is
error prone and leads to needless code duplication.
2020-07-31 10:56:13 -07:00
Jason Molenda abf546dd4f debguserver's type sniffer to only treat .app things that end in .app
On an iOS device, if debugserver is left to figure out how to launch
the binary provided, it looks at the filename to see if it contains
".app" and asks FrontBoard to launch it.  However, if this is actually
a command line app with the characters ".app" in the name, it would
end up trying to launch that via the FrontBoard calls even though it
needed to be launched via posix_spawn.  For instance, a command line
program called com.application.tester.

Jim suggested this patch where we only send binaries that end in ".app"
to FrontBoard.

Often debugsever is invoked with a --launch command line argument to
specify the launch method, and none of this code is hit in that
instance.

<rdar://problem/65297100>
2020-07-30 21:14:33 -07:00
Davide Italiano 57605758b5 [debugserver/Apple Silicon] Handoff connections when attaching to translated processes
When we detect a process that the native debugserver cannot handle,
handoff the connection fd to the translated debugserver.
2020-07-30 16:21:05 -07:00
Jonas Devlieghere 02c1bba670 [lldb/Docs] Remove stale bot on GreenDragon and add reproducer one
- Remove the link to the Python 3 job which no longer exists.
 - Add a link to the reproducer job.
2020-07-30 13:51:16 -07:00
Jonas Devlieghere 8c1a31d833 [lldb/Docs] Add lldb-arm-ubuntu to the list of bots 2020-07-30 13:47:21 -07:00
Jonas Devlieghere 3bb48898bc [lldb/Test] Use self.assertIn in TestGdbRemoteTargetXmlPacket
On the ARM buildbot the returned architecture is `armv8l` while
getArchitecture() just returns `arm`.
2020-07-30 11:48:35 -07:00
Jonas Devlieghere 41909e9682 [lldb] Add copy ctor/assignment operator to SBCommandInterpreterRunOptions 2020-07-30 10:39:30 -07:00
Jordan Rupprecht be198e03eb [lldb][test] Move registers-target-xml-reading target to the correct test location.
This test was added in D74217 (and the `.categories` file later added in ccf1c30cde) around the same time I moved the test tree from `lldb/packages/Python/lldbsuite/test` to `lldb/test/API` (D71151). Since this got lost in the move, it isn't running. (I introduced an intentional syntax error, and `ninja check-lldb` passes).

I moved it to the correct location, and now it runs and passes -- locally, at least -- as `ninja check-lldb-api-tools-lldb-server-registers-target-xml-reading`.
2020-07-30 10:28:32 -07:00
Jordan Rupprecht 09cb6f233d [lldb][NFC][test] Fix comment referring to FileCheck instead of yaml2obj 2020-07-30 09:47:44 -07:00
Jonas Devlieghere b6635b5b15 [lldb] Add SBCommandInterpreterRunOptions to LLDB.h 2020-07-30 08:46:19 -07:00
Raphael Isemann a4a0844248 [lldb] Don't use static locals for return value storage in some *AsCString functions
Let's just return a std::string to make this safe. formatv seemed overkill for formatting
the return values as they all just append an integer value to a constant string.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D84505
2020-07-30 12:17:42 +02:00
Jonas Devlieghere 9a3dbc9723 [lldb] Move finish_swig logic into a function in the binding dir
Move the finish_swig logic into a function in the bindings directory. By
making this a function I can reuse the logic internally where we ship
two Python versions and therefore need to finish the bindings twice.
2020-07-29 17:59:56 -07:00
Jonas Devlieghere 6587ff77ea [lldb] Fix llvm-lit in standalone builds
LLVM's make_paths_relative uses Python3_EXECUTABLE which isn't set in
standalone LLDB builds.
2020-07-29 15:38:40 -07:00
shafik 6700f4b9fe [LLDB] Add checks for ValueObjectSP in Cocoa summary providers
We saw a crash recently (rdar://problem/65276489) that looks related to an invalid ValueObjectSP in a summary providers in Cocoa.cpp e.g. NSBundleSummaryProvider(...).
This adds checks before we use them usually by calling NSStringSummaryProvider.

Differential Revision: https://reviews.llvm.org/D84272
2020-07-29 14:47:18 -07:00
Luboš Luňák 13978643b6 [lldb] implement 'up' and 'down' shortcuts in lldb gui
Also add a unittest.

Differential Revision: https://reviews.llvm.org/D68541
2020-07-29 22:30:23 +02:00
Luboš Luňák 336c7029ef [lldb] change shortcut for 'step out' from 'o' to 'f'
This makes it consistent with gdb tui, where 'f' is 'finish'.
See the discussion at https://reviews.llvm.org/D68541 .

Differential Revision: https://reviews.llvm.org/D68909
2020-07-29 22:30:23 +02:00
Luboš Luňák 47d2c7cd5d [lldb] remove somewhat dangerous 'd'(etach) and 'k'(ill) shortcuts
'd' would be much better used for up/down shortcuts, and this also removes
the possibility of ruining the whole debugging session by accidentally
hitting 'd' or 'k'. Also change menu to have both 'detach and resume'
and 'detach suspended' to make it clear which one is which. See
discussion at https://reviews.llvm.org/D68541 .

Differential Revision: https://reviews.llvm.org/D68908
2020-07-29 22:30:23 +02:00
Tatyana Krasnukha da0bba5c9a [lldb/Breakpoint] Rename StoppointLocation to StoppointSite and drop its relationship with BreakpointLocation
Both of BreakpointLocation and BreakpointSite were inherited from StoppointLocation. However, the only thing
they shared was hit counting logic. The patch encapsulates those logic into StoppointHitCounter, renames
StoppointLocation to StoppointSite, and stops BreakpointLocation's inheriting from it.

Differential Revision: https://reviews.llvm.org/D84527
2020-07-29 22:07:46 +03:00
Tatyana Krasnukha d5c1f686e3 [lldb/BreakpointSite] Handle all ways of control flow 2020-07-29 21:53:18 +03:00
Tatyana Krasnukha ebaa8b1c60 [lldb] Don't use hardware index to determine whether a breakpoint site is hardware
Most process plugins (if not all) don't set hardware index for breakpoints. They even
are not able to determine this index.

This patch makes StoppointLocation::IsHardware pure virtual and lets BreakpointSite
override it using more accurate BreakpointSite::Type.

It also adds assertions to be sure that a breakpoint site is hardware when this is required.

Differential Revision: https://reviews.llvm.org/D84257
2020-07-29 21:27:24 +03:00
Tatyana Krasnukha b352e62fea [lldb] Make process plugins check whether a hardware breakpoint is required
Remove @skipIfWindows as process should report the error correctly on Windows now.

Differential Revision: https://reviews.llvm.org/D84255
2020-07-29 21:27:23 +03:00
Tatyana Krasnukha f7ec3e3be7 [lldb] Skip overlapping hardware and external breakpoints when writing memory
This fixes the assertion `assert(intersects);` in the Process::WriteMemory function.

Differential Revision: https://reviews.llvm.org/D84254
2020-07-29 21:27:23 +03:00
Tatyana Krasnukha c114352edf [lldb/test] Put hardware breakpoint tests together, NFC
Create a common base class for them to re-use supports_hw_breakpoints function in decorators.

Differential Revision: https://reviews.llvm.org/D84311
2020-07-29 21:20:04 +03:00
Jonas Devlieghere 4add853647 [lldb] Improve platform handling in CreateTargetInternal
Currently, `target create` has no --platform option. However,
TargetList::CreateTargetInternal which is called under the hood, will
return an error when either no platform or multiple matching platforms
are found, saying that a platform should be specified with --platform.

This patch adds the platform option, but that doesn't solve either of
these errors.

 - If more than one platform matches, specifying the platform isn't
   going to fix that. The current code will only look at the
   architecture instead. I've updated the error message to ask the user
   to specify an architecture.

 - If no architecture is found, specifying a new one via platform isn't
   going to change that either because we already try to find one that
   matches the given architecture.

Differential revision: https://reviews.llvm.org/D84809
2020-07-29 10:30:20 -07:00
Jonas Devlieghere 2fa3da7dcd [lldb] Remove unused option '--platform-path' for 'target create'
Differential revision: https://reviews.llvm.org/D84800
2020-07-28 16:16:30 -07:00
Zahira Ammarguellat 80bd6ae13e On Windows build, making the /bigobj flag global , instead of passing it per file.
To avoid having this flag be passed in per/file manner, we are instead
passing it globally.

This fixes this bug: https://bugs.llvm.org/show_bug.cgi?id=46733

Reviewed-by: aaron.ballman, beanz, meinersbur

Differential Revision: https://reviews.llvm.org/D84038
2020-07-28 18:04:36 -05:00
Amy Huang 394db22595 Revert "Switch to using -debug-info-kind=constructor as default (from =limited)"
This reverts commit 227db86a1b.

Causing debug info errors in google3 LTO builds; also causes a
debuginfo-test failure.
2020-07-28 11:23:59 -07:00
Shu Anzai 5608f28f55 [lldb] Change the definition of ANSI_UNFAINT
Change the definition of ANSI_UNFAINT in Editline.cpp.

Differential revision: https://reviews.llvm.org/D84695
2020-07-28 11:06:45 -07:00
Fred Riss 8120eba5fc [lldb/ArchSpec] Always match simulator environment in IsEqualTo
Summary:
Initially, Apple simulator binarie triples didn't use a `-simulator`
environment and were just differentiated based on the architecture.
For example, `x86_64-apple-ios` would obviously be a simualtor as iOS
doesn't run on x86_64. With Catalyst, we made the disctinction
explicit and today, all simulator triples (even the legacy ones) are
constructed with an environment. This is especially important on Apple
Silicon were the architecture is not different from the one of the
simulated device.

This change makes the simulator part of the environment always part of
the criteria to detect whether 2 `ArchSpec`s are equal or compatible.

Reviewers: aprantl

Subscribers: inglorion, dexonsmith, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D84716
2020-07-27 17:33:37 -07:00
Petr Hosek 64d99cc6ab [CMake] Move find_package(ZLIB) to LLVMConfig
This way, downstream projects don't have to invoke find_package(ZLIB)
reducing the amount of boilerplate.

Differential Revision: https://reviews.llvm.org/D84691
2020-07-27 17:13:55 -07:00
Fred Riss ef748b58d3 [lldb] NFC: Use early exit in ArchSpec::IsEqualTo 2020-07-27 14:12:02 -07:00
Adrian Prantl 113f56fbb8 Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish)
This cleanup patch unifies all methods called GetByteSize() in the
ValueObject hierarchy to return an optional, like the methods in
CompilerType do. This means fewer magic 0 values, which could fix bugs
down the road in languages where types can have a size of zero, such
as Swift and C (but not C++).

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

This re-lands the patch with bogus :m_byte_size(0) initalizations removed.
2020-07-27 13:26:35 -07:00
Fred Riss 4c6eebf86a [lldb/AppleSimulator] Always provide a -simulator environment
Summary:
This commit is somewhat NFC-ish today as the environment of triples
is not considered when comparing s if one of them is
not set (I plan to change that).

We have made simulator triples unambiguous these days, but the
simulator platforms still advertise triples without the
environment. This wasn't an issue when the sims ran only on
a very different architecure than the real device, but this
has changed with Apple Silicon.

This patch simplifies the way GetSupportedArchitectureAtIndex
is implemented for the sim platforms and adds the environment.
It also trivially adds support for Apple Silicon to those
platforms.

Reviewers: aprantl

Subscribers: lldb-commits
2020-07-27 12:50:50 -07:00
Jonas Devlieghere 536baa11cf [lldb] Remove CMAKE_VERSION checks now that the minimum version is 3.13.4 2020-07-27 12:31:41 -07:00
Raphael Isemann 432241955e [lldb][NFC] Use a StringRef for AddRegexCommand::AddRegexCommand parameters
Summary: This way we can get rid of this 1024 char buffer workaround.

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D84528
2020-07-27 14:36:47 +02:00
Raphael Isemann db203e0268 [lldb] Modernize away some snprintf calls
Reviewers: #lldb, JDevlieghere

Reviewed By: #lldb, JDevlieghere

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D84530
2020-07-27 14:27:54 +02:00
Pavel Labath 1956cf1042 [lldb/DWARF] Don't treat class declarations with children as definitions
Summary:
This effectively reverts r188124, which added code to handle
(DW_AT_)declarations of structures with some kinds of children as
definitions. The commit message claims this is a workaround for some
kind of debug info produced by gcc. However, it does not go into
specifics, so it's hard to reproduce or verify that this is indeed still a
problem.

Having this code is definitely a problem though, because it mistakenly
declares incomplete dwarf declarations to be complete. Both clang (with
-flimit-debug-info) and gcc (by default) generate DW_AT_declarations of
structs with children. This happens when full debug info for a class is
not emitted in a given compile unit (e.g. because of vtable homing), but
the class has inline methods which are used in the given compile unit.
In that case, the compilers emit a DW_AT_declaration of a class, but
add a DW_TAG_subprogram child to it to describe the inlined instance of
the method.

Even though the class tag has some children, it definitely does not
contain enough information to construct a full class definition (most
notably, it lacks any members). Keeping the class as incomplete allows
us to search for a real definition in other modules, helping the
-flimit-debug-info flow. And in case the definition is not found we can
display a error message saying that, instead of just showing an empty
struct.

Reviewers: clayborg, aprantl, JDevlieghere, shafik

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83302
2020-07-27 12:58:22 +02:00
Pavel Labath 2e828e7579 [lldb] Fix e89414f406 for msvc
MSVC finds the APInt construction ambiguous. Use a case to help it
choose the right constructor.
2020-07-27 11:49:46 +02:00
Pavel Labath e89414f406 [lldb/Utility] Clean up Scalar constructors
- move initialization to initializer lists
- make desctructor non-virtual (nothing else is)
- fix long double constructor so that it actually works
2020-07-27 10:06:56 +02:00
Pavel Labath 81d7ebaf5c [lldb/Utility] Fix a bug in RangeMap::CombineConsecutiveRanges
The function didn't combine a large entry which overlapped several other
entries, if those other entries were not overlapping among each other.

E.g., (0,20),(5,6),(10,11) produced (0,20),(10,11)

Now it just produced (0,20).
2020-07-27 10:06:56 +02:00
Eric Christopher 4b14ef33e8 Temporarily Revert "Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish)"
as it's causing numerous (176) test failures on linux.

This reverts commit 1d9b860fb6.
2020-07-25 18:42:04 -07:00
Adrian Prantl 1d9b860fb6 Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish)
This cleanup patch unifies all methods called GetByteSize() in the
ValueObject hierarchy to return an optional, like the methods in
CompilerType do. This means fewer magic 0 values, which could fix bugs
down the road in languages where types can have a size of zero, such
as Swift and C (but not C++).

Differential Revision: https://reviews.llvm.org/D84285
2020-07-25 08:27:21 -07:00
Adrian Prantl e937840dbd Upstream macCatalyst support in ArchSpec and associated unit tests. 2020-07-24 18:01:41 -07:00
Jonas Devlieghere 34d4c8a53e [lldb] Have LanguageRuntime and SystemRuntime share a base class (NFC)
LangaugeRuntime and SystemRuntime now both inherit from Runtime.
2020-07-24 16:28:34 -07:00
Jonas Devlieghere 99996213eb [lldb] Don't wrap and release raw pointer in unique_ptr (NFC) 2020-07-24 16:28:34 -07:00
Petr Hosek c86f56e32e [CMake] Find zlib when building lldb as standalone
This addresses the issue introduced by 10b1b4a.
2020-07-24 13:36:13 -07:00
Yifan Shen 2c1bea88a5 Add Debug Info Size to Symbol Status
If a module has debug info, the size of debug symbol will be displayed after the Symbols Loaded Message for each module in the VScode modules view.{F12335461}

Reviewed By: wallace, clayborg

Differential Revision: https://reviews.llvm.org/D83731
2020-07-24 13:30:04 -07:00
Walter Erquinigo 313b60742a Revert "Add Debug Info Size to Symbol Status"
This reverts commit 986e3af53b.

It incorrectly deleted clang/tools/clang-format/git-clang-format
2020-07-24 13:28:29 -07:00
Yifan Shen 986e3af53b Add Debug Info Size to Symbol Status
Summary: If a module has debug info, the size of debug symbol will be displayed after the Symbols Loaded Message for each module in the VScode modules view.{F12335461}

Reviewers: wallace, clayborg

Reviewed By: wallace, clayborg

Subscribers: cfe-commits, aprantl, lldb-commits

Tags: #lldb, #clang

Differential Revision: https://reviews.llvm.org/D83731
2020-07-24 13:26:06 -07:00
shafik 0db2934b0f [ASTImporter] Modify ImportDefiniton for ObjCInterfaceDecl so that we always the ImportDeclContext one we start the definition
Once we start the definition of an ObjCInterfaceDecl we won't attempt to ImportDeclContext
later on. Unlike RecordDecl case which uses DefinitionCompleter to force completeDefinition
we don't seem to have a similar mechanism for ObjCInterfaceDecl.

This fix was needed due to a bug we see in LLDB expression parsing where an initial expression
cause an ObjCInterfaceDecl to be defined and subsequent expressions during import do not call
ImportDeclContext and we can end up in a situation where ivars are imported out of order and not all ivars are imported.

Differential Revision: https://reviews.llvm.org/D83972
2020-07-24 13:15:08 -07:00
Jonas Devlieghere 0b339c0692 [lldb] Inform every language runtime of the modified modules
When a process is notified that modules got loaded, currently only
existing language runtimes are given a chance to deal with that. This
means that if the runtime for a given language wasn't needed before it
won't be informed of the module chance.

This is wrong because the module change might be what triggers the need
for a certain runtime. Instead, we should give the language runtime for
every supported language a chance to deal with the modified modules.

Differential revision: https://reviews.llvm.org/D84475
2020-07-24 12:10:45 -07:00
Adrian Prantl 58d84eb534 debugserver: Support ios simulator load command disambiguation in qProcessInfo
This patch basically moves the disambiguation code from a place where
it was complicated to implement straight to where the load command is
parsed, which has the neat side affect of actually supporting all call
sites!

rdar://problem/66011909

Differential Revision: https://reviews.llvm.org/D84480
2020-07-24 09:49:16 -07:00
Fred Riss 22c16360dd [lldb/ObjectFileMachO] Correctly account for resolver symbols
Summary:
The resolver addresses stored in the dyld trie are relative to the base
of the __TEXT segment. This is usually 0 in a dylib, so this was never
noticed, but it is not 0 for most dylibs integrated in the shared cache.
As we started using the shared cache images recently as symbol source,
this causes LLDB to fail to resolve symbols which go through a runtime
resolver.

Reviewers: jasonmolenda, jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D84083
2020-07-24 09:19:17 -07:00
Petr Hosek 10b1b4a231 [CMake] Simplify CMake handling for zlib
Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219
2020-07-23 23:05:36 -07:00
Petr Hosek 38c71b7c85 Revert "[CMake] Simplify CMake handling for zlib"
This reverts commit 1d09ecf361 since
it breaks sanitizer bots.
2020-07-23 15:12:42 -07:00
Petr Hosek 1d09ecf361 [CMake] Simplify CMake handling for zlib
Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219
2020-07-23 14:47:25 -07:00
Jonas Devlieghere cee60bbf41 [lldb] Remove the user-defined copy-ctor in ConstString
ConstString is essentially trivially copyable yet it has a user defined
copy constructor that copies its one member pointer. Remove it so it
qualifies as trivial in the eyes of the compiler.

This also fixes two unused variable warnings now that the compiler knows
that the constructor has no side-effects.

Differential revision: https://reviews.llvm.org/D84440
2020-07-23 13:09:08 -07:00
Raphael Isemann 4a3a821c68 [lldb] Make socket_packet_pump.py work in Python3
Summary:

The `string_escape` encoding used here was removed in Python 3 which makes the
test crash during tearDown:

```
  File "lldb/third_party/Python/module/unittest2/unittest2/case.py", line 386, in run
    self.tearDown()
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py", line 124, in tearDown
    self._pump_queues.verify_queues_empty()
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py", line 55, in verify_queues_empty
    _dump_queue(self.packet_queue())
  File "lldb/packages/Python/lldbsuite/test/tools/lldb-server/socket_packet_pump.py", line 28, in _dump_queue
    print(codecs.encode(the_queue.get(True), "string_escape"))
LookupError: unknown encoding: string_escape
```

Just replace it with `repr` which should work in both Python versions.

Reviewers: labath, JDevlieghere

Reviewed By: labath, JDevlieghere

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D84017
2020-07-23 18:36:50 +02:00
Raphael Isemann 77ae06b8c6 [lldb][NFC] Remove FormatMap
Summary:

FormattersContainer.h has two containers: FormatMap and FormattersContainer
itself. FormatMap is essentially just a SetVector with a listener interface that
is aspiring to be thread-safe as most of its functions lock its member mutex.

FormattersContainer is for the most part just calling the matching functions of
internal FormatMap instance and essentially acts as a wrapper class with some
minor formatter search functionality on top. The only difference is that the
FormattersContainer's public `Get` function is actually searching formatters in
the list of formatters (and for example doing regex-matching) while FormatMap's
`Get` function is just looking up a a format by the type matcher string.

This patch deletes `FormatMap` by just renaming it to `FormattersContainer` and
pulling in the two `Get` functions from the original `FormattersContainer`
class.

The only other user of `FormatMap` was the `NamedSummariesMap` in the
`FormatManager` which I migrated by just making it also a `FormattersContainer`
and replaced the only call to the `Get` function (which now has new semantics)
with `GetExact` (which is FormattersContainer's function that has the semantics
of FormatMap's `Get`). As `NamedSummariesMap` only stores non-regex-based
formatters, both `Get` and `GetExact` would have worked, so this was mostly to
clarify that this is supposed to be NFC.

I also added the missing mutex lock in the `GetCount` function which was
previously missing in the `FormatMap` implementation. Technically not "NFC" but
I anyway had to change the function...

Reviewers: labath, mib

Reviewed By: labath

Subscribers: abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84296
2020-07-23 18:34:59 +02:00
Raphael Isemann 4d489e9f91 Reland [lldb] Unify type name matching in FormattersContainer II
This was originally reverted because the m_valid member in TypeMatcher was
unused in builds with disabled asserts. Now the member is gone and the default
constructor is deleted (thanks Eric for the idea!).

Summary:

FormattersContainer stores LLDB's formatters. It's implemented as a templated
map-like data structures that supports any kind of value type and only allows
ConstString and RegularExpression as the key types. The keys are used for
matching type names (e.g., the ConstString key `std::vector` matches the type
with the same name while RegularExpression keys match any type where the
RegularExpression instance matches).

The fact that a single FormattersContainer can only match either by string
comparison or regex matching (depending on the KeyType) causes us to always have
two FormatterContainer instances in all the formatting code. This also leads to
us having every type name matching logic in LLDB twice. For example,
TypeCategory has to implement every method twice (one string matching one, one
regex matching one).

This patch changes FormattersContainer to instead have a single `TypeMatcher`
key that wraps the logic for string-based and regex-based type matching and is
now the only possible KeyType for the FormattersContainer. This means that a
single FormattersContainer can now match types with both regex and string
comparison.

To summarize the changes in this patch:
* Remove all the `*_Impl` methods from `FormattersContainer`
* Instead call the FormatMap functions from `FormattersContainer` with a
  `TypeMatcher` type that does the respective matching.
* Replace `ConstString` with `TypeMatcher` in the few places that directly
  interact with `FormattersContainer`.

I'm working on some follow up patches that I split up because they deserve their
own review:

* Unify FormatMap and FormattersContainer (they are nearly identical now).
* Delete the duplicated half of all the type matching code that can now use one
  interface.
* Propagate TypeMatcher through all the formatter code interfaces instead of
  always offering two functions for everything.

There is one ugly design part that I couldn't get rid of yet and that is that we
have to support getting back the string used to construct a `TypeMatcher` later
on. The reason for this is that LLDB only supports referencing existing type
matchers by just typing their respective input string again (without even
supplying if it's a regex or not).

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84151
2020-07-23 18:17:42 +02:00
Jonas Devlieghere ccdb5b4bbe [lldb] Pass ConstString by value (again) (NFC)
This reverts "Eliminate unneeded value parameters in Utility" for
ConstString. As Pavel pointed out on the mailing list, the class *is*
trivially copyable.
2020-07-23 09:08:32 -07:00
Raphael Isemann 5477fbc294 [lldb] Make deleting frame recognizers actually work
Summary:

Frame recognizers are stored alongside a flag that indicates whether they were
deleted by the user. If the flag is set, they are supposed to be ignored by the
rest of the frame recognizer code. 'frame recognizer delete' is supposed to set
that flag. 'frame recognizer clear' however actually deletes all frame
recognizers (so, it doesn't set the flag but directly deletes them from the
list).

The current implementation of this concept is pretty broken. `frame recognizer
delete` sets the flag, but it somehow thinks that the recognizer id is an index
in the recognizer list. That's not true as it's actually just a member of each
recognizer entry. So it actually just sets the `deleted` flag for a random other
recognizer. The tests for the recognizer still pass as `frame recognizer list`
is also broken and just completely ignored the `deleted` flag and lists all
recognizers. Also `frame recognizer delete` just ignores if it can't actually
delete a recognizer if the id is invalid.

I think we can simplify this whole thing by just actually deleting recognizers
instead of making sure all code is actually respecting the `deleted` flag. I
assume the intention of this was to make sure that all recognizers are getting
unique ids over the course of an LLDB session, but as `clear` is actually
deleting them and we keep recycling ids, that didn't really work to begin with.

This patch deletes the `deleted` flag and just actually deletes the stored
recognizer. Also adds the missing error message in case it find a recognizer
with a given id.

Reviewers: mib

Reviewed By: mib

Subscribers: abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84404
2020-07-23 17:43:37 +02:00
Xing GUO 92874d2866 [DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.
This patch refactors `emitDebugInfo()` to make the length field be
inferred from its content. Besides, the `Visitor` class is removed in
this patch. The original `Visitor` class helps us determine an
appropriate length and emit the .debug_info section. These two
processes can be merged into one process. Besides, the length field
should be inferred when it's missing rather than when it's zero.

Reviewed By: jhenderson, labath

Differential Revision: https://reviews.llvm.org/D84008
2020-07-23 23:00:19 +08:00
Pavel Labath 9cdd68e7c1 Recommit "[lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)"
The patch was reverted 27d52cd86a because of failures in
TestWeakSymbols.py. These have now been addressed in D83552.

The original commit message was:
This function was documented to overwrite entries with D76111, which was
adding a couple of similar functions. However, this function (unlike the
functions added in that patch) was/is not actually overwriting variables
-- any pre-existing variables would get ignored.

This behavior does not seem to be intentional. In fact, before the refactor in
D41359, this function could introduce duplicate entries, which could
have very surprising effects both inside lldb and on other applications
(some applications would take the first value, some the second one; in
lldb, attempting to unset a variable could make the second variable
become active, etc.).

Overwriting seems to be the most reasonable behavior here, so change the
code to match documentation.

Differential Revision: https://reviews.llvm.org/D83306
2020-07-23 14:17:57 +02:00
Med Ismail Bennani e605994bb3 [lldb/test] Fix TestHistoryRecall failure (NFC)
This patch fixes a test failure in TestHistoryRecall caused by the move
of the `history` subcommand to the `session` command.

This change was introduced by commit 85fbb08fa2.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-23 13:27:12 +02:00
Med Ismail Bennani 85fbb08fa2 [lldb/interpreter] Move the history subcommand to session (NFCI)
This patch moves the `history` subcommand from the `command` to `session`
command. I think it makes more sense to have it there because as the `command`
usage suggests, it should be used to manage custom LLDB commands.

However, `history` is essentially tied to a debugging session and holds
all the commands (not specifically custom ones).

This also makes it more discoverable by adding an alias for it (mimicking
the shell builtin).

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-23 13:05:45 +02:00
Eric Christopher 3a75466f41 Temporarily Revert "Reland [lldb] Unify type name matching in FormattersContainer"
as it breaks bots with due to m_valid being an unused class member
except in assert builds.

This reverts commit 074b121642.
2020-07-23 00:47:05 -07:00
Serge Pavlov dab898f9ab [Windows] Fix limit on command line size
This reapplies commit d4020ef7c4, reverted in ac0edc5588 because it
broke build of LLDB. This commit contains appropriate changes for LLDB.
The original commit message is below.

Documentation on CreateProcessW states that maximal size of command line
is 32767 characters including ternimation null character. In the
function llvm::sys::commandLineFitsWithinSystemLimits this limit was set
to 32768. As a result if command line was exactly 32768 characters long,
a response file was not created and CreateProcessW was called with
too long command line.

Differential Revision: https://reviews.llvm.org/D83772
2020-07-23 11:39:42 +07:00
Logan Smith 77e0e9e17d Reapply "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
add_compile_options is more sensitive to its location in the file than add_definitions--it only takes effect for sources that are added after it. This updated patch ensures that the add_compile_options is done before adding any source files that depend on it.

Using add_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 17:50:19 -07:00
Jonas Devlieghere 8acaceb14c [lldb] Fix LLDB_DEFAULT_TEST_ARCH for standalone builds
LLVM_TARGET_ARCH is not exported by LLVM so we can't use it from
standalone builds. Default to the architecture in LLVM_HOST_TRIPLE when
no LLDB_DEFAULT_TEST_ARCH was specified.
2020-07-22 17:04:42 -07:00
Logan Smith 97a0f80c46 Revert "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
This reverts commit 388c9fb1af.
2020-07-22 15:07:01 -07:00
Logan Smith 388c9fb1af Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories.
Using add_compile_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 14:19:34 -07:00
Jonas Devlieghere 0d5fc82245 [lldb] Eliminate unneeded value parameters in Utility (NFC)
Eliminates value parameter for types that are not trivially copyable.
2020-07-22 13:56:23 -07:00
David Blaikie fdb45f54b6 lldb fix for b198de67e0 (PCH/modular codegen refactor) 2020-07-22 13:12:00 -07:00
Jonas Devlieghere d2ec91845c [lldb] Use std::make_unique<DynamicRegisterInfo> (NFC) 2020-07-22 11:32:48 -07:00
Louis Dionne afa1afd410 [CMake] Bump CMake minimum version to 3.13.4
This upgrade should be friction-less because we've already been ensuring
that CMake >= 3.13.4 is used.

This is part of the effort discussed on llvm-dev here:

  http://lists.llvm.org/pipermail/llvm-dev/2020-April/140578.html

Differential Revision: https://reviews.llvm.org/D78648
2020-07-22 14:25:07 -04:00
Hans Wennborg 3eec657825 Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.
After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8.
This reverts commit 81d68ad27b.
This reverts commit a361aa5249.
This reverts commit fa42b7cf29.
This reverts commit 955f87f947.
This reverts commit 8b16e45f66.
This reverts commit 308a127a38.
This reverts commit 274b6b0c7a.
This reverts commit 1c7037a2a5.
2020-07-22 20:23:58 +02:00
Adrian Prantl 6dbd4775bf Fix Windows build 2020-07-22 11:01:25 -07:00
Jonas Devlieghere 2419ded61d [lldb] Cleanup CommandObject registration (NFC)
- Remove the spurious argument to `CommandObjectScript`.
 - Use make_shared instead of bare `new`.
 - Move code duplication behind a macro.

Differential revision: https://reviews.llvm.org/D84336
2020-07-22 09:52:20 -07:00
Adrian Prantl 02f5837363 Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)
This patch has no effect for C and C++. In more dynamic languages,
such as Objective-C and Swift GetByteSize() needs to call into the
language runtime, so it's important to pass one in where possible. My
primary motivation for this is some work I'm doing on the Swift
branch, however, it looks like we are also seeing warnings in
Objective-C that this may resolve.  Everything in the SymbolFile
hierarchy still passes in nullptrs, because we don't have an execution
context in SymbolFile, since SymbolFile transcends processes.

Differential Revision: https://reviews.llvm.org/D84267
2020-07-22 08:56:29 -07:00
Benson Li c9d5a3058f [lldb] add printing of stdout compile errors to lldbsuite
Summary: Add printing of the output of stdout during compile errors, in
addition to stderr output.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D83425
2020-07-22 16:38:20 +02:00
Pavel Labath e00645cc78 [lldb/test] Delete result formatter machinery entirely
After more investigation, I realised this part of the code is totally
unused. It was used for communicating the test results from the
"inferior" dotest process to the main "dosep" process running
everything. Now that everything is being orchestrated through lit, this
is not used for anything.
2020-07-22 11:53:41 +02:00
Med Ismail Bennani 33981c6724 [lldb/interpreter] Fix formatting in CommandInterpreter.cpp (NFC)
This patch addresses some formatting issues introduced by commit
5bb742b10d

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-22 11:48:07 +02:00
Med Ismail Bennani 5bb742b10d [lldb/interpreter] Add ability to save lldb session to a file
This patch introduce a new feature that allows the users to save their
debugging session's transcript (commands + outputs) to a file.

It differs from the reproducers since it doesn't require to capture a
session preemptively and replay the reproducer file in lldb.
The user can choose the save its session manually using the session save
command or automatically by setting the interpreter.save-session-on-quit
on their init file.

To do so, the patch adds a Stream object to the CommandInterpreter that
will hold the input command from the IOHandler and the CommandReturnObject
output and error. This way, that stream object accumulates passively all
the interactions throughout the session and will save them to disk on demand.

The user can specify a file path where the session's transcript will be
saved. However, it is optional, and when it is not provided, lldb will
create a temporary file name according to the session date and time.

rdar://63347792

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-22 11:43:16 +02:00
Pavel Labath 5f4c850e7b [lldb/test] Do a better job at setting (DY)LD_LIBRARY_PATH
Summary:
registerSharedLibrariesWithTarget was setting the library path
environment variable to the process build directory, but the function is
also accepting libraries in other directories (in which case they won't
be found automatically).

This patch makes the function set the path variable correctly for these
libraries too. This enables us to remove the code for setting the path
variable in TestWeakSymbols.py, which was working only accidentally --
it was relying on the fact that
  launch_info.SetEnvironmentEntries(..., append=True)
would not overwrite the path variable it has set, but that is going to
change with D83306.

Reviewers: davide, jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83552
2020-07-22 11:37:02 +02:00
Raphael Isemann 074b121642 Reland [lldb] Unify type name matching in FormattersContainer
This was originally reverted because the Linux bots were red after this landed,
but it seems that was actually caused by a different commit. I double checked
that this works on Linux, so let's reland this on Linux.

Summary:

FormattersContainer stores LLDB's formatters. It's implemented as a templated
map-like data structures that supports any kind of value type and only allows
ConstString and RegularExpression as the key types. The keys are used for
matching type names (e.g., the ConstString key `std::vector` matches the type
with the same name while RegularExpression keys match any type where the
RegularExpression instance matches).

The fact that a single FormattersContainer can only match either by string
comparison or regex matching (depending on the KeyType) causes us to always have
two FormatterContainer instances in all the formatting code. This also leads to
us having every type name matching logic in LLDB twice. For example,
TypeCategory has to implement every method twice (one string matching one, one
regex matching one).

This patch changes FormattersContainer to instead have a single `TypeMatcher`
key that wraps the logic for string-based and regex-based type matching and is
now the only possible KeyType for the FormattersContainer. This means that a
single FormattersContainer can now match types with both regex and string
comparison.

To summarize the changes in this patch:
* Remove all the `*_Impl` methods from `FormattersContainer`
* Instead call the FormatMap functions from `FormattersContainer` with a
  `TypeMatcher` type that does the respective matching.
* Replace `ConstString` with `TypeMatcher` in the few places that directly
  interact with `FormattersContainer`.

I'm working on some follow up patches that I split up because they deserve their
own review:

* Unify FormatMap and FormattersContainer (they are nearly identical now).
* Delete the duplicated half of all the type matching code that can now use one
  interface.
* Propagate TypeMatcher through all the formatter code interfaces instead of
  always offering two functions for everything.

There is one ugly design part that I couldn't get rid of yet and that is that we
have to support getting back the string used to construct a `TypeMatcher` later
on. The reason for this is that LLDB only supports referencing existing type
matchers by just typing their respective input string again (without even
supplying if it's a regex or not).

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84151
2020-07-22 09:32:28 +02:00
Jonas Devlieghere e9f5ca0b79 [lldb] Adjust for getIntegerConstantExpression refactor 2020-07-21 23:04:22 -07:00
Xing GUO 8632931787 [DWARFYAML] Make the length field of compilation units optional. NFC.
This patch makes the length field of compilation units optional (0 by
default).
2020-07-22 12:16:19 +08:00
Jim Ingham 8d6aa688ee Remove the "bool" return from OptionValue::Clear and its subclasses.
Every override returns true and its return value is never checked.  I can't
see how clearing an OptionValue could fail, or what you would
do if it did.  The return serves no purpose.

Differential Revision: https://reviews.llvm.org/D84253
2020-07-21 11:32:55 -07:00
Vedant Kumar 46334dfc3b [lldb/test] Skip test in TestBitfieldIvars.py instead of xfailing it
The test triggers an ASan exception, causing job failures on the
sanitizer bot.

As suggested by Shafik.
2020-07-21 11:29:09 -07:00
Jonas Devlieghere dd064afe84 [lldb] Add missing member initialziation list
My previous commit added the default arguments but didn't use them in
the member initialization list...
2020-07-21 10:15:38 -07:00
Raphael Isemann e031eda08d Revert "[lldb] Unify type name matching in FormattersContainer"
This reverts commit 5b0de5756c.

Apparently that caused some test to get stuck on Linuxx. Reverting for now.
2020-07-21 19:03:33 +02:00
Jonas Devlieghere 98efa3d57f [lldb] Change the CommandArgumentData ctor (NFC)
By using default arguments the caller can specify a subset without the
need for overloads. This is particularly useful in combination with
emplace_back as these objects are generally stored in a vector.
2020-07-21 09:50:30 -07:00
Raphael Isemann 5b0de5756c [lldb] Unify type name matching in FormattersContainer
Summary:

FormattersContainer stores LLDB's formatters. It's implemented as a templated
map-like data structures that supports any kind of value type and only allows
ConstString and RegularExpression as the key types. The keys are used for
matching type names (e.g., the ConstString key `std::vector` matches the type
with the same name while RegularExpression keys match any type where the
RegularExpression instance matches).

The fact that a single FormattersContainer can only match either by string
comparison or regex matching (depending on the KeyType) causes us to always have
two FormatterContainer instances in all the formatting code. This also leads to
us having every type name matching logic in LLDB twice. For example,
TypeCategory has to implement every method twice (one string matching one, one
regex matching one).

This patch changes FormattersContainer to instead have a single `TypeMatcher`
key that wraps the logic for string-based and regex-based type matching and is
now the only possible KeyType for the FormattersContainer. This means that a
single FormattersContainer can now match types with both regex and string
comparison.

To summarize the changes in this patch:
* Remove all the `*_Impl` methods from `FormattersContainer`
* Instead call the FormatMap functions from `FormattersContainer` with a
  `TypeMatcher` type that does the respective matching.
* Replace `ConstString` with `TypeMatcher` in the few places that directly
  interact with `FormattersContainer`.

I'm working on some follow up patches that I split up because they deserve their
own review:

* Unify FormatMap and FormattersContainer (they are nearly identical now).
* Delete the duplicated half of all the type matching code that can now use one
  interface.
* Propagate TypeMatcher through all the formatter code interfaces instead of
  always offering two functions for everything.

There is one ugly design part that I couldn't get rid of yet and that is that we
have to support getting back the string used to construct a `TypeMatcher` later
on. The reason for this is that LLDB only supports referencing existing type
matchers by just typing their respective input string again (without even
supplying if it's a regex or not).

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

Differential Revision: https://reviews.llvm.org/D84151
2020-07-21 18:44:50 +02:00
Jonas Devlieghere 1c9cc094d0 [lldb] Fix typo that went unnoticed on my case insensitive FS 2020-07-21 09:13:26 -07:00
Jonas Devlieghere 9f8d481d68 [lldb/Reproducers] Don't recursively record everything in the CWD
RecordInterestingDirectory was added to collect dSYM bundles and their
content. For the current working directory we only want the directory to
be part of the VFS, not necessarily its contents. This patch renames the
current method to RecordInterestingDirectoryRecursively and adds a new
one that's not recursive.
2020-07-21 09:02:38 -07:00
Raphael Isemann 5c15426d7c [lldb] Remove FormattersContainer's name member
Summary:

FormattersContainer currently has an unused `m_name` member. Usually LLDB allows
giving objects names, but for the FormattersContainer it seems excessive. There
are only 4 FormattersContainer variables in LLDB and they are not usually passed
around, so one can always just go up a few frames when debugging to find out
which FormattersContainer you're dealing with.

Reviewers: mib, davide

Reviewed By: mib

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D84154
2020-07-21 13:54:38 +02:00
Muhammad Omair Javaid b621e8c787 [LLDB] Fix build on windows caused by LinuxPTraceDefines_arm64sve.h
This patch fixes build on lldb-x64-windows-ninja. The error is caused by
use of two leading underscores.

According to MSVC documentation:
In Microsoft C++, identifiers with two leading underscores are reserved
for compiler implementations.

https://docs.microsoft.com/en-us/cpp/cpp/keywords-cpp?view=vs-2019
2020-07-21 16:47:25 +05:00
Muhammad Omair Javaid 510e37c88c Revert "Revert "AArch64 SVE register infos and core file support""
This reverts commit d9920e0199.
2020-07-21 14:31:47 +05:00
Muhammad Omair Javaid 6960e39eff [LLDB] Fix LinuxPTraceDefines_arm64sve.h for AArch64 Linux host
LinuxPTraceDefines_arm64sve.h defines essential macros for manipulating
AArch64 SVE core dump registers. Add guard for aarch64/Linux hosts where
newer versions of ptrace.h or sigcontext.h might already define SVE macros.

Differential Revision: https://reviews.llvm.org/D83541
2020-07-21 14:31:47 +05:00
Muhammad Omair Javaid 62ccfb6ed0 [LLDB] Fix Arm/AArch64 Linux broken build
This patch fixes build breakage on LLDB Arm/AArch64 Linux buildbots.

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/6649
http://lab.llvm.org:8011/builders/lldb-arm-ubuntu/builds/1919

This build breakage was introduces by commit: 001c8e1fd9
2020-07-21 13:46:39 +05:00
Jonas Devlieghere cb5926795a [lldb] Make TestOptionValueFileColonLine work on Windows
The colon in the file name is interpreted as a drive name and therefore
the path looks like foo:\\bar.c. Compare FileSpecs instead of their
string representation so we don't have to worry about that.
2020-07-20 23:15:03 -07:00
Jonas Devlieghere 7926143fb0 [lldb] Fix redundant newline in AppendError calls.
AppendError always appends a newline to the given argument, while
AppendErrorWithFormat does not. I've updated the calls to remove the
extra newline.
2020-07-20 23:11:56 -07:00
Jonas Devlieghere 8953376478 [lldb] Remove redundant WithFormat suffixes (NFC)
Replace calls to FooWithFormat() with calls to Foo() when only one
argument is provided and the given string doesn't need to be formatted.
2020-07-20 23:00:32 -07:00
Jonas Devlieghere 138244f099 [lldb] fix warnings in TestOptionValueFileColonLine.cpp 2020-07-20 21:43:17 -07:00
Jonas Devlieghere 43031a38ff [lldb] Fix OptionValueFileColonLine to compile with MSVC
This should fix error C4716:
'lldb_private::OptionValueFileColonLine::Clear': must return a value
2020-07-20 21:25:33 -07:00
Jim Ingham bc0a9a17a4 Add an option (-y) to "break set" and "source list" that uses the same
file:line:column form that we use to print out locations.  Since we
print them this way it makes sense we also accept that form.

Differential Revision: https://reviews.llvm.org/D83975
2020-07-20 17:40:36 -07:00
Jonas Devlieghere b79dff0279 [lldb] Make sure we don't leak SBThreadPlan pointer (NFCI)
Make sure we don't accidentally leak the SBThreadPlan pointer when we
return before handing it off to Python to manage its lifetime.
2020-07-20 16:58:06 -07:00
Jonas Devlieghere 2ba7ce401e [lldb] Use weak_ptr to hold on to the underlying thread plan in SBThreadPlan
Use a weak pointer to hold on to the the underlying thread plan in
SBThreadPlan. When the process continues, all the popped ThreadPlans get
discarded, and you can’t reuse them, so you have to create them anew.
Therefore the SBThreadPlan doesn’t need to keep the ThreadPlan alive.

This fixes the cleanup error in TestThreadPlanCommands.py and
TestStepScripted.py caused by the thread plans never being deleted.

Differential revision: https://reviews.llvm.org/D84210
2020-07-20 16:55:17 -07:00
shafik a54c42df9a Fix how we handle bit-fields for Objective-C when creating an AST
Currently expressions dealing with bit-fields in Objective-C objects is pretty broken. When generating debug-info for Objective-C bit-fields DW_AT_data_bit_offset has a different meaning than it does to C and C++.
When we parse the DWARF we validate bit offsets for C and C++ correctly but not for ObjC. For ObjC in some cases we end up incorrectly flagging an error and we don't generate further bit-fields in the AST.
Later on when we do a name lookup we don't find the ObjCIvarDecl in the ObjCInterfaceDecl in some cases since we never added it and then we don't go to the runtime to obtain the offset.

This will fix how we handle bit-fields for the Objective-C case and add tests to verify this fix but also to documents areas that still don't work and will be addressed in follow-up PRs.

Note: we can never correctly calculate offsets statically because of how Objective-C deals with the fragile base class issue. Which means the runtime may need to shift fields over.

Differential Revision: https://reviews.llvm.org/D83433
2020-07-20 16:12:29 -07:00
Davide Italiano b1a6d373d5 [PlatformMacOSX] Remove unused variable. NFC. 2020-07-20 14:50:59 -07:00
Davide Italiano cd05406b10 [testsuite] Adapt lldb-server base test helper to run on arm64 2020-07-20 14:38:13 -07:00
Davide Italiano 001c8e1fd9 [PlatformDarwin] Add support for Apple Silicon.
Gets another large chunk of the testsuite to pass.
2020-07-20 14:11:19 -07:00
Martin Storsjö f07ddbc9c4 [LLDB] [COFF] Fix handling of symbols with more than one aux symbol
Differential Revision: https://reviews.llvm.org/D84070
2020-07-20 22:42:28 +03:00
Logan Smith 8b16e45f66 Enable -Wsuggest-override in the LLVM build
This patch adds Clang's new (and GCC's old) -Wsuggest-override to the warning flags for the LLVM build. The warning is a stronger form of -Winconsistent-missing-override which warns _everywhere_ that override is missing, not just in places where it's inconsistent within a class.

Some directories in the monorepo need the warning disabled for compatibility's, or sanity's, sake; in particular, libcxx/libcxxabi, and any code implementing or interoperating with googletest, googlemock, or google benchmark (which do not themselves use override). This patch adds -Wno-suggest-override to the relevant CMakeLists.txt's to accomplish this.

Differential Revision: https://reviews.llvm.org/D84126
2020-07-20 12:32:47 -07:00
Jonas Devlieghere f8df2e1a19 [lldb/Reproducers] Always record the current working directory
Setting the current working directory in the VFS will fail if the given
path doesn't exist in the YAML mapping or on disk.
2020-07-20 11:54:11 -07:00
Jonas Devlieghere 3f16114ddb [lldb] Fix method name to match LLDB code style (NFC)
recordInterestingDirectory -> RecordInterestingDirectory
2020-07-20 11:54:11 -07:00
Pavel Labath 7fadd70069 [lldb/Utility] Simplify Scalar::SetValueFromData
The function was fairly complicated and didn't support new bigger
integer sizes. Use llvm function for loading an APInt from memory to
write a unified implementation for all sizes.
2020-07-20 15:56:56 +02:00
Pavel Labath 9decf0405f [lldb/test] Simplify Makefile rules for .d files
The sed line in the rules was adding the .d file as a target to the
dependency rules -- to ensure the file gets rebuild when the sources
change. The same thing can be achieved more elegantly with some -M
flags.
2020-07-20 15:53:19 +02:00
Pavel Labath 9199457bfb [LLDB/test] Simplify result formatter code
Now that the main test results are reported through lit, and we only
have one formatter class, this code is unnecessarily baroque.
2020-07-20 14:56:49 +02:00
Muhammad Omair Javaid d9920e0199 Revert "AArch64 SVE register infos and core file support"
This reverts commit 7e017de0ad.
2020-07-20 17:37:17 +05:00
Muhammad Omair Javaid 7e017de0ad AArch64 SVE register infos and core file support
Summary:
This patch adds support for AArch64 SVE register infos description and
core file register access.

AArch64 SVE is a an optional extension of Arm v8.3-a architecture. It
has introduced 32 new vector registers Z, 16 predicate P registers and FFR
predicate register. These registers have fixed names but can dynamically
be configured to different size based on underlying OS configuration.

This patch adds register info struct that describes SVE register infos and
also provides RegisterContextPOSIXCore_arm64 routines to access SVE registers.

This patch also introduces a mechanism to configure SVE register sizes and
offsets at startup before exchanging register information across gdb-remote.

TestLinuxCore.py has been updated to include testing of SVE core files.

Reviewers: labath, clayborg, jankratochvil, jasonmolenda, rengolin

Reviewed By: labath

Subscribers: tschuett, kristof.beyls, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D77047
2020-07-20 17:21:16 +05:00
Muhammad Omair Javaid 7ca9b589c4 Remove Linux sysroot dependencies of SVE PT macros
Summary:
SVE elf note data requires SVE PT macros for reading writing data. Same macros are used by Linux ptrace SVE register access.
This patch makes necessary changes to lldb/source/Plugins/Process/Linux/LinuxPTraceDefines_arm64sve.h in order to make them sysroot independent.

Reviewers: labath, rengolin

Reviewed By: labath

Subscribers: tschuett, lldb-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D83541
2020-07-20 14:54:51 +05:00
Muhammad Omair Javaid 4923dca9bd Remove use of multiple reg index enums by RegisterContextPOSIX_arm64
Summary:
This patch removes dependence of RegisterContextPOSIX_arm64 on register number enums defined in lldb-arm64-register-enums.h.
RegisterContextPOSIX_arm64 makes use of helper functions to access register numbers defined in RegisterInfos_arm64.h via RegisterInfosPOSIX_arm64.

Reviewers: labath

Reviewed By: labath

Subscribers: emaste, kristof.beyls, arphaman, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D83753
2020-07-20 14:54:51 +05:00
Raphael Isemann 139e2a3f7b [lldb] Remove orphaned modules in a loop
Summary:

When modules reference each other (which happens for example with the different
modules LLDB loads when debugging -gmodules-compiled binaries), just iterating
over the module list once isn't good enough to find all orphans. Any removed
modules in the module list will also clear up the shared pointers they hold to
other modules, so after any module was removed from the list, LLDB should
iterate again and check if any additional modules can no be safely deleted.

This is currently causing that many gmodules tests are not cleaning up all
allocated modules which causes cleanup asserts to fail (right now these asserts
just mark the test as unsupported, but after D83865 the tests will start
failing).

Reviewers: aprantl, clayborg, JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D84015
2020-07-20 10:47:56 +02:00
Raphael Isemann 43f8a7c83b [lldb][NFC] Remove unused FormattersContainer::Get overload
This is unused and also calls a non-existent 'Get' overload.
2020-07-20 09:59:43 +02:00
Raphael Isemann fd50e7c06d [lldb][NFC] Make some RegularExpression constructor calls less verbose 2020-07-20 07:27:51 +02:00
Michele Scandale 53880b8cb9 [CMake] Make `intrinsics_gen` dependency unconditional.
The `intrinsics_gen` target exists in the CMake exports since r309389
(see LLVMConfig.cmake.in), hence projects can depend on `intrinsics_gen`
even it they are built separately from LLVM.

Reviewed By: MaskRay, JDevlieghere

Differential Revision: https://reviews.llvm.org/D83454
2020-07-17 16:43:17 -07:00
Jonas Devlieghere 0fbbf3a98c [lldb] Unify sleep and time outs in GDB remote testcases
Reduce sleep and time outs in GDB remote testcases to one default value
for each. Stop passing these values around and always use the default
instead.

Differential revision: https://reviews.llvm.org/D83904
2020-07-17 11:03:16 -07:00
Pavel Labath ede7c02b38 [lldb/COFF] Remove strtab zeroing hack
Summary:
This code (recently responsible for a unaligned access sanitizer
failure) claims that the string table offset zero should result in an
empty string.

I cannot find any mention of this detail in the Microsoft COFF
documentation, and the llvm COFF parser also does not handle offset zero
specially. This code was introduced in 0076e7159, which also does not go
into specifics, citing "various bugfixes".

Given that this is obviously a hack, and does not cause tests to fail, I
think we should just delete it.

Reviewers: amccarth, markmentovai

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83881
2020-07-17 13:24:59 +02:00
Pavel Labath f3fab392f5 [lldb/DWARF] Don't get confused by line sequences with tombstone values
Summary:
With D81784, lld has started debug info resolving relocations to
garbage-collected symbols as -1 (instead of relocation addend). For an
unaware consumer this generated sequences which seemingly wrap the
address space -- their first entry was 0xfffff, but all other entries
were low numbers.

Lldb stores line sequences concatenated into one large vector, sorted by
the first entry, and searched with std::lower_bound. This resulted in
the low-value entries being placed at the end of the vector, which
utterly confused the lower_bound algorithm, and caused it to not find a
match. (Previously, these sequences would be at the start of the vector,
and normally would contain addresses that are far smaller than any real
address we want to look up, so std::lower_bound was fine.)

This patch makes lldb ignore these kinds of sequences completely. It
does that by changing the construction algorithm from iterating over the
rows (as parsed by llvm), to iterating over the sequences. This is
important because the llvm parsed performs validity checks when
constructing the sequence array, whereas the row array contains raw
data.

Reviewers: JDevlieghere, MaskRay

Differential Revision: https://reviews.llvm.org/D83957
2020-07-17 11:51:52 +02:00
Raphael Isemann 1b7c9eae6d [lldb] Store StackFrameRecognizers in the target instead of a global list
Summary:

Currently the frame recognizers are stored in a global list (the list in the
StackFrameRecognizersManagerImpl singleton to be precise). All commands and
plugins that modify the list are just modifying that global list of recognizers
which is shared by all Target and Debugger instances.

This is clearly against the idea of LLDB being usable as a library and it also
leads to some very obscure errors as now multiple tests are sharing the used
frame recognizers. For example D83400 is currently failing as it reorders some
test_ functions which permanently changes the frame recognizers of all
debuggers/targets. As all frame recognizers are also initialized in a 'once'
guard, it's also impossible to every restore back the original frame recognizers
once they are deleted in a process.

This patch just moves the frame recognizers into the current target. This seems
the way everyone assumes the system works as for example the assert frame
recognizers is using the current target to find the function/so-name to look for
(which only works if the recognizers are stored in the target).

Reviewers: jingham, mib

Reviewed By: jingham, mib

Subscribers: MrHate, JDevlieghere

Differential Revision: https://reviews.llvm.org/D83757
2020-07-17 09:26:27 +02:00
Raphael Isemann 16926115ed [lldb] Only set the executable module for a target once
Summary:

When we try to find the executable module for our target we don't check
if we already have an executable module set. This causes that when debugging
a program that dlopens another executable, LLDB will take that other executable
as the new executable of the target (which causes that future launches of the
target will launch the dlopen'd executable instead of the original executable).

This just adds a check that we only set the executable when we haven't already
found one.

Fixes rdar://63443099

Reviewers: jasonmolenda, jingham, teemperor

Reviewed By: jasonmolenda, teemperor

Subscribers: jingham, JDevlieghere

Differential Revision: https://reviews.llvm.org/D80724
2020-07-17 08:35:38 +02:00
Jonas Devlieghere 2f99059aa0 [lldb/Test] Skip TestMacABImacOSFramework.py with reproducers
This test is hitting https://bugs.python.org/issue22393 which results in
the lit multiprocessing pool deadlocking and the reproducer job timing
out on GreenDragon.
2020-07-16 15:50:35 -07:00
Adrian McCarthy 72958c9ab1 [lldb] Eliminated unused local variable
I got misled by this remnant from earlier changes.
2020-07-16 14:44:24 -07:00
serge-sans-paille 515bc8c155 Harmonize Python shebang
Differential Revision: https://reviews.llvm.org/D83857
2020-07-16 21:53:45 +02:00
Walter Erquinigo 4c5d52397e [intel-pt] Fix building due to CMake + python changes
Python is now handled in CMake with different variables, thus
the intel plugin needs a corresponding update.

Test Plan:

Differential Revision: https://phabricator.intern.facebook.com/D22555992
2020-07-16 12:18:59 -07:00
Fred Riss 8113a8bb79 [lldb/ObjectFileMachO] Fetch shared cache images from our own shared cache
Summary:
On macOS 11, the libraries that have been integrated in the system
shared cache are not present on the filesystem anymore. LLDB was
using those files to get access to the symbols of those libraries.
LLDB can get the images from the target process memory though.

This has 2 consequences:
 - LLDB cannot load the images before the process starts, reporting
   an error if someone tries to break on a system symbol.
 - Loading the symbols by downloading the data from the inferior
   is super slow. It takes tens of seconds at the start of the
   debug session to populate the Module list.

To fix this, we can use the library images LLDB has in its own
mapping of the shared cache. Shared cache images are somewhat
special as their LINKEDIT segment is moved to the end of the cache
and thus the images are not contiguous in memory. All of this can
hidden in ObjectFileMachO.

This patch fixes a number of test failures on macOS 11 due to the
first problem described above and adds some specific unittesting
for the new SharedCache Host utilities.

Reviewers: jasonmolenda, labath

Subscribers: llvm-commits, lldb-commits

Tags: #lldb, #llvm

Differential Revision: https://reviews.llvm.org/D83023
2020-07-16 10:37:37 -07:00
Jaroslav Sevcik 93ec6cd684 [lldb] Desugar template specializations
Template specializations are not handled in many of the
TypeSystemClang methods. For example, GetNumChildren does not handle
the TemplateSpecialization type class, so template specializations
always look like empty objects.

This patch just desugars template specializations in the existing
RemoveWrappingTypes desugaring helper.

Differential Revision: https://reviews.llvm.org/D83858
2020-07-16 09:01:01 +02:00
Jonas Devlieghere c14e11b0bb [lldb/Test] Skip async process connect tests with reproducers
Reproducers only support synchronous mode.
2020-07-15 15:39:44 -07:00
Adrian Prantl b0ad73a2a0 Add missing include 2020-07-15 15:38:40 -07:00
Muhammad Omair Javaid 3c22996129 [LLDB] Disable lldb-vscode test_terminate_commands test on Arm
Summary:
test_terminate_commands is flaky on LLDB Arm buildbot as well. It was already
being skipped for aarch64. I am going to mark it skipped for Arm too.

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81978
2020-07-16 03:33:52 +05:00
Jonas Devlieghere 8b85f68ee2 [lldb/Test] Remove custom tearDownHooks from GDB Remote tests
Remove custom tearDownHooks from GDB Remote tests as we now cleanup
subprocesses unconditionally. This also changes the termination order to
be the reverse of the creation order. I don't think anything is relying
on that right now, but it better fits the setup/teardown paradigm.
2020-07-15 13:18:06 -07:00
Logan Smith 44b43a52dc [lldb][NFC] Add 'override' where missing in source/ and tools/
These were found by Clang's new -Wsuggest-override.

This patch doesn't touch any code in unittests/, since much of it intentionally doesn't use override to avoid massive warning spam from -Winconsistent-missing-override due to the use of MOCK_*** macros.

Differential Revision: https://reviews.llvm.org/D83847
2020-07-15 11:34:47 -07:00
Jordan Rupprecht cf3f100fcb [lldb][test] Prevent infinite loop while looking for use_lldb_suite_root.py.
Several scripts (two copies of use_lldb_suite.py, and an __init__.py) look for use_lldb_suite_root.py by checking parent directories. If for some reason it doesn't exist, it keeps checking parent directories until it finds it.

However, this only breaks when the parent directory is None, but at least on Linux, dirname('/') == '/', so this will never be None.

This changes the lookup to stop if the dirname(lldb_root) is unchanged. This was previously fixed in 67f6d842fa, but only in one copy of this script.

Additionally, this makes the failure mode more visible -- if the root is not found, it complains loudly instead of silently failing, and having later modules that need lldb_root fail.

Differential Revision: https://reviews.llvm.org/D83840
2020-07-15 09:16:30 -07:00
Jonas Devlieghere 700dd17399 [lldb/Test] Remove support for forking a subprocess from the test suite.
Remove the forkSubprocess method and its bookkeeping.
TestCreateAfterAttach is the only test using the fork method and I'm not
convinced it adds enough to warrant the maintenance. Pavel suggested the
same thing in D83815.
2020-07-15 08:57:54 -07:00
Raphael Isemann 9c1c6a3fcc Revert "[lldb] Use the basename of the Python test for the log name instead of the class name"
This reverts commit 29aab9b5c7.

It seems on Windows the file name is just always "lldbsuite.test.lldbtest" for
all tests and that breaks pretty much everything. Reverting until we have
a better solution.
2020-07-15 16:26:37 +02:00
Pavel Labath 313fca6520 [lldb/test] Remove JOIN_CMD from Makefile.rules
It's possible to achieve the same effect by providing multi-step recipe
instead of a single-step recipe where the step happens to contain
multiple commands.
2020-07-15 16:03:45 +02:00
Pavel Labath f819d25798 [lldb] Delete useless assertion
It served a puprose while we were using the test name to provide a name
for the created file. Now that the files are created in memory, we don't
need that.
2020-07-15 15:42:53 +02:00
Raphael Isemann 10fd550d30 [lldb] Make expect_expr fall back to the dummy target if no target is selected
Summary:

Currently expect_expr will not run the expression if no target is selected. This
patch changes this behavior so that expect_expr will instead fall back to the
dummy target similar to what the `expression` command is doing. This way we
don't have to compile an empty executable to be able to use `expect_expr` (which
is a waste of resources for tests that just test generic type system features).

As a test I modernized the TestTypeOfDeclTypeExpr into a Python test +
expect_expr (as it relied on the dummy target fallback of the expression
command).

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: abidh

Differential Revision: https://reviews.llvm.org/D83388
2020-07-15 13:56:00 +02:00
Raphael Isemann 29aab9b5c7 [lldb] Use the basename of the Python test for the log name instead of the class name
Summary:

From what I know we already have the restriction that every test in the test
suite needs to have a unique file name as that's used for generating the unique
build directory for a test. It seems there is also a restriction that every test
case class in the test suite needs to have a unique name as that's used to
generate the unique log file name for the test run.

This changes the log file format to use the basename of the test file instead so
that we only have to keep worrying about the 'unique file name' restriction from
now on.

This came up because I started naming the test classes "TestCase" (as repeating
the file name in the test class seems like redudant information that just makes
renaming tests a pain).

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: mgorny, abidh

Differential Revision: https://reviews.llvm.org/D83767
2020-07-15 13:54:43 +02:00
Raphael Isemann 001c78de35 [lldb][formatters] Add support for printing NSConstantDate and fix distantPast value
Summary:

Certain `NSDate` constructors return a special `NSConstantDate` class which
currently ends up being unformatted as it's not in the list of supported classes
for the NSDate formatter. This patch adds that class to the supported class list
so LLDB produces a summary for it.

One of these special constructors is `[NSDate distantPast]` which returns the
date for `0001-01-01 00:00:00 UTC`. LLDB has a special case for formatting this
date but for some reason we did hardcode the wrong summary string in that
special case. Maybe the summary string was correct back when the code was
written but it isn't correct anymore (`distantPast` isn't actually defined to be
a special date but just some 'a guaranteed temporal boundary.' so maybe someone
changed the value in the last 10 years).

If someone else is wondering why we even have this special case for
`distantPast` but not for the future. The reason seems to be that our date
formatting for really old dates is off by 24 hours. So for example, adding one
second to `distantPast` will cause LLDB to print `0000-12-30 00:00:01 UTC`
(which is 24 hours behind the expected result). So to make our code appear to be
correct it seems we just hardcoded the most common NSDate result from that time
span. I'll replace that logic with a generic solution in a probably more
invasive follow up patch.

I also took the freedom to replace the magic value `-63114076800` with some
constant + documentation. I heard there are some people that don't know from the
top of their head that there are 63114076800 seconds between 1. Jan 0001 and 1.
January 2001 in whatever calendar system NSDate is using.

Reviewers: mib, davide

Reviewed By: mib

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D83217
2020-07-15 10:28:10 +02:00
Petr Hosek bcd27d9d73 Revert "[CMake] Simplify CMake handling for zlib"
This reverts commit 8c1a79dc12 because
it fails when zlib isn't installed.
2020-07-14 19:56:10 -07:00
Petr Hosek 8c1a79dc12 [CMake] Simplify CMake handling for zlib
Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219
2020-07-14 19:30:08 -07:00
Davide Italiano 61cf9f4e72 [ObjectFilePECOFF] Try to avoid unaligned access.
Fixes an UBSAN error.
2020-07-14 18:53:23 -07:00
Adrian Prantl 74c8d01aff Fix the skipIfRosetta decorator
the form that takes func as an argument isn't compatible with the
optional bugnumber argument. This means that only correct for to use it is now
@skipIfRosetta(bugnumber='url')
2020-07-14 18:16:17 -07:00
Jonas Devlieghere 984e12ab48 [lldb/Test] Create reproducer dir if necessary
Create the reproducer directory under the build root if it doesn't
exists. The reproducer will only create the top level directory.
2020-07-14 16:17:53 -07:00
Jonas Devlieghere c6e8bf7287 [lldb/Test] Skip TestProcessConnect.py on Windows
Remote connections are not supported on Windows.
2020-07-14 14:07:06 -07:00
Jonas Devlieghere 4aafc479f2 [lldb/Test] Always set the cleanupSubprocesses tear down hook
Always clean up subprocesses on tear down instead of relying on the
caller to do so. This is not only less error prone but also means the
tests can be more concise.

Differential revision: https://reviews.llvm.org/D83787
2020-07-14 14:05:56 -07:00
Eric Christopher 368eb7712f Fix a -Wunused-variable warning. 2020-07-14 12:40:56 -07:00
Davide Italiano 3f2d880a93 [ObjC] Wrap namespace-global structs in an anonymous namespace to avoid ODR violations
<rdar://problem/65537147>

Differential Revision:  https://reviews.llvm.org/D83796
2020-07-14 11:26:20 -07:00
Jonas Devlieghere 5a62008f35 [lldb] Use runBuildCommands from buildGModules
Use runBuildCommands, like all other builders, to raise a build-specific
error when the command fails.
2020-07-14 10:41:45 -07:00
Jonas Devlieghere 9ecbad54c2 [lldb] lldbinline and lldbtest gardening (NFC)
- Make the open more Pythonic.
 - Remove the unused `cleanup` Make target.
 - Remove commented-out/obvious/low-value comments.
 - Cleanup the forked process PID list.
2020-07-14 10:41:45 -07:00
Jonas Devlieghere f5f15acebb [lldb/Test] Skip TestProcessConnect.py on Windows
Skip TestProcessConnect.py on Windows and Android (the same platforms as
TestPlatformProcessConnect.py) and mark it as a NO_DEBUG_INFO test so we
don't run all the variants.
2020-07-14 10:12:40 -07:00
Fred Riss a4a00ced0c [lldb/Module] Allow for the creation of memory-only modules
Summary:
This patch extends the ModuleSpec class to include a
DataBufferSP which contains the module data. If this
data is provided, LLDB won't try to hit the filesystem
to create the Module, but use only the data stored in
the ModuleSpec.

Reviewers: labath, espindola

Subscribers: emaste, MaskRay, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83512
2020-07-14 08:45:44 -07:00
Jonas Devlieghere 706cccb889 [lldb] Make `process connect` blocking in synchronous mode.
In synchronous mode, the process connect command and its aliases should
wait for the stop event before claiming the command is complete.
Currently, the stop event is always handled asynchronously by the
debugger.

The implementation takes the same approach as Process::ResumeSynchronous
which hijacks the event and handles it on the current thread. Similarly,
after this patch, the stop event is part of the command return object,
which is the property used by the test case.

Differential revision: https://reviews.llvm.org/D83728
2020-07-14 08:45:34 -07:00
Raphael Isemann 6f51ceea1f [lldb] Refactor character printing in DumpDataExtractor
Summary: Just unifying all that copy-pasted code.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D83662
2020-07-14 14:22:03 +02:00
Pavel Labath 3cdbacc464 [lldb/test] Avoid globbing in log file handling code
The glob expression for a test called "test" could match a log file for
a the test "test_foo". Instead of globbing, maintain an explicit list of
log files relevant to the current test.
2020-07-14 13:10:59 +02:00
Walter Erquinigo 9a9ae01f99 [lldb-vscode] Fix TestVSCode_setBreakpoints
It was failing because some module events had empty UUID, and that was not handled correctly.
The diff that added that logic is https://reviews.llvm.org/D82477
2020-07-13 18:27:53 -07:00
Walter Erquinigo 869d05fb3e [lldb-vscode] Fix TestVSCode_module
This test was added in https://reviews.llvm.org/D82477 and needs to wait a little bit before fetching some information.
2020-07-13 18:02:37 -07:00
Walter Erquinigo 77c9aafc5d Retry ""[lldb-vscode] Fix TestVSCode_module""
Original commit c60216db15.

The test can only run on Darwin because of how it was setup, so I'm
enforcing that.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2020-07-13 14:12:03 -07:00
Jonas Devlieghere 32d35fb74b [lldb] Remove unused argument (NFC)
Nobody is writing to the stream so there's no point in passing it
around.
2020-07-13 13:44:51 -07:00
Adrian Prantl 341ec56418 Add a decorator to skip tests when running under Rosetta
This allows skipping a test when running the testsuite on macOS under
the Rosetta translation layer.

Differential Revision: https://reviews.llvm.org/D83600
2020-07-13 13:09:53 -07:00
Martin Storsjö 340c376b87 [lldb] Fix a CMake warning typo. NFC. 2020-07-13 22:48:17 +03:00
Pavel Labath 1847f4dd75 [lldb/Utility] Rewrite Scalar::SetValueFromCString
The function's reliance on host types meant that it was needlessly
complicated, and did not handle the newer (wider) types. Rewrite it in
terms of APInt/APFloat functions to save code and improve functionality.
2020-07-13 16:44:42 +02:00
Pavel Labath a5803765d8 [lldb/dotest] Remove the "xunit" result formatter
Summary:
My understanding is that this was added to make dotest interact well
with the GreenDragon bots, back when dotest was the main test driver.
Now that everything goes through lit (which has its own xunit
formatter), it seems largely irrelevant.

There are more cleanups that can be done after removing this be done
here, but this should be enough to test the waters.

Reviewers: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83545
2020-07-13 16:33:38 +02:00
Raphael Isemann f3b3689c04 [lldb][NFC] Refactor instruction dumping out of DumpDataExtractor 2020-07-13 15:03:40 +02:00
Raphael Isemann aa933d82f8 [lldb][NFC] Early-exit in DWARFASTParserClang::ParseSingleMember
This patch just early-exits after the 'if (num_attributes > 0)' check.
2020-07-13 13:21:12 +02:00
Raphael Isemann 60cbbb306d [lldb][NFC] Remove misleading class_language variable in DWARFASTParserClang
There is a local 'class_language' veriable in DWARFASTParserClang which is named
as if it is related to the 'class_language' member of ParsedDWARFTypeAttributes.
However, it actually only has two possible enum values: 'ObjC' (which means the
current record is a Objective-C class) or 'Unknown' (which covers all other
cases).

This is confusing for the reader and also lead to some strange code where we
have several comparisons against the value "ObjC_plus_plus" (which is always
false).

This replaces the variable with either a const bool variable (if there are
multiple checks for that condition in a function) or a direct call to the
TypeSystemClang utility method for checking if it's a Objective-C
Object/Interface type.
2020-07-13 13:10:12 +02:00
Jonas Devlieghere 8ee225744f [lldb/Test] Fix missing yaml2obj in Xcode standalone build.
Rather than trying to find the yaml2obj from dotest we should pass it in
like we do for dsymutil and FileCheck.
2020-07-10 21:34:56 -07:00
Adrian Prantl 851cc2f8f6 Fix nesting of #ifdef
This fixes a compile error when building for an arm64 host.

Differential Revision: https://reviews.llvm.org/D83582
2020-07-10 17:13:46 -07:00
Walter Erquinigo c60216db15 Revert "[lldb-vscode] Fix TestVSCode_module"
This reverts commit 881af6eb00.

Revert "[lldb-vscode] Add Compile Unit List to Modules View"
This reverts commit 03ef61033f.

Revert "[lldb-vscode] Add Support for Module Event"
This reverts commit f7f8015975.

The debian buildbot has reported issues with the modules test.
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/13767/steps/test/logs/stdio

Reverting it for now.
2020-07-10 17:07:07 -07:00
Walter Erquinigo 881af6eb00 [lldb-vscode] Fix TestVSCode_module
For some reason this works on the original author's machine, but not on my. So I'm using a safer approach of using an unstripped dynamic library to place breakpoints on. The author was placing a breakpoint on the main symbol of a stripped library and for some reason it worked on their machine, but it shouldn't have...

Offender diff: D82477
2020-07-10 16:50:59 -07:00
Yifan Shen 03ef61033f [lldb-vscode] Add Compile Unit List to Modules View
Summary: User can expand and check compile unit list for the modules that have debug info.

Reviewers: wallace, clayborg

Reviewed By: clayborg

Subscribers: aprantl, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83072
2020-07-10 16:50:59 -07:00
Yifan Shen f7f8015975 [lldb-vscode] Add Support for Module Event
Summary:
Whenever a module is created, removed or changed, lldb-vscode is now sending an event that can be interpreted by the IDE so that modules can be rendered in the IDE, like the tree view in this screenshot

{F12229758}

Reviewers: wallace, clayborg, kusmour, aadsm

Reviewed By: clayborg

Subscribers: cfe-commits, labath, lldb-commits

Tags: #lldb, #clang

Differential Revision: https://reviews.llvm.org/D82477
2020-07-10 16:50:59 -07:00
Jonas Devlieghere 169c83208f [ldb/Reproducers] Add YamlRecorder and MultiProvider
This patch does several things that are all closely related:

 - It introduces a new YamlRecorder as a counterpart to the existing
   DataRecorder. As the name suggests the former serializes data as yaml
   while the latter uses raw texts or bytes.

 - It introduces a new MultiProvider base class which can be backed by
   either a DataRecorder or a YamlRecorder.

 - It reimplements the CommandProvider in terms of the new
   MultiProvider.

Finally, it adds unit testing coverage for the MultiProvider, a naive
YamlProvider built on top of the new YamlRecorder and the existing
MutliLoader.

Differential revision: https://reviews.llvm.org/D83441
2020-07-10 12:48:22 -07:00
Konrad Kleine ecfa01e956 [lldb] on s390x fix override issue
Summary:
This fixes an override issue by marking a function as const so that the
signature maps to the signature of the function in the base class.

This is the original error:

In file included from /root/llvm/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp:11:
/root/llvm/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h:79:10: error: 'size_t lldb_private::process_linux::NativeRegisterContextLinux_s390x::GetGPRSize()' marked 'override', but does not override
   79 |   size_t GetGPRSize() override { return sizeof(m_regs); }
      |          ^~~~~~~~~~

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83580
2020-07-10 15:11:49 -04:00
Jim Ingham e337350be9 This is a refinement on 96601ec28b. The intent of that change was to do the same work for the computation of the locations of the children of ValueObjectVariable as was done for the root ValueObjectVariable. This original patch did that by moving the computation from ValueObjectVariable to ValueObject. That fixed the problem but caused a handful of swift-lldb testsuite failures and a crash or two.
The problem is that synthetic value objects can sometimes represent objects in target memory, and other times they might be made up wholly in lldb memory, with pointers from one synthetic object to another, and so the ValueObjectVariable computation was not appropriate.

This patch delegates the computation to the root of the ValueObject in question. That solves the problem for ValueObjectVariable while not messing up the computation for ValueObjectConstResult or ValueObjectSynthetic.

Differential Revision: https://reviews.llvm.org/D83450
2020-07-10 11:11:59 -07:00
Pavel Labath d372a8e8bc [lldb/pecoff] Use a different llvm createBinary overload for parsing
Change the code the use the version which accepts a memory buffer,
instead of the one taking a file name.

This ensures we are not loading the file into memory twice
(ObjectFilePECOFF also loads a copy), reducing our memory footprint, as
well as enabling additional goodies in the future, like being able to
open files which don't exist on disk (D83512).
2020-07-10 11:57:11 +02:00
Muhammad Omair Javaid a65da5f592 [LLDB] Update AArch64 Dwarf and EH frame register numbers
This patch updates ARM64_ehframe_Registers.h and ARM64_DWARF_Registers.h
with latest register numbers in line with AArch64 SVE support.

For refernce take a look at "DWARF for the ARM® 64-bit Architecture (AArch64)
with SVE support" manual from Arm.
Version used: abi_sve_aadwarf_100985_0000_00_en.pdf
2020-07-10 11:45:39 +05:00
Jordan Rupprecht fbef6c55bc [lldb] Declare extern template instantiation to fix linking issues.
NativeProcessELF::GetELFImageInfoAddress<...>() is declared in NativeProcessELF.h, but only defined in NativeProcessELF.cpp. Via some optimized builds (e.g. thinlto), this instantiation may be removed when it is used in a different TU (NativeProcessELFTest.cpp).
2020-07-09 18:43:53 -07:00
Amy Huang 227db86a1b Switch to using -debug-info-kind=constructor as default (from =limited)
Summary:
-debug-info-kind=constructor reduces the amount of class debug info that
is emitted; this patch switches to using this as the default.

Constructor homing emits the complete type info for a class only when the
constructor is emitted, so it is expected that there will be some classes that
are not defined in the debug info anymore because they are never constructed,
and we shouldn't need debug info for these classes.

I compared the PDB files for clang, and there are 273 class types that are defined with `=limited`
but not with `=constructor` (out of ~60,000 total class types).
We've looked at a number of the types that are no longer defined with =constructor. The vast
majority of cases are something like class A is used as a parameter in a member function of
some other class B, which is emitted. But the function that uses class A is never called, and class A
is never constructed, and therefore isn't emitted in the debug info.

Bug: https://bugs.llvm.org/show_bug.cgi?id=46537

Subscribers: aprantl, cfe-commits, lldb-commits

Tags: #clang, #lldb

Differential Revision: https://reviews.llvm.org/D79147
2020-07-09 15:26:46 -07:00
Jonas Devlieghere 10aa9e19fa [LLDB/Reproducers] Add flag to avoid installing the signal handler.
There are bugs where you don't want the signal handler to trigger, most
notably when that will cause another crash. Examples of this are lldb
running out of memory or a bug in the reproducer generation code. This
adds an escape hatch trough a (developer oriented) flag to not install
the signal handler.

rdar://problem/65149595

Differential revision: https://reviews.llvm.org/D83496
2020-07-09 11:50:45 -07:00
Jonas Devlieghere 84557c18b3 [lldb/Reproducers] Rename developer-oriented reproducer flags.
This is a preparatory rename of the developer facing reproducer flags.

reproducer-skip-version-check -> reproducer-no-version-check
reproducer-auto-generate      -> reproducer-generate-on-quit
2020-07-09 11:50:45 -07:00
Vedant Kumar f8f259ce4a [lldb/Function] Reflow doxygen comments for member variables, NFC
As suggested in the review for https://reviews.llvm.org/D83359.
2020-07-09 10:37:09 -07:00
Vedant Kumar 6cfc90b9b7 [Function] Lock the function when parsing call site info
Summary:
DWARF-parsing methods in SymbolFileDWARF which update module state
typically take the module lock. ParseCallEdgesInFunction doesn't do
this, but higher-level locking within lldb::Function (which owns the
storage for parsed call edges) is necessary.

The lack of locking could explain some as-of-yet unreproducible crashes
which occur in Function::GetTailCallingEdges(). In these crashes, the
`m_call_edges` vector is non-empty but contains a nullptr, which
shouldn't be possible. (If this vector is non-empty, it _must_ contain a
non-null unique_ptr.)

This may address rdar://55622443 and rdar://65119458.

Reviewers: jasonmolenda, friss, jingham

Subscribers: aprantl, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83359
2020-07-09 10:37:09 -07:00
Fred Riss e529d774c4 [lldb] Use enum constant instead of raw value 2020-07-09 09:43:50 -07:00
Adrian Prantl 15149e4064 Fix debugserver reporting of deployment target
This patch fixes debugserver incorrectly returning the SDK version
instead of the minimum deployment target version.

rdar://problem/65001691

Differential Revision: https://reviews.llvm.org/D83443
2020-07-08 17:21:43 -07:00
Adrian Prantl 9726dc4d07 Updated the list of supported platforms in LLDB to include Apple silicon. 2020-07-08 15:33:00 -07:00
Adrian Prantl 3728133d3f Unify the ExecutionContextScope computation in Materializer.
This is an NFC cleanup for Clang, and a bugfix for the Swift
branch. In swift-lldb one target may have multiple scratch
TypeSystems, so it is important to pick the one that belongs to the
current frame, rather than the one for the current target.

<rdar://problem/65001402>
2020-07-08 15:18:21 -07:00
Davide Italiano 27d52cd86a Revert "[lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)"
This reverts commit 695b33a569 beacuse
it broke the macOS bot.
2020-07-08 13:09:24 -07:00
shafik 63b0f8c788 [RecordLayout] Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source
Currently the ItaniumRecordLayoutBuilder when laying out base classes has the virtual
and non-virtual bases mixed up when pulling the base class layouts from the external source.

This came up in an LLDB bug where on arm64 because of differences in how it deals with
tail padding would layout the bases differently without the correct layout from the
external source (LLDB). This would result in some fields being off by 4 bytes.

Differential Revision: https://reviews.llvm.org/D83008
2020-07-08 10:07:15 -07:00
Pavel Labath 7fd29699d6 [lldb] Modernize/clean up ValueObject::GetChildMemberWithName 2020-07-08 17:42:47 +02:00
Med Ismail Bennani 9c31da8538 [lldb/Core] Update comment to make it more explicit (NFC)
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-08 14:03:59 +02:00
Pavel Labath 88c82474d2 [lldb/Utility] Simplify Scalar float accessors
Make use of APFloat conversion methods to avoid needing to switch based
on the stored value type.
2020-07-08 13:57:32 +02:00
Pavel Labath 695b33a569 [lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)
Summary:
This function was documented to overwrite entries with D76111, which was
adding a couple of similar functions. However, this function (unlike the
functions added in that patch) was/is not actually overwriting variables
-- any pre-existing variables would get ignored.

This behavior does not seem to be intentional. In fact, before the refactor in
D41359, this function could introduce duplicate entries, which could
have very surprising effects both inside lldb and on other applications
(some applications would take the first value, some the second one; in
lldb, attempting to unset a variable could make the second variable
become active, etc.).

Overwriting seems to be the most reasonable behavior here, so change the
code to match documentation.

Reviewers: clayborg, wallace, jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83306
2020-07-08 13:35:31 +02:00
Raphael Isemann ebee165184 [lldb][NFC] Fix indentation in expect_expr 2020-07-08 12:33:31 +02:00
Raphael Isemann e9f943429c [lldb] Skip TestIOHandlerResizeNoEditline on Windows
It seems opening the empty file and trying use that file object as an input
stream doesn't work on Windows. Skipping it for now.
2020-07-08 11:45:38 +02:00
Muhammad Omair Javaid 1f780c997c [LLDB] Disable flaky lldb-vscode tests on arm
Summary:
These two tests are flaky on lldb Arm buildbot as well. They are already
being skipped for aarch64. I am going to mark them skipped for Arm.

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81978
2020-07-08 07:07:10 +05:00
Davide Italiano 4dba3f4e03 [dotest] Log a warning when --server and --out-of-tree-debugserver are set
Suggested by Vedant.
2020-07-07 15:03:08 -07:00
Davide Italiano 5832473dcf Do not set LLDB_DEBUGSERVER_PATH if --out-of-tree-debugserver is passed.
This gets rid of some surprising interplay between the flags.
Mainly needed because of Rosetta debugserver & Apple Silicon.

Differential Revision:  https://reviews.llvm.org/D82804
2020-07-07 15:01:21 -07:00
Med Ismail Bennani 0d7401cf9d
[lldb/api] Add checks for StackFrame::GetRegisterContext calls (NFC)
This patch fixes a crash that is happening because of a null pointer
dereference in SBFrame.

StackFrame::GetRegisterContext says explicitly that you might not get
a valid RegisterContext back but the pointer wasn't tested before,
resulting in crashes. This should solve the issue.

rdar://54462095

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-07 23:30:24 +02:00
Muhammad Omair Javaid 2bf6c50c7f Minor fixups to LLDB AArch64 register infos macros for SVE register infos
Summary:
This patch adds some cosmetic changes to LLDB AArch64 register infos macros in order to use them in SVE register infos struct in follow up patches.
This patch initially added invalidate lists to register infos struct but that is no longer needed and problem disappeared after updating qemu testing environment.

old headline comments for reference:
AArch64 reigster X and V registers are primary GPR and vector registers respectively. If these registers are modified their corresponding children w regs or s/d regs should be invalidated. Specially when a register write fails it is important that failure gets reflected to all the registers which draw their value from a particular value register.

Reviewers: labath, rengolin

Reviewed By: labath

Subscribers: tschuett, kristof.beyls, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D77045
2020-07-08 01:07:17 +05:00
Med Ismail Bennani 7177e63fb5 [lldb/Core] Fix crash in ValueObject::CreateChildAtIndex
The patch fixes a crash in ValueObject::CreateChildAtIndex caused by a
null pointer dereferencing. This is a corner case that is happening when
trying to dereference a variable with an incomplete type, and this same
variable doesn't have a synthetic value to get the child ValueObject.

If this happens, lldb will now return a null pointer that will results
in an error message.

rdar://65181171

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-07 20:37:13 +02:00
Jonas Devlieghere 5e9b16b67f [lldb] Fix unaligned load in DataExtractor
Somehow UBSan would only report the unaligned load in TestLinuxCore.py
when running the tests with reproducers. This patch fixes the issue by
using a memcpy in the GetDouble and the GetFloat method.

Differential revision: https://reviews.llvm.org/D83256
2020-07-07 10:13:41 -07:00
Muhammad Omair Javaid 7fa7b81bcb Combine multiple defs of arm64 register sets
Summary:
This patch aims to combine similar arm64 register set definitions defined in NativeRegisterContextLinux_arm64 and RegisterContextPOSIX_arm64.
I have implemented a register set interface out of RegisterInfoInterface class and moved arm64 register sets into RegisterInfosPOSIX_arm64 which is similar to Utility/RegisterContextLinux_* implemented by various other targets. This will help in managing register sets of new ARM64 architecture features in one place.

Built and tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabihf targets.

Reviewers: labath

Reviewed By: labath

Subscribers: mhorne, emaste, kristof.beyls, atanasyan, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D80105
2020-07-07 20:25:02 +05:00
Pavel Labath 52495b98ee [lldb/Utility] Fix float->integral conversions in Scalar APInt getters
These functions were doing a bitcast on the float value, which is not
consistent with the other getters, which were doing a numeric conversion
(47.0 -> 47). Change these to do numeric conversions too.
2020-07-07 16:59:06 +02:00
Pavel Labath 72ae70032c [lldb/test] Fix lldbutil.run_to_***_breakpoint for shared libraries
Even non-remote targets may need to set the launch environment
((DY)LD_LIBRARY_PATH, specifically) to run successfully.

Also, add an assertion to better detect the case when launching a target
fails and the breakpoint is never hit.
2020-07-07 16:07:35 +02:00
Raphael Isemann de0175d04b [lldb] Make TestIOHandlerResizeNoEditline pass with Python 2
io.BytesIO seems to produce a stream in Python 2 which isn't recognized
as a file object in the SWIG API, so this test fails for Python 2 (and I assume
also an old SWIG version needs to be involved).

Instead just open an empty input file which is a file object in all Python
versions to make this test pass everywhere.
2020-07-07 13:54:14 +02:00
Pavel Labath 2cdf108d32 [lldb/DWARF] Add a utility function for (forceful) completion of types
Summary:
Unify the code for requiring a complete type and move it into a single
place. The only functional change is that the "cannot start a definition
of an incomplete type" is upgrated from a runtime error/warning to an
lldbassert. An plain assert might also be fine, since (AFAICT) this can
only happen in case of a programmer error.

Reviewers: teemperor, aprantl, shafik

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83199
2020-07-07 11:37:55 +02:00
Adrian Prantl 60c07fd016 Use CMAKE_OSX_SYSROOT instead of the environment variable SYSROOT
to detect energy support in debugserver.  The way that Swift
build-script is invoked the former may be overridden manually.

<rdar://problem/63840635>
2020-07-06 13:17:31 -07:00
Raphael Isemann 5814255e1a [lldb] Always round down in NSDate's formatter to match NSDate's builtin format
Summary:

When printing an NSDate (for example with `NSLog` or `po`) the seconds value is
always rounded down. LLDB's own formatter however isn't following that behaviour
which leads to situations where the formatted result is sometimes one second
off. For example:

```
(lldb) p [NSDate dateWithTimeIntervalSince1970:0.1]
(__NSTaggedDate *) $1 = [...] 1970-01-01 00:00:01 UTC
(lldb) po [NSDate dateWithTimeIntervalSince1970:0.1]
1970-01-01 00:00:00 +0000

(lldb) p [NSDate dateWithTimeIntervalSince1970:0.6]
(__NSTaggedDate *) $4 =[...] 1970-01-01 00:00:01 UTC
(lldb) po [NSDate dateWithTimeIntervalSince1970:0.6]
1970-01-01 00:00:00 +0000
```

This patch just always rounds down the seconds value we get from the NSDate
object.

Fixes rdar://65084800

Reviewers: mib, davide

Reviewed By: mib

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D83221
2020-07-06 16:59:37 +02:00
Pavel Labath 5daa39aa4c [lldb/Utility] Merge Scalar::Get(Value)TypeAsCString 2020-07-06 10:34:12 +02:00
Pavel Labath b65d4b23f6 [lldb/DWARF] Look for complete array element definitions in other modules
This applies the same logic we have for incomplete class bases and
members to array element types.
2020-07-06 10:09:13 +02:00
Raphael Isemann 779432690f [lldb][NFC] Clarify that spaces can't be in breakpoint names
We already check for spaces but we don't mention it in the error message.
2020-07-05 10:55:02 +02:00
Raphael Isemann fc1d95eb7b [lldb][NFC] Remove an unnecessary cast in SBCommandInterpreter 2020-07-05 10:54:18 +02:00
Pavel Labath b3b952873f [lldb/DWARF] Look for complete member definitions in other modules
With -flimit-debug-info, we can have a definition of a class, but no
definition for some of its members. This extends the same logic we were
using for incomplete base classes to cover incomplete members too.

Test forward-declarations.s is removed as it is no longer applicable --
we don't warn anymore when encountering incomplete members as they could
be completed elsewhere. New checks added to TestLimitDebugInfo cover the
handling of incomplete members more thoroughly.
2020-07-03 16:50:49 +02:00
Pavel Labath 228ea81583 [lldb/Utility] Simplify more Scalar methods
A lot of the methods handle all integral and all floating point types
the same way. They can be changed to switch on the category of the type,
instead of the actual type, saving a lot of boilerplate.

This patch does that for the methods where I could be reasonably certain
of their expected semantics.
2020-07-03 16:35:14 +02:00
Bruno Ricci 473fbc90d1
[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumper
In general there is no way to get to the ASTContext from most AST nodes
(Decls are one of the exception). This will be a problem when implementing
the rest of APValue::dump since we need the ASTContext to dump some kinds of
APValues.

The ASTContext* in ASTDumper and TextNodeDumper is not always non-null.
This is because we still want to be able to use the various dump() functions
in a debugger.

No functional changes intended.

Reverted in fcf4d5e449 since a few dump()
functions in lldb where missed.
2020-07-03 13:59:22 +01:00
Martin Svensson 3faec83376 [lldb] Fix missing characters when autocompleting LLDB commands in REPL
Summary:

When tabbing to complete LLDB commands in REPL, characters would at best be
missing but at worst cause the REPL to crash due to out of range string access.
This patch appends the command character to the completion results to fulfill
the assumption that all matches are prefixed by the request's cursor argument
prefix.

Bug report for the Swift REPL
https://bugs.swift.org/browse/SR-12867

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D82835
2020-07-03 12:10:00 +02:00
Pavel Labath b725142c8d [lldb] Fix type conversion in the Scalar getters
Summary:
The Scalar class claims to follow the C type conversion rules. This is
true for the Promote function, but it is not true for the implicit
conversions done in the getter methods.

These functions had a subtle bug: when extending the type, they used the
signedness of the *target* type in order to determine whether to do
sign-extension or zero-extension. This is not how things work in C,
which uses the signedness of the *source* type. I.e., C does
(sign-)extension before it does signed->unsigned conversion, and not the
other way around.

This means that: (unsigned long)(int)-1
      is equal to (unsigned long)0xffffffffffffffff
      and not (unsigned long)0x00000000ffffffff

Unsurprisingly, we have accumulated code which depended on this
inconsistent behavior. It mainly manifested itself as code calling
"ULongLong/SLongLong" as a way to get the value of the Scalar object in
a primitive type that is "large enough". Previously, the ULongLong
conversion did not do sign-extension, but now it does.

This patch makes the Scalar getters consistent with the declared
semantics, and fixes the couple of call sites that were using it
incorrectly.

Reviewers: teemperor, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D82772
2020-07-02 18:02:57 +02:00
Pavel Labath c1f1db8502 [lldb] Add a host-independent test for handling -flimit-debug-info
This complements the existing TestLimitDebugInfo.py, which tests this
scenario more comprehensively, but is not able to run on all hosts.
Specifically, it's hard to trigger this code from windows because clang
tries hard to ensure that debug info for types marked with
__declspec(dllexport) is emitted even under -flimit-debug-info (and
dllexport is needed to use a type across shared libraries).

This assembly-based test serves two purposes:
- it tests that -flimit-debug-info code path works for windows binaries
  (even though the aforementioned feature means its less likely to be
  used there)
- it gives basic test coverage for the -flimit-debug-info handling code
  when running the test suite on windows hosts.
2020-07-02 15:51:20 +02:00
Pavel Labath d6343e607a [lldb] Skip TestLimitDebugInfo on windows
The test does not work on windows, because clang will emit full type
information for __declspec(dllexport) types even under
-flimit-debug-info. __declspec(dllexport) is needed to be able to use
the type across shared library boundaries on windows, which makes this a
pretty good heuristic, but defeats the purpose of this test.

I am going to create (in another patch) an basic assembly test, so that
the relevant code gets at least some coverage on windows hosts.

This also reverts commit 1276855f2b, which
added the __declspec annotations -- they are not necessary anymore, and
they needlessly complicate the test.
2020-07-02 14:34:33 +02:00
Raphael Isemann 83aa58d795 [lldb][NFC] Don't pass around passthrough from ClangDiagnosticManagerAdapter
The passthrough DiagnosticConsumer is an implementation detail of
ClangDiagnosticManagerAdapter and we can just hide it behind the normal
DiagnosticConsumer interface that ClangDiagnosticManagerAdapter is supposed
to implement.
2020-07-02 10:42:14 +02:00
Raphael Isemann 11b1eeeaec [lldb][NFC] Fix a variable name in ClangDiagnosticManagerAdapter 2020-07-02 09:10:07 +02:00
Fred Riss c9f251aa6f [lldb/build.py] Always pass an SDK to the compiler on Darwin
On macOS 11, system libraries which are part of the shared cache
are not present on the filesystem anymore. This causes issues
with build.py, because it fails to link binaries with libSystem
or libc++.

The real issue is that build.py was not passing an SDK to the
compiler. The script accepts an argument for the SDK, but it
is currently unused. This patch just threads the SDK through
to the compile and link steps and this fixes a bunch of Shell
test failures on very recent macOS builds.
2020-07-01 20:27:38 -07:00
Fred Riss 4a674b6237 [lldb/ObjC] Add support for direct selector references
On macOS 11 (and other aligned OSs), the shared cache method
lists get an additional optimization which removes one level
of indirection to get to the selector.
This patch supports this new optimization. Both codepaths are
covered byt the existing Objective-C tests.
2020-07-01 20:27:37 -07:00
Fred Riss 61d22ef236 [lldb/ObjCRuntime] Implement support for small method lists
On macOS 11 (and other aligned Apple OSs), the Objective-C runtime
has a new optimization which saves memory by making the method
lists smaller.
This patch adds support for this new method list encoding (while
also keeping backward compatibility). This is implicitely covered
by some existing Objective-C tests.
2020-07-01 20:27:37 -07:00
Jonas Devlieghere d9d992bb88 [lldb/API] Add missing LLDB_RECORD_RESULT 2020-07-01 14:41:11 -07:00
Adrian Prantl 278874f07f debugserver: Return a nullptr in GetPlatformString()
This un-breaks the testsuite after https://reviews.llvm.org/D82616
2020-07-01 11:06:25 -07:00
Adrian Prantl 116b103373 Revert "Revert "Improve the detection of iOS/tvOS/watchOS simulator binaries in""
This reverts commit 98c3a38a19.
2020-07-01 11:06:15 -07:00
Jonas Devlieghere 98c3a38a19 Revert "Improve the detection of iOS/tvOS/watchOS simulator binaries in"
This reverts commit 0da0437b2a to unbreak
the following tests:

lldb-api.tools/lldb-server.TestAppleSimulatorOSType.py
lldb-api.tools/lldb-server.TestGdbRemoteAttach.py
lldb-api.tools/lldb-server.TestGdbRemoteProcessInfo.py
lldb-api.tools/lldb-server.TestGdbRemoteRegisterState.py
lldb-api.tools/lldb-server.TestGdbRemoteThreadsInStopReply.py
lldb-api.tools/lldb-server.TestLldbGdbServer.py
2020-07-01 10:46:19 -07:00
Raphael Isemann 9010cef2af [lldb] Replace StringConvert with llvm::to_integer when parsing integer values in CommandObjects
Summary:

This replaces the current use of LLDB's own `StringConvert` with LLVM's
`to_integer` which has a less error-prone API and doesn't use special 'error
values' to designate parsing problems.

Where needed I also added missing error handling code that prints a parsing
error instead of continuing with the error value returned from `StringConvert`
(which either gave a cryptic error message or just took the error value
performed an incorrect action with it. For example, `frame recognizer delete -1`
just deleted the frame recognizer at index 0).

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: labath, abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D82297
2020-07-01 17:19:31 +02:00
Pavel Labath 1276855f2b [lldb] Attempt to fix TestLimitDebugInfo on windows
The test fails due to link errors. I believe this change should fix
that.
2020-07-01 16:56:56 +02:00
Raphael Isemann f3b5bf3eb7 [lldb] Fix NSDate test after Scalar change
The formatter was requesting an unsigned integer from the ValueObject,
but CFAbsoluteTime is a signed double, so in the NSDate test the formatter
actually just printed the 'error value' date which is the Cocoa epoch. This
started failing after the recent Scalar changes.

This patch just changes the logic to use a signed value which fits to the data
we try to read and avoids this issue.
2020-07-01 16:00:10 +02:00
Pavel Labath a03dc8c9fa [lldb] Add basic -flimit-debug-info support to expression evaluator
Summary:
This patch adds support for evaluation of expressions referring to types
which were compiled in -flimit-debug-info (a.k.a -fno-standalone-debug)
in clang. In this mode it's possible that the debug information needed
to fully describe a c++ type is not present in a single shared library
-- for example debug info for a base class or a member of a type can
only be found in another shared library.  This situation is not
currently handled well within lldb as we are limited to searching within
a single shared library (lldb_private::Module) when searching for the
definition of these types.

The way that this patch gets around this limitation is by doing the
search at a later stage -- during the construction of the expression ast
context. This works by having the parser (currently SymbolFileDWARF, but
a similar approach is probably needed for PDBs too) mark a type as
"forcefully completed". What this means is that the parser has marked
the type as "complete" in the module ast context (as this is necessary
to e.g. derive classes from it), but its definition is not really there.
This is done via a new field on the ClangASTMetadata struct.

Later, when we are importing such a type into the expression ast, we
check this flag. If the flag is set, we try to find a better definition
for the type in other shared libraries. We do this by initiating a
new lookup for the "forcefully completed" classes, which then imports the
type from a module with a full definition.

This patch only implements this handling for base classes, but other
cases (members, array element types, etc.). The changes for that should
be fairly simple and mostly revolve around marking these types as
"forcefully completed" at an approriate time -- the importing logic is
generic already.

Another aspect, which is also not handled by this patch is viewing these
types via the "frame variable" command. This does not use the AST
importer and so it will need to handle these types on its own -- that
will be the subject of another patch.

Differential Revision: https://reviews.llvm.org/D81561
2020-07-01 14:50:14 +02:00
Med Ismail Bennani f70cad2612
[lldb/api] Improve error reporting in SBBreakpoint::AddName (NFCI)
This patch improves the error reporting for SBBreakpoint::AddName by
adding a new method `SBBreakpoint::AddNameWithErrorHandling` that returns
a SBError instead of a boolean.

This way, if the breakpoint naming failed in the backend, the client
(i.e. Xcode), will be able to report the reason of that failure to the
user.

rdar://64765461

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-01 12:45:05 +02:00
Med Ismail Bennani a61f62a7b6 Revert "[lldb/api] Improve error reporting in SBBreakpoint::AddName (NFCI)"
This reverts commit 56bb1d1755.
2020-07-01 12:41:32 +02:00
Med Ismail Bennani 56bb1d1755 [lldb/api] Improve error reporting in SBBreakpoint::AddName (NFCI)
This patch improves the error reporting for SBBreakpoint::AddName by
adding a new method `SBBreakpoint::AddNameWithErrorHandling` that returns
a SBError instead of a boolean.

This way, if the breakpoint naming failed in the backend, the client
(i.e. Xcode), will be able to report the reason of that failure to the
user.

rdar://64765461

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-07-01 12:37:00 +02:00
Pavel Labath 8270a903ba [lldb] Scalar re-fix UB in float->int conversions
The refactor in 48ca15592f reintroduced UB when converting out-of-bounds
floating point numbers to integers -- the behavior for ULongLong() was
originally fixed in r341685, but did not survive my refactor because I
based my template code on one of the methods which did not have this
fix.

This time, I apply the fix to all float->int conversions, instead of
just the "double->unsigned long long" case. I also use a slightly
simpler version of the code, with fewer round-trips
(APFloat->APSInt->native_int vs
APFloat->native_float->APInt->native_int).

I also add some unit tests for the conversions.
2020-07-01 10:29:42 +02:00
Adam Balogh ff2d09148c [LLDB][Clang Integration][NFC] Remove redundant condition
Condition `omit_empty_base_classes` is checked both in an outer and
in an inner `if` statement in `TypeSystemClang::GetNumBaseClasses()`.
This patch removes the redundant inner check.

The issue was found using `clang-tidy` check under review
`misc-redundant-condition`. See https://reviews.llvm.org/D81272.

Differential Revision: https://reviews.llvm.org/D82559
2020-07-01 09:04:26 +02:00
Adam Balogh 1b2d2d70e1 [LLDB][NFC] Remove redundant condition
Condition `auto_advance_pc` is checked both in an outer and in an
inner `if` statement in `EmulateInstructionARM::EvaluateInstruction()`,
`EmulateInstructionARM64::EvaluateInstruction()` and
`EmulateInstructionPPC64::EvaluateInstruction()`. This patch removes the
redundant inner check.

The issue was found using `clang-tidy` check under review
`misc-redundant-condition`. See https://reviews.llvm.org/D81272.

Differential Revision: https://reviews.llvm.org/D82558
2020-07-01 09:04:26 +02:00
Davide Italiano 983a4b520e Skip arm-(fp|gp)-read.test on Darwin.
Our assembler doesn't seem to grok floating point literals.

<rdar://problem/64951608>
2020-06-30 12:53:20 -07:00
Davide Italiano 4f1f253ce5 [TestReturnValue] Skip based on architecutre, not platform. 2020-06-30 12:48:23 -07:00
Jonas Devlieghere 2501e86acd [lldb/Scalar] Fix undefined behavior
Fix UBSan error detected in TestDataFormatterObjCCF.py and
TestDataFormatterObjCNSDate.py:

Scalar.cpp:698:27: runtime error: -4.96303e+08 is outside the range of
representable values of type 'unsigned long long'.
2020-06-30 12:41:41 -07:00
Jonas Devlieghere 66d9c0d4fc [lldb/Test] Skip TestIOHandlerResizeNoEditline with reproducers 2020-06-30 11:40:17 -07:00
Adrian Prantl 0da0437b2a Improve the detection of iOS/tvOS/watchOS simulator binaries in
debugserver and lldb

This patch improves the heuristics for correctly identifying simulator binaries on Darwin and adds support for simulators running on Apple Silicon.

rdar://problem/64046344

Differential Revision: https://reviews.llvm.org/D82616
2020-06-30 11:22:03 -07:00
Jonas Devlieghere 69b2d9f42f [lldb/Test] Skip recognizer tests when Python is disabled
The `frame recognizer` command only exists when Python scripting is
enabled. Therefore the test should be made conditional on Python.
Without it, the test fails with "'frame recognizer' is not a known
command."
2020-06-30 08:59:44 -07:00
Pavel Labath e55a09793d [lldb/Scripts]
Fix analyze-project-deps.py. "lldb/Plugins" (home of Plugins.def) does
not depend on anything. Make sure this does not crash the script.
2020-06-30 17:06:14 +02:00
Pavel Labath 35674976f0 [lldb/Test] Introduce "assertSuccess"
Summary:
A lot of our tests do 'self.assertTrue(error.Success()'. The problem
with that is that when this fails, it produces a completely useless
error message (False is not True) and the most important piece of
information -- the actual error message -- is completely hidden.

Sometimes we mitigate that by including the error message in the "msg"
argument, but this has two additional problems:
- as the msg argument is evaluated unconditionally, one needs to be
  careful to not trigger an exception when the operation was actually
  successful.
- it requires more typing, which means we often don't do it

assertSuccess solves these problems by taking the entire SBError object
as an argument. If the operation was unsuccessful, it can format a
reasonable error message itself. The function still accepts a "msg"
argument, which can include any additional context, but this context now
does not need to include the error message.

To demonstrate usage, I replace a number of existing assertTrue
assertions with the new function. As this process is not easily
automatable, I have just manually updated a representative sample. In
some cases, I did not update the code to use assertSuccess, but I went
for even higher-level assertion apis (runCmd, expect_expr), as these are
even shorter, and can produce even better failure messages.

Reviewers: teemperor, JDevlieghere

Subscribers: arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D82759
2020-06-30 15:41:03 +02:00
Raphael Isemann bc163f6324 [lldb] Fix TestModuleGetXcodeSDK test after DWARFYAML change
D82622 / fe08ab542b changes the YAML format
so this test was failing as the test yaml wasn't updated.
2020-06-30 14:05:20 +02:00
Gongyu Deng c37d25f0d1 [lldb] Tab completion for `frame recognizer delete`
Summary: Provided tab completion for command `frame recognizer delete`.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor, JDevlieghere

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81241
2020-06-30 13:50:14 +02:00
Gongyu Deng 80eb42281f [lldb] Tab completion for `frame select`
Summary: Provided the tab completion for command `frame select`.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81177
2020-06-30 13:13:38 +02:00
Raphael Isemann 502773d743 [lldb][NFC] Remove ImportInProgress lock in ClangASTSource
Summary:

The ClangASTSource has a lock that globally disables all lookups into the
external AST source when we explicitly "guarded" copy a type. It's not used for
anything else, so importing declarations or importing types that are
dependencies of a declaration actually won't activate that lock. The lookups it
is supposed to prevent also don't actually happen in our test suite. The check
in `ClangExpressionDeclMap::FindExternalVisibleDecls` is never executed and the
check in the `ClangASTSource::FindExternalVisibleDeclsByName` is only ever
reached by the `Import-std-module` tests (which explicitly do a lookup into the
expression context on purpose).

This lock was added in 6abfabff61 as a replacement
for a list of types we already looked up which appeared to be an optimisation
strategy. I assume back then this lock had a purpose but these days the
ASTImporter and LLDB seem to be smart enough to avoid whatever lookups this
tried to prevent.

I would say we remove it from LLDB. The main reason is that it blocks D81561
(which explicitly does a specific lookup to resolve placeholder types produced
by `-flimit-debug-info`) but it's semantics are also very confusing. The naming
implies it's a flag to indicate when we import something at the moment which is
practically never true as described above. Also the fact that it makes our
ExternalASTSource alternate between doing lookups into the debug info and
pretending it doesn't know any external decls could really break our lookup in
some weird way if Clang decides to cache a fake empty lookup result that was
generated while the lock was active.

Reviewers: labath, shafik, JDevlieghere, aprantl

Reviewed By: labath, JDevlieghere, aprantl

Subscribers: aprantl, abidh

Differential Revision: https://reviews.llvm.org/D81749
2020-06-30 12:46:28 +02:00
Raphael Isemann 621f845679 [lldb] Modernize TestOperatorOverload.py asserts 2020-06-30 11:38:42 +02:00
Xing GUO fe08ab542b [DWARFYAML][debug_info] Replace 'InitialLength' with 'Format' and 'Length'.
'InitialLength' is replaced with 'Format' (DWARF32 by default) and 'Length' in this patch.
Besides, test cases for DWARFv4 and DWARFv5, DWARF32 and DWARF64 is
added.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D82622
2020-06-30 16:28:39 +08:00
Jason Molenda c48ccb6b4e Simplify conditionals in DNBArchMachARM64::EnableHardwareSingleStep 2020-06-29 14:04:44 -07:00
Davide Italiano 300bbbcb70 [ProcessGDBRemote] Get rid of an unused function.
The define was wrong. I could've fixed it, but given this is
unused I decided to drop the function altogether.
2020-06-29 12:39:09 -07:00
Muhammad Omair Javaid 3936b753ba [LLDB] skip TestCreateDuringInstructionStep on aarch64/linux
TestCreateDuringInstructionStep have started failing again on
aarch64/linux after moving to new machine. I am going mark it skipped
for aarch64/linux.
2020-06-29 21:32:48 +05:00
Jonas Devlieghere 6292702d12 [lldb/Test] Skip TestVSCode_disconnect on Darwin
It's failing on the sanitized bot on GreenDragon.
2020-06-29 07:48:09 -07:00
Pavel Labath 48ca15592f [lldb] Deduplicate Scalar integral getters
These functions all follow the same pattern. Use template functions to
deduplicate.
2020-06-29 15:24:39 +02:00
Jonas Devlieghere b4180fe477 [lldb/Test] Disable eh-frame-augment-noop.test on macOS
The test fails on Darwin because a different Asynchronous UnwindPlan is
chosen:

  Asynchronous (not restricted to call-sites) UnwindPlan is 'assembly
  insn profiling'`

instead of what the test expects:

  Asynchronous (not restricted to call-sites) UnwindPlan is 'eh_frame
  CFI'
2020-06-26 15:59:59 -07:00
Raphael Isemann bb91520e4f [lldb] Re-add X-Fail for Windows to TestDollarInVariable
This got removed by accident in 048d11de43 when
the test was rewritten as a non-inline test.
2020-06-26 15:24:15 +02:00
Simon Pilgrim 754f3c4af4 Fix implicit Twine.h include dependency. 2020-06-26 13:24:32 +01:00
Raphael Isemann 048d11de43 [lldb][NFC] Make TestDollarInVariable a non-inline test 2020-06-26 12:56:22 +02:00
Pavel Labath 5ed8765e2f [lldb/Unwind] Use eh_frame plan directly when it doesn't need to be augmented
Summary:
This fixes a bug in the logic for choosing the unwind plan. Based on the
comment in UnwindAssembly-x86, the intention was that a plan which
describes the function epilogue correctly does not need to be augmented
(and it should be used directly). However, the way this was implemented
(by returning false) meant that the higher level code
(FuncUnwinders::GetEHFrameAugmentedUnwindPlan) interpreted this as a
failure to produce _any_ plan and proceeded with other fallback options.
The fallback usually chosed for "asynchronous" plans was the
"instruction emulation" plan, which tended to fall over on certain
functions with multiple epilogues (that's a separate bug).

This patch simply changes the function to return true, which signals the
caller that the unmodified plan is ready to be used.

The attached test case demonstrates the case where we would previously
fall back to the instruction emulation plan, and unwind incorrectly --
the test asserts that the "augmented" eh_frame plan is used, and that
the unwind is correct.

Reviewers: jasonmolenda, jankratochvil

Subscribers: davide, echristo, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D82378
2020-06-26 11:46:47 +02:00
Pavel Labath ce275d3030 [lldb] Rewrite Scalar::Promote
This function was implementing c-like promotion rules by switching on
the both types. C promotion rules are complicated, but they are not
*that* complicated -- they basically boil down to:
- wider types trump narrower ones
- unsigned trump signed
- floating point trumps integral

With a couple of helper functions, we can rewrite the function in terms
of these rules and greatly reduce the size and complexity of this
function.
2020-06-26 11:46:47 +02:00
Jonas Devlieghere f441313464 [lldb/ScriptInterpreter] Fix Windows error C2371: 'pid_t': redefinition
pyconfig.h(194): error C2371: 'pid_t': redefinition; different basic types
PosixApi.h(82): note: see declaration of 'pid_t'
2020-06-25 17:15:29 -07:00
Davide Italiano c7eb06a880 [test] XFail TestStepNoDebug based on arch rather than OS 2020-06-25 16:23:59 -07:00
Davide Italiano 38135b2a7f [test] XFail TestSigtrampUnwind based on arch rather than OS 2020-06-25 16:22:52 -07:00
Davide Italiano 0df7be2344 [lldb/test] XFAIL TestHWBreakMultiThread on arch rather platform. 2020-06-25 16:21:23 -07:00
Davide Italiano d358ec4639 [lldb/test] Skip TestBreakpointThumbCodesection on arm64.
This test relies on thumb, which is a 32-bits feature only.
2020-06-25 16:20:27 -07:00
Jonas Devlieghere 11f2ef4d9e [lldb/ScriptInterpreter] Fix missing include on Windows 2020-06-25 12:19:04 -07:00
Jonas Devlieghere 2bdd41b8c0 [lldb/Docs] Add more details to the issues with custom Python installs on macOS
Although this issue is not specific to macOS, Python (in)compatibility
comes up quite often and we've been linking users to this page. This
just adds more details for this particular scenario.

Differential revision: https://reviews.llvm.org/D82507
2020-06-25 10:53:30 -07:00
Raphael Isemann 4df7d852af [lldb][NFC] Use expect_expr in TestDollarInVariable 2020-06-25 19:07:55 +02:00
Jonas Devlieghere ed8184b781 [lldb/Lua] Redirect Lua stdout/stderr to the CommandReturnObject
Redirect the output of stdout and stderr to the CommandReturnObject for
one line commands.

Differential revision: https://reviews.llvm.org/D82412
2020-06-25 09:55:46 -07:00
Jonas Devlieghere 842283652e [lldb/ScriptInterpreter] Let the IORedirect factory handle IO being disabled.
Have one factory method that decides how to initialize the
ScriptInterpreterIORedirect object based on whether IO is enabled or
disabled.
2020-06-25 09:55:46 -07:00
Jonas Devlieghere d79273c941 [lldb/ScriptInterpreter] Extract IO redirection logic
This patch takes the IO redirection logic from ScriptInterpreterPython
and moves it into the interpreter library so that it can be used by
other script interpreters. I've turned it into a RAII object so that we
don't have to worry about cleaning up in the calling code.

Differential revision: https://reviews.llvm.org/D82396
2020-06-25 09:43:28 -07:00
Pavel Labath d0fa52cc37 [lldb] Rewrite Scalar::GetBytes
This function was modifying and returning pointers to static storage,
which meant that any two accesses to different Scalar objects could
potentially race (depending on which types the objects were storing and
the host endianness).

In the new version the user is responsible for providing a buffer into
which this method will store its binary representation. The main caller
(RegisterValue::GetBytes) already has one such buffer handy, so this did
not require any major rewrites.

To make that work, I've needed to mark the RegisterValue value buffer
mutable -- not an ideal solution, but definitely better than modifying
global storage. This could be further improved by changing
RegisterValue::GetBytes to take a buffer too.
2020-06-25 15:31:48 +02:00
Aleksandr Urakov 895529cfd8 [lldb][PDB] Constexpr static member values as AST literals
Summary:
When evaluating an expression referencing a constexpr static member variable, an
error is issued because the PDB does not specify a symbol with an address that
can be relocated against.

Rather than attempt to resolve the variable's value within the IR execution, the
values of all constants can be looked up and incorporated into the AST of the
record type as a literal, mirroring the original compiler AST.

This change applies to DIA and native PDB loaders.

Patch By: jackoalan

Reviewers: aleksandr.urakov, jasonmolenda, zturner, jdoerfert, teemperor

Reviewed By: aleksandr.urakov

Subscribers: sstefan1, lldb-commits, llvm-commits, #lldb

Tags: #lldb, #llvm

Differential Revision: https://reviews.llvm.org/D82160
2020-06-25 11:27:16 +03:00
Jonas Devlieghere 06412dae82 [lldb] Use std::make_unique<> (NFC)
Update the rest of lldb to use std::make_unique<>. I used clang-tidy to
automate this, which probably missed cases that are wrapped in ifdefs.
2020-06-24 17:48:40 -07:00
Davide Italiano 47ac45332e [HostInfoMacOS] Parse correctly the triple for Apple Silicon.
Again, debugging doesn't work on the new platform without this, so
it's implicitly covered by the testsuite.
2020-06-24 16:37:21 -07:00
Davide Italiano 2010444e5e [Apple Silicon] Handle macOS in PlatformDarwin
This makes "target create /bin/ls" properly detect which platform
is needed when running lldb. Covered by many tests in the suite.
2020-06-24 16:35:36 -07:00
Jonas Devlieghere 1c0bbe4341 [lldb/API] Use std::make_unique<> (NFC)
I was holding off on this change until we moved to C++14 as to not have
to convert llvm::make_unique to std::make_unique. That happened a while
ago so here's the first patch for the API which had a bunch of raw
`new`s.
2020-06-24 16:29:30 -07:00
Martin Storsjö 0cd9e59829 [ProcessGDBRemote] Fix a typo in an ifdef from 58de2a3851 2020-06-24 23:49:33 +03:00
Davide Italiano 58de2a3851 [ProcessGDBRemote] Placate the Windows buildbot.
I'm probably going to rewrite this function anyway, but, in
the meanwhile.
2020-06-24 13:23:49 -07:00
Raphael Isemann cad79f73b6 [lldb][NFC] Use expect_expr in TestStructTypes.py 2020-06-24 22:12:17 +02:00
Davide Italiano b4fdddf971 [Apple Silicon] Debugging of process under Rosetta is supported.
Remove this early exit. It's vestigial from the ppc -> Intel transition,
but it doesn't apply anymore.
2020-06-24 12:25:01 -07:00
Davide Italiano fd19ddb8f2 [Apple Silicon] Initial support for Rosetta
Translated processes talk with a different debugserver, shipped with
macOS 11. This patch detects whether a process is translated and
attaches to the correct debugserver implementation.
It's the first patch of a series. Tested on the lldb test suite.

Differential Revision:  https://reviews.llvm.org/D82491
2020-06-24 12:19:21 -07:00
Walter Erquinigo d4ef569577 Disable a flaky lldb-vscode test on aarch64
Summary:
These tests isflaky only on this arch for some reason. It's testing important features and is not flaky on x86_64, so I'll investigate this arm issue separatedly.

A flaky run:
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5540/steps/test/logs/stdio

Diff that created those tests:
https://reviews.llvm.org/D81978
2020-06-24 11:09:21 -07:00
Walter Erquinigo 8e08422385 Disable flaky lldb-vscode tests on aarch64
Summary:
These two tests are flaky only on this arch for some reason. They are testing important features and are not flaky on x86_64, so I'll investigate this arm issue separatedly.

Some flaky runs:
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5517/steps/test/logs/stdio
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5527/steps/test/logs/stdio

Diff that created those tests:
https://reviews.llvm.org/D81978
2020-06-24 08:57:20 -07:00
Pavel Labath 16e17ca16a [lldb] Refactor Scalar::TruncOrExtendTo
The "type" argument to the function is mostly useless -- the only
interesting aspect of it is signedness. Pass signedness directly and
compute the value of bits and signedness fields -- that's exactly
what the single caller of this function does.
2020-06-24 15:58:33 +02:00
Konrad Kleine 4bfa43809f [lldb] fix typo in docs: withing -> within 2020-06-24 05:19:47 -04:00
Jonas Devlieghere 6507bc5621 [lldb/Test] Temporarily disable TestSimulatorPlatform.py 2020-06-23 22:41:01 -07:00
Jonas Devlieghere be494adb30 [lldb/Lua] Fix typo: s/stdout/stderr/
This wasn't caught by the existing test, but will be covered by the
extended test that's part of D82412.
2020-06-23 14:19:03 -07:00
Walter Erquinigo 74ab1da028 Redo of Add terminateCommands to lldb-vscode protocol
Summary:
This redoes https://reviews.llvm.org/D79726 and fixes two things.
- The logic that determines whether to automatically disconnect during the tear down is not very dumb compared to the original implementation. Each test will determine whether to do that or not.
- The terminate commands and terminate event were being sent after the disconnect response was sent to the IDE. That was not good, as VSCode stops the debug session as soon as it receives a disconnect response. Now, the terminate event and terminateEvents are being executed before the disconnect response is sent. This ensures that any connection between the IDE and lldb-vscode is alive while the terminate commands are executed. Besides, it also allows displaying the output of the terminate commands on the debug console, as it's still alive.

Reviewers: clayborg, aadsm, kusmour, labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81978
2020-06-23 12:51:43 -07:00
Davide Italiano 33ece57241 Generalize TestFormattersBoolRefPtr to work on Apple Silicon. 2020-06-23 12:45:31 -07:00
Davide Italiano 63d597093c [ObjectFileMachO] Check for TARGET_EMBEDDED instead of listing architectures.
Now that Apple Silicon is a thing, we need to generalize the check.
2020-06-23 12:37:45 -07:00
Davide Italiano 3c79212319 [Host] Check for TARGET_OS_EMBEDDED instead of listing architectures.
With the advent of Apple Silicon, checking for the architectures
specifically is not correct anymore. This code is only supposed to
run on embedded devices (iPhones et similia), so mark it accordingly.
2020-06-23 12:27:21 -07:00
Walter Erquinigo 0a9e7d0b6b [vscode] set default values for terminateDebuggee for the disconnect request
Summary:
Recently I've noticed that VSCode sometimes doesn't send the terminateDebuggee flag within the disconnectRequest,
even though lldb-vscode sets the terminateDebuggee capability correctly.
This has been causing that inferiors don't die after the debug session ends, and many users have reported issues because of this.

An easy way to mitigate this is to set better default values for the terminateDebuggee field in the disconnect request.
I'm assuming that for a launch request, the default will be true, and for attach it'll be false.

Reviewers: clayborg, labath, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81200
2020-06-23 11:47:43 -07:00
Raphael Isemann d13c3e2f88 [lldb][NFC] Add some more tests for edge cases LLDB's builtin formatters
OSType with less than 8 bytes has special code that isn't tested yet.
The same for C-strings that don't have `const char *` type. Also we're now testing
escaping the ASCII escape sequence (\033).
2020-06-23 19:59:46 +02:00
Davide Italiano 2276bb48be [debugserver] Initial support for Apple Silicon.
Set the correct os type in the arch triple when running macOS.
Debugserver currently always assumes macOS == x86_64. This patch
generalizes the support to make sure it works on a different
architecture.

Differential Revision:  https://reviews.llvm.org/D82394
2020-06-23 10:47:16 -07:00
Jonas Devlieghere 6e670e0796 [lldb/Lua] Require Lua 5.3 2020-06-23 09:24:01 -07:00
Jonas Devlieghere fa1b4a96a0 [lldb/Lua] Use the debugger's output and error file for Lua's I/O library.
Add support for changing the stdout and stderr file in Lua's I/O library
and hook it up with the debugger's output and error file respectively
for the interactive Lua interpreter.

https://reviews.llvm.org/D82273
2020-06-23 09:05:51 -07:00
Sander de Smalen 121e585ec8 [AArch64][SVE] ACLE: Add bfloat16 to struct load/stores.
This patch contains:
- Support in LLVM CodeGen for bfloat16 types for ld2/3/4 and st2/3/4.
- New bfloat16 ACLE builtins for svld(2|3|4)[_vnum] and svst(2|3|4)[_vnum]

Reviewers: stuij, efriedma, c-rhodes, fpetrogalli

Reviewed By: fpetrogalli

Tags: #clang, #lldb, #llvm

Differential Revision: https://reviews.llvm.org/D82187
2020-06-23 12:12:35 +01:00
Pavel Labath 5a4d78064e [lldb] Split ClangASTSource::CompleteType
Move the part of the code which is responsible for finding a complete
definition of the type into a separate function (FindCompleteType). This
is split off from D81561, as it's a generally useful cleanup.

No functional change.
2020-06-23 11:47:52 +02:00
Jonas Devlieghere 1728dec255 [lldb/Lua] Recognize "quit" as a way to exit the script interpreter.
Add a way to quit the interactive script interpreter from a shell tests.
Currently, the only way (that I know) to exit the interactive Lua
interpreter is to send a EOF with CTRL-D. I noticed that the embedded
Python script interpreter accepts quit (while the regular python
interpreter doesn't). I've added a special case to the Lua interpreter
to do the same.

Differential revision: https://reviews.llvm.org/D82272
2020-06-22 09:27:12 -07:00
Raphael Isemann 79608371f1 [lldb][NFC] Add more test for builtin formats
Reland 90c1af106a . This changes the char format
tests which were printing the pointer value of the C-string instead of its
contents, so this test failed on other machines. Now they just print the
bytes in a uint128_t.

Original commit description:

The previous tests apparently missed a few code branches in DumpDataExtractor
code. Also renames the 'test_instruction' which had the same name as another
test (and Python therefore ignored the test entirely).
2020-06-22 15:13:41 +02:00
Jonas Devlieghere 6e3faaeb44 [lldb/Lua] Remove redundant variable (NFC) 2020-06-20 23:28:22 -07:00
Jonas Devlieghere e13fca4fac [lldb] Remove unused <iostream> includes (NFC) 2020-06-20 22:38:45 -07:00
Eric Christopher 10b4354136 Temporarily Revert "[lldb][NFC] Add more test for builtin formats"
as it's failing on the debian buildbots:

http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/12531

This reverts commit 90c1af106a.
2020-06-20 14:21:42 -07:00
Raphael Isemann 90c1af106a [lldb][NFC] Add more test for builtin formats
The previous tests apparently missed a few code branches in DumpDataExtractor
code. Also renames the 'test_instruction' which had the same name as another
test (and Python therefore ignored the test entirely).
2020-06-20 19:31:40 +02:00
Raphael Isemann ab888262b3 [lldb] Skip TestBuiltinFormats.py on arm for now 2020-06-20 11:22:44 +02:00
Jonas Devlieghere 8027f04a6d [lldb/Test] Disable TestBuiltinFormats.py on Windows
Disable the test to turn the Windows bot green again until Raphael has
time to investigate.
2020-06-19 22:41:29 -07:00
Jonas Devlieghere 7a9a341953 [lldb/Test] Temporarily skip watch simulator in TestSimulatorPlatform.py
The simulator doesn't launch on green-dragon-10.

rdar://problem/64552748
2020-06-19 22:41:29 -07:00
Eric Christopher 2db1d75396 As part of using inclusive language within the llvm project,
migrate away from the use of blacklist and whitelist.
2020-06-19 14:51:04 -07:00
Eric Christopher efb328f674 As part of using inclusive language with the llvm project,
migrate away from the use of blacklist and whitelist.
2020-06-19 14:48:48 -07:00
Raphael Isemann aa7cd42993 [lldb][NFC] Add test for builtin formats 2020-06-19 22:33:02 +02:00
Jonas Devlieghere 827c012297 [lldb] Replace calls to new with std::make_shared<> (NFC) 2020-06-19 11:20:15 -07:00
Raphael Isemann f5eaa2afe2 [lldb] Replace std::isprint/isspace with llvm's locale-independent version
Summary:
LLVM is using its own isPrint/isSpace implementation that doesn't change depending on the current locale. LLDB should do the same
to prevent that internal logic changes depending on the set locale.

Reviewers: JDevlieghere, labath, mib, totally_not_teemperor

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D82175
2020-06-19 19:17:56 +02:00
Raphael Isemann 8340fbb9c7 [lldb] Reactivate Objective-C++ plugin
Summary:
Since commit 7b3ef05a37 the Objective-C++ plugin is dead code.
That commit added Objective-C++ to the list of languages for which `Language::LanguageIsCPlusPlus`
returns true. As the C++ language plugin also uses that method to figure out if it is responsible for a
given language, the C++ plugin since then also became the plugin that we found when looking for
a language plugin for Objective-C++. The only real fallout from that is that the source highlighting
for Objective-C++ files never worked as we always found the C++ plugin which refuses to highlight
files with Objective-C++ extensions.

This patch just adds a special exception for Objective-C++ to the list of languages that are governed
by the C++ plugin. Also adds a test that makes sure that we find the right plugin for all C language
types and that the highlighting for `.mm` (Objective-C++) and `.m` (Objective-C) files works.

I didn't revert 7b3ef05a37 as it does make sense to return
true for Objective-C++ from `Language::LanguageIsCPlusPlus` (e.g., we currently check if we care about
ODR violations by doing `if (Language::LanguageIsCPlusPlus(...))` and this should also work for
Objective-C++).

Fixes rdar://64420183

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: mgorny, abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D82109
2020-06-19 19:16:46 +02:00
Raphael Isemann be18df3d23 [lldb] Fix that SIGWINCH crashes IOHandlerEditline when we are not using the editline backend
Summary:
TerminalSizeChanged is called from our SIGWINCH signal handler but the
IOHandlerEditline currently doesn't check if we are actually using the real
editline backend. If we're not using the real editline backend, `m_editline_up`
won't be set and `IOHandlerEditline::TerminalSizeChanged` will access
the empty unique_ptr. In a real use case we don't use the editline backend
when we for example read input from a file. We also create some temporary
IOHandlerEditline's during LLDB startup it seems that are also treated
as non-interactive (apparently to read startup commands).

This patch just adds a nullptr check for`m_editline_up` as we do in the rest of
IOHandlerEditline.

Fixes rdar://problem/63921950

Reviewers: labath, friss

Reviewed By: friss

Subscribers: abidh, JDevlieghere

Differential Revision: https://reviews.llvm.org/D81729
2020-06-19 19:14:16 +02:00
Adrian Prantl 7e825abd57 Repair support for launching ios/tv/watch simulator binaries through platform
and delete a bunch (but not all) redundant code. If you compare the remaining implementations of Platform*Simulator.cpp, there is still an obvious leftover cleanup task.

Specifically, this patch

- removes SDK initialization from dotest (there is equivalent but more
  complete code in Makefile.rules)

- make Platform*Simulator inherit the generic implementation of
  PlatformAppleSimulator (more can be done here)

- simplify the platform logic in Makefile.rules

- replace the custom SDK finding logic in Platform*Simulator with XcodeSDK

- adds a test for each supported simulator

Differential Revision: https://reviews.llvm.org/D81980
2020-06-19 09:42:44 -07:00
Raphael Isemann 6331c7d0be [lldb] Disable complex tests on Windows
The tests fail to compile there:
```
complex/main.c:4:16: error: expected ';' at end of declaration
  float complex complex_float = -1.5f + -2.5f * I;
               ^
               ;
```
2020-06-19 18:40:08 +02:00
Raphael Isemann 85e7e3b1c9 [lldb] Fix TestComplexInt on ARM
On the buildbot long and int have the same size but long and long long don't,
so the bug where we find the first type by size will produce a different error.
Make the test dynamic based on int/long/long long size to fix the bot.
2020-06-19 17:47:16 +02:00
Raphael Isemann 1e8e1ec00c [lldb][NFC] Remove unused DEPTH_INCREMENT in CompilerType.cpp 2020-06-19 16:35:03 +02:00
Raphael Isemann 3e66bd291f [lldb][NFC] Add test for C99 and GCC complex types
LLDB has a lot of code for supporting complex types but we don't have a single
test for it. This adds some basic tests and documents the found bugs.
2020-06-19 16:22:16 +02:00
Derek Schuff c1709e5d90 Set appropriate host defines for building under emscripten
Emscripten has emulations for several headers found on Linux,
including spwan.h and endian.h

Differential Revision: https://reviews.llvm.org/D82121
2020-06-18 17:00:53 -07:00
Eric Christopher 50939c0a67 Add SveBFloat16 to type switch. 2020-06-18 12:39:03 -07:00
Muhammad Omair Javaid 6c45532908 Remove code duplication from RegisterContextPOSIX_*
Summary:
This patch aims to remove multiple copies of GetByteOrder() and ConvertRegisterKindToRegisterNumber used in various versions of RegisterContextPOSIX_*.

Both register implementations are move to RegisterContext class which is parent of RegisterContextPOSIX_* classes.

Built and tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabihf targets.

Reviewers: labath

Reviewed By: labath

Subscribers: wuzish, nemanjai, kristof.beyls, kbarton, atanasyan, lldb-commits

Differential Revision: https://reviews.llvm.org/D80104
2020-06-18 01:02:46 +05:00
Jonas Devlieghere 64c87a94ca [lldb/Test] Fix tests that rely on logfiles with reproducers.
Now that the log file is included in the reproducers, the path needs to
be remapped for the test to find the new file in the reproducer.
2020-06-17 10:09:06 -07:00
Muhammad Omair Javaid e29b31513f [lldb] Remove xfail aarch64/linux from TestBuiltinTrap.py
The underlying clang bug seems to have been fixed in and test is
consistently passing on aarch64-linux buildbot.
2020-06-17 15:48:59 +05:00
Jonas Devlieghere c151230533 [lldb/Test] Cleanup TestJITLoaderGDB and make it compatible with reproducers 2020-06-16 15:46:14 -07:00
Jonas Devlieghere c0f1dcf31e [lldb/Test] Pass the lldb_tool_dir when setting the lldb-repro substitutions
Otherwise LIT can't find the lldb-repro script in standalone builds.
2020-06-16 13:56:16 -07:00
Jonas Devlieghere 4dd3dfe8e3 [lldb/Python] Fix the infinitely looping Python prompt bug
Executing commands below will get you bombarded by a wall of Python
command prompts (>>> ).

$ echo 'foo' | ./bin/lldb -o script
$ cat /tmp/script
script
print("foo")
$ lldb --source /tmp/script

The issue is that our custom input reader doesn't handle EOF. According
to the Python documentation, file.readline always includes a trailing
newline character unless the file ends with an incomplete line. An empty
string signals EOF. This patch raises an EOFError when that happens.

[1] https://docs.python.org/2/library/stdtypes.html#file.readline

Differential revision: https://reviews.llvm.org/D81898
2020-06-16 11:05:19 -07:00
Jonas Devlieghere e4a84590e8 [lldb/Test] Create dir if it doesn't yet exist in getReproducerArtifact
The type test use this method to store the golden output. This currently
fails if the reproducer directory hasn't yet been created.
2020-06-16 09:46:48 -07:00