Commit Graph

23277 Commits

Author SHA1 Message Date
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