Commit Graph

23709 Commits

Author SHA1 Message Date
Jonas Devlieghere 08249d7f72 [lldb] Fix TestAPILog.py for reproducer replay
With the log file being a build artifact we don't need to clean it up.
If this happens before the reproducer is captured, the file will be
missing from the reproducer root but being part of the mapping.
2020-08-21 10:35:35 -07:00
Jonas Devlieghere 2799031a14 [lldb] Skip PDB and NativePDB tests with reproducers 2020-08-21 09:09:45 -07:00
Gongyu Deng e1cd7cac8a [lldb] Tab completion for process load/unload
1. Complete `process load` with the common disk file completion, so there is not test provided for it;
2. Complete `process unload` with the tokens of valid loaded images.

Thanks for Raphael's help on the test for `process unload`.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D79887
2020-08-21 10:36:39 +02:00
Jonas Devlieghere 6ad3de350c [lldb] Fix a new -Wdocumetnation issues (NFC) 2020-08-20 22:59:13 -07:00
Jonas Devlieghere e0b220d22e [lldb] Remove redundant call to FindBacktrace (NFC)
We're not using any of the Backtrace_* CMake variables set by
FindBacktrace in LLDB.
2020-08-20 22:41:49 -07:00
Jonas Devlieghere c1bc4fb95e [lldb] Simplify CMake logic with LLVM's append_if function
Use the append_if CMake function from HandleLLVMOptions. Since we
include this file in LLDBStandalone it should work in both for in-tree
and out-of-tree builds.
2020-08-20 22:35:31 -07:00
Xing GUO 290e399f96 [DWARFYAML] Add support for emitting multiple abbrev tables.
This patch adds support for emitting multiple abbrev tables. Currently,
compilation units will always reference the first abbrev table.

Reviewed By: jhenderson, labath

Differential Revision: https://reviews.llvm.org/D86194
2020-08-21 10:12:08 +08:00
Jonas Devlieghere 73af341beb [lldb] Capture and load home directory from the reproducer.
When replaying the reproducer, lldb should source the .lldbinit file
that was captured by the reproducer and not the one in the current home
directory. This requires that we store the home directory as part of the
reproducer. By returning the virtual home directory during replay, we
ensure the correct virtual path gets constructed which the VFS can then
find and remap to the correct file in the reproducer root.

This patch adds a new HomeDirectoryProvider, similar to the existing
WorkingDirectoryProvider. As the home directory is not part of the VFS,
it is stored in LLDB's FileSystem instance.
2020-08-20 18:08:59 -07:00
Jonas Devlieghere c90ca0c8e4 [lldb] Implement WorkingDirectoryProvider in terms of DirectoryProvider (NFC)
Add an abstract base class that can be used to create other directory
providers.
2020-08-20 18:08:59 -07:00
Eric Leese 4e266eaf13 Make DWARFExpression::GetLocationExpression public
This method is used to get the DataExtractor when the expression is a location list.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D86090
2020-08-20 15:12:28 -07:00
Jonas Devlieghere ed17b6f630 [lldb] Extract FileSystem initialization code into helper (NFC)
The FileSystem initialization depends on the reproducer mode. It has
been growing organically to the point where it deserves its own helper
function. This also allows for early returns to simplify the code.
2020-08-20 15:10:38 -07:00
Fangrui Song b587ca93be [test] Replace `yaml2obj >` with `yaml2obj -o` and remove unneeded input redirection 2020-08-20 15:01:09 -07:00
Jonas Devlieghere 921c1b7df3 [lldb] Provide GetHomeDirectory wrapper in Host::FileSystem (NFC)
Provider a wrapper around llvm::sys::path::home_directory in the
FileSystem class. This will make it possible for the reproducers to
intercept the call in a central place.
2020-08-20 14:07:05 -07:00
Gongyu Deng 22e63cba17 [lldb] tab completion for breakpoint names
1. created a common completion for breakpoint names;
2. bound the breakpoint name common completion with eArgTypeBreakpointName;
3. implemented the dedicated completion for breakpoint read -N.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D80693
2020-08-20 20:56:34 +02:00
Jordan Rupprecht 0de3d0c612 [lldb][asan] Mark destructor as virtual to allow subclasses.
`lldb_private::ScriptInterpreterPython::CommandDataPython` inherits from `lldb_private::BreakpointOptions::CommandData`, but the latter does not have a virtual destructor. This leads to a new-delete-type-mismatch error when running certain tests (such as `functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py`) under asan.
2020-08-20 09:21:33 -07:00
Pavel Labath 8a8a2dd316 [lldb/Utility] Simplify Scalar handling of float types
Similarly to D85836, collapse all Scalar float types to a single enum
value, and use APFloat semantics to differentiate between. This
simplifies the code, and opens to door to supporting other floating
point semantics (which would be needed for fully supporting
architectures with more interesting float types such as PPC).

Differential Revision: https://reviews.llvm.org/D86220
2020-08-20 16:26:02 +02:00
Pavel Labath 9109311356 [lldb] Forcefully complete a type when adding typedefs
This is very similar to D85968, only more elusive to since we were not
adding the typedef type to the relevant DeclContext until D86140, which
meant that the DeclContext was populated (and the relevant assertion
hit) only after importing the type into the expression ast in a
particular way.

I haven't checked whether this situation can be hit in the gmodules
case, but my money is on "yes".

Differential Revision: https://reviews.llvm.org/D86216
2020-08-20 15:19:10 +02:00
Jonas Devlieghere a6eb70c052 [lldb] Return empty string from getExtraMakeArgs when not implemented
No return statement means the method returns None which breaks a list
comprehension down the line that expects a str instance.
2020-08-19 17:52:50 -07:00
Jonas Devlieghere 09ca3f41bb [lldb] Update TestSimulatorPlatform.py to set ARCH_CFLAGS instead of TRIPLE
I move the triple (de)composition logic into the builder in e5d08fcbac
but this test is relying on Make to construct the set the ARCH,
ARCH_CFLAGS and SDKROOT based on the given TRIPLE. This patch updates
the test to pass these variables directly.

Differential revision: https://reviews.llvm.org/D86244
2020-08-19 15:42:44 -07:00
Med Ismail Bennani 868b45b5b3 [lldb/interpreter] Add REPL-specific init file
This patch adds the infrastructure to have language specific REPL init
files. It's the foundation work to a following patch that will introduce
Swift REPL init file.

When lldb is launched with the `--repl` option, it will look for a REPL
init file in the home directory and source it. This overrides the
default `~/.lldbinit`, which content might make the REPL behave
unexpectedly. If the REPL init file doesn't exists, lldb will fall back
to the default init file.

rdar://65836048

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-08-20 00:36:32 +02:00
Jonas Devlieghere a3fc61c80f [lldb] Move Xcode SDK helper functions into lldbutil
This allows the logic to be reused by both the builders and the tests.
2020-08-19 13:30:27 -07:00
Jonas Devlieghere 9f5210aacf [lldb] Print the load command that wasn't found in TestSimulatorPlatform
Print which load command we were looking for when the sanity check
fails:

  AssertionError: 0 != 1 : wrong number of load commands for
  LC_VERSION_MIN_MACOSX
2020-08-19 12:42:59 -07:00
Jonas Devlieghere b40a3814b6 [lldb] Code sign binaries with entitlements
Binaries need to be code signed with entitlements to run on device.

Differential revision: https://reviews.llvm.org/D86237
2020-08-19 11:55:36 -07:00
Jonas Devlieghere e5d08fcbac [lldb] Extend Darwin builder to pass the ARCH_CFLAGS spec to Make.
Construct the ARCH_CFLAGS in Python rather than in Make by disassembling
the TRIPLE.

Differential revision: https://reviews.llvm.org/D85539
2020-08-19 11:47:29 -07:00
Jonas Devlieghere 074c591a7e [lldb] Add getExtraMakeArgs to Builder (NFC)
Instead of a new method for each variable any subclass might want to
set, have a method getExtraMakeArgs that each subclass can use to return
whatever extra Make arguments it wants.

As per Pavel's suggestion in D85539.
2020-08-19 09:47:25 -07:00
Jonas Devlieghere 804691adc9 [lldb] Fix buildDsym signature in Builder base class
The method was missing the optional argument `testname`.
2020-08-19 09:47:25 -07:00
Jonas Devlieghere b623f3c0b4 [lldb] Move builders under lldbsuite.test as they import lldbtest (NFC) 2020-08-19 09:07:51 -07:00
Jonas Devlieghere 1922bf12e1 [lldb] Convert builders to use inheritance (NFC)
Rather than have different modules for different platforms, use
inheritance so we can have a Builer base class and optional child
classes that override platform specific methods.

Differential revision: https://reviews.llvm.org/D86174
2020-08-19 08:44:29 -07:00
Pavel Labath 9cc2f13dee [lldb] Clean up DW_AT_declaration-with-children.s test
Address some post-commit feedback on D85968.
2020-08-19 14:58:50 +02:00
Pavel Labath d7363397c6 [lldb] Add typedefs to the DeclContext they are created in
TypeSystemClang::CreateTypedef was creating a typedef in the right
DeclContext, but it was not actually adding it as a child of the
context. The resulting inconsistent state meant that we would be unable
to reference the typedef from an expression directly, but we could use
them if they end up being pulled in by some previous subexpression
(because the ASTImporter will set up the correct links in the expression
ast).

This patch adds the typedef to the decl context it is created in.

Differential Revision: https://reviews.llvm.org/D86140
2020-08-19 14:57:43 +02:00
Raphael Isemann c1b1868f35 [lldb] Make error messages in TestQueues more helpfull 2020-08-19 13:30:31 +02:00
Muhammad Omair Javaid bd791e97f8 [LLDB] Minor fix in TestSVERegisters.py for AArch64/Linux buildbot
This adds a minor test case fix to previously submitted AArch64 SVE
ptrace support. This was failing on LLDB/AArch64 Linux buildbot.

Differential Revision: https://reviews.llvm.org/D79699
2020-08-19 15:47:59 +05:00
Muhammad Omair Javaid 567ba6c468 [LLDB] Add ptrace register access for AArch64 SVE registers
This patch adds NativeRegisterContext_arm64 ptrace routines to access
AArch64 SVE register set. This patch also adds a test-case to test
AArch64 SVE register access and dynamic size configuration capability.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D79699
2020-08-19 15:11:01 +05:00
Muhammad Omair Javaid af4f40c376 [LLDB] NativeThreadLinux invalidate register cache on stop
In our discussion D79699 SVE ptrace register access support we decide to
invalidate register context cached data on every stop instead of doing
at before Step/Resume.

InvalidateAllRegisters was added to facilitate flushing of SVE register
context configuration and cached register values. It now makes more
sense to move invalidation after every stop where we initiate SVE
configuration update if needed by calling ConfigureRegisterContext.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D84501
2020-08-19 12:30:38 +05:00
Muhammad Omair Javaid 090306fc80 Convert SVE macros into c++ constants and inlines
This patch updates LLDB's in house version of SVE ptrace/sig macros by
converting them into constants and inlines. They are housed under sve
namespace and are used by process elf-core for reading SVE register data.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D85641
2020-08-19 12:28:16 +05:00
Jonas Devlieghere 514bcb325d [lldb] Remove unused function getArchFlag (NFC) 2020-08-18 15:20:57 -07:00
Greg Clayton 08748d15b8 Fix a check that was attempting to see if an object file was in memory.
Checking if an object file is in memory should use the ObjectFile::IsInMemory(), not test ObjectFile::BaseAddress(). ObjectFile::BaseAddress() is designed to be overridden by all classes and is for mach-o, ELF and COFF plug-ins. They find the header base adddress and return that as a section offset address. The default implementation of ObjectFile::BaseAddress() does try and make an Address() from the ObjectFile::m_memory_addr, but I switched it to a correct function call.

Differential Revision: https://reviews.llvm.org/D86122
2020-08-18 13:24:22 -07:00
David Blaikie f7a49d2aa6 [WIP][DebugInfo] Lazily parse debug_loclist offsets
Parsing DWARFv5 debug_loclist offsets when a CU is parsed is weighing
down memory usage of symbolizers that don't need to parse this data at
all. There's not much benefit to caching these anyway - since they are
O(1) lookup and reading once you know where the offset list starts (and
can do bounds checking with the offset list size too).

In general, I think it might be time to start paying down some of the
technical debt of loc/loclist/range/rnglist parsing to try to unify it a
bit more.

eg:

* Currently DWARFUnit has: RangeSection, RangeSectionBase, LocSection,
  LocSectionBase, LocTable, RngListTable, LoclistTableHeader (be nice if
  these were all wrapped up in two variables - one for loclists, one for
  rnglists)

* rnglists and loclists are handled differently (see:
  LoclistTableHeader, but no RnglistTableHeader)

* maybe all these types could be less stateful - lazily parse what they
  need to, even reparsing rather than caching because it doesn't seem
  too expensive, for instance. (though admittedly so long as it's
  constantcost/overead per compilatiton that's probably adequate)

* Maybe implementing and using a DWARFDataExtractor that can be
  sub-ranged (so we could slice it up to just the single contribution) -
  though maybe that's not so useful because loc/ranges need to refer to
  it by absolute, not contribution-relative mechanisms

Differential Revision: https://reviews.llvm.org/D86110
2020-08-18 10:49:39 -07:00
Jan Kratochvil 7baed769c7 [lldb] [testsuite] Add split-file for check-lldb dependencies
D85968 started to use `split-file` and while buildbots run fine while
doing `make check-lldb` by hand I get:

.../llvm-monorepo-clangassert/tools/lldb/test/SymbolFile/DWARF/Output/DW_AT_declaration-with-children.s.script: line 2: split-file: command not found
failed:
  lldb-shell :: SymbolFile/DWARF/DW_AT_declaration-with-children.s

Differential Revision: https://reviews.llvm.org/D86144
2020-08-18 18:10:55 +02:00
Luboš Luňák dcd4589a0d [lldb][gui] use left/right in the source view to scroll
I intentionally decided not to reset the column automatically
anywhere, because I don't know where and if at all that should happen.
There should be always an indication of being scrolled (too much)
to the right, so I'll leave this to whoever has an opinion.

Differential Revision: https://reviews.llvm.org/D85290
2020-08-18 13:25:01 +02:00
Harmen Stoppels a52173a3e5 Use find_library for ncurses
Currently it is hard to avoid having LLVM link to the system install of
ncurses, since it uses check_library_exists to find e.g. libtinfo and
not find_library or find_package.

With this change the ncurses lib is found with find_library, which also
considers CMAKE_PREFIX_PATH. This solves an issue for the spack package
manager, where we want to use the zlib installed by spack, and spack
provides the CMAKE_PREFIX_PATH for it.

This is a similar change as https://reviews.llvm.org/D79219, which just
landed in master.

Differential revision: https://reviews.llvm.org/D85820
2020-08-17 19:52:52 -07:00
Adrian Prantl a1a3b86910 Convert to early exit (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl fc1464c6df Simplify error reporting (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl a615ec9a1b Convert if cascade to switch (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl 8bb81c29b9 Convert to early exit (NFC) 2020-08-17 14:42:25 -07:00
Adrian Prantl 1d5e9d37c3 Convert to early exit (NFC) 2020-08-17 14:42:24 -07:00
Jonas Devlieghere 9c5e25a696 [lldb] Skip test_launch_simple with reproducers
The test checks the inferior's output. During replay the binary doesn't
actually run and the output isn't captured by the reproducers.
2020-08-17 11:47:07 -07:00
Jonas Devlieghere 5a7b61b183 [lldb] Skip TestMultipleDebuggers on Windows 2020-08-17 11:34:25 -07:00
Jonas Devlieghere 24d3210e62 [lldb] Skip the Apple Simulator tests with reproducers 2020-08-17 11:29:37 -07:00
Jonas Devlieghere 6dabd267bd [lldb] Skip TestError.test with reproducers
This tests the driver, which is bypassed by the reproducer during
replay.
2020-08-17 10:42:58 -07:00
Jonas Devlieghere e095e98a3a [lldb] Add missing LLDB_REGISTER for GarbageCollectAllocatedModules
Add the missing LLDB_REGISTER_STATIC_METHOD macro and format the file.
2020-08-17 10:14:41 -07:00
Jonas Devlieghere e9b0994012 [lldb] Replace unittest2.expectedFailure with expectedFailure (NFC)
Rename the existing expectedFailure to expectedFailureIfFn to better
describe its purpose and provide an overload for
unittest2.expectedFailure in decorators.py.
2020-08-17 10:05:49 -07:00
Raphael Isemann c6cc566c8a [lldb] Use os.path.sep in TestInvalidArgsLog.py to fix Windows bot 2020-08-17 19:03:27 +02:00
Jonas Devlieghere 8b67b707b0 [lldb] Add missing signal include for TestMultipleDebuggers.py
Fixes multi-process-driver.cpp:221:19: error: use of undeclared
identifier 'SIG_IGN'
2020-08-17 09:41:45 -07:00
Jonas Devlieghere 6cc0b00f4d [lldb] Only link against Python 3 when LLDB_ENABLE_PYTHON is set.
Only link against Python3_LIBRARY when LLDB_ENABLE_PYTHON is true. We
have to be more strict now becuase Python3_LIBRARY might be set to
NOTFOUND instead of being not set at all.
2020-08-17 09:31:52 -07:00
Jonas Devlieghere a0a328ed4f [lldb] Fix and re-enable TestMultipleDebuggers
The comment says that TestMultipleDebuggers was XFAILed because it was
failing nondeterministically in which case it should be skipped not
failed (as XPASS will cause the test suite to fail).

The reason it fails is because it was not marked as a no-debug-info test
case. I've ran the test in a loop and it has been passing consistently.
Let's enable it and see if the bots agree, if not we can skip it.
2020-08-17 09:20:20 -07:00
Walter Erquinigo 99614d410c [lldb-vscode] NFC: clang format
Run clang-format on all the c++ file of this project.
2020-08-17 09:18:01 -07:00
Jonas Devlieghere 75966ee241 [lldb] Get rid of helper CMake variables for Python
This patch is a big sed to rename the following variables:

  s/PYTHON_LIBRARIES/Python3_LIBRARIES/g
  s/PYTHON_INCLUDE_DIRS/Python3_INCLUDE_DIRS/g
  s/PYTHON_EXECUTABLE/Python3_EXECUTABLE/g
  s/PYTHON_RPATH/Python3_RPATH/g

I've also renamed the CMake module to better express its purpose and for
consistency with FindLuaAndSwig.

Differential revision: https://reviews.llvm.org/D85976
2020-08-17 08:47:52 -07:00
Raphael Isemann f5f22f0448 [lldb] Skip TestSimulatorPlatform with sanitized builds
The test executable crashes when ran on a simulator. Skipping until this is
fixed.

rdar://67238668
2020-08-17 15:06:48 +02:00
Raphael Isemann cfb773c676 [lldb][NFC] Use StringRef in CreateFunctionDeclaration/GetDeclarationName
CreateFunctionDeclaration should just take a StringRef. GetDeclarationName is
(only) used by CreateFunctionDeclaration so that's why now also takes a
StringRef.
2020-08-17 14:17:20 +02:00
Raphael Isemann 7e6c437fb4 [lldb][NFC] Remove name parameter from CreateFunctionTemplateDecl
It's unused and not documented.
2020-08-17 13:44:10 +02:00
Raphael Isemann 42b9a68352 [lldb][NFC] Use expect_expr in more tests 2020-08-17 13:14:57 +02:00
Raphael Isemann cd2139a527 [lldb][NFC] Use the proper type for the 'storage' parameter of CreateFunctionDeclaration
All the callers pass an enum and we cast the int anyway back to the actual type,
so we might as well just use the type for the parameter.
2020-08-17 12:53:58 +02:00
Raphael Isemann 6b97fa0bfe [lldb] Remove OS-specific string from TestInvalidArgsLog
This is the error message from the OS, so we shouldn't check against the
OS-specific part of the string.

Fixes the test on Windows which returns a different error message.
2020-08-17 11:57:43 +02:00
Raphael Isemann 24c74f5e8c [lldb] Don't delete orphaned shared modules in SBDebugger::DeleteTarget
In D83876 the consensus seems that LLDB should never deleted orphaned modules
implicitly. However, SBDebugger::DeleteTarget is currently doing exactly that.
This code was added in 753406221b but I don't see
any explanation in the commit, so I think we should delete it.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D83933
2020-08-17 11:30:56 +02:00
Pavel Labath 67cdb899c6 [lldb/Utility] Simplify and generalize Scalar class
The class contains an enum listing all host integer types as well as
some non-host types. This setup is a remnant of a time when this class
was actually implemented in terms of host integer types. Now that we are
using llvm::APInt, they are mostly useless and mean that each function
needs to enumerate all of these cases even though it treats most of them
identically.

I only leave e_sint and e_uint to denote the integer signedness, but I
want to remove that in a follow-up as well.

Removing these cases simplifies most of these functions, with the only
exception being PromoteToMaxType, which can no longer rely on a simple
enum comparison to determine what needs to be promoted.

This also makes the class ready to work with arbitrary integer sizes, so
it does not need to be modified when someone needs to add a larger
integer size.

Differential Revision: https://reviews.llvm.org/D85836
2020-08-17 11:09:56 +02:00
Pavel Labath 2d89a3ba12 [lldb] Forcefully complete a type when adding nested classes
With -flimit-debug-info, we can run into cases when we only have a class
as a declaration, but we do have a definition of a nested class. In this
case, clang will hit an assertion when adding a member to an incomplete
type (but only if it's adding a c++ class, and not C struct).

It turns out we already had code to handle a similar situation arising
in the -gmodules scenario. This extends the code to handle
-flimit-debug-info as well, and reorganizes bits of other code handling
completion of types to move functions doing similar things closer
together.

Differential Revision: https://reviews.llvm.org/D85968
2020-08-17 11:09:13 +02:00
Raphael Isemann c2f9454a16 [lldb] Add SBModule::GarbageCollectAllocatedModules and clear modules after each test run
Right now the only places in the SB API where lldb:: ModuleSP instances are
destroyed are in SBDebugger::MemoryPressureDetected (where it's just attempted
but not guaranteed) and in SBDebugger::DeleteTarget (which will be removed in
D83933). Tests that directly create an lldb::ModuleSP and never create a target
therefore currently leak lldb::Module instances. This triggers the sanity checks
in lldbtest that make sure that the global module list is empty after a test.

This patch adds SBModule::GarbageCollectAllocatedModules as an explicit way to
clean orphaned lldb::ModuleSP instances. Also we now start calling this method
at the end of each test run and move the sanity check behind that call to make
this work. This way even tests that don't create targets can pass the sanity
check.

This fixes TestUnicodeSymbols.py when D83865 is applied (which makes that the
sanity checks actually fail the test).

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D83876
2020-08-17 11:00:19 +02:00
Raphael Isemann 867c347c32 [lldb] Fix that log enable's -f parameter causes LLDB to crash when it can't open the log file
We didn't do anything with the llvm::Error we get from `Open`, so when we end up in the
error case we just crash due to the llvm::Error sanity check. Also add the missing newline
behind the error message so it no longer messes with the next (lldb) prompt.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D85970
2020-08-17 10:43:00 +02:00
Raphael Isemann c57ea1b48f [lldb] Get lldb-server platform's --socket-file working again
`lldb-server platform --socket-file /any/path` currently always fails to create
the socket file.  This stopped working after D67424 which changed the
input variables of `writeFileAtomically` slightly. We're expected to
pass in a temporary path template (`/tmp/foo-%%%%%`) and the final
path we want to write. Instead we currently pass in the never set
`temp_file_path` as the temporary path (which will make this function always
fail) and pass in the temp_file_spec's path as the final path (which is actually
the template path such as `/tmp/foo-%%%%%`) instead of the actual path
we want to write (e.g. `/tmp/foo`).

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D85890
2020-08-17 10:29:06 +02:00
Raphael Isemann 5913f2591c [lldb][NFC] Remove stride parameter from GetArrayElementType
This parameter isn't used anywhere in LLDB nor the Swift downstream branch. It
also doesn't really fit into the TypeSystem APIs that usually don't return
additional related functionality via some output parameters. Also the
implementations already states that the calculated value there is wrong.

Let's remove it. If we need this functionality at some point then Swift's much
nicer `GetByteStride` function seems like the way to go.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D84299
2020-08-17 10:19:51 +02:00
Raphael Isemann 24fc3177c1 [lldb] Print the exception traceback when hitting cleanup errors
Right now if the test suite encounters a cleanup error it just prints "CLEANUP
ERROR:" but not any additional information.

This patch just prints the exception that caused the cleanup error. This should
make debugging the failing tests for D83865 easier (and seems in general nice to
have).

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D83874
2020-08-17 09:53:52 +02:00
Raphael Isemann 7208cb1ac4 [lldb] Remove XFAIL from now passing TestPtrRefs/TestPtreRefsObjC
8fcfe2862f and
0cceb54366 fixed those tests.
2020-08-15 08:14:44 +02:00
Davide Italiano 0cceb54366 [TestPtrRefsObjC] Prefer `command script import`. 2020-08-14 15:31:02 -07:00
Davide Italiano 8fcfe2862f [TestPtrRefs] Prefer `command script import`. 2020-08-14 15:30:31 -07:00
Jim Ingham b6db0a544d Add python enumerators for SBTypeEnumMemberList, and some tests for this API.
Differential Revision: https://reviews.llvm.org/D85951
2020-08-14 09:57:46 -07:00
Jonas Devlieghere ce439cb1c9 [lldb] Remove Python 2 fallback and only support Python 3
This removes the fallback to Python 2 and makes Python 3 the only
supported configuration. This is the first step to fully migrate to
Python 3 over the coming releases as discussed on the mailing list.

http://lists.llvm.org/pipermail/lldb-dev/2020-August/016388.html

As a reminder, for the current release the test suite and the generated
bindings should remain compatible with Python 2.

Differential revision: https://reviews.llvm.org/D85942
2020-08-14 08:50:11 -07:00
Jonas Devlieghere 37ec83fcfc [lldb] Use file to synchronize TestDeepBundle and TestBundleWithDotInFilename
Currently these two tests use an arbitrary wait of 5 seconds for the
inferior to finish setting up. When the test machine is under heavy load
this sometimes is insufficient leading to spurious test failures. This
patch adds synchronization trough a token on the file system. In
addition to making the test more reliable it also makes it much faster
because we no longer have to wait the full 5 seconds if the setup was
completed faster than that.

Differential revision: https://reviews.llvm.org/D85915
2020-08-14 08:32:21 -07:00
Raphael Isemann 46ed27ff1b [lldb] Make packetlog_get_dylib_info returns the last full response
In sanitized builds the last packet this function finds for the
TestMacCatalyst and TestPlatformSimulator tests is for the asan runtime.

```
 <  69> send packet: $jGetLoadedDynamicLibrariesInfos:{"solib_addresses":[4296048640]}]#3a <
 715> read packet: ${"images":[{"load_address":4296048640,"mod_date":0,"pathname":
 "/Users/buildslave/jenkins/workspace/lldb-cmake-sanitized/host-compiler/lib/clang/12.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib",
 "uuid":"8E38A2CD-753F-3E0F-8EB0-F4BD5788A5CA",
 "min_version_os_name":"macosx","min_version_os_sdk":"10.9",
 "mach_header":{"magic":4277009103,"cputype":16777223,"cpusubtype":3,"filetype":6,
 "flags":43090053}],"segments":[{"name":"__TEXT","vmaddr":0,"vmsize":565248,"fileoff":0,
 "filesize":565248,"maxprot":5}],{"name":"__DATA","vmaddr":565248,"vmsize":13152256,"fileoff":565248,
 "filesize":20480,"maxprot":3}],{"name":"__LINKEDIT","vmaddr":13717504,"vmsize":438272,"fileoff":585728,
 "filesize":435008,"maxprot":1}]]}]]}]#00
```

This just fetches the last package which has fetch_all_solibs and we know
it will contain the image of our test executable to get the tests running again.
2020-08-14 14:51:13 +02:00
Raphael Isemann bb4efab9a4 [lldb] Use SBProcess::Continue instead of 'run' command in TestTargetAPI.py
This test is flaky on Green Dragon as it often fails when the process state
is "Invalid" in the assert:
    self.assertEqual(process.GetState(), lldb.eStateExited)
It seems this is related to just doing "run" which apparently invalidates
the Target's process in case it's still running and needs to be restarted.
Just doing 'continue' on the process (and ignoring the error in case it already
finished) prevents that and makes this consistently pass for me.

Just pushing this out to get Green Dragon back online.
2020-08-14 13:12:52 +02:00
Pavel Labath fdc6aea3fd [lldb] Check Decl kind when completing -flimit-debug-info types
The search for the complete class definition can also produce entries
which are not of the expected type. This can happen for instance when
there is a function with the same name as the class we're looking up
(which means that the class needs to be disambiguated with the
struct/class tag in most contexts).

Previously we were just picking the first Decl that the lookup returned,
which later caused crashes or assertion failures if it was not of the
correct type. This patch changes that to search for an entry of the
correct type.

Differential Revision: https://reviews.llvm.org/D85904
2020-08-14 12:31:37 +02:00
Pavel Labath e6b1b61054 [lldb] Fix py3 incompatibility in gdbremote_testcase.py
This didn't cause test failures since this variable is only used during
connection shutdown.
2020-08-14 12:15:25 +02:00
Raphael Isemann f974d64b37 [lldb] Deduplicate copy-pasted TypeSystemMap::GetTypeSystemForLanguage
There are two implementations for `TypeSystemMap::GetTypeSystemForLanguage`
which are both identical beside one taking a `Module` and one taking a `Target`
(and then passing that argument to the `TypeSystem::CreateInstance` function).

This merges both implementations into one function with a lambda that wraps the
different calls to `TypeSystem::CreateInstance`.

Reviewed By: #lldb, JDevlieghere

Differential Revision: https://reviews.llvm.org/D82537
2020-08-14 11:58:54 +02:00
Shu Anzai de9e85026f [lldb] Display autosuggestion part in gray if there is one possible suggestion
This is relanding D81001. The patch originally failed as on newer editline
versions it seems CC_REFRESH will move the cursor to the start of the line via
\r and then back to the original position. On older editline versions like
the one used by default on macOS, CC_REFRESH doesn't move the cursor at all.
As the patch changed the way we handle tab completion (previously we did
REDISPLAY but now we're doing CC_REFRESH), this caused a few completion tests
to receive this unexpected cursor movement in the output stream.
This patch updates those tests to also accept output that contains the specific
cursor movement commands (\r and then \x1b[XC). lldbpexpect.py received an
utility method for generating the cursor movement escape sequence.

Original summary:

I implemented autosuggestion if there is one possible suggestion.
I set the keybinds for every character. When a character is typed, Editline::TypedCharacter is called.
Then, autosuggestion part is displayed in gray, and you can actually input by typing C-k.
Editline::Autosuggest is a function for finding completion, and it is like Editline::TabCommand now, but I will add more features to it.

Testing does not work well in my environment, so I can't confirm that it goes well, sorry. I am dealing with it now.

Reviewed By: teemperor, JDevlieghere, #lldb

Differential Revision: https://reviews.llvm.org/D81001
2020-08-14 11:37:49 +02:00
Pavel Labath 40d774265b [lldb/Utility] Simplify Scalar::PromoteToMaxType
The function had very complicated signature, because it was trying to
avoid making unnecessary copies of the Scalar object. However, this
class is not hot enough to worry about these kinds of optimizations. My
making copies unconditionally, we can simplify the function and all of
its call sites.

Differential Revision: https://reviews.llvm.org/D85906
2020-08-14 11:09:16 +02:00
Raphael Isemann bbe3c479a6 [lldb] Fix a crash when tab-completion an empty line in a function with only one local variable
When LLDB sees only one possible completion for an input, it will add a trailing
space to the completion to signal that to the user. If the current argument is
quoted, that also means LLDB needs to add the trailing quote to finish the
current argument first.

In case the user is in a function with only one local variable and is currently
editing an empty line in the multiline expression editor, then we are in the
unique situation where we can have a unique completion for an empty input line.
(In a normal LLDB session this would never occur as empty input would just list
all the possible commands).

In this special situation our check if the current argument needs to receive a
trailing quote will crash LLDB as there is no current argument and the
completion code just unconditionally tries to access the current argument. This
just adds the missing check if we even have a current argument before we check
if we need to add a terminating quote character.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D85903
2020-08-14 09:06:52 +02:00
Jonas Devlieghere 3da939686c [lldb] Improve diagnostics in lldb-repro when replay fails
- Print the replay invocation.
 - Keep the reproducer around.
 - Return the "opposite" exit code so we don't have to rely on FileCheck
   to fail the test when the expected exit code is non-zero.
2020-08-13 14:38:34 -07:00
shafik 25bbceb047 [LLDB] Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()
When bit-field data was stored in a Scalar in ValueObjectChild during UpdateValue()
it was extracting the bit-field value. Later on in lldb_private::DumpDataExtractor(…)
we were again attempting to extract the bit-field. Which would then not obtain the
correct value. This will remove the extra extraction in UpdateValue().
We hit this specific case when values are passed in registers, which we could only
reproduce in an optimized build.

Differential Revision: https://reviews.llvm.org/D85376
2020-08-13 11:53:14 -07:00
Jonas Devlieghere 2ddba09e06 [lldb] Set the launch flags to GetLaunchInfo().GetLaunchFlags()
Instead of clearing the launch flags, always pass the target's current
launch flags.
2020-08-13 10:24:35 -07:00
Jonas Devlieghere 180d6ed667 [lldb] Skip TestStepScripted with reproducers
Some of the test methods were already skipped because of an unexpected
packet. The test started failing after it was expanded. Skip the whole
test with reproducers so we don't have to add the decorator for every
method.
2020-08-13 09:46:52 -07:00
Raphael Isemann 8af160b0b8 [lldb][NFC] Use llvm::is_contained instead of std::find in a few places 2020-08-13 14:11:28 +02:00
Raphael Isemann ac2b7f8ac1 [lldb][NFC] Fix indentation in TCPSocket::CloseListenSockets 2020-08-13 12:29:24 +02:00
Jonas Devlieghere fbfd831dda [lldb] Fix relative imports and set the appropriate include dirs
After moving python.swig and lua.swig into their respective
subdirectories, the relative paths in these files were out of date. This
fixes that and ensures the appropriate include paths are set in the SWIG
invocation.

Differential revision: https://reviews.llvm.org/D85859
2020-08-12 16:28:46 -07:00
Adrian McCarthy 7ddfb956e1 [lldb] Fix unit test parsing to handle CR+LF as well as LF
Apparently when the strings are created, the `'\n'` is converted to the
platform's natural new line indicator, which is CR+LF on Windows.  But
upon reading back with `sscanf`, the CRs caused a matching failure.
2020-08-12 13:56:16 -07:00
Vedant Kumar d49aedd315 Build a flat LLDB.framework for embedded Darwin targets
This patch configures LLDB.framework to build as a flat unversioned
framework on non-macOS Darwin targets, which have never supported the
macOS framework layout.

This patch also renames the 'IOS' cmake variable to 'APPLE_EMBEDDED' to
reflect the fact that lldb is built for several different kinds of embedded
Darwin targets, not just iOS.

Differential Revision: https://reviews.llvm.org/D85770
2020-08-12 13:34:29 -07:00
Raphael Isemann cff880b0c9 Revert "[lldb] Display autosuggestion part in gray if there is one possible suggestion"
This reverts commit 246afe0cd1. This broke
the following tests on Linux it seems:
  lldb-api :: commands/expression/multiline-completion/TestMultilineCompletion.py
  lldb-api :: iohandler/completion/TestIOHandlerCompletion.py
2020-08-12 13:52:03 +02:00
Shu Anzai 246afe0cd1 [lldb] Display autosuggestion part in gray if there is one possible suggestion
I implemented autosuggestion if there is one possible suggestion.
I set the keybinds for every character. When a character is typed, Editline::TypedCharacter is called.
Then, autosuggestion part is displayed in gray, and you can actually input by typing C-k.
Editline::Autosuggest is a function for finding completion, and it is like Editline::TabCommand now, but I will add more features to it.

Testing does not work well in my environment, so I can't confirm that it goes well, sorry. I am dealing with it now.

Reviewed By: teemperor, JDevlieghere, #lldb

Differential Revision: https://reviews.llvm.org/D81001
2020-08-12 13:11:20 +02:00
Raphael Isemann dd0fdf8030 [lldb] Add support for checking children in expect_expr
expect_expr currently can't verify the children of the result SBValue.

This patch adds the ability to check them. The idea is to have a CheckValue
class where one can specify what attributes of a SBValue should be checked.
Beside the properties we already check for (summary, type, etc.) this also
has a list of children which is again just a list of CheckValue object (which
can also have children of their own).

The main motivation is to make checking the children no longer based
on error-prone substring checks that allow tests to pass just because
for example the error message contains the expected substrings by accident.

I also expect that we can just have a variant of `expect_expr` for LLDB's
expression paths (aka 'frame var') feature.

Reviewed By: labath

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

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

Differential Revision: https://reviews.llvm.org/D79219
2020-08-11 20:22:11 -07:00
Adrian McCarthy 479f5bfdb0 [LLDB] Improve PDB discovery
When loading a PE/COFF target, the associated PDB file often wasn't
found.  The executable module contains a path for the associated PDB
file, but people often debug from a different directory than the one
their build system uses.  (This is especially common in post-mortem
and cross platform debugging.)

Suppose the COFF executable being debugged is `~/proj/foo.exe`, but
it was built elsewhere and refers to `D:\remote\build\env\foobar.pdb`,
LLDB wouldn't find it.

With this change, if no file exists at the PDB path, LLDB will look
in the executable directory for a PDB file that matches the name of
the one it expected (e.g., `~/proj/foobar.pdb`).  If found, the PDB
is subject to the same matching criteria (GUIDs and age) as would
have been used had it been in the original location.

This same-directory-as-the-binary rule is commonly used by debuggers
on Windows.

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

What this patch does is:

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

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

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

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

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

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

Reviewed By: jarin

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

Reviewed By: teemperor

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

Reviewed By: teemperor

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

Reviewed By: teemperor

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

Reviewed By: JDevlieghere

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

Reviewed By: teemperor

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

Reviewed By: teemperor

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

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

Reviewed By: amccarth

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

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

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

2. Added a related test case.

Reviewed By: teemperor, JDevlieghere

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

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

Reviewed By: teemperor

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

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

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

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

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

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

<rdar://problem/64229484>

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

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

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

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

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

rdar://problem/66024437

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

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

rdar://problem/66545307

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

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

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

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

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

Reviewed By: jhenderson

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

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

Reviewed By: omjavaid

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

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

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

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

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

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

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

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

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

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

Reviewed By: MaskRay

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

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

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

Reviewed By: JDevlieghere

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

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

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

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

Reviewed By: clayborg

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

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

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

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

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

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

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

rdar://problem/66059257

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

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

Reviewed By: wallace, clayborg

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

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

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

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

Reviewed By: JDevlieghere

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

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

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

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

Reviewed By: JDevlieghere

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

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

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

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

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

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

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

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

Reviewed By: labath

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reviewed-by: aaron.ballman, beanz, meinersbur

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

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

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

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

Reviewers: aprantl

Subscribers: inglorion, dexonsmith, lldb-commits

Tags: #lldb

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

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

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

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

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

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

Reviewers: aprantl

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

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: JDevlieghere

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

Reviewed By: #lldb, JDevlieghere

Subscribers: JDevlieghere

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

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

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

Reviewers: clayborg, aprantl, JDevlieghere, shafik

Subscribers: lldb-commits

Tags: #lldb

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

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

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

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

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

Reviewed By: wallace, clayborg

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

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

Reviewers: wallace, clayborg

Reviewed By: wallace, clayborg

Subscribers: cfe-commits, aprantl, lldb-commits

Tags: #lldb, #clang

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

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

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

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

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

rdar://problem/66011909

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

Reviewers: jasonmolenda, jingham

Subscribers: lldb-commits

Tags: #lldb

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

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

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

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

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

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

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

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

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

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

Reviewers: labath, JDevlieghere

Reviewed By: labath, JDevlieghere

Subscribers: JDevlieghere

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

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

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

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

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

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

Reviewers: labath, mib

Reviewed By: labath

Subscribers: abidh, JDevlieghere

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

Summary:

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

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

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

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

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

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

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

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

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

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

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

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

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

Reviewers: mib

Reviewed By: mib

Subscribers: abidh, JDevlieghere

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

Reviewed By: jhenderson, labath

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

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

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

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

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

This change was introduced by commit 85fbb08fa2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reviewed By: labath

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

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

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

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

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

rdar://63347792

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

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

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

Reviewers: davide, jingham

Subscribers: lldb-commits

Tags: #lldb

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

Summary:

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

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

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

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

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

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

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

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

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

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

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

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

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

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

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

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

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

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

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

Reviewers: davide, mib

Reviewed By: mib

Subscribers: mgorny, JDevlieghere

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

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

Reviewers: mib, davide

Reviewed By: mib

Subscribers: JDevlieghere

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reviewers: labath, clayborg, jankratochvil, jasonmolenda, rengolin

Reviewed By: labath

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

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

Reviewers: labath, rengolin

Reviewed By: labath

Subscribers: tschuett, lldb-commits, kristof.beyls

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

Reviewers: labath

Reviewed By: labath

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

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

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

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

Reviewers: aprantl, clayborg, JDevlieghere

Reviewed By: JDevlieghere

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

Reviewed By: MaskRay, JDevlieghere

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

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

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

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

Reviewers: amccarth, markmentovai

Subscribers: lldb-commits

Tags: #lldb

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

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

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

Reviewers: JDevlieghere, MaskRay

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

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

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

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

Reviewers: jingham, mib

Reviewed By: jingham, mib

Subscribers: MrHate, JDevlieghere

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

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

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

Fixes rdar://63443099

Reviewers: jasonmolenda, jingham, teemperor

Reviewed By: jasonmolenda, teemperor

Subscribers: jingham, JDevlieghere

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

Test Plan:

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

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

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

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

Reviewers: jasonmolenda, labath

Subscribers: llvm-commits, lldb-commits

Tags: #lldb, #llvm

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

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

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

Tags: #lldb

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

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

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

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

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

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

Differential Revision: https://reviews.llvm.org/D83840
2020-07-15 09:16:30 -07:00
Jonas Devlieghere 700dd17399 [lldb/Test] Remove support for forking a subprocess from the test suite.
Remove the forkSubprocess method and its bookkeeping.
TestCreateAfterAttach is the only test using the fork method and I'm not
convinced it adds enough to warrant the maintenance. Pavel suggested the
same thing in D83815.
2020-07-15 08:57:54 -07:00