Commit Graph

23678 Commits

Author SHA1 Message Date
Jonas Devlieghere
c565f09f4b [lldb] Don't strip LLDB.framework on install
The framework build will run dsymutil after LLDB.framework is installed.
2020-10-20 18:16:36 -07:00
Jonas Devlieghere
de6f3d1c71 [lldb] Add a page to the docs with (external) links on how to use LLDB
In a discussion with Jim last week we came to the realization that often
we get asked about things that might not be documented on the website,
but that have been pretty well explained elsewhere. In those situations
it's often easier to quickly answer the question than searching for that
presentation you gave 3 years ago if you remember at all.

This often results in us having to answer the same questions over and
over again. We could add the questions and their answer to the website,
but that means we (1) have to duplicate the work and (2) now have to
maintain it.

A more efficient solution is to add a page with external resources with
the caveat that they might be outdated. That's exactly the purpose of
this patch.

I've added a few links that came to mind, but I don't want to be the
arbiter of what should and should not be included. I'd hope that over
time the community can crowd-source the best resources.

Differential revision: https://reviews.llvm.org/D89215
2020-10-20 11:43:31 -07:00
Duncan P. N. Exon Smith
b333d6e129 lldb: Migrate to MemoryBufferRef for createFileID (after 51d1d585e5)
I missed these two lldb users before deleting the `UnownedTag` API for
`createFileID` in 51d1d585e5. This should
fix the build.
2020-10-20 13:52:39 -04:00
Jason Molenda
c932266c8d Add a nul byte to packet str before logging, increase default size.
Add a nul byte to the stream in CommunicationKDP::CheckForPacket
before we send the GetData() to a Log::Printf as a c-str.  Avoids
a crash when logging kdp communications and memory layout isn't
in your favor.
2020-10-20 01:43:31 -07:00
Duncan P. N. Exon Smith
f96e16bc15 lldb: Update for change in clang::Lexer's constructor
b3eff6b7bb updated `Lexer::Lexer` to take
`clang::MemoryBufferRef` instead of `clang::MemoryBuffer*`. Update LLDB
to fix the bots.
2020-10-19 20:09:27 -04:00
Walter Erquinigo
8a203bb22d [trace] rename ThreadIntelPT into TraceTrace
Renamed ThreadIntelPT to TreaceThread, making it a top-level class. I noticed that this class can and shuld work for any trace plugin and there's nothing intel-pt specific in it.
With that TraceThread change, I was able to move most of the json file parsing logic to the base class TraceSessionFileParser, which makes adding new plug-ins easier.

This originally was part of https://reviews.llvm.org/D89283

Differential Revision: https://reviews.llvm.org/D89408
2020-10-19 15:15:02 -07:00
Alexandre Ganea
89b72209ad [LLDB][TestSuite] Improve skipIfWindowsAndNonEnglish in decorators.py
Differential Revision: https://reviews.llvm.org/D89716
2020-10-19 14:28:08 -04:00
Jan Kratochvil
0e5248be86 [nfc] [lldb] Move LookupAddress to DWARFCompileUnit
LookupAddress makes no sense for DWARFTypeUnit.
Also make GetNonSkeletonUnit to preserve the called type.

Differential Revision: https://reviews.llvm.org/D89646
2020-10-19 12:44:33 +02:00
Pavel Labath
dfb2266328 [lldb] Make DW_AT_declaration-with-children.s test more realistic
(Re)add DW_AT_specification and DW_AT_object_pointer attributes. These
were removed in fa89f641c, as they were bogus due to bad test case
reduction.
2020-10-19 10:34:13 +02:00
Jan Kratochvil
fa89f641cf [nfc] [lldb] [testsuite] Fix DW_FORM_ref* in DW_AT_declaration-with-children.s .
There were invalid DIE references which nobody used. If LLDB starts to
report invalid DIE references it would lock up (mutex lock).

These invalid DIE references are there since initial check-in by:
  https://reviews.llvm.org/D83302
2020-10-18 16:57:27 +02:00
Jan Kratochvil
224caaf69b [nfc] [lldb] Delete an empty trailing line.
A patchset being prepared shows needless diffs.
2020-10-18 10:16:00 +02:00
Dave Lee
ae4fe1984f [lldb] Enable cmake policy CMP0077 for option()
In lldb, explicitly set the "option() honors normal variables" CMake policy. This applies for
standalone lldb builds and matches what llvm, clang, etc do. This prevents potentially unwanted
clearing of variables like `LLVM_ENABLE_WARNINGS`, and also prevents unnecessary build warnings.

See: https://cmake.org/cmake/help/latest/policy/CMP0077.html

Differential Revision: https://reviews.llvm.org/D89614
2020-10-17 00:16:24 -07:00
Jason Molenda
32021eeff0 Un-indent the section on 'Writing Target Stop-Hooks in Python'
it was ending up in a code block from the previous section,
instead of being its own section.
2020-10-16 23:23:25 -07:00
Sriraman Tallam
2e5b701d93 This test includes a source that will produce basic blocks and hence sections with -fbasic-block-sections=all.
The test reorders the basic blocks to be dis-contiguous in the address space and checks if the back trace contains the right symbol.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D89179
2020-10-16 21:31:42 -07:00
Dave Lee
f16cecf375 [lldb] Implement ObjCExceptionThrowFrameRecognizer::GetName()
Implement `GetName` for `ObjCExceptionThrowFrameRecognizer`. Otherwise, `frame recognizer list` shows "(internal)" for the name.

Differential Revision: https://reviews.llvm.org/D89589
2020-10-16 14:24:03 -07:00
Adrian Prantl
cf24508651 Add support for more OS types to AddClangModuleCompilationOptionsForSDKType()
This patch also avoids hardcoding the clang options, which makes it
less likely for them to become out-of-date.

rdar://problem/63791367+66927829

Differential Revision: https://reviews.llvm.org/D89428
2020-10-16 11:43:22 -07:00
Joseph Tremoulet
d30797b404 [lldb] Minidump: check for .text hash match with directory
When opening a minidump, we might discover that it reports a UUID for a
module that doesn't match the build ID, but rather a hash of the .text
section (according to either of two different hash functions, used by
breakpad and Facebook respectively).  The current logic searches for a
module by filename only to check the hash; this change updates it to
first search by directory+filename.  This is important when the
directory specified in the minidump must be interpreted relative to a
user-provided sysoort, as the leaf directory won't be in the search path
in that case.

Also add a regression test; without this change, module validation fails
because we have just the placeholder module which reports as its path
the platform path in the minidump.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D89155
2020-10-16 09:32:08 -04:00
Pavel Labath
daae4a8482 [lldb] Modernize PseudoTerminal::OpenSecondary 2020-10-16 15:22:55 +02:00
Pavel Labath
e338ca7bce [lldb] Fix FreeBSD build for ea3a547 2020-10-16 13:50:53 +02:00
Jim Ingham
6754caa9bf Add an SB API to get the SBTarget from an SBBreakpoint
Differential Revision: https://reviews.llvm.org/D89358
2020-10-15 14:28:44 -07:00
Michał Górny
87d38831d9 [lldb] [Process/FreeBSDRemote] Initial multithreading support
Implement initial support for watching thread creation and termination.
Update ptrace() calls to correctly indicate requested thread.
Watchpoints are not supported yet.

This patch fixes at least multithreaded register tests.

Differential Revision: https://reviews.llvm.org/D89413
2020-10-15 17:37:37 +02:00
Raphael Isemann
82ed18601d [lldb] Explicitly test the template argument SB API 2020-10-15 11:17:43 +02:00
Jason Molenda
af5504edd6 Increase timeout to find a dSYM in macos DownloadObjectAndSymbolFile
With a large dSYM over a slow home connection, the two minute timeout
would sometimes be exceeded, and we haven't seen instances of a
long timeout causing people any problems, so we're bumping it up.

640 seconds ought to be enough for anyone.

<rdar://problem/67759526>
2020-10-15 00:57:23 -07:00
Jason Molenda
b19856881c Fix typeo in attach failed error message.
<rdar://problem/70296751>
2020-10-14 23:31:24 -07:00
Pavel Labath
a1ab2b773b [lldb] More memory allocation test fixes
XFAIL nodefaultlib.cpp on darwin - the test does not pass there

XFAIL TestGdbRemoteMemoryAllocation on windows - memory is allocated
with incorrect permissions
2020-10-14 20:43:47 +02:00
Michał Górny
ff30bff136 [lldb] [Process/FreeBSDRemote] Support YMM reg via PT_*XSTATE
Add a framework for reading/writing extended register sets via
PT_GETXSTATE/PT_GETXSTATE_INFO/PT_SETXSTATE, and use it to support
YMM0..YMM15.  The code is prepared to handle arbitrary XSAVE extensions,
including correct offset handling.

This fixes Shell/Register/*ymm* tests.

Differential Revision: https://reviews.llvm.org/D89193
2020-10-14 19:56:46 +02:00
Pavel Labath
36f22cd28d [lldb] Fix TestGdbRemoteMemoryAllocation on windows
It appears that memory allocation actually works on windows (but it was
not fully wired up before 2c4226f8).
2020-10-14 16:46:10 +02:00
Pavel Labath
ea3a547f0b [lldb] Remove bogus ProcessMonitor forward-decls
This class is not used in those files.
2020-10-14 16:43:45 +02:00
Pavel Labath
2c4226f8ac [lldb-server][linux] Add ability to allocate memory
This patch adds support for the _M and _m gdb-remote packets, which
(de)allocate memory in the inferior. This works by "injecting" a
m(un)map syscall into the inferior. This consists of:
- finding an executable page of memory
- writing the syscall opcode to it
- setting up registers according to the os syscall convention
- single stepping over the syscall

The advantage of this approach over calling the mmap function is that
this works even in case the mmap function is buggy or unavailable. The
disadvantage is it is more platform-dependent, which is why this patch
only works on X86 (_32 and _64) right now. Adding support for other
linux architectures should be easy and consist of defining the
appropriate syscall constants. Adding support for other OSes depends on
the its ability to do a similar trick.

Differential Revision: https://reviews.llvm.org/D89124
2020-10-14 15:02:09 +02:00
Pavel Labath
6bb123b819 [lldb] Modernize PseudoTerminal::OpenFirstAvailablePrimary
replace char*+length combo with llvm::Error
2020-10-14 14:55:03 +02:00
Michał Górny
caedbc317a [lldb] [test/Register] Add read/write tests for multithreaded process
Add a test to verify that 'register read' and 'register write' commands
work correctly in a multithreaded program, in particular that they read
or write registers for the correct thread.  The tests use locking
to ensure that events are serialized and the test can execute reliably.

Differential Revision: https://reviews.llvm.org/D89248
2020-10-14 11:08:36 +02:00
Raphael Isemann
cb81e662a5 [lldb] Reject redefinitions of persistent variables
Currently one can redefine a persistent variable and LLDB will just silently
ignore the second definition:

```
(lldb) expr int $i = 1
(lldb) expr int $i = 2
(lldb) expr $i
(int) $i = 1
```

This patch makes this an error and rejects the expression with the second
definition.

A nice follow up would be to refactor LLDB's persistent variables to not just be
a pair of type and name, but also contain some way to obtain the original
declaration and source code that declared the variable. That way we could
actually make a full diagnostic as we would get from redefining a variable twice
in the same expression.

Reviewed By: labath, shafik, JDevlieghere

Differential Revision: https://reviews.llvm.org/D89310
2020-10-14 10:24:35 +02:00
Jonas Devlieghere
3b33b41604 [lldb] Remove lexical block and fix formatting LoadScriptingModule (NFC) 2020-10-13 23:50:57 -07:00
Jonas Devlieghere
1197ee35b8 [lldb] Unconditionally strip the .py(c) extension when loading a module
Currently we only strip the Python extension when the file exists on
disk because we assumed that if it didn't exist it was a module.
However, with the change from D89334 this is no longer the case as we
want to be able to import a relative path to a .py as a module. Since we
always import a scripting module as a "python module" we should always
strip the extension if present.

Differential revision: https://reviews.llvm.org/D89352
2020-10-13 23:50:57 -07:00
Adrian Prantl
f9586a3b3c Replace bool constants with named constants for improved readibility (NFC) 2020-10-13 17:41:26 -07:00
Adrian Prantl
9b1c06c0e8 Move initialization of Variable::m_loc_is_const_data into constructor (NFC)
This makes it symmetric with all other flags and makes it easier to
not forget to initialize it.

https://reviews.llvm.org/D89351
2020-10-13 17:01:28 -07:00
Jason Molenda
7d67c06391 Remove unused build configurations from debugserver xcode project
the xcode project file for debugserver exists only to make my
life easier when I'm working only on debugserver and don't need
to build the rest of llvm/lldb.  It had many build configurations
to reflect our old lldb xcode project file, which is long gone.
Removing them to simplify the configurations.

Specifically dropping CustomSwift-Debug, DebugClang, DebugPresubmission,
CustomSwift-Release, BuildAndIntegration.  Keeping Debug & Release.
2020-10-13 16:39:30 -07:00
Jason Molenda
e763709d14 Add a new launch flag option for watchos, WatchComplicationLaunch.
Link against CarouselServices on watchos, recognize the
WatchComplicationLaunch launch flag option when that framework
is available.

<rdar://problem/62473967>, <rdar://problem/61230088>
2020-10-13 16:28:16 -07:00
Raphael Isemann
6733b25447 [lldb][cmake] Remove custom logic for finding VCS file to fix LLDB's VCSVersion.inc generation
We are still implementing our own logic for this that looks for a VCS file in
the place where it was before the monorepo migration. This removes this logic
and just uses the CMake function that LLVM/Clang are using.

Reviewed By: JDevlieghere, kastiglione

Differential Revision: https://reviews.llvm.org/D88950
2020-10-13 17:14:43 +02:00
Raphael Isemann
02114e15da [lldb] Allow limiting the number of error diagnostics when parsing an expression
While debugging another bug I found out that we currently don't set any limit
for the number of diagnostics Clang emits. If a user does something that
generates a lot of errors (like including some long header file from within the
expression function), then we currently spam the LLDB output with potentially
thousands of Clang error diagnostics.

Clang sets a default limit of 20 errors, but given that LLDB is often used
interactively for small expressions I would say a limit of 5 is enough. The
limit is implemented as a setting, so if a user cares about seeing having a
million errors printed to their terminal then they can just increase the
settings value.

Reviewed By: shafik, mib

Differential Revision: https://reviews.llvm.org/D88889
2020-10-13 17:12:43 +02:00
Raphael Isemann
24e07570cc [lldb] Remove all the RegisterInfo name constification code
RegisterInfo's `reg_name`/`reg_alt_name` fields are C-Strings and are supposed
to only be generated from a ConstString. The reason for that is that
`DynamicRegisterInfo::GetRegisterInfo` and
`RegInfoBasedABI::GetRegisterInfoByName` try to optimise finding registers by
name by only comparing the C string pointer values instead of the underlying
strings. This only works if both C strings involved in the comparison come from
a ConstString. If one of the two C strings doesn't come from a ConstString the
comparison won't work (and most likely will silently fail).

I added an assert in b0060c3a78 which checks that
both strings come from a ConstString. Apparently not all ABI plugins are
generating their register names via ConstString, so this code is now not just
silently failing but also asserting.

In D88375 we did a shady fix for the MIPS plugins by just copying the
ConstString setup code to that plugin, but we still need to fix ABISysV_arc,
ABISysV_ppc and ABISysV_ppc64 plugins.

I would say we just fix the remaining plugins by removing the whole requirement
to have the register names coming from ConstStrings. I really doubt that we
actually save any time with the whole ConstString search trick (searching ~50
strings that have <4 characters doesn't sound more expensive than calling the
really expensive ConstString constructor + comparing the same amount of pointer
values). Also whatever small percentage of LLDB's runtime is actually spend in
this function is anyway not worth the complexity of this approach.

This patch just removes all this and just does a normal string comparison.

Reviewed By: JDevlieghere, labath

Differential Revision: https://reviews.llvm.org/D88490
2020-10-13 17:10:29 +02:00
Raphael Isemann
4cd873c4bd [lldb][NFC] Remove property predicate matcher
That's supposed to be used to implement things such as `settings set target.run-args{basename==test&&arch==x86_64} arg1`
but it's not actually fully implemented or tested anywhere.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D88910
2020-10-13 17:09:27 +02:00
Raphael Isemann
ef733d9df4 [lldb] Add targets for running test suite against Watch/TV/iPhone simulators
This patch adds several build system targets that run the normal test suite but
against the Watch/TV/iPhone simulators.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D89224
2020-10-13 17:07:46 +02:00
Raphael Isemann
dfc7243952 [lldb] Don't add no-sandbox entitlement when running tests on simulator
It seems that if codesigning the test executables with the
`com.apple.private.security.no-sandbox` entitlement then the simulator refuses
to launch them and every test fails with `Process launch failed: process exited
with status -1 (no such process.)`.

This patch checks if we're trying to run the test suite on the simulator and
then avoids signing the executable with `no-sandbox`.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D89052
2020-10-13 15:08:46 +02:00
Raphael Isemann
480c440f9a [lldb] Don't let dotest silently fall back to default SDK if the specified one can't be found
If the SDK name passed to dotest can't be found by `xcrun` we silently fall back
to the default SDK. This leads to rather cryptic errors being reported later on
when linking the actual test executables.

Instead just directly log and abort when this situation is encountered and
inform the user about the invalid argument.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D89053
2020-10-13 15:07:45 +02:00
Raphael Isemann
f4f4d54ae0 [lldb] Fill Watch/AppleTV simulator gaps in PlatformDarwin
When running the test suite against the Watch/AppleTV simulator we currently hitting
the unimplemented parts of PlatformDarwin for the respective simulator platforms.

This just adds the respective switch cases.

This whole code path depends on having a valid Target, so can't just unittest this code
without refactoring it. So instead this is tested by just running the testsuite against
the respective simulators (which is how I found this).

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D89106
2020-10-13 15:06:41 +02:00
Adrian Prantl
ec2c2ad2a2 Add accessors. (NFC)
There's a place in swift-lldb where it is useful to create a copy of
an lldb_private::Variable. Adding these two accessors makes this
possible.
2020-10-12 17:45:49 -07:00
Dave Lee
08924b54de [lldb] Remove unused code in GetVersion (NFC)
Small cleanup to `lldb_private::GetVersion()`.

Differential Revision: https://reviews.llvm.org/D88939
2020-10-12 16:31:14 -07:00
Dave Lee
a52cc9b4be [lldb] Handle alternative output in TestAbortExitCode
This test

On macOS, this test can instead return `status = 0 (0x00000000) Terminated due to signal 6`. This updates the `CHECK` accordingly.

Differential Revision: https://reviews.llvm.org/D89273
2020-10-12 16:27:06 -07:00
Jonas Devlieghere
360ab009e2 [lldb] Add instrumentation runtime category 2020-10-12 16:02:40 -07:00