Commit Graph

21971 Commits

Author SHA1 Message Date
Jason Molenda 83bea6d99d Remove 'process launch failed:' message prefix in Target::Launch
SB API clients can describe the failure message in a more natural
way for their UI, this doesn't add information for them.

Differential Revision: https://reviews.llvm.org/D74585
<rdar://problem/49953304>
2020-02-14 18:42:38 -08:00
Jonas Devlieghere 4f2cccc5ce [lldb/Editline] Fix mistake in HistoryOperation mapping
In 0e9b0b6d11 I introduced the
HistoryOperation enum to navigate the history. While this fixed the
behavior of HistoryOperation::Older and HistoryOperation::Newer, it
confused the mapping for HistoryOperation::Oldest and
HistoryOperation::Newest.

I tried to write a PExpect test to make sure this doesn't regress, but
I'm unable to prime the history in such a way that it recalls a known
element. I suspect this is an LLDB bug, but the  most recent entry
doesn't get update with entries from the current session. I considered
spoofing the home directory but that needs to happen before libLLDB is
loaded and you'll need to account for the widechar support. If anyone
has another suggestion I'd love to hear it.
2020-02-14 14:07:29 -08:00
Jonas Devlieghere bba9ba8d95 [lldb/Plugin] s/LLDB_PLUGIN/LLDB_PLUGIN_DEFINE/ (NFC)
Rename LLDB_PLUGIN to LLDB_PLUGIN_DEFINE as Pavel suggested in D73067 to
avoid name conflict.
2020-02-14 09:58:24 -08:00
Raphael Isemann a57ad008b4 [lldb] Print result when expect_expr unexpectedly succeeds 2020-02-14 12:57:10 +01:00
Pavel Labath 9dc84e9b02 [lldb/DWARF] Don't hold a unique SymbolFileDWARFDwo in a DWARFUnit
This is the second dwp preparatory patch. When a SymbolFileDWARFDwo will
hold more than one split unit, it will not be able to be uniquely owned
by a single DWARFUnit. I achieve this by changing the
unique_ptr<SymbolFileDWARFDwo> member of DWARFUnit to
shared_ptr<DWARFUnit>. The shared_ptr points to a DWARFUnit, but it is
in fact holding the entire SymbolFileDWARFDwo alive. This is the same
method used by llvm DWARFUnit (except that is uses the DWARFContext
class).

Differential Revision: https://reviews.llvm.org/D73782
2020-02-14 11:09:45 +01:00
Pavel Labath 07211d951d [lldb/dotest] Remove the "exclusive test subdir" concept
Summary:
This was added in 2018 (r339929), when we were still using the
hand-rolled test runner.

It does not seem to be relevant anymore. In fact as far as I can tell,
it's a big no-op now as the exclusive_test_subdir variable is never set.

Reviewers: vsk, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74551
2020-02-14 10:24:12 +01:00
Pavel Labath 189c701332 [lldb] Remove accidentally checked-in debugging code 2020-02-14 10:21:35 +01:00
Pavel Labath 65e843c9e0 [lldb] Add a test for launch failure and its error message 2020-02-14 08:43:03 +01:00
Jonas Devlieghere 16bf89267e [lldb/Test] Partially revert assertTrue change
This reverts b3a0c4d7dc for
TestBreakpointHitCount.py because it's now timing out on the Windows
bot. I'm not sure this is the cause, but the substitution doesn't look
correct anyway...
2020-02-13 21:55:48 -08:00
Jonas Devlieghere f10e2df7bc [lldb/Plugins] Have one initializer per ABI plugin
After the recent change that grouped some of the ABI plugins together,
those plugins ended up with multiple initializers per plugin. This is
incompatible with my proposed approach of generating the initializers
dynamically, which is why I've grouped them together in a new entry
point.

Differential revision: https://reviews.llvm.org/D74451
2020-02-13 21:49:38 -08:00
Jim Ingham 4570f2c7cf Add a test for debugserver handling threads suspended from within a program.
Mach allows you to suspend and resume other threads within a program, so
debugserver has to be careful not to interfere with this when it goes to supend and
resume threads while stepping over breakpoints and calling functions.  Even
trickier, if you call a function on a suspended thread, it has to resume the
thread to get the expression to run, and then suspend it properly when done.

This all works already, but there wasn't a test for it.  Adding that here.

This same test could be written for a unix that supports pthread_{suspend,resume}_np, but
macOS doesn't support these calls, only the mach version.  It doesn't look like
a lot of Linux'es support this (AIX does apparently...)  And IIUC Windows allows
you to suspend and resume other threads, but the code for that would look pretty
different than this main.c.  So for simplicity's sake I wrote this test for Darwin-only.
2020-02-13 15:48:38 -08:00
Jason Molenda 14d686309a Small reformat to avoid tripping up possible formatting. 2020-02-13 13:06:44 -08:00
Jason Molenda 1287977b9e Document third option to python synthetic type summary
callback unconditionally; it was added to lldb five years
ago and we don't need to qualify its availability.
2020-02-13 13:04:51 -08:00
Greg Clayton 7202d1c2f6 Fix lldb-vscode logging and enable logging for all lldb-vscode tests.
Summary:
This patch fixes logging to log incoming packets which was removed during a refactor.

We also enable logging to a "vscode.txt" file for each lldb-vscode test by creating the log file in the build artifacts directory for each test. This allows users to see the packets for their tests if needed and the log file is in a directory that will be removed after tests have been run.

Reviewers: labath, aadsm, serhiy.redko, jankratochvil, xiaobai, wallace

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74566
2020-02-13 09:58:30 -08:00
Greg Clayton c84a0bd9ad Fix buildbots by disabling this new test until I can fix it.
This tests works on Darwin. I will need to check windows and linux.
2020-02-13 09:32:19 -08:00
Ted Woodward cecc185166 Add REQUIRES: x86 so this won't be run if x86 is not available. 2020-02-13 11:17:27 -06:00
Tatyana Krasnukha 21d09ccf26 [lldb-vscode] Ensure that target matches the executable file
This commit fixes an issue with lldb-vscode failing to run programs that
use different architecture/platform than the "empty" in the target.
Original implementation was creating a default target without specifying
the target architecture, platform or program, and then would set
executable file through SBLaunchInfo, assuming that this would update
architecture and platform accordingly. However this wasn't really
happening, and architecture and platform would remain at whatever values
were in the "empty" target. The simple solution is to create target
already for a desired architecture and platform.

Function request_attach is updated in a similar fashion.

This commit also adds new JSON properties to "launch" and "attach"
packets to allow user to override desired platform and architecture.
This might be especially important for cases where information in ELF is
not enough to derive those values correctly.

New code has a behavior similar to LLDB MI [1], where typically IDE would
specify target file with -file-exec-and-symbols, and then only do -exec-run
command that would launch the process. In lldb-vscode those two actions are
merged into one request_launch function. Similarly in the interpreter
session, user would first do "file" command, then "process launch"

Differential Revision: https://reviews.llvm.org/D70847
Signed-off-by: Anton Kolesov <anton.kolesov@synopsys.com>
2020-02-13 19:34:01 +03:00
Greg Clayton 9cb227f561 Stop emitting a breakpoint for each location in a breakpoint when responding to breakpoint commands.
Summary: The VS Code DAP expects on response for each breakpoint that was requested. If we responsd with multiple entries for one breakpoint the VS Code UI gets out of date. Currently the VS code DAP doesn't handle one breakpoint with multiple locations. If this ever gets fixed we can modify our code.

Reviewers: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73665
2020-02-13 08:23:19 -08:00
Francesco Petrogalli 7a0e98bc74 [llvm][lldb] Update links to ABI for the Arm Architecture. [NFC] 2020-02-13 14:57:53 +00:00
Pavel Labath 12e32d32d3 [lldb] Introduce "RegInfoBasedABI"
Summary:
This patch creates a new subclass of the ABI class in order to abstract away the
mechanism in which we "augment" register information. This enables alternate
augmentation strategies to be introduced.

All existing ABI classes have been modified to inherit from RegInfoBasedABI, but
they will be refactored in subsequent patches.

Reviewers: JDevlieghere, jasonmolenda

Subscribers: sdardis, nemanjai, kbarton, jrtc27, atanasyan, jsji, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74243
2020-02-13 15:29:12 +01:00
Raphael Isemann b3a0c4d7dc [lldb] Replace assertTrue(a == b, "msg") with assertEquals(a, b, "msg") in the test suite
Summary:
The error message from the construct `assertTrue(a == b, "msg") ` are nearly always completely useless for actually debugging the issue.
This patch is just replacing this construct (and similar ones like `assertTrue(a != b, ...)` with the proper call to assertEqual or assertNotEquals.

This patch was mostly written by a shell script with some manual verification afterwards:
```
lang=python
import sys

def sanitize_line(line):
  if line.strip().startswith("self.assertTrue(") and " == " in line:
    line = line.replace("self.assertTrue(", "self.assertEquals(")
    line = line.replace(" == ", ", ", 1)
  if line.strip().startswith("self.assertTrue(") and " != " in line:
    line = line.replace("self.assertTrue(", "self.assertNotEqual(")
    line = line.replace(" != ", ", ", 1)
  return line

for a in sys.argv[1:]:
  with open(a, "r") as f:
    lines = f.readlines()
  with open(a, "w") as f:
    for line in lines:
      f.write(sanitize_line(line))
```

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74475
2020-02-13 15:00:55 +01:00
Pavel Labath 91e0c258c2 [lldb] Fix lldb-dotest
to account for the new location of test files from 99451b445.
2020-02-13 14:31:08 +01:00
Pavel Labath 5d3926a5a2 [lldb] Clean up ProcessGDBRemote::DidLaunchOrAttach
- reduce indentation by removing the defensive
  GetID()!=INVALID_PROCESS_ID check -- this function is only called when
  an attach or launch succeeds
- replace LLDB_LOGF with LLDB_LOG
2020-02-13 10:32:15 +01:00
Pavel Labath cb6c9f731b [lldb] Make gdbremote.py utility py2and3 compatible 2020-02-13 09:18:55 +01:00
Jonas Devlieghere 6e30fd05c9 [lldb/Plugins] Move DynamicLoaderMacOS into DynamicLoaderMacOSXDYLD (NFCI)
Move the logic for initialization and termination for DynamicLoaderMacOS
into DynamicLoaderMacOSXDYLD so that there's one initializer for the
DynamicLoaderMacOSXDYLD plugin.
2020-02-12 13:44:20 -08:00
Jonas Devlieghere 654086cbf5 [lldb/Plugins] Move SymbolFileDWARFDebugMap into SymbolFileDWARF (NFCI)
Move the logic for initialization and termination for
SymbolFileDWARFDebugMap into SymbolFileDWARF so that there's one
initializer for the SymbolFileDWARF plugin.
2020-02-12 11:30:17 -08:00
Vedant Kumar 90a94c02fb [lldb/LibCxx] Have ExtractLibcxxStringInfo return an Optional result, NFC
Differential Revision: https://reviews.llvm.org/D74018
2020-02-12 11:24:03 -08:00
Vedant Kumar 7aabad1312 [lldb/StringPrinter] Avoid reading garbage in uninitialized strings
This patch fixes a few related out-of-bounds read bugs in the
string data formatters. These issues have to do with mishandling of un-
initialized strings. These manifest as ASan exceptions when debugging a
clang binary.

The first issue was that the std::string formatter treated strings in
"short mode" with length greater than the size of the inline buffer as
valid.

The second issue was that the StringPrinter facility did not check that
a full utf8 codepoint sequence can be read from the buffer (i.e. there
are some missing range checks). I took the opportunity here to delete
some untested code that was meant to deal with invalid input and replace
it with fail-on-invalid logic ([1][2][3]). This means we'll give up on
formatting an invalid string instead of guessing our way through it.

The third issue is that StringPrinter did not check that a utf8 sequence
could actually be fully read from the string payload. This one is especially
tricky as we may overflow the buffer pointer while reading the sequence.

I also noticed that the std::string formatter would spew the raw version of
the underlying ValueObject when garbage is detected. I've changed this to
just print "Summary Unavailable" instead, as we do elsewhere.

I've added regression tests for these issues to
test/functionalities/data-formatter/data-formatter-stl/libcxx/string.

[1]
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/DataFormatters/StringPrinter.cpp.html#L136
[2]
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/DataFormatters/StringPrinter.cpp.html#L163
[3]
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/DataFormatters/StringPrinter.cpp.html#L357

rdar://59080026

Differential Revision: https://reviews.llvm.org/D73860
2020-02-12 11:24:03 -08:00
Vedant Kumar d6e47a405a [lldb/TypeSystemClang] Supply trivial TypeSourceInfo to NonTypeTemplateParmDecl::Create
This fixes a UBSan error seen while debugging clang:

Member call on null pointer of type 'clang::TypeSourceInfo'

rdar://58783517

Differential Revision: https://reviews.llvm.org/D73808
2020-02-12 11:24:02 -08:00
Pavel Labath 034c2c6771 [lldb/DWARF] Use DWARFDebugInfoEntry * in ElaboratingDIEIterator
This is simpler, faster, and sufficient to uniquely idenify a DIE.
2020-02-12 12:48:49 +01:00
Martin Storsjö 7002128ca9 [LLDB] Fix GCC warnings about extra semicolons. NFC. 2020-02-12 13:40:33 +02:00
Djordje Todorovic 97ed706a96 Revert "[DebugInfo] Enable the debug entry values feature by default"
This reverts commit rG9f6ff07f8a39.

Found a test failure on clang-with-thin-lto-ubuntu buildbot.
2020-02-12 11:59:04 +01:00
Raphael Isemann 320647c02a [lldb] Pass a valid SourceLocation to Sema::RequireCompleteType in ASTResultSynthesizer
Sema::RequireCompleteTypeImpl is supposed to have an assert that checks that the
SourceLocation that is passed in is always valid. It's currently commented out, but
as soon as this assert goes active, nearly every LLDB expression will start crashing as
we always pass in an invalid SourceLocation from the ASTResultSynthesizer.

This patch just passes in the valid SourceLocation of the expression (which is
the SourceLocation where the complete type is required) to prevent that from happening.
2020-02-12 11:22:56 +01:00
Djordje Todorovic 9f6ff07f8a [DebugInfo] Enable the debug entry values feature by default
This patch enables the debug entry values feature.

  - Remove the (CC1) experimental -femit-debug-entry-values option
  - Enable it for x86, arm and aarch64 targets
  - Resolve the test failures
  - Leave the llc experimental option for targets that do not
    support the CallSiteInfo yet

Differential Revision: https://reviews.llvm.org/D73534
2020-02-12 10:25:14 +01:00
Raphael Isemann 30ce956aec [lldb][NFC] Remove GetConstTypeName and GetConstQualifiedTypeName from CompilerType
Beside these two functions just being wrappers around GetTypeName they are also
just a leftover from migrating the CompilerType interface to ConstString.
2020-02-12 09:49:39 +01:00
Raphael Isemann 440460f1e7 [lldb][NFC] Move common_completions mapping out of CommandCompletions header. 2020-02-12 09:48:51 +01:00
Raphael Isemann 4617fb0b7f [lldb] Move implementation of GetDisplayName to TypeSystem class
CompilerType doesn't implement logic.
2020-02-12 09:32:09 +01:00
Raphael Isemann 572fc89742 [lldb][NFC] Move all completer subclasses into source file
They are all implementation details so let's keep them out of the interface.
Also makes this code more readable by keeping these small classes
not spread over header and source file.
2020-02-12 09:08:44 +01:00
Raphael Isemann 477c09043e [lldb][NFC] Remove eCustomCompletion mode
It's not used by anyone. Also if something implements its own
completion it could just not call the method instead of having
a parameter that makes the function a no-op.
2020-02-12 08:34:02 +01:00
Raphael Isemann 346cb7b50f [lldb] Remove skipIfFreeBSD from TestCompletion
This was skipped because of an pexpect issue (http://llvm.org/pr22784),
but this test is no longer using pexpect and is running fine on FreeBSD.
2020-02-12 07:14:46 +01:00
Davide Italiano d797e33cc0 [TestConstVariable] Clean-up XFAIL lists.
These versions of `clang` are ancient history.
2020-02-11 20:31:09 -08:00
Jonas Devlieghere 413307d456 [lldb/Plugins] Rename OSPython plugin to OperatingSystemPython (NFC)
Rename the plugin to match both the directory structure and the class.
2020-02-11 16:32:08 -08:00
Jason Molenda f9fdd1172c Rewrite default "could not attach" msg to point to hints
about where more information can be found about why it
may have failed.
<rdar://problem/59277928>
2020-02-11 16:18:49 -08:00
Jonas Devlieghere 2d3ecade38 [lldb/Plugins] Move PlatformRemoteiOS into PlatformMacOSX (NFCI)
Move the logic for initialization and termination for PlatformRemoteiOS
into PlatformMacOSX, like we did for the other Darwin platforms in
a731c6ba94.
2020-02-11 15:54:36 -08:00
Raphael Isemann f65f9d3bc5 [lldb][NFC] Test ModuleCompletion mode by completing the target modules load argument 2020-02-11 20:38:21 +01:00
Raphael Isemann 8888992dee [lldb][NFC] Test SourceFileCompletion by completing the target line-table argument 2020-02-11 19:59:21 +01:00
Jordan Rupprecht 99451b4453 [lldb][test] Remove symlink for API tests.
Summary: Moves lldbsuite tests to lldb/test/API.

This is a largely mechanical change, moved with the following steps:

```
rm lldb/test/API/testcases
mkdir -p lldb/test/API/{test_runner/test,tools/lldb-{server,vscode}}
mv lldb/packages/Python/lldbsuite/test/test_runner/test lldb/test/API/test_runner
for d in $(find lldb/packages/Python/lldbsuite/test/* -maxdepth 0 -type d | egrep -v "make|plugins|test_runner|tools"); do mv $d lldb/test/API; done
for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-vscode -maxdepth 1 -mindepth 1 | grep -v ".py"); do mv $d lldb/test/API/tools/lldb-vscode; done
for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-server -maxdepth 1 -mindepth 1 | egrep -v "gdbremote_testcase.py|lldbgdbserverutils.py|socket_packet_pump.py"); do mv $d lldb/test/API/tools/lldb-server; done
```

lldb/packages/Python/lldbsuite/__init__.py and lldb/test/API/lit.cfg.py were also updated with the new directory structure.

Reviewers: labath, JDevlieghere

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71151
2020-02-11 10:03:53 -08:00
Raphael Isemann 62174682a0 [lldb][NFC] Remove support file searching from SourceFileCompleter
This code seems wrong as the directory variable actually contains
the file name. It's also unreachable code as m_include_support_files
is hardcoded to false which is the condition for the surrounding 'if
statement'. Let's just remove all of this.
2020-02-11 18:50:25 +01:00
Jan Kratochvil 98c940bf51 [NFC] [lldb] Remove unused declaration
ObjectFileELF::GetSectionIndexByType declaration without definition was
added by commit 17220c1886.
2020-02-11 14:59:52 +01:00
Raphael Isemann e8e7cf810c [lldb][NFC] Remove the CppVirtualMadness test
We now have a virtual-functions test and a multiple-inheritance test that
are testing the same functionality (and more) using the newer test functions which
we have in LLDB these days. These tests should also be less flaky and
less dependent on other unrelated LLDB functionality.
2020-02-11 14:09:58 +01:00