Commit Graph

22866 Commits

Author SHA1 Message Date
Muhammad Omair Javaid 6c45532908 Remove code duplication from RegisterContextPOSIX_*
Summary:
This patch aims to remove multiple copies of GetByteOrder() and ConvertRegisterKindToRegisterNumber used in various versions of RegisterContextPOSIX_*.

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

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

Reviewers: labath

Reviewed By: labath

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

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

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

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

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

Differential revision: https://reviews.llvm.org/D81898
2020-06-16 11:05:19 -07:00
Jonas Devlieghere e4a84590e8 [lldb/Test] Create dir if it doesn't yet exist in getReproducerArtifact
The type test use this method to store the golden output. This currently
fails if the reproducer directory hasn't yet been created.
2020-06-16 09:46:48 -07:00
Jonas Devlieghere 388afd8406 [lldb] Remove redundant access specifiers (NFC) 2020-06-15 21:34:13 -07:00
Jonas Devlieghere 5ddd4fc5a6 [lldb/Lua] Fix override/virtual in ScriptInterpreterLua (NFC) 2020-06-15 21:15:35 -07:00
Jonas Devlieghere 93571c3c3b [lldb/Python] Various cleanups in ScriptInterpreterPython (NFC) 2020-06-15 21:07:43 -07:00
Jonas Devlieghere 8d2acfc40e [lldb/Interpreter] Use std::make_shared<StreamString> (NFC) 2020-06-15 20:48:55 -07:00
Jonas Devlieghere 18e356b75d [lldb/Docs] Reword paragraph and omit 'build slave' 2020-06-15 18:25:57 -07:00
Jonas Devlieghere 0965b59bf4 [lldb/debugserver] Rename Master/Slave to Primary/Secondary (NFC) 2020-06-15 18:22:22 -07:00
Jason Molenda 480a383551 Upstream two performance monitor collectors to MachTask
Add two more perf monitors to MachTask::GetProfileData.

<rdar://problem/63984105>
2020-06-15 16:37:56 -07:00
Jonas Devlieghere 64ec505dd4 [lldb] Rename Master/Slave to Primary/Secondary (NFC) 2020-06-15 15:38:28 -07:00
Jonas Devlieghere d74323606d [lldb] Remove indentation before help output.
This patch remove the indentation before the command help output.
Supposedly it was meant to be aligned with the different subcommands.

Differential revision: https://reviews.llvm.org/D81783
2020-06-15 09:27:17 -07:00
Kirill Bobyrev 2d8f8c4de3
[lldb] Handle all Clang::Type::Builtin enums
Cleanup after https://reviews.llvm.org/D81459
2020-06-15 10:18:59 +02:00
Xing GUO 8a2ff19272 [lldb][test] Trying to fix build bot after 0431e4bcb2 2020-06-13 23:53:13 +08:00
Xing GUO 0431e4bcb2 Recommit "[DWARFYAML][debug_line] Replace `InitialLength` with `Format` and `Length`."
This recommits fcc0c186e9
2020-06-13 23:39:11 +08:00
Jonas Devlieghere ff058e7331 [lldb] Remove unnecessary c_str() in OutputFormattedHelpText calls (NFC) 2020-06-12 21:13:21 -07:00
Jonas Devlieghere 58e34ede5b [lldb] Small improvements in ValueObjectPrinter::PrintDecl (NFC)
Remove unused argument, simply code and reformat.
2020-06-12 21:05:05 -07:00
Jonas Devlieghere da601ea731 [lldb/Test] Assert that no targets or modules remain after a test completes.
The reproducer intentionally leak every object allocated during replay,
which means that modules never get orphaned. If this were to happen for
another reason, we might not be testing what we think we are. Assert
that there are no targets left at the end of a test and that the global
module cache is empty in the non-reproducer scenario.

Differential revision: https://reviews.llvm.org/D81612
2020-06-12 15:17:44 -07:00
Jonas Devlieghere 8f9eb70353 [lldb/Test] Fix unit test suffixes and add a CMake error.
Lit will only look for unittest targets ending in `Tests`. Add an error
when the target doesn't have the `Tests` suffix.
2020-06-12 14:18:27 -07:00
Jonas Devlieghere bfea1df9f0 [lldb/Test] Fix unittest name
Lit looks for the Tests prefix in the unit test name.
2020-06-12 14:01:14 -07:00
Jonas Devlieghere 2b34632a57 [lldb/SymbolFile] Don't parse the whole line table for the support files
Prior to my patch of using the LLVM line table parsing code,
SymbolFileDWARF::ParseSupportFiles would only parse the line table
prologues to get the file list for any files that could be in the line
table.

With the old behavior, if we found the file that someone is setting the
breakpoint in in the support files list, we would get a valid index. If
we didn't, we would not look any further. So someone sets a breakpoint
one "MyFile.cpp:12" and if we find "MyFile.cpp" in the support file list
for the compile unit, then and only then would we get the entire line
table for that compile unit.

With the current behavior, no matter what, we always fully parse the
line table for all compile units any time any file and line breakpoint
is set. This creates a serious problem when debugging a large DWARF in
.o file project.

This patch re-instates the old behavior. Unfortunately it means we might
end up parsing to prologue twice, but I don't think that outweighs the
cost of trying to cache/reuse it.

Differential revision: https://reviews.llvm.org/D81589
2020-06-12 09:39:17 -07:00
Raphael Isemann a8c755545b [lldb] Test creating persistent variables with $[digit] names 2020-06-12 16:12:33 +02:00
Raphael Isemann f52e4129a7 [lldb][NFC] Modernize TestPersistentVariables 2020-06-12 16:06:05 +02:00
Raphael Isemann 91728b9172 [lldb] Don't print IRForTarget errors directly to the console
Summary:

When we get an error back from IRForTarget we directly print that error to the
debugger output stream instead of putting it in the result object. The result
object only gets a vague "The expression could not be prepared to run in the
target" error message that doesn't actually tell the user what went wrong.

This patch just puts the IRForTarget errors into the status object that is
returned to the caller instead of directly printing it to the debugger. Also
updates one test that now can actually check for the error message it is
supposed to check for (instead of the default error which is all we had before).

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D81654
2020-06-12 10:27:25 +02:00
Jonas Devlieghere 526e0c8d15 [lldb/Test] Fix ASan/TSan workaround for Xcode Python 3
The Python 3 interpreter in Xcode has a relative RPATH and dyld fails to
load it when we copy it into the build directory.

This patch adds an additional check that the copied binary can be
executed. If it doesn't, we assume we're dealing with the Xcode python
interpreter and return the path to the real executable. That is
sufficient for the sanitizers because only system binaries need to be
copied to work around SIP.

This patch also moves all that logic out of LLDBTest and into the lit
configuration so that it's executed only once per test run, instead of
once for every test. Although I didn't benchmark the difference this
should result in a mild speedup.

Differential revision: https://reviews.llvm.org/D81696
2020-06-11 19:36:42 -07:00
Jonas Devlieghere 8d8ec55035 [lldb/Test] Unify DYLD_INSERT_LIBRARIES solution for ASan and TSan
Add the same fix for loading the sanitizer runtime for TSan as we
currently have for ASan and unify the code with a helper function.
2020-06-11 16:04:46 -07:00
Ilya Bukonkin 3b43f00629 [lldb] Check if thread was suspended during previous stop added.
Encountered the following situation: Let we started thread T1 and it hit
breakpoint on B1 location. We suspended T1 and continued the process.
Then we started thread T2 which hit for example the same location B1.
This time in a breakpoint callback we decided not to stop returning
false.

Expected result: process continues (as if T2 did not hit breakpoint) its
workflow with T1 still suspended. Actual result: process do stops (as if
T2 callback returned true).

Solution: We need invalidate StopInfo for threads that was previously
suspended just because something that is already inactive can not be the
reason of stop. Thread::GetPrivateStopInfo() may be appropriate place to
do it, because it gets called (through Thread::GetStopInfo()) every time
before process reports stop and user gets chance to change
m_resume_state again i.e if we see m_resume_state == eStateSuspended
it definitely means it was set during previous stop and it also means
this thread can not be stopped again (cos' it was frozen during
previous stop).

Differential revision: https://reviews.llvm.org/D80112
2020-06-11 15:02:46 -07:00
Reid Kleckner 1c03389c29 Re-land "Migrate the rest of COFFObjectFile to Error"
This reverts commit 101fbc0138.

Remove leftover debugging attribute.

Update LLDB as well, which was missed before.
2020-06-11 14:46:16 -07:00
Jonas Devlieghere 5a33ba52b6 [lldb/Test] Ensure inline tests have a unique build directory
Inline tests have one method named 'test' which means that multiple
inline tests in the same file end up sharing the same build directory
per variant.

This patch overrides the getBuildDirBasename method for the InlineTest
class to include the test name.

Differential revision: https://reviews.llvm.org/D81516
2020-06-11 09:36:54 -07:00
Pavel Labath e966a5deaa [lldb] Remove Scalar operator= overloads
The are not needed as Scalar is implicitly constructible from all of
these types (so the compiler will use a combination of a constructor +
move assignment instead), and they make it very easy for implementations
of assignment and construction operations to diverge.
2020-06-11 13:55:02 +02:00
Raphael Isemann dc0f098048 [lldb] Fix a crash in PlatformAppleSimulator::GetCoreSimulatorPath when Xcode developer directory can't be found
Summary:

`PlatformAppleSimulator::GetCoreSimulatorPath` currently checks if
`m_core_simulator_framework_path` wasn't set yet and then tries to calculate its
actual value. However, if `GetXcodeDeveloperDirectory` returns an invalid
FileSpec, `m_core_simulator_framework_path` is never assigned a value which
causes that the `return m_core_simulator_framework_path.getValue();` at the end
of the function will trigger an assert.

This patch just assigns an invalid FileSpec to `m_core_simulator_framework_path`
which seems what the calling code in `PlatformAppleSimulator::LoadCoreSimulator`
expects as an error value.

I assume this can be reproduces on machines that don't have an Xcode
installation, but this patch is mostly based on this backtrace I received from
someone else that tried to run the test suite:

```
Assertion failed: (hasVal), function getValue, file llvm/include/llvm/ADT/Optional.h, line 73.
[...]
3   libsystem_c.dylib             	0x00007fff682a1ac6 __assert_rtn + 314
4   liblldb.11.0.0git.dylib       	0x000000010b835931 PlatformAppleSimulator::GetCoreSimulatorPath() (.cold.1) + 33
5   liblldb.11.0.0git.dylib       	0x0000000107e92f11 PlatformAppleSimulator::GetCoreSimulatorPath() + 369
6   liblldb.11.0.0git.dylib       	0x0000000107e9383e void std::__1::__call_once_proxy<std::__1::tuple<PlatformAppleSimulator::LoadCoreSimulator()::$_1&&> >(void*) + 30
7   libc++.1.dylib                	0x00007fff654d5bea std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) + 139
8   liblldb.11.0.0git.dylib       	0x0000000107e92019 PlatformAppleSimulator::LaunchProcess(lldb_private::ProcessLaunchInfo&) + 89
9   liblldb.11.0.0git.dylib       	0x0000000107e92be5 PlatformAppleSimulator::DebugProcess(lldb_private::ProcessLaunchInfo&, lldb_private::Debugger&, lldb_private::Target*, lldb_private::Status&) + 101
10  liblldb.11.0.0git.dylib       	0x0000000107cb044d lldb_private::Target::Launch(lldb_private::ProcessLaunchInfo&, lldb_private::Stream*) + 669
11  liblldb.11.0.0git.dylib       	0x000000010792c9c5 lldb::SBTarget::Launch(lldb::SBLaunchInfo&, lldb::SBError&) + 1109
12  liblldb.11.0.0git.dylib       	0x0000000107a92acd _wrap_SBTarget_Launch(_object*, _object*) + 477
13  org.python.python             	0x000000010681076f PyCFunction_Call + 321
14  org.python.python             	0x000000010689ee12 _PyEval_EvalFrameDefault + 7738
```

Reviewers: JDevlieghere, jasonmolenda

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D80997
2020-06-11 09:48:39 +02:00
Jonas Devlieghere 6b2e676555 [Debugger] Use FileSystem instead of calling openFileForWrite directly.
This replaces the (only) call to llvm::sys::fs::openFileForWrite with
FileSystem::Open. This guarantees that we include log files in the
reproducers.

Differential revision: https://reviews.llvm.org/D81499
2020-06-10 18:13:32 -07:00
Jonas Devlieghere 351823fbf1 [lldb/Test] Add 'std-module' category and skip them with reproducers
These tests are flaky on the reproducer bot. I suspect it has something
to do with the module cache. Skipping the whole category while I
investigate the issue.
2020-06-10 14:59:05 -07:00
Adrian Prantl 661fcfcd8a debugserver: Enable -DLLDB_ENERGY when compiling against an internal SDK
This brings over functionality from the xcodeproject that went missing during the CMake transition.

rdar://problem/63840635

Differential Revision: https://reviews.llvm.org/D81300
2020-06-10 14:10:27 -07:00
Pavel Labath 42229b6de7 [lldb] XFAIL TestForwardDeclaration.test_debug_names on windows
Before 539b47c9 this test was not actually using the debug_names section
because the -gdwarf added by Makefile.rules on windows overrode the
-gdwarf-5 flag from CFLAGS_EXTRAS. Now that -gdwarf-5 is respected, the
test is failing.
2020-06-10 17:09:51 +02:00
Raphael Isemann bb9d93f4d5 [lldb] Replace the LEB128 decoding logic in LLDB's DataExtractor with calls to LLVM's LEB128 implementation
Reviewers: labath, JDevlieghere

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D81453
2020-06-10 16:35:09 +02:00
Pavel Labath 040eca7717 [lldb/Utility] Remove m_ieee_quad from Scalar
This field is unused (the only way to change its value is via a
constructor which is never called), and as far as I can tell it has been
unused since it was introduced in D12100. It also has some soundness
issues -- e.g.  operator= does not reinitialize it, but uses the old
value from the overwritten object.

It sounds like this class should be able to support different floating
point semantics, but if that is needed, it would be better to start
afresh -- probably by passing in an APFloat::fltSemantics object instead
of a bool flag.
2020-06-10 15:15:01 +02:00
Pavel Labath 539b47c9d1 [lldb/Makefile.rules] Apply CFLAGS_EXTRAS after debug-info mode flags
This makes it possible to conditionally override some of these flags via
CFLAGS_EXTRAS. It should be NFC right now, but this seems the logical
order in which to apply these things, and I am going to make use of this
in another patch.
2020-06-10 14:27:53 +02:00
Raphael Isemann 834708a6a0 [lldb][NFC] Rename ClangExpressionDeclMap::AddThisType and clarify documentation 2020-06-10 12:26:47 +02:00
Jonas Devlieghere 7dd86c9e7c [lldb/Reproducers] Skip test_remove_placeholder_add_real_module with reproducers
Modules are not orphaned and it finds the existing module with the same
UUID from test_partial_uuid_match.
2020-06-09 16:17:53 -07:00
Jonas Devlieghere 2c0afacada [lldb/CMake] Add LLDB_PYTHON_VERSION to use Python 2 with CMake > 3.12
In addition to having the default fallback from Python 3 to Python 2, it
should also be possible to build against Python 2 explicitly. This patch
makes that possible by setting LLDB_PYTHON_VERSION. The variable only
has effect with CMake 3.12 or later.

Differential revision: https://reviews.llvm.org/D81501
2020-06-09 14:11:11 -07:00
Jaroslav Sevcik fac5d05eb7 [lldb] Fix and enable Windows minidump tests
SBFileSpec.fullpath always uses the forward slash to join the directory with the
base name. This causes mismatches when comparing Windows paths with backslashes
in two of the minidump tests. To get around that we just compare the directory
names separately from the filenames.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D81465
2020-06-09 20:03:44 +00:00
Jonas Devlieghere 6c5c4a2a50 [lldb/Reproducers] Also collect ::open and ::fopen
Report files opened trough ::open and ::fopen to the FileCollector.
2020-06-09 11:59:02 -07:00
Jonas Devlieghere de019b88dd [lldb/Interpreter] Support color in CommandReturnObject
Color the error: and warning: part of the CommandReturnObject output,
similar to how an error is printed from the driver when colors are
enabled.

Differential revision: https://reviews.llvm.org/D81058
2020-06-09 10:45:45 -07:00
Raphael Isemann 70a21887f7 [lldb] Test compatibility between a class type from a member function expr and its original version 2020-06-09 15:48:00 +02:00
Jan Kratochvil 4515d35f5c [lldb] Fix DW_TAG_GNU_call_site-DW_AT_low_pc as produced by GCC
D80519 <https://reviews.llvm.org/D80519>
added support for `DW_TAG_GNU_call_site` but
Bug 45886 <https://bugs.llvm.org/show_bug.cgi?id=45886>
found one case did not work.

There is:

  0x000000b1:     DW_TAG_GNU_call_site
                    DW_AT_low_pc  (0x000000000040111e)
                    DW_AT_abstract_origin (0x000000cc "a")
  ...
  0x000000cc:   DW_TAG_subprogram
                  DW_AT_name      ("a")
                  DW_AT_prototyped        (true)
                  DW_AT_low_pc    (0x0000000000401109)
                  ^^^^^^^^^^^^ - here it did overwrite the 'low_pc' variable containing value 0x40111e we wanted
                  DW_AT_high_pc   (0x0000000000401114)
                  DW_AT_frame_base        (DW_OP_call_frame_cfa)
                  DW_AT_GNU_all_call_sites        (true)

DW_TAG_GNU_call_site attributes order as produced by GCC:
0x000000b1:     DW_TAG_GNU_call_site
                  DW_AT_low_pc  (0x000000000040111e)
                  DW_AT_abstract_origin (0x000000cc "a")

clang produces the attributes in opposite order:
0x00000064:     DW_TAG_GNU_call_site
                  DW_AT_abstract_origin (0x0000002a "a")
                  DW_AT_low_pc  (0x0000000000401146)

Differential Revision: https://reviews.llvm.org/D81334
2020-06-09 13:41:41 +02:00