Commit Graph

12303 Commits

Author SHA1 Message Date
Michal Gorny a292a4943b [lldb] [Process/NetBSD] Fix handling LLDB_INVALID_SIGNAL_NUMBER
Fix NativeProcessNetBSD::Resume() to handle LLDB_INVALID_SIGNAL_NUMBER
correctly.  Fixes breakage caused by r372090 and r372300.  I have major
rewrite of that function pending; however, the fixes to gdb-remote
were committed prior to that.

llvm-svn: 372755
2019-09-24 13:41:54 +00:00
Pavel Labath 13a4e8f3ef Enhance SymbolFileDWARF::ParseDeclsForContext performance
This implements
DWARFASTParserClang::EnsureAllDIEsInDeclContextHaveBeenParsed so as to
provide a faster way to ensure all DIEs linked to a certain declaration
context have been parsed.

Currently, we rely on SymbolFileDWARF::ParseDeclsForContext calling
DWARFASTParserClang::GetDIEForDeclContext, and only then
DWARFASTParserClang::GetDeclForUIDFromDWARF. This change shortcuts that
logic and removes redundant calls to DWARFASTParserClang::
GetClangDeclForDIE by deleting DIEs from the m_decl_ctx_to_die map once
they have been parsed.

Differential Revision: https://reviews.llvm.org/D67760
Patch by Guilherme Andrade <guiandrade@google.com>.

llvm-svn: 372744
2019-09-24 12:36:54 +00:00
Martin Storsjo 544c8f48c8 [LLDB] Add tests for PECOFF arm architecture identification
Add a test case for the change from SVN r372657, and for the
preexisting ARM identification.

Add a missing ArchDefinitionEntry for PECOFF/arm64, and tweak
the ArmNt case to set the architecture to armv7 (ArmNt never ran
on anything lower than that). (This avoids a case where
ArchSpec::MergeFrom would override the arch from arm to armv7 and
ArchSpec::CoreUpdated would reset the OS to unknown at the same time.)

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

llvm-svn: 372741
2019-09-24 12:20:52 +00:00
Martin Storsjo e37b882421 [LLDB] Fix typo in RegisterContextDarwin_arm64
In these cases, the register number should be calculated from
fpu_d0, not fpu_s0.

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

llvm-svn: 372738
2019-09-24 12:20:21 +00:00
Raphael Isemann 08f90e3d57 [lldb] Use convert_to_slash in CppModuleConfiguration
That's what we actually want to do. Might fix the Windows bot.

llvm-svn: 372729
2019-09-24 11:17:38 +00:00
Raphael Isemann 6bac09afe8 [lldb][NFC] Use llvm::StringRef in formatters::NSStringSummaryProvider
llvm-svn: 372724
2019-09-24 11:00:37 +00:00
Raphael Isemann 9379d19ff8 [lldb] Decouple importing the std C++ module from the way the program is compiled
Summary:
At the moment, when trying to import the `std` module in LLDB, we look at the imported modules used in the compiled program
and try to infer the Clang configuration we need from the DWARF module-import. That was the initial idea but turned out to
cause a few problems or inconveniences:

* It requires that users compile their programs with C++ modules. Given how experimental C++ modules are makes this feature inaccessible
for many users. Also it means that people can't just get the benefits of this feature for free when we activate it by default
(and we can't just close all the associated bug reports).
* Relying on DWARF's imported module tags (that are only emitted by default on macOS) means this can only be used when using DWARF (and with -glldb on Linux).
* We essentially hardcoded the C standard library paths on some platforms (Linux) or just couldn't support this feature on other platforms (macOS).

This patch drops the whole idea of looking at the imported module DWARF tags and instead just uses the support files of the compilation unit.
If we look at the support files and see file paths that indicate where the C standard library and libc++ are, we can just create the module
configuration this information. This fixes all the problems above which means we can enable all the tests now on Linux, macOS and with other debug information
than what we currently had. The only debug information specific code is now the iteration over external type module when -gmodules is used (as `std` and also the
`Darwin` module are their own external type module with their own files).

The meat of this patch is the CppModuleConfiguration which looks at the file paths from the compilation unit and then figures out the include paths
based on those paths. It's quite conservative in that it only enables modules if we find a single C library and single libc++ library. It's still missing some
test mode where we try to compile an expression before we actually activate the config for the user (which probably also needs some caching mechanism),
but for now it works and makes the feature usable.

Reviewers: aprantl, shafik, jdoerfert

Reviewed By: aprantl

Subscribers: mgorny, abidh, JDevlieghere, lldb-commits

Tags: #c_modules_in_lldb, #lldb

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

llvm-svn: 372716
2019-09-24 10:08:18 +00:00
Martin Storsjo 02dddfd2ae [LLDB] [Windows] Add missing ifdefs to fix building for non-x86 architectures
While debugging on those architectures might not be supported yet,
the generic code should still be buildable. This file accesses x86
specific fields in the CONTEXT struct.

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

llvm-svn: 372699
2019-09-24 08:39:06 +00:00
Raphael Isemann 8126340b3f [lldb] Fix log output and UtilityTests/LogChannelTest.List
I refactored this code in 372691 and it seems I didn't fully
replicate the original log output, so that test was failing.

llvm-svn: 372696
2019-09-24 08:20:05 +00:00
Raphael Isemann ef06dd4328 [lldb] Remove redundant argument lists in CompletionRequest
We currently have two lists in the CompletionRequest that we
inherited from the old API: The complete list of arguments ignoring
where the user requested completion and the list of arguments that
stops at the cursor. Having two lists of arguments is confusing
and can lead to subtle errors, so let's remove the complete list
until we actually need it.

llvm-svn: 372692
2019-09-24 07:22:44 +00:00
Raphael Isemann 6ba63d8851 [lldb] Add completion support for log enable/disable/list
Reviewers: #lldb, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 372691
2019-09-24 07:18:09 +00:00
Raphael Isemann bd2a910a63 Ignore generated @import statements in the expression evaluator
Summary:
The ClangModulesDeclVendor is currently interpreting all injected `@import` statements in our expression
wrapper as modules that the user has explicitly requested to be persistently loaded. As we inject
`@import` statements with our std module prototype, the ClangModulesDeclVendor will start compiling
and loading unrelated C++ modules because it thinks the user has requested that it should load them. As
the ClangModulesDeclVendor is lacking the setup to compile these modules (e.g. it lacks the include paths),
it will then actually just fail to compile them and cause the whole expression evaluation to fail. This causes
these tests to fail on systems that enable the ClangModulesDeclVendor (such as macOS).

This patch fixes this by preventing the ClangModulesDeclVendor from interpreting `@import` statements
in the wrapper source code. This is done by check if the import happens in the fake source file containing
our wrapper code (which implies it was generated by LLDB).

This patch doesn't reenable the tests as there is more work needed to get the tests running on macOS (D67760)

Reviewers: aprantl, shafik, jingham

Subscribers: lldb-commits

Tags: #c_modules_in_lldb, #lldb

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

llvm-svn: 372690
2019-09-24 06:58:39 +00:00
Martin Storsjo e64849b11e [LLDB] [Windows] Map COFF ARM machine ids to the right triple architectures
Differential Revision: https://reviews.llvm.org/D67913

llvm-svn: 372658
2019-09-23 20:43:22 +00:00
Martin Storsjo 638f072f87 [LLDB] [PECOFF] Recognize arm64 executables
Differential Revision: https://reviews.llvm.org/D67912

llvm-svn: 372657
2019-09-23 20:43:16 +00:00
Jonas Devlieghere 948786c929 File::SetDescriptor() should require options
lvm_private::File::GetStream() can fail if m_options == 0

It's not clear from the header a File created with a descriptor will be
not be usable by many parts of LLDB unless SetOptions is also called,
but it is.

This is because those parts of LLDB rely on GetStream() to use the
file, and that in turn relies on calling fdopen on the descriptor. When
calling fdopen, GetStream relies on m_options to determine the access
mode. If m_options has never been set, GetStream() will fail.

This patch adds options as a required argument to File::SetDescriptor
and the corresponding constructor.

Patch by: Lawrence D'Anna

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

llvm-svn: 372652
2019-09-23 20:36:46 +00:00
Jonas Devlieghere a7d186c796 [Host] File::GetWaitableHandle() should call fileno()
If the file has m_stream, it may not have a m_descriptor.
GetWaitableHandle() should call GetDescriptor(), which will call
fileno(), so it will get waitable descriptor whenever one is available.

Patch by: Lawrence D'Anna

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

llvm-svn: 372644
2019-09-23 19:34:26 +00:00
Jonas Devlieghere 869ef0a627 [ABISysV] Fix regression for Simulator and MacABI
The ABISysV ABI was refactored in r364216 to support the Windows ABI for
x86_64. In particular it changed ABISysV_x86_64::CreateInstance to
switch on the OS type. This breaks debugging MacABI apps as well as apps
in the simulator. This adds back the necessary cases.

We have a test on Github that exercises this code path and which I'd
like to upstream once the remaining MacABI parts become available in
clang.

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

llvm-svn: 372642
2019-09-23 19:06:00 +00:00
Martin Storsjo 8b98f12a7a [LLDB] Check for _WIN32 instead of _MSC_VER for code specific to windows in general
These ifdefs contain code that isn't specific to MSVC but useful for
any windows target, like MinGW.

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

llvm-svn: 372592
2019-09-23 12:03:56 +00:00
Martin Storsjo 02d3cc97fa [LLDB] Remove a now redundant windows specific workaround
vsnprintf(NULL, 0, ...) works for measuring the needed string
size on all supported Windows variants; it's supported since
at least MSVC 2015 (and LLVM requires a newer version than that),
and works on both msvcrt.dll (since at least XP) and UCRT with MinGW.

The previous use of ifdefs was wrong as well, as __MINGW64__ only is
defined for 64 bit targets, and the define without trailing
underscores is never defined automatically (neither by clang nor
by gcc).

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

llvm-svn: 372591
2019-09-23 12:03:33 +00:00
Martin Storsjo d67b0997d2 [LLDB] Add a void* cast when passing object pointers to printf %p
This fixes build warnings in MinGW mode.

Also remove leftover if (log) {} around the log macro.

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

llvm-svn: 372590
2019-09-23 12:03:28 +00:00
Martin Storsjo 799d61f269 [LLDB] Remove a stray semicolon. NFC.
This fixes build warnings with at least GCC.

llvm-svn: 372588
2019-09-23 12:03:14 +00:00
Martin Storsjo fb31852fbc [LLDB] Add a missing specification of linking against dbghelp
The PECOFF object file plugin uses the dbghelp API, but doesn't
specify that it has to be linked in anywhere.

Current MSVC based builds have probably succeeded, as other parts
in LLDB have had a "#pragma comment(lib, "dbghelp.lib")", but there's
currently no such pragma in the PECOFF plugin.

The "#pragma comment(lib, ...)" approach doesn't work in MinGW mode
(unless the compiler is given the -fms-extensions option, and even
then, it's only supported by clang/lld, not by GCC/binutils), thus
add it to be linked via CMake. (The other parts of LLDB that use
dbghelp are within _MSC_VER ifdefs.)

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

llvm-svn: 372587
2019-09-23 12:03:08 +00:00
Raphael Isemann db6617ddb7 [lldb][NFC] Remove unused variable in Options::HandleOptionArgumentCompletion
llvm-svn: 372574
2019-09-23 10:02:26 +00:00
Raphael Isemann 48d38ca6ac [lldb][NFC] Remove dead code in Options::HandleOptionArgumentCompletion
llvm-svn: 372572
2019-09-23 09:56:53 +00:00
Raphael Isemann 14f6465c15 [lldb] Make cursor index in CompletionRequest unsigned
The fact that index==-1 means "no arguments" is not obvious and only
used in one place from what I can tell. Also fixes several warnings
about using the cursor index as if it was a size_t when comparing.

Not fully NFC as we now also correctly update the partial argument list
when injecting the fake empty argument in the CompletionRequest
constructor.

llvm-svn: 372566
2019-09-23 09:46:17 +00:00
Raphael Isemann 93ca36d756 [lldb][NFC] Remove argument prefix checking boilerplate when adding completions
llvm-svn: 372561
2019-09-23 08:59:21 +00:00
Raphael Isemann f8e733f149 [lldb] Reduce some dangerous boilerplate with CompletionRequest::ShiftArguments
We should in general not allow external code to fiddle with the internals of
CompletionRequest, but until this is gone let's at least provide a utility
function that makes this less dangerous.

This also now correct updates the partially parsed argument list,
but it doesn't seem to be used by anything that is behind one of
the current shift/SetCursorIndex calls, so this doesn't seeem to
fix any currently used completion.

llvm-svn: 372556
2019-09-23 08:16:19 +00:00
Raphael Isemann c9e902406f [lldb] Fix that importing decls in a TagDecl end up in wrong declaration context (partly reverts D61333)
Summary:
In D61333 we dropped some code from ClangASTSource that checks if imported declarations
ended up in the right DeclContext. While this code wasn't tested by the test suite (or better, it was hit
by the test suite but we didn't have any checks that were affected) and the code seems pointless
(as usually Decls should end up in the right DeclContext), it actually broke the data formatters in LLDB
and causes a bunch of obscure bugs where structs suddenly miss all their members. The first report we got about
this was that printing a std::map doesn't work anymore when simply doing "expr m" (m is the std::map).

This patch reverts D61333 partly and reintroduces the check in a more stricter way (we actually check now that
we *move* the Decl and it is in a single DeclContext). This should fix all the problems we currently have until
we figure out how to properly fix the underlying issues. I changed the order of some std::map formatter tests
which is currently the most reliable way to test this problem (it's a tricky setup, see description below).

Fixes rdar://55502701 and rdar://55129537

--------------------------------------

Some more explanation what is actually going on and what is going wrong:

The situation we have is that if we have a `std::map m` and do a `expr m`, we end up seeing an empty map
(even if `m` has elements). The reason for this is that our data formatter sees that std::pair<int, int> has no
members. However, `frame var m` works just fine (and fixes all following `expr m` calls).

The reason for why `expr` breaks std::map is that we actually copy the std::map nodes in two steps in the
three ASTContexts that are involved: The debug information ASTContext (D-AST), the expression ASTContext
we created for the current expression (E-AST) and the persistent ASTContext we use for our $variables (P-AST).

When doing `expr m` we do a minimal import of `std::map` from D-AST to E-AST just do the type checking/codegen.
This copies std::map itself and does a minimal.import of `std::pair<int, int>` (that is, we don't actually import
the `first` and `second` members as we don't need them for anything). After the expression is done, we take
the expression result and copy it from E-AST to P-AST. This imports the E-AST's `std::pair` into P-AST which still
has no `first` and `second` as they are still undeserialized. Once we are in P-AST, the data formatter tries to
inspect `std::map` (and also `std::pair` as that's what the elements are) and it asks for the `std::pair` members.
We see that `std::pair` has undeserialized members and go to the ExternalASTSource to ask for them. However,
P-ASTs ExternalASTSource points to D-AST (and not E-AST, which `std::pair` came from). It can't point to E-AST
as that is only temporary and already gone (and also doesn't actually contain all decls we have in P-AST).

So we go to D-AST to get the `std::pair` members. The ASTImporter is asked to copy over `std::pair` members
and first checks if `std::pair` is already in P-AST. However, it only finds the std::pair we got from E-AST, so it
can't use it's map of already imported declarations and does a comparison between the `std::pair` decls we have
Because the ASTImporter thinks they are different declarations, it creates a second `std::pair` and fills in the
members `first` and `second` into the second `std::pair`. However, the data formatter is looking at the first
`std::pair` which still has no members as they are in the other decl. Now we pretend we have no declarations
and just print an empty map as a fallback.

The hack we had before fixed this issue by moving `first` and `second` to the first declaration which makes
the formatters happy as they can now see the members in the DeclContext they are querying.

Obviously this is a temporary patch until we get a real fix but I'm not sure what's the best way to fix this.
Implementing that the ClassTemplateSpecializationDecl actually understands that the two std::pair's are the same
decl fixes the issue, but this doesn't fix the bug for all declarations. My preferred solution would be to
complete all declarations in E-AST before they get moved to P-AST (as we anyway have to do this from what I can
tell), but that might have unintended side-effects and not sure what's the best way to implement this.

Reviewers: friss, martong

Reviewed By: martong

Subscribers: aprantl, rnkovacs, christof, abidh, JDevlieghere, lldb-commits, shafik

Tags: #lldb

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

llvm-svn: 372549
2019-09-23 07:27:14 +00:00
Raphael Isemann 15695cd69c [lldb] Fix LLDB build after r372538
llvm-svn: 372548
2019-09-23 06:59:35 +00:00
Haibo Huang 5c82608d20 Use _WIN32 instead of _MSC_VER
Summary: This way it works better with MinGW.

Subscribers: mstorsjo, lldb-commits

Tags: #lldb

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

llvm-svn: 372493
2019-09-22 01:21:34 +00:00
Martin Storsjo 5534a67500 [LLDB] Cast -1 (as invalid socket) to the socket type before comparing
This silences warnings about comparison of integers between unsigned
long long (which is what the Windows SOCKET type is) and signed int
when building in MinGW mode.

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

llvm-svn: 372486
2019-09-21 19:10:15 +00:00
Martin Storsjo ed78dc8e43 [LLDB] Use SetErrorStringWithFormatv for cases that use LLVM style format strings
SetErrorStringWithFormat only supports normal printf style format
strings.

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

llvm-svn: 372485
2019-09-21 19:10:00 +00:00
Martin Storsjo 5c38730dbd [LLDB] Use LLVM_FALLTHROUGH instead of a custom comment
This fixes a warning when built with Clang in MinGW mode.

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

llvm-svn: 372484
2019-09-21 19:09:54 +00:00
Martin Storsjo 2e25c44dc3 [LLDB] Check for the GCC/MinGW compatible arch defines for windows, in addition to MSVC defines
This matches how it is done in all other similar ifdefs throughout
lldb.

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

llvm-svn: 372483
2019-09-21 19:09:49 +00:00
Martin Storsjo f4deacf995 [LLDB] Fix compilation for MinGW, remove redundant class name on inline member
This fixes build errors like these:

NativeRegisterContextWindows.h:22:33: error: extra qualification on member 'NativeRegisterContextWindows'
  NativeRegisterContextWindows::NativeRegisterContextWindows(
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

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

llvm-svn: 372482
2019-09-21 19:09:43 +00:00
Adrian Prantl 330014843c Doxygenify comments.
llvm-svn: 372411
2019-09-20 17:15:57 +00:00
Raphael Isemann 6192ad2622 Move decl completion out of the ASTImporterDelegate and document it [NFC]
Summary:
The ASTImporterDelegate is currently responsible for both recording and also completing
types. This patch moves the actual completion and recording code outside the ASTImporterDelegate
to reduce the amount of responsibilities the ASTImporterDelegate has to fulfill.

As I anyway had to touch the code when moving I also documented and refactored most of it
(e.g. no more asserts that we call the deporting start/end function always as a pair).

Note that I had to make the ASTImporterDelegate and it's related functions public now so that
I can move out the functionality in another class (that doesn't need to be in the header).

Reviewers: shafik, aprantl, martong, a.sidorin

Reviewed By: martong

Subscribers: rnkovacs, lldb-commits

Tags: #lldb

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

llvm-svn: 372385
2019-09-20 12:52:55 +00:00
Michal Gorny c36b0bf310 [lldb] [Process/gdb-remote] Correct more missing LLDB_INVALID_SIGNAL_NUMBER
Correct more uses of 0 instead of LLDB_INVALID_SIGNAL_NUMBER.

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

llvm-svn: 372300
2019-09-19 05:49:14 +00:00
Raphael Isemann 1442efea9a [lldb] Print better diagnostics for user expressions and modules
Summary:
Currently our expression evaluators only prints very basic errors that are not very useful when writing complex expressions.

For example, in the expression below the user made a type error, but it's not clear from the diagnostic what went wrong:
```
(lldb) expr printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3)
error: invalid operands to binary expression ('int' and 'double')
```

This patch enables full Clang diagnostics in our expression evaluator. After this patch the diagnostics for the expression look like this:

```
(lldb) expr printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3)
error: <user expression 1>:1:54: invalid operands to binary expression ('int' and 'float')
printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3)
                                               ~~~~~~^~~~
```

To make this possible, we now emulate a user expression file within our diagnostics. This prevents that the user is exposed to
our internal wrapper code we inject.

Note that the diagnostics that refer to declarations from the debug information (e.g. 'note' diagnostics pointing to a called function)
will not be improved by this as they don't have any source locations associated with them, so caret or line printing isn't possible.
We instead just suppress these diagnostics as we already do with warnings as they would otherwise just be a context message
without any context (and the original diagnostic in the user expression should be enough to explain the issue).

Fixes rdar://24306342

Reviewers: JDevlieghere, aprantl, shafik, #lldb

Reviewed By: JDevlieghere, #lldb

Subscribers: usaxena95, davide, jingham, aprantl, arphaman, kadircet, lldb-commits

Tags: #lldb

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

llvm-svn: 372203
2019-09-18 08:53:35 +00:00
Jonas Devlieghere 20b52c33ba [ScriptInterpreter] Limit LLDB's globals to interactive mode.
Jim pointed out that the LLDB global variables should only be available
in interactive mode. When used from a command for example, their values
might be stale or not at all what the user expects. Therefore we want to
explicitly make these variables unavailable.

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

llvm-svn: 372192
2019-09-18 00:30:01 +00:00
Jonas Devlieghere abb3d13778 [ScriptInterpreter] Remove ScriptInterpreterPythonImpl::Clear() (NFC)
This method is never called.

llvm-svn: 372190
2019-09-18 00:01:52 +00:00
Michal Gorny e4d25e9e16 [lldb] [Process/gdb-remote] Fix defaulting signal to invalid in action list
Fix processing of "C" packet with signal for the whole process to
default signal value for action list to LLDB_INVALID_SIGNAL_NUMBER
rather than 0.

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

llvm-svn: 372090
2019-09-17 09:31:00 +00:00
Raphael Isemann 3ee98a1455 Reland "[lldb][NFC] Make ApplyObjcCastHack less scary"
First version had a typo.

llvm-svn: 372077
2019-09-17 07:58:01 +00:00
Jonas Devlieghere a879f40ba1 [ScriptInterpreter] Initialize globals when loading a scripting module.
The LoadScriptingModule used by command script import wasn't
initializing the LLDB global variables (things like `lldb.frame` and
`lldb.debugger`). They would get initialized however when running the
interactive script interpreter or running a single script line (e.g.
`script print(lldb.frame)`). This patch fixes that by properly
initializing the globals when loading a Python module.

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

llvm-svn: 372060
2019-09-17 03:55:58 +00:00
Jim Ingham 66e9f239b5 Revert "[lldb][NFC] Make ApplyObjcCastHack less scary"
This reverts commit 21641a2f6d.

It was causing the following test failures:

lldb-Suite.lang/objc/objc-class-method.TestObjCClassMethod.py
lldb-Suite.lang/objc/foundation.TestObjCMethodsString.py
lldb-Suite.lang/objc/foundation.TestConstStrings.py
lldb-Suite.lang/objc/radar-9691614.TestObjCMethodReturningBOOL.py
lldb-Suite.lang/objc/foundation.TestObjCMethodsNSArray.py

llvm-svn: 372057
2019-09-17 00:44:48 +00:00
Jonas Devlieghere 8fc8d3fe01 [Reproducer] Implement dumping packets.
This patch completes the dump functionality by adding support for
dumping a reproducer's GDB remote packets.

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

llvm-svn: 372046
2019-09-16 23:31:06 +00:00
Jonas Devlieghere 4e053ff1d1 [NFC] Move dumping into GDBRemotePacket
This moves the dumping logic from the GDBRemoteCommunicationHistory
class into the GDBRemotePacket so that it can be reused from the
reproducer command object.

llvm-svn: 372028
2019-09-16 20:02:57 +00:00
Raphael Isemann 21641a2f6d [lldb][NFC] Make ApplyObjcCastHack less scary
llvm-svn: 372017
2019-09-16 18:02:21 +00:00
Jonas Devlieghere 97fc8eb438 [Reproducer] Add reproducer dump command.
This adds a reproducer dump commands which makes it possible to inspect
a reproducer from inside LLDB. Currently it supports the Files, Commands
and Version providers. I'm planning to add support for the GDB Remote
provider in a follow-up patch.

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

llvm-svn: 371909
2019-09-13 23:27:31 +00:00
Jonas Devlieghere ff5225bfb6 [Reproducer] Move GDB Remote Packet into Utility. (NFC)
To support dumping the reproducer's GDB remote packets, we need the
(de)serialization logic to live in Utility rather than the GDB remote
plugin. This patch renames StreamGDBRemote to GDBRemote and moves the
relevant packet code there.

Its uses in the GDBRemoteCommunicationHistory and the
GDBRemoteCommunicationReplayServer are updated as well.

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

llvm-svn: 371907
2019-09-13 23:14:10 +00:00
Adrian McCarthy 646a893f15 Fix error in ProcessLauncherWindows.cpp
Restored missing parens on a function call.

llvm-svn: 371882
2019-09-13 18:50:39 +00:00
Raphael Isemann 0d9a201e26 [lldb][NFC] Remove ArgEntry::ref member
The StringRef should always be identical to the C string, so we
might as well just create the StringRef from the C-string. This
might be slightly slower until we implement the storage of ArgEntry
with a string instead of a std::unique_ptr<char[]>. Until then we
have to do the additional strlen on the C string to construct the
StringRef.

llvm-svn: 371842
2019-09-13 11:26:48 +00:00
Raphael Isemann 1f644bb163 [lldb][NFC] Simplify Args::ReplaceArgumentAtIndex
This code is not on any performance critical path that would
justify this shortening optimization. It also makes it possible
to turn 'ref' into a function (as this is the only place where
we modify this ArgEntry member).

llvm-svn: 371836
2019-09-13 10:41:29 +00:00
Raphael Isemann a024f5e370 [lldb][NFC] Make ArgEntry::quote private and provide a getter
llvm-svn: 371823
2019-09-13 08:26:00 +00:00
Richard Smith c624510f13 For PR17164: split -fno-lax-vector-conversion into three different
levels:

 -- none: no lax vector conversions [new GCC default]
 -- integer: only conversions between integer vectors [old GCC default]
 -- all: all conversions between same-size vectors [Clang default]

For now, Clang still defaults to "all" mode, but per my proposal on
cfe-dev (2019-04-10) the default will be changed to "integer" as soon as
that doesn't break lots of testcases. (Eventually I'd like to change the
default to "none" to match GCC and general sanity.)

Following GCC's behavior, the driver flag -flax-vector-conversions is
translated to -flax-vector-conversions=integer.

This reinstates r371805, reverted in r371813, with an additional fix for
lldb.

llvm-svn: 371817
2019-09-13 06:02:15 +00:00
Alex Langford 5b2b38e053 [Target] Move InferiorCall to Process
Summary:
InferiorCall is only ever used in Process, and it is not specific to
POSIX. By moving it to Process, we can remove all dependencies on plugins from
Process. Moving InferiorCall to Process seems to achieve this quite well.
Additionally, the name InferiorCall is a little vague now, so we rename
it something a bit more specific.

Reviewers: JDevlieghere, clayborg, compnerd, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 371796
2019-09-13 00:02:05 +00:00
Jonas Devlieghere decff073ee [NFC] Sort source files in Utility/CMakeLists.txt
llvm-svn: 371784
2019-09-12 22:34:59 +00:00
Jonas Devlieghere 4a491ec491 [Reproducer] Move the command loader into the reproducer (NFC)
This just moves the CommandLoader utility into the reproducer namespace
and makes it accessible outside the API layer. This is setting things up
for a bigger change.

llvm-svn: 371689
2019-09-11 23:27:12 +00:00
Jonas Devlieghere d9aec34b97 [NFC] Reformat SBDebugger before making changes
llvm-svn: 371688
2019-09-11 23:27:09 +00:00
Jonas Devlieghere bcc24e46ba [Reproducer] Move GDB Remote Provider into Reproducer (NFC)
Originally the idea was for providers to be defined close to where they
are used. While this helped designing the providers in such a way that
they don't depend on each other, it also means that it's not possible to
access them from a central place. This proved to be a problem for some
providers and resulted in them living in the reproducer class.

The ProcessGDBRemote provider is the last remaining exception. This
patch makes things consistent and moves it into the reproducer like the
other providers.

llvm-svn: 371685
2019-09-11 23:15:12 +00:00
Vedant Kumar 21d417dc18 [DWARF] Evaluate DW_OP_entry_value
Add support for evaluating DW_OP_entry_value. This involves parsing
DW_TAG_call_site_parameter and wiring the information through to the expression
evaluator.

rdar://54496008

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

llvm-svn: 371668
2019-09-11 21:23:45 +00:00
Alex Langford 1b385a1802 [Plugins/Process] Remove direct use of ClangASTContext from InferiorCallPOSIX
Summary:
InferiorCallPOSIX directly grabs a ClangASTContext from the Target it
has and does no error checking. I don't think these functions have a
reason to know about clang specifically. Additionally, using
`GetScratchTypeSystemForLanguage` forces us to do error checking since
it returns an Expected.

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

llvm-svn: 371654
2019-09-11 20:36:28 +00:00
Konrad Kleine 2f3884ca1d Revert "[LLDB][ELF] Load both, .symtab and .dynsym sections"
This reverts commit 3a4781bbf4.

llvm-svn: 371625
2019-09-11 14:33:37 +00:00
Konrad Kleine d44c4a71df Revert "[LLDB][ELF] Fixup for comments in D67390"
This reverts commit 813f05915d.

llvm-svn: 371624
2019-09-11 14:33:21 +00:00
Raphael Isemann 3ad8278737 [lldb][NFC] Make include directories in Clang expression parser a std::string
We never compare these directories (where ConstString would be good) and
essentially just convert this back to a normal string in the end. So we might
as well just use std::string. Also makes it easier to unittest this code
(which was the main motivation for this change).

llvm-svn: 371623
2019-09-11 14:33:11 +00:00
Raphael Isemann 1761f6fc42 [lldb][NFC] Remove dead code in SBAddress::GetDescription
llvm-svn: 371618
2019-09-11 13:57:41 +00:00
Konrad Kleine 813f05915d [LLDB][ELF] Fixup for comments in D67390
llvm-svn: 371600
2019-09-11 10:12:36 +00:00
Konrad Kleine 3a4781bbf4 [LLDB][ELF] Load both, .symtab and .dynsym sections
Summary:
This change ensures that the .dynsym section will be parsed even when there's already is a .symtab.

It is motivated because of minidebuginfo (https://sourceware.org/gdb/current/onlinedocs/gdb/MiniDebugInfo.html#MiniDebugInfo).

There it says:

    Keep all the function symbols not already in the dynamic symbol table.

That means the .symtab embedded inside the .gnu_debugdata does NOT contain the symbols from .dynsym. But in order to put a breakpoint on all symbols we need to load both. I hope this makes sense.

My other patch D66791 implements support for minidebuginfo, that's why I need this change.

Reviewers: labath, espindola, alexshap

Subscribers: JDevlieghere, emaste, arichardson, MaskRay, lldb-commits

Tags: #lldb

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

llvm-svn: 371599
2019-09-11 10:00:30 +00:00
David Zarzycki b250d5ff5e [LLDB] Do not try to canonicalize gethostname() result
This code is trying too hard and failing. Either the result of
gethostname() is canonical or it is not. If it is not, then trying to
canonicalize it is – for various reasons – a lost cause. For example, a
given machine might have multiple network interfaces with multiple
addresses per interface, each with a different canonical name.
Separably, the result of HostInfoPosix::GetHostname() and latency
thereof shouldn't depend on whether networking is up or down or what
network the machine happened to be attached to at any given moment (like
a laptop that travels between work and home).

https://reviews.llvm.org/D67230

llvm-svn: 371596
2019-09-11 08:32:37 +00:00
Vedant Kumar ff02109ad4 [Function] Factor out GetCallEdgeForReturnAddress, NFC
Finding the call edge in a function which corresponds to a particular
return address is a generic/useful operation.

llvm-svn: 371543
2019-09-10 18:36:50 +00:00
Adrian Prantl 9b23df63ec Implement DW_OP_convert
This patch adds basic support for DW_OP_convert[1] for integer
types. Recent versions of LLVM's optimizer may insert this opcode into
DWARF expressions. DW_OP_convert is effectively a type cast operation
that takes a reference to a base type DIE (or zero) and then casts the
value at the top of the DWARF stack to that type. Internally this
works by changing the bit size of the APInt that is used as backing
storage for LLDB's DWARF stack.

I managed to write a unit test for this by implementing a mock YAML
object file / module that takes debug info sections in yaml2obj
format.

[1] Typed DWARF stack. http://www.dwarfstd.org/ShowIssue.php?issue=140425.1

<rdar://problem/48167864>

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

llvm-svn: 371532
2019-09-10 16:17:38 +00:00
David Carlier c190890c29 [LLDB] FreeBSD fix new SetFile call.
llvm-svn: 371491
2019-09-10 07:33:39 +00:00
Jonas Devlieghere e0ea8d87eb [Utility] Replace `lldb_private::CleanUp` by `llvm::scope_exit`
This removes the CleanUp class and replaces its usages with llvm's
ScopeExit, which has similar semantics.

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

llvm-svn: 371474
2019-09-10 00:20:50 +00:00
Alex Langford 1dbee8f043 [Expression] Remove unused header from LLVMUserExpression
llvm-svn: 371472
2019-09-09 23:59:54 +00:00
Alex Langford 9e86561878 [Symbol] Give ClangASTContext a PersistentExpressionState instead of a ClangPersistentVariables
ClangASTContext doesn't use m_persistent_variables in a way specific to
ClangPersistentVariables. Therefore, it should hold a unique pointer to
PersistentExpressionState instead of a ClangPersistentVariablesUP.
This also prevents you from pulling in a plugin header when including
ClangASTContext.h

Doing this exposed an implicit dependency in ObjCLanguage that was
corrected by including ClangModulesDeclVendor.h

llvm-svn: 371470
2019-09-09 23:11:43 +00:00
Jonas Devlieghere 9b961cc604 [Reproducer] Disconnect when the replay server is out of packets.
This is a fix for the issue described in r371144.

> On more than one occasion I've found this test got stuck during replay
> while waiting for a packet from debugserver when the debugger was in
> the process of being destroyed.

When the replay server is out of packets we should just disconnect so
the debugger doesn't have to do any cleanup that it wouldn't do during
capture.

llvm-svn: 371459
2019-09-09 22:05:48 +00:00
Greg Clayton 4f68c226a5 Fix ELF core file memory reading for PT_LOAD program headers with no p_filesz
Prior to this fix, ELF files might contain PT_LOAD program headers that had a valid p_vaddr, and a valid file p_offset, but the p_filesz would be zero. For example in llvm-project/lldb/test/testcases/functionalities/postmortem/elf-core/thread_crash/linux-i386.core we see:

Program Headers:
Index   p_type           p_flags    p_offset           p_vaddr            p_paddr            p_filesz           p_memsz            p_align
======= ---------------- ---------- ------------------ ------------------ ------------------ ------------------ ------------------ ------------------
[    0] PT_NOTE          0x00000000 0x0000000000000474 0x0000000000000000 0x0000000000000000 0x0000000000001940 0x0000000000000000 0x0000000000000000
[    1] PT_LOAD          0x00000005 0x0000000000002000 0x0000000008048000 0x0000000000000000 0x0000000000000000 0x0000000000003000 0x0000000000001000
[    2] PT_LOAD          0x00000004 0x0000000000002000 0x000000000804b000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[    3] PT_LOAD          0x00000006 0x0000000000002000 0x000000000804c000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[    4] PT_LOAD          0x00000006 0x0000000000002000 0x0000000009036000 0x0000000000000000 0x0000000000000000 0x0000000000025000 0x0000000000001000
[    5] PT_LOAD          0x00000000 0x0000000000002000 0x00000000f63a1000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[    6] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f63a2000 0x0000000000000000 0x0000000000000000 0x0000000000800000 0x0000000000001000
[    7] PT_LOAD          0x00000000 0x0000000000002000 0x00000000f6ba2000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[    8] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f6ba3000 0x0000000000000000 0x0000000000000000 0x0000000000804000 0x0000000000001000
[    9] PT_LOAD          0x00000005 0x0000000000002000 0x00000000f73a7000 0x0000000000000000 0x0000000000000000 0x00000000001b1000 0x0000000000001000
[   10] PT_LOAD          0x00000004 0x0000000000002000 0x00000000f7558000 0x0000000000000000 0x0000000000000000 0x0000000000002000 0x0000000000001000
[   11] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f755a000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   12] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f755b000 0x0000000000000000 0x0000000000000000 0x0000000000003000 0x0000000000001000
[   13] PT_LOAD          0x00000005 0x0000000000002000 0x00000000f755e000 0x0000000000000000 0x0000000000000000 0x0000000000019000 0x0000000000001000
[   14] PT_LOAD          0x00000004 0x0000000000002000 0x00000000f7577000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   15] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f7578000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   16] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f7579000 0x0000000000000000 0x0000000000000000 0x0000000000002000 0x0000000000001000
[   17] PT_LOAD          0x00000005 0x0000000000002000 0x00000000f757b000 0x0000000000000000 0x0000000000000000 0x000000000001c000 0x0000000000001000
[   18] PT_LOAD          0x00000004 0x0000000000002000 0x00000000f7597000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   19] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f7598000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   20] PT_LOAD          0x00000005 0x0000000000002000 0x00000000f7599000 0x0000000000000000 0x0000000000000000 0x0000000000053000 0x0000000000001000
[   21] PT_LOAD          0x00000004 0x0000000000002000 0x00000000f75ec000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   22] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f75ed000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   23] PT_LOAD          0x00000005 0x0000000000002000 0x00000000f75ee000 0x0000000000000000 0x0000000000000000 0x0000000000176000 0x0000000000001000
[   24] PT_LOAD          0x00000004 0x0000000000002000 0x00000000f7764000 0x0000000000000000 0x0000000000000000 0x0000000000006000 0x0000000000001000
[   25] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f776a000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   26] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f776b000 0x0000000000000000 0x0000000000000000 0x0000000000003000 0x0000000000001000
[   27] PT_LOAD          0x00000006 0x0000000000002000 0x00000000f778a000 0x0000000000000000 0x0000000000000000 0x0000000000002000 0x0000000000001000
[   28] PT_LOAD          0x00000004 0x0000000000002000 0x00000000f778c000 0x0000000000000000 0x0000000000002000 0x0000000000002000 0x0000000000001000
[   29] PT_LOAD          0x00000005 0x0000000000004000 0x00000000f778e000 0x0000000000000000 0x0000000000002000 0x0000000000002000 0x0000000000001000
[   30] PT_LOAD          0x00000005 0x0000000000006000 0x00000000f7790000 0x0000000000000000 0x0000000000000000 0x0000000000022000 0x0000000000001000
[   31] PT_LOAD          0x00000004 0x0000000000006000 0x00000000f77b3000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   32] PT_LOAD          0x00000006 0x0000000000006000 0x00000000f77b4000 0x0000000000000000 0x0000000000000000 0x0000000000001000 0x0000000000001000
[   33] PT_LOAD          0x00000006 0x0000000000006000 0x00000000ffa25000 0x0000000000000000 0x0000000000000000 0x0000000000022000 0x0000000000001000
Prior to this fix if users tried to read memory from one of these addresses like 0x8048000, they would end up incorrectly reading from the next memory region that actually had a p_filesz which would be 0x00000000f778c000 in this case. This fix correctly doesn't include program headers with zero p_filesz in the ProcessELFCore::m_core_aranges that is used to read memory. I found two cores files that have this same issue and added tests.

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

llvm-svn: 371457
2019-09-09 21:45:49 +00:00
David Carlier f707dac742 LLDB - Simplify GetProgramFileSpec
Reviewers: zturner, emaste

Reviewed By: emaste

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

llvm-svn: 371417
2019-09-09 16:10:14 +00:00
Jason Molenda 5b0a687d89 Long timeouts for the MacOSX SystemRuntime plugins under ASAN; else quick.
In April via r357829, Adrian unified timeouts across lldb and set the
default value high so that we wouldn't get timeouts on ASAN bots that
were running under load.

The library that the MacOSX SystemRuntime has functions that need
to take a lock, and if that lock is held already, those functions
will never complete; we're seeing the 15 second timeout being hit
with inferiors that are doing a lot of enqueuing and dequeuing of
libdispatch work items causing this deadlocking behavior.

This patch reverts to a very short timeout for these SystemRuntime
function calls, given the behavior of this library that they are 
calling into.  When lldb is built with AddressSanitizer enabled,
they will use the default 15 second timeout.

tl;dr: this reverts to the previous timeouts for these SystemRuntime
inf func calls.

<rdar://problem/54538149> 

llvm-svn: 371280
2019-09-07 01:38:37 +00:00
Alex Langford b482db6dfe [Core] Remove use of ClangASTContext in DumpDataExtractor
Summary:
DumpDataExtractor uses ClangASTContext in order to get the proper llvm
fltSemantics for the type it needs so that it can dump floats in a more
precise way. However, there's no reason that this behavior needs to be
specific ClangASTContext. Instead, I think it makes sense to ask
TypeSystems for the float semantics for a type of a given size.

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

llvm-svn: 371258
2019-09-06 21:05:21 +00:00
Serge Guelton 90d32df7db Remove call to obsolete gethostbyname, using getaddrinfo
Differential Revision: https://reviews.llvm.org/D67230

llvm-svn: 371195
2019-09-06 11:06:23 +00:00
Raphael Isemann 7841e80e79 [lldb][NFC] Remove Args::StripSpaces
This just reimplemented llvm::StringRef::[r/l]trim().

llvm-svn: 371181
2019-09-06 08:40:31 +00:00
Raphael Isemann dd8e73ffc0 [lldb][NFC] Remove unused Args::GetArgumentQuoteCharAtIndex
llvm-svn: 371176
2019-09-06 07:54:47 +00:00
Aleksandr Urakov 6179c0eb0d [Windows] Add support of watchpoints to `ProcessWindows`
Summary:
This patch adds support of watchpoints to the old `ProcessWindows` plugin.

The `ProcessWindows` plugin uses the `RegisterContext` to set and reset
watchpoints. The `RegisterContext` has some interface to access watchpoints,
but it is very limited (e.g. it is impossible to retrieve the last triggered
watchpoint with it), that's why I have implemented a slightly different
interface in the `RegisterContextWindows`. Moreover, I have made the
`ProcessWindows` plugin responsible for search of a vacant watchpoint slot,
because watchpoints exist per-process (not per-thread), then we can place
the same watchpoint in the same slot in different threads. With this scheme
threads don't need to have their own watchpoint lists, and it simplifies
identifying of the last triggered watchpoint.

Reviewers: asmith, stella.stamenova, amccarth

Reviewed By: amccarth

Subscribers: labath, zturner, leonid.mashinskiy, abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 371166
2019-09-06 05:37:03 +00:00
Jonas Devlieghere f5687d7c12 Remove `bugreport` command
The bugreport command exists to create domain-specific bug reports.
Currently it has one implementation for filing bugs on the unwinder. As
far as we can tell, it has never been of use. Although not exactly the
same as the reproducers, it's a bit confusing to have two parallel
command trees for (kind of) the same thing.

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

llvm-svn: 371132
2019-09-05 21:43:32 +00:00
Pavel Labath 7790858b00 Obliterate LLDB_CONFIGURATION_BUILDANDINTEGRATION
Summary:
With the XCode project gone, there doesn't seem to be anything setting
this macro anymore -- and the macro wasn't doing much anyway.

Reviewers: jingham, sgraenitz

Subscribers: emaste, lldb-commits

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

llvm-svn: 371018
2019-09-05 07:09:31 +00:00
Pavel Labath c3bea40bf7 Breakpad: Basic support for STACK WIN unwinding
Summary:
This patch makes it possible to unwind via breakpad STACK WIN records.
It is "basic" because two important features are missing:
- support for the .raSearch keyword
- support for multiple STACK WIN records within a single function
Right now, we just reject the .raSearch records, and always pick the
first record for the whole function
SymbolFileBreakpad, and so I think it can serve as a good example of
what is needed of the symbol file and unwinding machinery to make this
work.

However, it is already useful for unwinding in some situations, and it
sets up the general framework for the parsing of these kinds of records,
which reduces the size of the followup patches implementing the two
other components.

Reviewers: amccarth, rnk, markmentovai

Subscribers: lldb-commits

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

llvm-svn: 371017
2019-09-05 07:05:15 +00:00
Jonas Devlieghere 0910e17d52 [Disassembler] Simplify a few methods (2/2) (NFC)
Use early returns to highlight preconditions and make the code easier to
follow.

llvm-svn: 370998
2019-09-04 23:05:32 +00:00
Jonas Devlieghere 4be6706eb6 [Disassembler] Simplify a few methods (NFC)
Use early returns to highlight preconditions and make the code easier to
follow.

llvm-svn: 370994
2019-09-04 22:38:20 +00:00
Adrian Prantl 2461061168 Upstream macCatalyst support in debugserver and the macOS dynamic loader
plugin.

Unfortunately the test is currently XFAILed because of missing changes
to the clang driver.

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

llvm-svn: 370931
2019-09-04 17:23:15 +00:00
Pavel Labath 0522975246 disassemble command: fix error message when disassembly fails
We were printing the start_addr field, which is not correct, as in this
branch we are processing the memory described by cur_range. Print that
instead.

Ideally, in particular this case, the error message would also say
something about not being able to disassemble due to not having found
the module from the core file, but that is not easy to do right now, so
I'm leaving that for another time.

llvm-svn: 370898
2019-09-04 13:26:41 +00:00
Raphael Isemann f8b476282e [lldb] Fix log statement in Socket::Write
We change num_bytes in this method, so this doesn't actually
log the parameter that we called the function with. No test
as we don't test logging code.

llvm-svn: 370887
2019-09-04 12:38:43 +00:00
Raphael Isemann e5814d78ce [lldb] Limit the amount of zeroes we use for padding when printing small floats
Summary:
We got a radar that printing small floats is not very user-friendly in LLDB as we print them with up to
100 leading zeroes before starting to use scientific notation. This patch changes this by already using
scientific notation when we hit 6 padding zeroes by default and moves this value into a target setting
so that users can just set this number back to 100 if they for some reason preferred the old behaviour.

This new setting is influencing how we format data, so that's why we have to reset the data visualisation
cache when it is changed.

Note that we have always been using scientific notation for large numbers because it seems that
the LLVM implementation doesn't support printing out the padding zeroes for them. I would have fixed
that if it was trivial, but looking at the LLVM implementation for this it seems that this is not as trivial
as it sounds. I would say we look into this if we ever get a bug report about someone wanting to have
a large amount of trailing zeroes in their numbers instead of using scientific notation.

Fixes rdar://39744137

Reviewers: #lldb, clayborg

Reviewed By: clayborg

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 370880
2019-09-04 11:41:23 +00:00
Jan Kratochvil 5aa1d81969 Code cleanup: Change FormattersContainer::KeyType from SP to rvalue
There is now std::shared_ptr passed around which is expensive for manycore
CPUs. Most of the times (except for 3 cases) it is now just std::moved with no
CPU locks needed. It also makes it possible to sort the keys (which is now not
needed much after D66398).

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

llvm-svn: 370863
2019-09-04 09:47:18 +00:00
Raphael Isemann 42fb94993d [lldb][NFC] Rename ReadRegisterValue to PrintRegisterValue
That was the actual name I had in mind, but it seems git didn't pick
that change up when committing my previous commit.

llvm-svn: 370856
2019-09-04 09:18:10 +00:00
Raphael Isemann ac6aff70a8 [lldb][NFC] Remove WriteRegister copy-pasta from ObjectFileMachO
The function had the same name as one of the member function, so
it was just copied to all classes so that the lookup works. We
could also give the function a more better and unique name
(because it's actually printing the register value and writing
to the stream, not writing to the register).

Also removes the unused return value.

llvm-svn: 370854
2019-09-04 09:10:28 +00:00
Raphael Isemann b187eef616 [lldb][NFC] Remove unused overload of File::Read
Summary: It's neither used or tested here and in swift-lldb, so let's get rid of it.

Reviewers: #lldb, davide

Reviewed By: #lldb, davide

Subscribers: davide, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 370802
2019-09-03 18:11:14 +00:00
Michal Gorny 3276fffc17 [lldb] Replace std::call_once() with llvm::call_once()
Remove the single instance of std::call_once() in lldbTarget library
with llvm::call_once().  The former fails to build on NetBSD when
combined with llvm::once_flag (which replaced std::once_flag
in r369618), and combining the two is probably generally incorrect
anyway.

llvm-svn: 370748
2019-09-03 12:31:24 +00:00
Raphael Isemann 607c92afda [lldb] Test 'frame select -r' and fix that INT32_MIN breaks the option parser
llvm-svn: 370734
2019-09-03 10:15:45 +00:00
Raphael Isemann d77ea5b297 [lldb] Test 'command' commands and fix the found crashes
llvm-svn: 370712
2019-09-03 09:06:12 +00:00
Pavel Labath eafede2afe [dotest] Add @skipIfCursesSupportMissing and annotate the new gui test
Summary:
The gui command requires curses support, which can be disabled at
compile time. This patch adds the ability to detect this situation in
the test suite and skip the test accordingly.

Reviewers: teemperor, jankratochvil

Subscribers: lldb-commits

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

llvm-svn: 370658
2019-09-02 13:33:12 +00:00
Pavel Labath 3f3673ead9 NativeProcessLinux: Remove some register context boilerplate
Summary:
This patch follows the spirit of D63594, and removes some null checks
for things which should be operating invariants. Specifically
{Read,Write}[GF]PR now no longer check whether the supplied buffers are
null, because they never are. After this, the Do*** versions of these
function no longer serve any purpose and are inlined into their callers.

Other cleanups are possible here too, but I am taking this one step at a
time because this involves a lot of architecture-specific code, which I
don't have the hardware to test on (I did do a build-test though).

Reviewers: mgorny, jankratochvil, omjavaid, alexandreyy, uweigand

Subscribers: nemanjai, javed.absar, kbarton, lldb-commits

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

llvm-svn: 370653
2019-09-02 12:50:18 +00:00
Omair Javaid 1da33fd4ef [ARM64] Simplify RegisterInfos_arm64.h with macro based RegisterInfo array
This patches paves way for upcoming SVE RegisterInfo definitions. This is cosmetic change which allows us to define ARM64 RegisterInfo using macros.

In future we ll have define two different RegisterInfos to choose between SVE vs non-SVE RegisterInfo with decision being made at thread creation.

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

llvm-svn: 370644
2019-09-02 11:53:29 +00:00
Raphael Isemann 6897a814e6 [lldb] Add description to option completions.
Summary:
Right now our argument completions are rather cryptic for command options as they only list the letters:

```
(lldb) breakpoint set -
Available completions:
	-G
	-C
	-c
	-d
	-i
	-o
	-q
	-t
	-x
[...]
```

With the new completion API we can easily extend this with the flag description so that it looks like this now:

```
(lldb) breakpoint set -
Available completions:
	-G -- The breakpoint will auto-continue after running its commands.
	-C -- A command to run when the breakpoint is hit, can be provided more than once, the commands will get run in order left to right.
	-c -- The breakpoint stops only if this condition expression evaluates to true.
	-d -- Disable the breakpoint.
	-i -- Set the number of times this breakpoint is skipped before stopping.
	-o -- The breakpoint is deleted the first time it stop causes a stop.
	-q -- The breakpoint stops only for threads in the queue whose name is given by this argument.
	-t -- The breakpoint stops only for the thread whose TID matches this argument.
	-x -- The breakpoint stops only for the thread whose index matches this argument.
```

The same happens with --long-options now.

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: labath, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 370628
2019-09-02 08:34:57 +00:00
Raphael Isemann 434b81d0a2 [lldb] Test and fix invalid log command invocations
llvm-svn: 370619
2019-09-01 19:29:01 +00:00
Raphael Isemann 04a4c0910b [lldb] Unify target checking in CommandObject
Summary:
We currently have several CommandObjects that manually reimplement the checking for a selected target
or a target in the execution context (which is the selected target when they are invoked). This patch removes
all these checks and replaces them by setting the eCommandRequiresTarget flag that Pavel suggested. With
this flag we are doing the same check but without having to duplicate this code in all these CommandObjects.

I also added a `GetSelectedTarget()` variant of the `GetSelectedOrDummyTarget()` function to the
CommandObject that checks that the flag is set and then returns a reference to the target. I didn't rewrite
all the `target` variables from `Target *` to `Target &` in this patch as last time this change caused a lot of merge
conflicts in Swift and I would prefer having that in a separate NFC commit.

Reviewers: labath, clayborg

Reviewed By: labath, clayborg

Subscribers: clayborg, JDevlieghere, jingham, amccarth, abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 370571
2019-08-31 09:41:25 +00:00
Raphael Isemann b0ca908808 [lldb][NFC] Move Clang-specific flags to ClangUserExpression
LLVMUserExpression doesn't use these variables and they are all specific to Clang.

Also removes m_const_object as this was actually never used by anyone (and Clang
didn't report it as we assigned it in the constructor which seems to count as use).

llvm-svn: 370440
2019-08-30 07:44:29 +00:00
Raphael Isemann b859168ec9 [lldb][NFC] Document options parameter in ClangUserExpression constructor
Somehow this option was only documented in the swift branch.

llvm-svn: 370395
2019-08-29 18:53:20 +00:00
Davide Italiano 6347aa5d16 Revert "[TSanRuntime] Upstream thread swift race detector."
Sometimes it's easier to resolve merge conflict than arguing.

llvm-svn: 370385
2019-08-29 17:14:25 +00:00
Pavel Labath f07b4aff06 Fix GetDIEForDeclContext so it only returns entries matching the provided context
Currently, we return all the entries such that their decl_ctx pointer >= decl_ctx provided.
Instead, we should return only the ones that decl_ctx pointer == decl_ctx provided.

Differential Revision: https://reviews.llvm.org/D66357
Patch by Guilherme Andrade <guiandrade@google.com>.

llvm-svn: 370374
2019-08-29 15:30:52 +00:00
Pavel Labath ef82098a80 Remove DWARFExpression::LocationListSize
Summary:
The only reason for this function's existance is so that we could pass
the correct size into the DWARFExpression constructor. However, there is
no harm in passing the entire data extractor into the DWARFExpression,
since the same code is performing the size determination as well as the
subsequent parse. So, if we get malformed input or there's a bug in the
parser, we'd compute the wrong size anyway.

Additionally, reducing the number of entry points into the location list
parsing machinery makes it easier to switch the llvm debug_loc(lists)
parsers.

While inside, I added a couple of tests for invalid location list
handling.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, javed.absar, kristof.beyls, lldb-commits

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

llvm-svn: 370373
2019-08-29 15:21:26 +00:00
Davide Italiano a633d29ba1 [TSanRuntime] Upstream thread swift race detector.
Summary:
This is self-contained, and doesn't need anything in the
compiler to work. Mainly to reduce the diff between upstream
and downstream.

Patch by Kuba Mracek!

Reviewers: kubamracek

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 370286
2019-08-29 01:39:26 +00:00
Alex Langford 3e45e3ba95 [Core] Use GetAPInt instead of constructing APInts in place
GetAPInt should be able to handle all cases. I have plans to generalize
the float dumping logic and this makes it easier to do later.

llvm-svn: 370255
2019-08-28 20:15:57 +00:00
Raphael Isemann 2f323fc790 [lldb][NFC] Refactor and document ClangASTContext::IsOperator
Should make it clearer what actually is going on in there.

llvm-svn: 370201
2019-08-28 13:46:01 +00:00
Raphael Isemann efb8b7b1ec [lldb] Fix and test completion for ambiguous long options
The refactoring patch for the option completion broke the completion
for ambiguous long options. As this feature was also untested (as
testing ambiguous options with the current test methods is impossible),
I just noticed now. This patch restores the old behavior and adds a
test for this feature.

llvm-svn: 370185
2019-08-28 10:17:23 +00:00
Raphael Isemann ac5a475b53 [lldb][NFC] Get rid of C-strings in HandleOptionCompletion
llvm-svn: 370179
2019-08-28 09:32:30 +00:00
Jason Molenda deeda85f3f Update name of objc runtime SPI function we call for class names.
A new SPI was added to the objc runtime to get class names without
any demangling; AppleObjCRuntimeV2::ParseClassInfoArray was using
the original prototype name but had not been updated for the final
name yet, so lldb was falling back to the old function and doing
extra work for classes that were demangled.  This commit fixes that.

llvm-svn: 370152
2019-08-28 02:14:07 +00:00
Adrian Prantl 29db51dad4 Revert "[lldb] Move redundant persistent variable counter to ClangPersistentVariables"
This reverts commit r367842 since it wasn't quite as NFC as advertised
and broke Swift support.  See https://reviews.llvm.org/D46083 for the
rationale behind the original functionality.

rdar://problem/54619322

llvm-svn: 370126
2019-08-27 22:50:40 +00:00
Nathan Lanza 0c01d92051 [Platform/Android] Read the adb server from an env variable if set
Summary:
The environment variable ANDROID_ADB_SERVER_PORT can be defined to have
adbd litsen on a different port. Teach lldb how to understand this via
simply checking the env var.

Reviewers: xiaobai, clayborg

Subscribers: srhines

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

llvm-svn: 370106
2019-08-27 20:00:02 +00:00
Tatyana Krasnukha 900f9ba217 [lldb] Fix x86 compilation
Differential Revision: https://reviews.llvm.org/D66655

Patch by Leonid Mashinskiy

llvm-svn: 370078
2019-08-27 17:22:03 +00:00
Raphael Isemann 5edee822d2 [lldb] Allow partial completions to fix directory completion.
On the command line we usually insert a space after a completion to indicate that
the completion was successful. After the completion API refactoring, this also
happens with directories which essentially breaks file path completion (as
adding a space terminates the path and starts a new arg). This patch restores the old
behavior by again allowing partial completions. Also extends the iohandler
and SB API tests as the implementation for this is different in Editline
and SB API.

llvm-svn: 370043
2019-08-27 11:32:22 +00:00
Pavel Labath e588b8b664 DWARFExpression: Simplify class interface
Summary:
The DWARFExpression methods have a lot of arguments. This removes two of
them by removing the ability to slice the expression via two offset+size
parameters. This is a functionality that it is not always needed, and
when it is, we already have a different handy way of slicing a data
extractor which we can use instead.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, lldb-commits

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

llvm-svn: 370027
2019-08-27 07:49:41 +00:00
Pavel Labath 3131aed59b Fix an unused variable warning in no-assert builds
llvm-svn: 370026
2019-08-27 07:46:07 +00:00
Pavel Labath 365b30a3fa CommandObjectExpression: Fix a misleading-indentation warning
llvm-svn: 370019
2019-08-27 06:42:42 +00:00
Jonas Devlieghere ece176e0f6 [ConnectionFileDescriptor] Add shutdown check in ::Write.
The disconnect method sets the shutdown flag to true. This currently
only prevents any reads from happening, but not writes, which is
incorrect. Presumably this was just an oversight when adding
synchronization to the class. This adds the same shutdown check to the
Write method.

Over-the-shoulder reviewed by Jim!

llvm-svn: 370002
2019-08-27 01:34:16 +00:00
Alex Langford 5e777e1ed2 [Core] GetAPInt should return an Optional
The current implementation returns a bool for indicating success and
whether or not the APInt passed by reference was populated. Instead of
doing that, I think it makes more sense to return an Optional<APInt>.

llvm-svn: 369970
2019-08-26 21:09:57 +00:00
Raphael Isemann cb2380c9fa [lldb][NFC] Remove dead code that handles situations where LLDB has no dummy target
Summary:
We always have a dummy target, so any error handling regarding a missing dummy target is dead code now.
Also makes the CommandObject methods that return Target& to express this fact in the API.

This patch just for the CommandObject part of LLDB. I'll migrate the rest of LLDB in a follow-up patch that's WIP.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 369939
2019-08-26 18:12:44 +00:00
Pavel Labath 341df3f13a Really fix the type mismatch error in GDBRemoteCommunicationServerCommon
My previous attempt in attempt in r369904 actually broke the 32bit build
because File::Read expects to take a reference to size_t. Fix the
warning by using SIZE_MAX to denote failure instead.

llvm-svn: 369910
2019-08-26 13:56:33 +00:00
Tatyana Krasnukha 55aafa35ea [ProcessWindows] Remove equivalent macros
llvm-svn: 369908
2019-08-26 13:35:59 +00:00
Pavel Labath 602f29fd7c ProcessInstanceInfo: Fix dumping of invalid user ids
Don't attempt to print invalid user ids. Previously, these would come
out as UINT32_MAX, or as an assertion failure.

llvm-svn: 369906
2019-08-26 13:03:21 +00:00
Pavel Labath 27f56c1200 Fix a type mismatch error in GDBRemoteCommunicationServerCommon
GetU64 returns a uint64_t. Don't store it in size_t as that is only
32-bit on 32-bit platforms.

llvm-svn: 369904
2019-08-26 12:42:28 +00:00
Pavel Labath c7deb7f808 Postfix: move more code out of the PDB plugin
Summary:
Previously we moved the code which parses a single expression out of the PDB
plugin, because that was useful for DWARF expressions in breakpad. However, FPO
programs are used in breakpad files too (when unwinding on windows), so this
completes the job, and moves the rest of the FPO parser too.

Reviewers: amccarth, aleksandr.urakov

Subscribers: aprantl, markmentovai, rnk, lldb-commits

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

llvm-svn: 369894
2019-08-26 11:44:14 +00:00
Pavel Labath 0a9f47d7cc Breakpad: Add support for parsing STACK WIN records
Summary: The fields that aren't useful for us right now are simply ignored.

Reviewers: amccarth, markmentovai

Subscribers: rnk, lldb-commits

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

llvm-svn: 369892
2019-08-26 11:25:28 +00:00
Raphael Isemann d43d912b4b [lldb] Construct the dummy target when the first Debugger object is constructed
Summary:
We should always have a dummy target, so we might as well construct it directly when we create a Debugger object.

The idea is that if this patch doesn't cause any problems that we can get rid of all the logic
that handles situations where we don't have a dummy target (as all that code is currently
untested as there seems to be no way to have no dummy target in LLDB).

Reviewers: labath, jingham

Reviewed By: labath, jingham

Subscribers: jingham, abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 369885
2019-08-26 09:20:59 +00:00
Raphael Isemann 72ca5f3694 [lldb][NFC] Add ProcessInfo::GetNameAsStringRef to simplify some code
llvm-svn: 369880
2019-08-26 08:22:52 +00:00
Jonas Devlieghere 0a8a225f8e [NFC] Fix comments and formatting.
llvm-svn: 369827
2019-08-23 23:56:19 +00:00
Adrian Prantl f869ec8d49 Upstream support for macCatalyst Mach-O binaries.
On macOS one Mach-O slice can contain multiple load commands: One load
command for being loaded into a macOS process and one load command for
being loaded into a macCatalyst process. This patch adds support for
the new load command and makes sure ObjectFileMachO returns the
Architecture that matches the Module.

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

llvm-svn: 369814
2019-08-23 21:28:14 +00:00
Saleem Abdulrasool e7823a5316 Windows: explicitly cast constants to `DWORD`
STATUS_SINGLE_STEP and STATUS_BREAKPOINT are defined as 0x8------ which
is negative and thus can't be implicitly narrowed to a DWORD which is
unsigned.  The value is defined differently across winnt.h and ntstatus.h.

Patch by Gwen Mittertreiner!

llvm-svn: 369788
2019-08-23 17:58:53 +00:00
Alex Langford cb68bd726d [Symbol] Decouple clang from DeclVendor
Summary:
This removes DeclVendor's dependency on clang (and ClangASTContext).
DeclVendor has no need to know about specific TypeSystems.

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

llvm-svn: 369735
2019-08-23 06:11:32 +00:00
Jonas Devlieghere 6c9dc12caa [LLDB] Address post-commit code review feedback.
This patch addresses Adrian McCarthy's code review feedback in
https://reviews.llvm.org/D66447

llvm-svn: 369731
2019-08-23 04:11:38 +00:00
Adrian Prantl aa97a89d83 Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch.

In multi-language projects it is extremely common to have, e.g., a
Clang type and a similarly-named rendition of that same type in
another language. When searching for a type It is much cheaper to pass
a set of supported languages to the SymbolFile than having it
materialize every result and then rejecting the materialized types
that have the wrong language.

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

<rdar://problem/54471165>

This reapplies r369690 with a previously missing constructor for LanguageSet.

llvm-svn: 369710
2019-08-22 21:45:58 +00:00
Adrian Prantl b041602e3f Revert Extend FindTypes with CompilerContext to allow filtering by language.
This reverts r369690 (git commit aa3a564efa)

llvm-svn: 369702
2019-08-22 20:41:16 +00:00
Adrian Prantl 83108e7556 Rename lldb/source/Interpreter/OptionValueFileSpecListTmp.cpp to
lldb/source/Interpreter/OptionValueFileSpecList.cpp (NFC)

llvm-svn: 369699
2019-08-22 20:10:24 +00:00
Adrian Prantl 06d778f00a Rename lldb/source/Interpreter/OptionValueFileSpecLIst.cpp to
lldb/source/Interpreter/OptionValueFileSpecListTmp.cpp (NFC)

llvm-svn: 369698
2019-08-22 20:08:46 +00:00
Adrian Prantl aa3a564efa Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch.

In multi-language projects it is extremely common to have, e.g., a
Clang type and a similarly-named rendition of that same type in
another language. When searching for a type It is much cheaper to pass
a set of supported languages to the SymbolFile than having it
materialize every result and then rejecting the materialized types
that have the wrong language.

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

<rdar://problem/54471165>

llvm-svn: 369690
2019-08-22 19:24:55 +00:00
Adrian Prantl 9a0f124f26 Remove redundant curly braces.
llvm-svn: 369670
2019-08-22 16:58:56 +00:00
Raphael Isemann 4ae79199ed [lldb] Remove ')' to fix the build
That ')' slipped in by accident in the reformatting commit.

llvm-svn: 369660
2019-08-22 15:18:40 +00:00
Jan Kratochvil b17d6c52fd [lldb] Fix `TestDataFormatterStdList` regression
Since D66174 I see failures of TestDataFormatterStdList in about 50% of runs on
Fedora 30 x86_64 libstdc++. I have found out that LLDB internally expects these
RegularExpressions to be matched in their alphabetical order:
	^std::(__cxx11::)?list<.+>(( )?&)?$
	^std::__[[:alnum:]]+::list<.+>(( )?&)?$

But since D66174 they are sometimes matched in reverse order. In fact it was
only some luck it worked before as there is internally
std::map<lldb::RegularExpressionSP, FormatterImpl> (FormattersContainer).

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

llvm-svn: 369655
2019-08-22 14:29:52 +00:00
Raphael Isemann 00235e1b92 [lldb][NFC] Fix indentation in CommandObjectProcess
llvm-svn: 369652
2019-08-22 13:50:54 +00:00
Raphael Isemann 494370c101 [lldb][NFC] Remove unused return value from HandleOptionArgumentCompletion
llvm-svn: 369635
2019-08-22 09:14:42 +00:00
Raphael Isemann 1153dc9603 [lldb][NFC] NFC cleanup for the completion code
llvm-svn: 369632
2019-08-22 09:02:54 +00:00
Raphael Isemann 36162014c4 [lldb][NFC] Remove dead code that is supposed to handle invalid command options
Summary:
We currently have a bunch of code that is supposed to handle invalid command options, but
all this code is unreachable because invalid options are already handled in `Options::Parse`.
The only way we can reach this code is when we declare but then not implement an option
(which will be made impossible with D65386, which is also when we can completely remove
the `default` cases).

This patch replaces all this code with `llvm_unreachable` to make clear this is dead code
that can't be reached.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 369625
2019-08-22 08:08:05 +00:00
Raphael Isemann ae34ed2c0d [lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:

* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.

I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.

A few words why those things should be removed/replaced:

* The return values are really cryptic, partly redundant and rarely documented.
  They are also completely ignored by Xcode, so whatever information they contain will end up
  breaking Xcode's completion mechanism. They are also partly impossible to even implement
  as we assign negative values special meaning and our completion API sometimes returns size_t.

  Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
  in some untested code path to expand the history repeat character to the full command, but
  I haven't figured out why that doesn't work at the moment.
  Completion functions return -1 to 'insert the completion character', but that isn't implemented
  (even though we seem to activate this feature in LLDB sometimes).
  All positive values have to match the number of results. This is obviously just redundant information
  as the user can just look at the result list to get that information (which is what Xcode does).

* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
  reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
  that we calculate this to make the life of the API caller easier, but obviously forcing people to have
  1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
  0-based like Xcode has to do).

* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
  idea is that we let the top-level API know that we just provided a full completion. Interestingly we
  `WordComplete` is just a single bool that somehow represents all N completions. And we always
  provide full completions in LLDB, so in theory it should always be true.
  The only use it currently serves is providing redundant information about whether we have a single
  definitive completion or not (which we already know from the number of results we get).

This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.

For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).

I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: arphaman, abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 369624
2019-08-22 07:41:23 +00:00
Jonas Devlieghere 2621f7bdb4 [FormatManage] Fix the format info order
The format info entries need to match the order of the enum entries.
This should fix the two failing data-formatter tests.

llvm-svn: 369617
2019-08-22 03:12:25 +00:00
Jonas Devlieghere 12002fbd21 [FormatManager] Add static_assert to keep formats in sync.
This adds a static assert that ensures that there's a format info entry
for every format enum value. This should prevent others from making the
same mistake I made and Jason kindly fixed in r369611. (Thanks!)

llvm-svn: 369614
2019-08-22 02:56:00 +00:00
Jason Molenda ca4409b4dc The g_format_infos table needs to be updated in concert with the
enum Format entries; else we can crash in a place like
FormatManager::GetFormatAsCString().  We should add  bounds checks
to prevent this more reliably, but for tonight I'm just adding this
entry to keep an address-sanitizer test run working.

llvm-svn: 369611
2019-08-22 02:06:03 +00:00
Jonas Devlieghere c46d39b9e8 Add char8_t support (C++20)
This patch adds support for the char8_t type introduced in C++20
char8_t. The original patch was submitted by James Blachly  on the LLDB
mailing list [1]. I modified the patch a bit and added a test.

[1] http://lists.llvm.org/pipermail/lldb-dev/2019-August/015393.html

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

llvm-svn: 369582
2019-08-21 21:30:55 +00:00
Adrian Prantl 330ae19a1a Generalize FindTypes with CompilerContext to support fuzzy lookup
This patch generalizes the FindTypes with CompilerContext interface to
support looking up a type of unknown kind by name, as well as looking
up a type inside an unspecified submodule. These features are
motivated by the Swift branch, but are fully tested via unit tests and
lldb-test on llvm.org.  Specifically, this patch adds an AnyModule and
an AnyType CompilerContext kind.

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

rdar://problem/54471165

llvm-svn: 369555
2019-08-21 18:06:56 +00:00
Raphael Isemann 34a04e703d [lldb] Add tests for 'settings remove' and fix error message typos
llvm-svn: 369524
2019-08-21 13:24:21 +00:00
Pavel Labath d139e8838a Recommit "Minidump/Windows: Fix module lookup""
This recommits r368416, which was reverted in r368838 because of test
failures under ASAN. These have been dealt with by llvm r369370.

The original commit message was:
When opening a minidump, we were failing to find an executable because
we were searching for i386-unknown-windows, whereas we recognize the
pe/coff files as i386-pc-windows. This fixes the triple computation code
in the minidump parser to match pe/coff, and adds an appropriate test.

NB: I'm not sure setting the vendor to "pc" is really correct for
arm(64) windows, but right now that seems to match what we do in the
pe/coff case (ArchSpec.cpp:935).

Reviewers: clayborg, amccarth

Subscribers: javed.absar, kristof.beyls, rnk, markmentovai, lldb-commits

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

llvm-svn: 369523
2019-08-21 13:20:25 +00:00
Pavel Labath 65a376f091 Fix two compiler warnings
llvm-svn: 369522
2019-08-21 13:11:30 +00:00
Raphael Isemann 006d22de50 [lldb] Add tests for setting completions and enable 'settings remove' completion
llvm-svn: 369521
2019-08-21 12:57:06 +00:00
Pavel Labath 9cb317968a Fix an unused variable warning in ClangASTContext.cpp
llvm-svn: 369503
2019-08-21 08:22:19 +00:00
Alex Langford 7719495e2c [Symbol] Remove unused clang headers from Type
llvm-svn: 369494
2019-08-21 04:56:23 +00:00
Jonas Devlieghere d35b42f20a [NFC] Return llvm::StringRef from StringExtractor::GetStringRef.
This patch removes the two variant of StringExtractor::GetStringRef that
return (non-)const references to std::string. The non-const one was
being abused to reinitialize the StringExtractor and its uses are
replaced by calls to the copy asignment operator. The const variant was
refactored to return an actual llvm::StringRef.

llvm-svn: 369493
2019-08-21 04:55:56 +00:00
Jonas Devlieghere 7483005c59 [NFC] Remove unused function GetHexWithFixedSize
The implementation of this function was obviously incorrect, as the
result variable was never used. This led me to check if it was actually
used anywhere, which came back negative.

llvm-svn: 369492
2019-08-21 04:55:53 +00:00
Jonas Devlieghere dc333e6398 [NFC] Simplify code
This simplifies the code and updates the comments.

llvm-svn: 369491
2019-08-21 04:55:50 +00:00
Jonas Devlieghere 4b3c0fd5da [NFC] Remove lldb_utility namespace.
While generating the Doxygen I noticed this lone namespace that has one
class and one function in it. This moves them into lldb_private.

llvm-svn: 369485
2019-08-21 00:50:46 +00:00
Alex Langford b2232a1af3 [Symbol] Move VerifyDecl to ClangASTContext
VerifyDecl is specific to clang and is only used in ClangASTContext.

llvm-svn: 369456
2019-08-20 22:06:13 +00:00
Alex Langford cb40f89c6e [Symbol][NFC] Remove references to clang in TypeMap
llvm-svn: 369436
2019-08-20 20:44:36 +00:00
Alex Langford 1271521ed8 [ClangExpressionParser] Add ClangDeclVendor
Summary:
This introduces a layer between DeclVendor and the currently implemented
DeclVendors (ClangModulesDeclVendor and AppleObjCDeclVendor). This
allows the removal of DeclVendor::GetImporterSource which is extremely
clang-specific, freeing up the interface to be more general.

A good follow up to this would be to remove the remaining instances of
clang in DeclVendor, either by moving things to ClangDeclVendor or by
using wrappers (e.g. CompilerDecl instead of clang::NamedDecl).

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

llvm-svn: 369424
2019-08-20 18:47:30 +00:00
Jan Kratochvil 1c56d3df19 [lldb] Use the new Regex::isValid() with no parameter
Differential Revision: https://reviews.llvm.org/D66463

llvm-svn: 369398
2019-08-20 16:08:27 +00:00
Jan Kratochvil f9d90bc5f6 [lldb] D66174 `RegularExpression` cleanup
I find as a good cleanup to drop the Compile method. As I do not find TIMTOWTDI
as an advantage and there is already constructor parameter to compile the
regex.

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

llvm-svn: 369352
2019-08-20 09:24:20 +00:00
Saleem Abdulrasool 2e8b57558d Windows: Include "windows" Instead of "Windows"
The actual include directory is lldb/Host/windows not
lldb/Host/Windows which breaks on case sensitive file systems

Patch by Gwen Mittertreiner!

llvm-svn: 369307
2019-08-19 22:45:01 +00:00
Matthias Gehre 8b0d15e43f Fix use-after-free
Summary:
The warning
```
lldb/source/Core/FormatEntity.cpp:2350:25: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling]
```
is emitted after annotating `llvm::StringRef` with `[[gsl::Pointer]]`.

The reason is that in
```
 size_t FormatEntity::AutoComplete(CompletionRequest &request) {
  llvm::StringRef str = request.GetCursorArgumentPrefix().str();
```
the function `GetCursorArgumentPrefix()` returns a `StringRef`, and `StringRef::str()` returns
a temporary `std::string`.

Reviewers: jingham, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 369304
2019-08-19 21:39:16 +00:00
Raphael Isemann 0684132107 [lldb][NFC] Use CompletionRequest in Variable::AutoComplete
llvm-svn: 369252
2019-08-19 11:49:43 +00:00
Raphael Isemann b8639f5c0f [lldb][NFC] Remove StringList::AutoComplete
We don't need this very specific function in StringList that
we only call once in LLDB.

llvm-svn: 369242
2019-08-19 08:15:46 +00:00
Raphael Isemann 81094aad61 [lldb][NFC] Use GetMaxStringLength in CommandObjectApropos::DoExecute
llvm-svn: 369240
2019-08-19 07:59:44 +00:00
Raphael Isemann 21599876be [lldb][NFC] Address review comments to StringList for-loop support
llvm-svn: 369237
2019-08-19 07:22:19 +00:00
Raphael Isemann 37a928efd9 [lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariable
llvm-svn: 369198
2019-08-17 21:57:51 +00:00
Adrian Prantl 69cef325a3 Simplify code (NFC).
llvm-svn: 369179
2019-08-17 00:38:58 +00:00
Jonas Devlieghere 3af3f1e8e2 [Utility] Reimplement RegularExpression on top of llvm::Regex
Originally I wanted to remove the RegularExpression class in Utility and
replace it with llvm::Regex. However, during that transition I noticed
that there are several places where need the regular expression string.
So instead I propose to keep the RegularExpression class and make it a
thin wrapper around llvm::Regex.

This patch also removes the workaround for empty regular expressions.
The result is that we are now (more or less) POSIX conformant.

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

llvm-svn: 369153
2019-08-16 21:25:36 +00:00
Raphael Isemann 4c78b78825 [lldb][NFC] Allow for-ranges on StringList
llvm-svn: 369113
2019-08-16 14:27:35 +00:00
Jonas Devlieghere de0ce98abe [DebugLine] Don't try to guess the path style
In r368879 I made an attempt to guess the path style from the files in
the line table. After some consideration I now think this is a poor
idea. This patch undoes that behavior and instead adds an optional
argument to specify the path style. This allows us to make that decision
elsewhere where we have more information. In case of LLDB based on the
Unit.

llvm-svn: 369072
2019-08-15 23:53:15 +00:00
Jim Ingham 7049b0ad4d Stop-hooks weren't getting called on step-out. Fix that.
There was a little bit of logic in the StopInfoBreakpoint::PerformAction
that would null out the StopInfo once we had a completed plan so that the
next call to GetStopInfo would replace it with the StopInfoThreadPlan.

But the stop-hooks check for whether a thread stopped for a reason didn't
trigger this conversion.  So I added an API to do that directly, and then
called it where before we just reset the StopInfo.

<rdar://problem/54270767>

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

llvm-svn: 369052
2019-08-15 21:37:52 +00:00
Raphael Isemann 2fc20f652c [lldb][NFC] Refactor remaining completion logic to use CompletionRequests
This patch moves the remaining completion functions from the
old completion API (that used several variables) to just
passing a single CompletionRequest.

This is for the most part a simple change as we just replace
the old arguments with a single CompletionRequest argument.

There are a few places where I had to create new CompletionRequests
in the called functions as CompletionRequests itself are immutable
and don't expose their internal match list anymore. This means that
if a function wanted to change the CompletionRequest or directly
access the result list, we need to work around this by creating
a new CompletionRequest and a temporary match/description list.

Preparation work for rdar://53769355

llvm-svn: 369000
2019-08-15 13:14:10 +00:00
Jonas Devlieghere 706cd70569 Fix variable mismatch between signature and body
I updated the signature to conform to the LLDB coding style but
accidentally forgot to update the function body.

llvm-svn: 368962
2019-08-15 05:09:09 +00:00
Jonas Devlieghere a7d4cec437 [NFC] Fix documentation for some utility classes.
This fixes a few warnings emitted when compiling with -Wdocumentation.

llvm-svn: 368959
2019-08-15 04:35:46 +00:00
Shafik Yaghmour 62abe494fb Improve anonymous class heuristic in ClangASTContext::CreateRecordType
Summary:
Currently the heuristic used in ClangASTContext::CreateRecordType to identify an anonymous class is that there is that name is a nullptr or simply a null terminator. This heuristic is not accurate since it will also sweep up unnamed classes and lambdas. The improved heuristic relies on the requirement that an anonymous class must be contained within a class.

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

llvm-svn: 368937
2019-08-14 22:30:29 +00:00
Jonas Devlieghere a8f3ae7c9c [LLDB] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

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

llvm-svn: 368933
2019-08-14 22:19:23 +00:00
Raphael Isemann 66214b581c Revert "[lldb] Reinstate original guard variable check"
It seems this breaks the following tests:
    lldb-Suite :: expression_command/call-function/TestCallUserDefinedFunction.py
    lldb-Suite :: expression_command/rdar42038760/TestScalarURem.py

Let's revert this patch and wait until we find an actual issue that could be
fixed by also doing the guard variable check on Windows.

llvm-svn: 368920
2019-08-14 21:21:14 +00:00
Jordan Rupprecht 4ee1376dc6 [lldb][NFC] Remove unused function
llvm-svn: 368904
2019-08-14 19:31:56 +00:00
Jonas Devlieghere c0a9b1edca [DebugLine] Improve path handling.
After switching over LLDB's line table parser to libDebugInfo, we
noticed two regressions on the Windows bot. The problem is that when
obtaining a file from the line table prologue, we append paths without
specifying a path style. This leads to incorrect results on Windows for
debug info containing Posix paths:

  0x0000000000201000: /tmp\b.c, is_start_of_statement = TRUE

This patch is an attempt to fix that by guessing the path style whenever
possible.

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

llvm-svn: 368879
2019-08-14 17:00:10 +00:00
Pavel Labath b8ee0dd723 Revert "Minidump/Windows: Fix module lookup"
Although there is nothing wrong with this patch, the test added here
uncovers a problem in other parts of the code which cause the test to
fail when running under asan. Reverting the patch until I can fix the
underlying issue(s).

This reverts commit r368416.

llvm-svn: 368838
2019-08-14 12:26:51 +00:00
Pavel Labath 72ef113d40 [API] Have SBCommandReturnObject::GetOutput/Error return "" instead of nullptr
Summary:
It seems this was an unintended side-effect of D26698. AFAICT, these
functions did return an empty string before that patch, and the patch
contained code which attempted to ensure that, but those efforts were
negated by ConstString::AsCString, which by default returns a nullptr
even for empty strings.

This patch:
- fixes the GetOutput/Error methods to really return empty strings
- adds and explicit test for that
- removes a workaround in lldbtest.py, which was masking this problem
  from our other tests

Reviewers: jingham, clayborg

Subscribers: zturner, lldb-commits

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

llvm-svn: 368806
2019-08-14 08:11:20 +00:00
Raphael Isemann afd493ea2b [lldb] Reinstate original guard variable check
The isGuardVariableSymbol option for ignoring Microsoft's ABI
was originally added to get the bots green, but now that we found
the actual issue (that we checked for prefix instead of suffix
in the MS ABI check), we should be able to properly implement
the guard variable check without any strange Microsoft exceptions.

llvm-svn: 368802
2019-08-14 05:52:33 +00:00
Jonas Devlieghere b6946a2d12 Fix warning: suggest braces around initialization of subobject
This patch adds braces to the DEFINE_XMM macro.

llvm-svn: 368782
2019-08-14 01:25:10 +00:00
Aaron Smith 216944ee03 Enable lldb-server on Windows
Summary:
This commit contains three small changes to enable lldb-server on Windows.

- Add lldb-server for Windows to the build
- Disable pty redirection on Windows for the initial lldb-server bring up
- Add a support to get the parent pid for a process on Windows
- Ifdef some signals which aren't supported on Windows

Thanks to Hui Huang for the help with this patch!

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere, compnerd, Hui, amccarth, xiaobai, srhines, mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 368774
2019-08-13 23:50:54 +00:00
Jonas Devlieghere 3cb3aa2ee8 [DebugLine] Be more robust in geussing the path style
My previous change didn't fix the Windows bot. This patch is an attempt
to make guessing the path style more robust by first looking at the
compile dir and falling back to the actual file if that's unsuccessful.

llvm-svn: 368772
2019-08-13 23:30:11 +00:00
Aaron Smith 5146a9ea5d Initial support for native debugging of x86/x64 Windows processes
Summary: Thanks to Hui Huang and the reviewers for all the help with this patch.

Reviewers: labath, Hui, jfb, clayborg, amccarth

Reviewed By: labath

Subscribers: amccarth, compnerd, dexonsmith, mgorny, jfb, teemperor, lldb-commits

Tags: #lldb

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

llvm-svn: 368759
2019-08-13 22:18:01 +00:00
Jonas Devlieghere 4d82fa6895 [DWARF] Guess the path style
Try to guess the FileSpec path style before defaulting to native.

llvm-svn: 368746
2019-08-13 21:00:27 +00:00
Jonas Devlieghere 235339357d [DWARF} Use LLVM's debug line parser in LLDB.
The line number table header was substantially revised in DWARF 5 and is
not fully supported by LLDB's current debug line implementation.

This patch replaces the LLDB debug line parser with its counterpart in
LLVM. This was possible because of the limited contact surface between
the code to parse the DWARF debug line section and the rest of LLDB.

We pay a small cost in terms of performance and memory usage. This is
something we plan to address in the near future.

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

llvm-svn: 368742
2019-08-13 19:51:51 +00:00
Alex Langford bddab07d4a [Symbol] Decouple clang from CompilerType
Summary:
Ideally CompilerType would have no knowledge of clang or any individual
TypeSystem. Decoupling clang is relatively straightforward.

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

llvm-svn: 368741
2019-08-13 19:40:36 +00:00
Raphael Isemann a23b25031e [lldb] Fix Microsoft guard variable detection
Apparently we need to check for a suffix, not a prefix. This broke
probably broke expression evaluation on Windows.

llvm-svn: 368695
2019-08-13 14:13:39 +00:00
Raphael Isemann 7f7b2966f7 [lldb] Reland "Refactor guard variable checks in IRForTarget"
It seems the broken guard variable check for Windows was a feature(TM)
and not a bug, so let's keep add a flag to the guard check that keeps
the old behavior in the places where we ignored guard variables before.

llvm-svn: 368688
2019-08-13 13:09:18 +00:00
Alex Langford f4446f1775 [Symbol] Remove redundant include
llvm-svn: 368638
2019-08-13 00:25:49 +00:00
Davide Italiano 7f9bbe0599 [CompilerType] Pass an ExecutionContextScope to GetTypeBitAlign.
llvm-svn: 368620
2019-08-12 21:49:54 +00:00
Stella Stamenova 532e724992 Revert "[lldb] Refactor guard variable checks in IRForTarget"
This reverts commit 94fbbf712e.

llvm-svn: 368616
2019-08-12 20:08:07 +00:00
Stella Stamenova e7daf78e05 Revert "[lldb] Fix dynamic_cast by no longer failing on variable without metadata"
This reverts commit b448d1bf21.

llvm-svn: 368615
2019-08-12 20:08:05 +00:00
Davide Italiano 36f13e4912 [Symbol] GetTypeBitAlign() should return None in case of failure.
Summary:
And not `zero`. This is the last API needed to be converted to
an Optional<T>.

Reviewers: xiaobai, compnerd

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 368614
2019-08-12 20:03:19 +00:00
Raphael Isemann 8940687c6d [lldb] Remove undocumented return value from DiagnosticManager::PutString
The returned value is currently unused. It also seems to imply that
it somehow represents 'printf-style' the number of characters/bytes
written to some output stream (which is incorrect, as we only know
the actual size of the written message when we have rendered it,
e.g. via GetString and DiagnosticManagers have no associated
output stream).

llvm-svn: 368577
2019-08-12 14:11:37 +00:00
Raphael Isemann b448d1bf21 [lldb] Fix dynamic_cast by no longer failing on variable without metadata
Summary:
Our IR rewriting infrastructure currently fails when it encounters a variable which has no metadata associated.
This causes dynamic_cast to fail as in this case IRForTarget considers the type info pointers ('@_ZTI...') to be
variables without associated metadata. As there are no variables for these internal variables, this is actually
not an error and dynamic_cast would work fine if we didn't throw this error.

This patch fixes this by removing this diagnostics code. In case we would actually hit a variable that has no
metadata (but is supposed to have), we still have the error in the expression log so this shouldn't make it
harder to diagnose any missing metadata errors.

This patch should fix dynamic_cast and also adds a bunch of test coverage to that language feature.

Fixes rdar://10813639

Reviewers: davide, labath

Reviewed By: labath

Subscribers: friss, labath, abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 368511
2019-08-10 10:56:17 +00:00
Haibo Huang 575ce5da7d Small format fix
Differential Revision: https://reviews.llvm.org/D66034

llvm-svn: 368497
2019-08-09 22:59:56 +00:00
Haibo Huang a20a59d87a Detects whether RESOURCE_TYPE_IO is defined.
Summary: This fixes lldb build on macOS SDK prior to 10.12.

Reviewers: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 368496
2019-08-09 22:47:46 +00:00
Raphael Isemann 19351b24ca [lldb][NFC] Assert on invalid cursors positions when creating CompletionRequest
Before we just triggered undefined behavior on invalid positions.

llvm-svn: 368444
2019-08-09 14:32:50 +00:00
Raphael Isemann db7d874b71 [lldb][NFC] Remove unused IRForTarget::BuildRelocation
llvm-svn: 368442
2019-08-09 14:21:27 +00:00
Raphael Isemann ac42e741e0 [lldb][NFC] Unify InstrList typedef in IRForTarget
llvm-svn: 368425
2019-08-09 10:01:51 +00:00
Raphael Isemann 339b5d1ac2 [lldb][NFC] Fix warning about missing switch cases
These types were recently added in D62960 but it seems the patch didn't
consider LLDB which causes a bunch of compiler warnings about
missing enum values. It seems this feature isn't fully implemented yet,
so I don't think we can write any test for this. For now lets just add
the missing types to our usual list of unsupported types.

llvm-svn: 368424
2019-08-09 09:58:47 +00:00
Raphael Isemann 94fbbf712e [lldb] Refactor guard variable checks in IRForTarget
Not NFC as this will probably fix a wrong guard variable check
on Windows. Not sure though what Windows test can now be safely
enabled.

llvm-svn: 368417
2019-08-09 09:27:04 +00:00
Pavel Labath af1744cd6e Minidump/Windows: Fix module lookup
Summary:
When opening a minidump, we were failing to find an executable because
we were searching for i386-unknown-windows, whereas we recognize the
pe/coff files as i386-pc-windows. This fixes the triple computation code
in the minidump parser to match pe/coff, and adds an appropriate test.

NB: I'm not sure setting the vendor to "pc" is really correct for
arm(64) windows, but right now that seems to match what we do in the
pe/coff case (ArchSpec.cpp:935).

Reviewers: clayborg, amccarth

Subscribers: javed.absar, kristof.beyls, rnk, markmentovai, lldb-commits

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

llvm-svn: 368416
2019-08-09 09:10:50 +00:00
Raphael Isemann 4ef50a33b1 [lldb][NFC] Clean up logging in IRForTarget
llvm-svn: 368415
2019-08-09 08:54:01 +00:00
Raphael Isemann 474d70b220 [lldb][NFC] Remove last C string uses from IRForTarget
llvm-svn: 368406
2019-08-09 08:10:02 +00:00
Raphael Isemann dced445b24 [lldb][NFC] Use range-based for-loops in IRForTarget
llvm-svn: 368405
2019-08-09 07:59:18 +00:00
Raphael Isemann 50f7e945ee [lldb][NFC] Modernize IRForTarget::CreateResultVariable
llvm-svn: 368359
2019-08-08 22:19:16 +00:00
Raphael Isemann a7040525ce [lldb][NFC] Move to StringRef in some places in IRForTarget
llvm-svn: 368353
2019-08-08 21:43:21 +00:00
Haibo Huang 7debc93afc [lldb] Fix HAVE_LIBCOMPRESSION
Summary:
This test doesn't make sense. Change to be consistent with what we did
in GDBRemoteCommunication.cpp.

Reviewers: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 368352
2019-08-08 21:42:33 +00:00
Raphael Isemann 7491f36494 [lldb][NFC] Directly use StringRef instead of temporary std::string
llvm-svn: 368346
2019-08-08 21:22:21 +00:00
Adrian Prantl fe9eaadd68 SymbolFileDWARF: Unconditionally scan through clang modules. NFCish
When looking up a type by name, also scan through any referenced Clang
modules regardsless of whether a type with this name has been
found. This is NFCish (= a potential performance regression) for Clang
projects, but necessary in mixed Swift and Objective-C projects (and
tested in swift-lldb).

This only affects projects compiled with -gmodules that were not run
through dsymutil.

llvm-svn: 368345
2019-08-08 21:16:01 +00:00
Jim Ingham 8240b0d7fe Fix a comment which was incorrect.
llvm-svn: 368340
2019-08-08 20:47:40 +00:00
Adrian Prantl d9cbd2acfa Remove unused and undocumented data_offset parameter (NFC)
Value::GetValueAsData() takes an undocumented parameter called
data_offset that is always 0.

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

llvm-svn: 368330
2019-08-08 19:22:32 +00:00
Raphael Isemann 0e5eef5c8f [lldb][NFC] Simplify return in MaybeHandleVariable
This function anyway returns true, no need to do this extra work.

llvm-svn: 368309
2019-08-08 16:41:32 +00:00
Pavel Labath 0de33de813 Fix LLDB_CONFIGURATION_DEBUG builds for the GetSymbolVendor removal
fix one usage that is ifdefed-out in non-debug builds.

llvm-svn: 368279
2019-08-08 11:49:55 +00:00
Pavel Labath 579d6d1aa5 Remove Module::GetSymbolVendor
Summary:
This patch removes the GetSymbolVendor function, and the various
mentions of the SymbolVendor in the Module class. The implementation of
GetSymbolVendor is "inlined" into the GetSymbolFile class which I
created earlier.

After this patch, the SymbolVendor class still exists inside the Module
object, but only as an implementation detail -- a fancy holder for the
SymbolFile. That will be removed in the next patch.

Reviewers: clayborg, JDevlieghere, jingham, jdoerfert

Subscribers: jfb, lldb-commits

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

llvm-svn: 368263
2019-08-08 07:34:07 +00:00
Davide Italiano e04c62bb23 [Materializer] Remove wrong SetSizeAndAlignmentFromType().
This function is unused.  It's also wrong, because it computes
the size and the alignment of the type without asking the runtime,
so it doesn't work for any language that has one (e.g. swift).

One could consider re-implementing this passing an execution scope
context, and modifying GetTypeBitAlign() to do the right thing,
but given there are no uses, it's not really useful.

llvm-svn: 368249
2019-08-08 03:15:48 +00:00
Jonas Devlieghere b78c8a0a35 [Utility] Remove unused function 'GetMatchSpanningIndices'
llvm-svn: 368243
2019-08-08 01:44:03 +00:00
Adrian Prantl f81d6fe75c Adjust a ValueObjectChild's offset when the child is a bitfield
If a bitfield doesn't fit into the child_byte_size'd window at
child_byte_offset, move the window forward until it fits.  The problem
here is that Value has no notion of bitfields and thus the Value's
DataExtractor is sized like the bitfields CompilerType; a sequence of
bitfields, however, can be larger than their underlying type.

This was not in the big-endian-derived DWARF 2 bitfield attributes
because their offsets were counted from the end of the window, so they
always fit.

rdar://problem/53132189

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

llvm-svn: 368226
2019-08-07 22:40:05 +00:00
Jonas Devlieghere 333f14d52d [CommandObject] Remove unused function
llvm-svn: 368208
2019-08-07 20:56:17 +00:00
Alex Langford 4cd04547f5 [Symbol] Remove commented out code from CompileUnit
llvm-svn: 368205
2019-08-07 20:51:21 +00:00
Nico Weber 8883ec7da2 Add support for deterministically linked binaries on macOS to lldb.
When ld64 links a binary deterministically using the flag ZERO_AR_DATE,
it sets a timestamp of 0 for N_OSO members in the symtab section, rather
than the usual last modified date of the object file. Prior to this
patch, lldb would compare the timestamp from the N_OSO member against
the last modified date of the object file, and skip loading the object
file if there was a mismatch. This patch updates the logic to ignore the
timestamp check if the N_OSO member has timestamp 0.

The original logic was added in https://reviews.llvm.org/rL181631 as a
safety check to avoid problems when debugging if the object file was out
of date. This was prior to the introduction of deterministic build in
ld64. lld still doesn't support deterministic build.

Other code in llvm already relies on and uses the assumption that a
timestamp of 0 means deterministic build. For example, commit
9ccfddc39d adds similar timestamp checking
logic to dsymutil, but special cases timestamp 0. Likewise, commit
0d1bb79a04 adds a long comment describing
deterministic archive, which mostly uses timestamp 0 for determinism.

Patch from Erik Chen <erikchen@chromium.org>!

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

llvm-svn: 368199
2019-08-07 19:29:04 +00:00
Jonas Devlieghere 9f75418e1a [Driver] Expand the executable path in the target create output
Resolve the path in the target create output. This is nice when passing
relative paths to the lldb command line driver.

  $ lldb ./binary
  (lldb) target create "./binary"
  Current executable set to '/absolute/path/to/binary' (x86_64).

This change only affects the target create output and does not change
the debugger's behavior. It doesn't resolve symbolic links so it won't
cause confusing when debugging something like clang++ that's symlinked
to clang.

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

llvm-svn: 368182
2019-08-07 16:21:40 +00:00
Jonas Devlieghere af0c828a1e [ExecutionContext] Return the target/process byte order.
Currently ExecutionContext::GetByteOrder() always returns the host byte
order. This seems like a simple mistake: the return keyword appears to
have been omitted by accident. This patch fixes that and adds a unit
test.

Bugreport: https://llvm.org/PR37950

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

llvm-svn: 368181
2019-08-07 16:09:35 +00:00
Pavel Labath b9f31b6f4e ProcessElfCore: Remove linux and freebsd NT_*** constants
These are already defined in llvm/BinaryFormat/ELF.h. Leaving the NetBSD
and OpenBSD constants as-is, as they have no llvm counterparts.

llvm-svn: 368168
2019-08-07 13:12:59 +00:00
Pavel Labath 8280730f96 ObjectFileELF: Remove NT_*** constants
llvm now has definitions of those in BinaryFormat/ELF.h. Use those
instead.

llvm-svn: 368159
2019-08-07 12:13:48 +00:00
Raphael Isemann 44b8e5f4a6 [lldb][NFC] Remove commented out code in ClangASTContext::AddMethodToCXXRecordType
llvm-svn: 368150
2019-08-07 10:59:34 +00:00
Haibo Huang c6551bf013 Detect HAVE_SYS_TYPES_H in lldb
Summary:
After rL368069 I noticed that HAVE_SYS_TYPES_H is not defined in
Platform.h, or anywhere else in lldb. This change fixes that.

Reviewers: labath

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 368125
2019-08-07 06:15:01 +00:00
Jason Molenda 6cebeafac3 Upstream a few small Apple changes to debugserver - arm64_32, Catalyst
Adrian's changes to support Catalyst processes and my
changes to support debugserver running on an arm64_32
device (Apple Watch Series 4, which uses an IPL32 model
on arm64 cpus).

llvm-svn: 368118
2019-08-07 02:06:06 +00:00
Jonas Devlieghere 171dd2e6e5 [Gardening] Remove more dead code from IOHandler
Remove more dead code and reformat the file.

llvm-svn: 368116
2019-08-07 01:50:03 +00:00
Raphael Isemann 4c7b28d6bb [lldb][NFC] Minor refactorings to (Clang)ExpressionSourceCode
llvm-svn: 368082
2019-08-06 20:25:02 +00:00
Alex Langford 5fdf10bae8 [SymbolFile] Remove commented out method
llvm-svn: 368075
2019-08-06 19:47:08 +00:00
Haibo Huang a63417fe6c Various build fixes for lldb on MinGW
Subscribers: mstorsjo, lldb-commits

Tags: #lldb

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

llvm-svn: 368069
2019-08-06 18:20:43 +00:00