Commit Graph

16695 Commits

Author SHA1 Message Date
Vedant Kumar 9c36859b33 [MachException] Avoid alignment UB, NFC
Fix alignment UB in some Mach exception-handling logic.

This lets us build lldb and debugserver with UBSan in trapping mode, and
get further along in the testing process before a trap is encountered.

rdar://35923991

llvm-svn: 320127
2017-12-08 01:09:40 +00:00
Vedant Kumar b773e488c9 Remove extant references to g_message_mutex, NFC
Thanks to Jim Ingham for providing the explanation!

llvm-svn: 320126
2017-12-08 01:09:39 +00:00
Jim Ingham 6c96486962 These tests don't depend on debug info format.
Mark them as such.

llvm-svn: 320077
2017-12-07 19:44:09 +00:00
Vedant Kumar 9df6e0a5ea Disable warnings related to anonymous types in the ObjC plugin
This part of lldb make use of anonymous structs and unions. The usage is
idiomatic and doesn't deserve a warning. Logic in the NSDictionary and NSSet
plugins use anonymous structs in a manner consistent with the relevant Apple
frameworks.

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

llvm-svn: 320071
2017-12-07 18:57:09 +00:00
Davide Italiano e2564051be [SBBreakpointOptionCommon] Give this class an explicit destructor.
llvm-svn: 320067
2017-12-07 18:06:06 +00:00
Davide Italiano c218ee58ac [SBBreakpoint] Outline some functions to prevent to be exported.
They're hidden, so all they cause is a linker warning.

ld: warning: cannot export hidden symbol
lldb::SBBreakpointNameImpl::operator==(lldb::SBBreakpointNameImpl const&) from
tools/lldb/source/API/CMakeFiles/liblldb.dir/SBBreakpointName.cpp.o

llvm-svn: 320066
2017-12-07 18:06:06 +00:00
Davide Italiano e1407c2c13 [Target] Remove commented out code. Found by inspection. NFCI.
llvm-svn: 320060
2017-12-07 17:05:56 +00:00
Pavel Labath 62ef18562b Variable: Fix usage of uninitialised value
Summary:
Variable::GetValuesForVariableExpressionPath was passing an
uninitialised value for the final_task_on_target argument. On my
compiler/optimization level combo, the final_task_on_target happened to
contain "dereference" in some circumstances, which produced hilarious
results. The same is true for other arguments to the
GetValueForExpressionPath call.

The correct behavior here seems to be to just omit the arguments
altogether and let the default behavior take place.

Reviewers: jingham

Subscribers: mehdi_amini, lldb-commits

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

llvm-svn: 320021
2017-12-07 10:38:22 +00:00
Shoaib Meenai 5e8d5ccfe7 [lldb] Use PRIVATE in target_link_libraries
This is a follow-up to r319840. I guess none of the systems I'd tested
on before had LLDB_SYSTEM_LIBS set, which is why I didn't see any local
errors, but I'm surprised none of the bots caught it either.

llvm-svn: 319953
2017-12-06 20:53:03 +00:00
Vedant Kumar 50048ac65e Fix the -Wunused-function warning properly (MachProcess.mm)
r319938 was not NFC, because it got the preprocessor guard wrong. Check
WITH_FBS and WITH_BKS before defining SplitEventData.

llvm-svn: 319943
2017-12-06 19:27:20 +00:00
Vedant Kumar 94d788fa78 Fix const-correctness in RegisterContext methods, NFC
A few methods in RegisterContext classes accept const objects which are
cast to a non-const thread_state_t. Drop const-ness more explicitly
where we mean to do so. This fixes a slew of warnings.

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

llvm-svn: 319939
2017-12-06 19:21:12 +00:00
Vedant Kumar eacb0929e8 Fix an -Wunused-function warning, NFC
llvm-svn: 319938
2017-12-06 19:21:11 +00:00
Vedant Kumar 07d956149b Fix misc -Wcast-qual warnings, NFC
llvm-svn: 319937
2017-12-06 19:21:11 +00:00
Vedant Kumar 606908aab5 Remove no-op function pointer null checks, NFC
Null-checking functions which aren't marked weak_import is a no-op
(the compiler rewrites the check to 'true'), regardless of whether a
library providing its definition is weak-linked. If the deployment
target is greater than the minimum requirement, the availability markup
on APIs does not lower to weak_import.

Remove no-op null checks to clean up the code and silence warnings.

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

llvm-svn: 319936
2017-12-06 19:21:10 +00:00
Vedant Kumar 8465c38b1e Use a static_cast instead of a C cast, NFC
Pointed out by Davide Italiano in post-commit review.

llvm-svn: 319935
2017-12-06 19:21:09 +00:00
Vedant Kumar a73324b0a9 [MappedHash] Fix alignment violations
This fixes a few alignment problems pointed out by UBSan, and is
otherwise NFC.

llvm-svn: 319934
2017-12-06 19:21:08 +00:00
Fangrui Song c09bce1146 Do not use default arguments of DataLayout::getPointer*. NFC
Summary: There are "FIXME"s in include/llvm/IR/DataLayout.h to remove the default arguments.

Reviewers: zturner, clayborg

Reviewed By: zturner

Subscribers: bjope

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

llvm-svn: 319869
2017-12-06 01:32:06 +00:00
Shoaib Meenai d806af3499 [CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.

Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.

Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).

Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.

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

llvm-svn: 319840
2017-12-05 21:49:56 +00:00
Davide Italiano f363fd8d30 [Darwin] Delete dead code. NFCI.
llvm-svn: 319832
2017-12-05 20:55:36 +00:00
Jim Ingham ba205c1b76 Add target.process.stop-on-exec setting, and obey it.
Also add a test.  There should also be control for this
in ProcessLaunchInfo and a "target launch" flag, but at least
this will allow you to control it somehow.

<rdar://problem/35842137>

llvm-svn: 319731
2017-12-05 02:50:45 +00:00
Jim Ingham 45816d6b91 Clean up stop hook output in case a hook restarts.
I was warning about the fact that this will abort
further stop hooks, but didn't check that there WAS
a further stop hook.  Also the warning was missing a
newline.

llvm-svn: 319730
2017-12-05 02:34:05 +00:00
Aaron Ballman 05b618e31f Switch from C++1z to C++17; corresponds to r319688 in Clang.
llvm-svn: 319694
2017-12-04 20:46:43 +00:00
Pavel Labath fd9a526a30 Makefile.rules: compile all tests with -fno-limit-debug-info
Summary:
This flag is on by default for darwin and freebsd, but off for linux.
Without it, clang will sometimes not emit debug info for types like
std::string. Whether it does this, and which tests will fail because of
that depends on the linux distro and c++ library version.

A bunch of tests were already setting these flags manually, but here
instead I take a whole sale approach and enable this flag for all tests.
Any test which does not want to have this flag (right now we have one
such test) can turn it off explicitly via
CFLAGS_EXTRAS+=$(LIMIT_DEBUG_INFO_FLAGS)

This fixes a bunch of data formatter tests on red-hat.

Reviewers: davide, jankratochvil

Subscribers: emaste, aprantl, krytarowski, JDevlieghere, lldb-commits

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

llvm-svn: 319653
2017-12-04 13:31:56 +00:00
Zachary Turner a6d5464cfe Add a symbols subcommand to lldb-test.
Differential Revision: https://reviews.llvm.org/D40745

llvm-svn: 319599
2017-12-02 00:15:29 +00:00
Jim Ingham 2f1cb7ed82 Don't use llvm::EnablePrettyStackTrace on macOS.
LLDB.framework gets loaded into Xcode and other 
frameworks, and this is inserting a signal handler into
the process even when lldb isn't used.  I have a bunch
of reports of this SignalHandler blowing out the stack,
which renders crash reports for the crash useless.

And in any case libraries really shouldn't be installing
signal handlers.

I only turned this off for APPLE platforms, I'll let
the maintainers of other platforms decide what policy
they want to have w.r.t. this.

llvm-svn: 319598
2017-12-02 00:11:18 +00:00
Vedant Kumar 1541c37cb9 Fix warning in DynamicLoaderDarwinKernel.cpp, NFC
llvm-svn: 319597
2017-12-01 23:53:01 +00:00
Vedant Kumar 02de50fdc4 Fix warnings in JSON.cpp, NFC
These asserts are no-ops, and are supplanted by -Wcovered-switch.

llvm-svn: 319596
2017-12-01 23:29:04 +00:00
Vedant Kumar 01e86df684 Fix warnings in DNBDataRef.cpp, NFC
llvm-svn: 319595
2017-12-01 23:24:12 +00:00
Jan Kratochvil 4f39b294aa Prevent vain lldb::user_id_t 0xffffffff lookups
I have found LLDB commonly looks up lldb::user_id_t 0xffffffff failing to find
its DIE. One would rather expect LLDB_INVALID_UID == 0xffffffffffffffff in such
case.

DWARFASTParserClang.cpp:495
492             type_sp.reset(
493                 new Type(die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
494                          DIERef(encoding_uid).GetUID(dwarf), encoding_data_type,
495                          &decl, clang_type, resolve_state));
encoding_uid = (DWARFFormValue) {m_cu = 0x0, m_form = 0, m_value = {value = {uval = 0, sval = 0, cstr = 0x0}, data = 0x0}}
-> DIERef::DIERef(const DWARFFormValue &form_value = {m_cu = 0x0, m_form = 0, m_value = {value = {uval = 0, sval = 0, cstr = 0x0}, data = 0x0}})
-> (DIERef) {cu_offset = 0xffffffff, die_offset = 0xffffffff}
-> lldb::user_id_t DIERef::GetUID(SymbolFileDWARF *dwarf = 0x61d00000b480) const
-> Type::Type(lldb::user_id_t encoding_uid = 0xffffffff)
But 0xffffffff !=
#define LLDB_INVALID_UID UINT64_MAX

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

llvm-svn: 319580
2017-12-01 20:14:09 +00:00
Pavel Labath 11edb4eeef Kill struct IOVEC
struct iovec is used as an interface to system (posix) api's. As such,
we shouldn't be using it in os-independent code, and we shouldn't be
defining our own iovec replacements.

Fortunately, its usage was not very widespread, so the removal was very
easy -- I simply moved a couple declarations into os-specific code.

llvm-svn: 319536
2017-12-01 12:05:00 +00:00
Jim Ingham 4e29eed498 ClangASTContext::ParseClassTemplateDecl doesn't always succeed.
When it does, it returns a NULL ClassTemplateDecl.  Don't use 
it if it is NULL...

<rdar://problem/35672107>

llvm-svn: 319516
2017-12-01 03:41:30 +00:00
Zachary Turner 888a428292 Add lldb-test.
This is basically a proof-of-concept and starting point for having a
testing-centric tool in LLDB.  I'm sure this leaves a lot of room to be
desired, but this at least allows us to have something to build on.

Right now there is only one command, the `module-sections` command, and I
created this command not because it was particularly special, but
because it addressed an immediate use case and was extremely simple.

Run the tool as `lldb-test module-sections <path-to-object>`.

Feel free to add testing related stuff to your heart's content after
this goes in.  Implementing the commands themselves takes some work, but
once they're there they can be reused without writing any code and
result in very easy to use and maintain tests.

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

llvm-svn: 319504
2017-12-01 00:52:51 +00:00
Jason Molenda c187147572 We had a situation where a kext was inlined into the kernel,
but still listed in the kernel's kext table with the kernel
binary UUID.  This resulted in the kernel text section being
loaded at the kext address and problems ensuing.  Instead,
if there is a kext with the same UUID as the kernel, lldb
should skip over it.

<rdar://problem/35757689> 

llvm-svn: 319500
2017-11-30 23:31:18 +00:00
Alexander Shaposhnikov 03c17a0c87 [lldb] A few minor fixes in TaskPool
1. Move TaskPool into the namespace lldb_private.
2. Add missing std::move in TaskPoolImpl::Worker.
3. std:🧵:hardware_concurrency may return 0,
handle this case correctly.

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

Test plan: make check-all

llvm-svn: 319492
2017-11-30 22:56:11 +00:00
Jim Ingham 0b7c822f84 Fix this test so that the breakpoints you set are
unambiguously on one bit of code.  On macOS these
lines mapped to two distinct locations, and that
was artificially throwing off the test.

llvm-svn: 319472
2017-11-30 20:43:00 +00:00
Jim Ingham 27f55dda1d Remove a long out-of-date comment.
llvm-svn: 319454
2017-11-30 18:35:35 +00:00
Pavel Labath 6b75fab1fb Add a test case for open bug 35480
The test is about failing to hit breakpoints in global constructors in
shared libraries.

llvm-svn: 319443
2017-11-30 15:39:57 +00:00
Pavel Labath f59056ff93 Fix assertion in ClangASTContext
Summary:
llvm::APSInt(0) asserts because it creates an int with bit-width 0 and
not (as I thought) a value 0.

Theoretically it should be sufficient to change this to APSInt(1), as
the intention there was that the value of the first argument should be
ignored if the type is invalid, but that would look dodgy.

Instead, I use llvm::Optional to denote an invalid value and use a
special struct instead of a std::pair, to reduce typing and increase
clarity.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 319414
2017-11-30 10:16:54 +00:00
Jan Kratochvil bc3205e7bf refactor: Simplify loop with DWARFCompileUnit::Extract
Forgotten small simplification in D40212.

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

llvm-svn: 319402
2017-11-30 05:49:02 +00:00
Jim Ingham a5d07a79e4 Fix the gtest target for the move of ArchSpecTest.cpp from Core to Utility.
<rdar://problem/35562389>

llvm-svn: 319389
2017-11-30 00:23:42 +00:00
Jan Kratochvil ca9c2b290c refactor: Unify+simplify DWARFCompileUnit ctor+Clear() into in-class initializers + Extract()
It has no functionality effect.

I was concerned about the worse performance of DWARFDebugInfo::Parse this way
of allocating+destroying a CU for each iteration but I see it is now used only
by DWARFDebugInfo::Dump so that is no longer a problem.

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

llvm-svn: 319359
2017-11-29 21:13:11 +00:00
Jim Ingham 4e0b043009 Add elf-core/RegisterUtilities.{cpp,h} to the project file.
llvm-svn: 319226
2017-11-28 21:11:15 +00:00
Greg Clayton 7547aca722 Update remote debugging page with many more details.
llvm-svn: 319213
2017-11-28 20:04:43 +00:00
Stephane Sezer 5011298958 Simplify UUID constructors
Summary: This remove a small amount of duplicated code.

Reviewers: clayborg, zturner, davide

Subscribers: lldb-commits

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

llvm-svn: 319191
2017-11-28 17:50:31 +00:00
Pavel Labath bc8cc867a1 elf-core: Convert remaining register context to use register set maps
In https://reviews.llvm.org/D39681, we started using a map instead
passing a long list of register sets to the ppc64le register context.
However, existing register contexts were still using the old method.

This converts the remaining register contexts to use this approach.
While doing that, I've had to modify the approach a bit:
- the general purpose register set is still kept as a separate field,
because this one is always present, and it's parsing is somewhat
different than that of other register sets.
- since the same register sets have different IDs on different operating
systems, but we use the same register context class to represent
different register sets, I've needed to add a layer of indirection to
translate os-specific constants (e.g. NETBSD::NT_AMD64_FPREGS) into more
generic terms (e.g. floating point register set).

While slightly more complicated, this setup allows for better separation
of concerns. The parsing code in ProcessElfCore can focus on parsing
OS-specific core file notes, and can completely ignore
architecture-specific register sets (by just storing any unrecognised
notes in a map). These notes will then be passed on to the
architecture-specific register context, which can just deal with
architecture specifics, because the OS-specific note types are hidden in
a register set description map.

This way, adding an register set, which is already supported on other
OSes, to a new OS, should in most cases be as simple as adding a new
entry into the register set description map.

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

llvm-svn: 319162
2017-11-28 11:10:23 +00:00
Pavel Labath d2cfe0e597 Fix floating point register write on new x86 linux kernels
Summary:
New linux kernels (on systems that support the XSAVES instruction) will
not update the inferior registers unless the corresponding flag in the
XSAVE header is set. Normally this flag will be set in our image of the
XSAVE area (since we obtained it from the kernel), but if the inferior
has never used the corresponding register set, the respective flag can
be clear.

This fixes the issue by making sure we explicitly set the flags
corresponding to the registers we modify. I don't try to precisely match
the flags to set on each write, as the rules could get quite complicated
-- I use a simpler over-approximation instead.

This was already caught by test_fp_register_write, but that was only
because the code that ran before main() did not use some of the register
sets. Since nothing in this test relies on being stopped in main(), I
modify the test to stop at the entry point instead, so we can be sure
the inferior did not have a chance to access these registers.

Reviewers: clayborg, valentinagiusti

Subscribers: lldb-commits

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

llvm-svn: 319161
2017-11-28 10:56:54 +00:00
Stephane Sezer b108dbcc91 Remove some duplicated code in UUID.cpp
Summary: Formatting needs to be done only once. Ran check-lldb and nothing changes.

Reviewers: clayborg, davide

Reviewed By: clayborg, davide

Subscribers: zturner, davide, lldb-commits

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

llvm-svn: 319132
2017-11-28 01:26:07 +00:00
Stephane Sezer 2072552360 Mark UUID::GetByteSize() const
Summary:
This method doesn't modify anything in the object it's called on so we
can mark it const to make it usable in a const context.

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 319095
2017-11-27 21:16:37 +00:00
Pavel Labath 11479d1bab Remove custom TimePoint-formatting code
This was a temporary thing, until llvm has proper support for formatting
time. That time has come, so we can remove the relevant code. There
should be no change in the format of the time.

llvm-svn: 319048
2017-11-27 17:06:42 +00:00
Pavel Labath daa3c97e5a dotest: Mark more android targets as chatty
New android ndk linker started adding more flags to the produced
binaries, which causes older dynamic linkers display warnings to stderr
about unsupported flags. This interferes with our stderr tests.

Extend the hasChattyStderr function to catch these targets as well.

llvm-svn: 319028
2017-11-27 13:47:14 +00:00