Commit Graph

19650 Commits

Author SHA1 Message Date
Davide Italiano
0cdae2681a Revert "Fix a crash in option parsing."
This fails on the bots around 1/10 of the time.

llvm-svn: 363999
2019-06-20 23:44:37 +00:00
Tatyana Krasnukha
36358cd3ed [unittests] Use object library if cmake supports it
Differential Revision: https://reviews.llvm.org/D63544

llvm-svn: 363933
2019-06-20 15:06:31 +00:00
Michal Gorny
d687fa7d02 [lldb] [Process/NetBSD] Remove unnecessary register buffer abstraction
Remove most of the abstraction over ptrace() register operations,
as it has little value and introduces more code than it saves.
Instead, leave a single ptrace() wrapper method and call it directly
from ReadRegisterSet() and WriteRegisterSet() with correct PT_* request
and buffer.

Remove the remaining direct ReadGPR() and WriteGPR() invocations
with ReadRegisterSet() and WriteRegisterSet().

Cleanup suggested by Pavel Labath in D63545.

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

llvm-svn: 363923
2019-06-20 12:44:37 +00:00
Pavel Labath
5418d335e1 Fix -Wmismatched-tags introduced in r363910
That commit changed DIERef from a struct to a class, but did not update
the forward-declarations. This fixes one forward-declaration, and
removes other (unused) decls.

llvm-svn: 363915
2019-06-20 09:46:37 +00:00
Pavel Labath
0de98ebd00 DWARF: Provide accessors to DIERef fields
Summary:
Instead of accessing the fields directly, use accessor functions to
provide access to the DIERef components. This allows us to decouple the
external interface, from the internal representation. The external
interface can use llvm::Optional and similar goodies, while the data can
still be stored internally in a more compact representation.

I also document the purpose of the existing DIERef fields.

The main motivation for this change is a need to introduce an additional
field to the DIERef class, but I believe the change has its own merit.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: arphaman, lldb-commits

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

llvm-svn: 363910
2019-06-20 08:24:46 +00:00
Alex Langford
86df61cc93 [Process] Remove unused field from HistoryThread
Summary:
These fields are unused and have been since their inception, from what
I can tell.

Reviewers: compnerd, JDevlieghere, davide, labath

Subscribers: kubamracek, lldb-commits

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

llvm-svn: 363881
2019-06-19 21:33:44 +00:00
Michal Gorny
a5992997d9 [lldb] [Process/NetBSD] Fix constructor after r363707
llvm-svn: 363827
2019-06-19 15:49:47 +00:00
Michal Gorny
a644b04b8c [lldb] [Process/NetBSD] Remove unnecessary FPU presence checks for x86_64
Remove the checks for FPU presence, FXSAVE support and usage from
the code for x86_64.  Those are always true for this architecture,
and in fact are hardcoded to true inside NetBSD kernel.

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

llvm-svn: 363823
2019-06-19 15:35:01 +00:00
Stefan Granitz
f2ffa7320e Specify log level for CMake messages (less stderr)
Summary:
Specify message levels in CMake. Prefer STATUS (stdout).

As the default message mode (i.e. level) is NOTICE in CMake, more then necessary messages get printed to stderr. Some tools,  noticably ccmake treat this as an error and require additional confirmation and re-running CMake's configuration step.

This commit specifies a mode (either STATUS or WARNING or FATAL_ERROR)  instead of the default.

* I used `csearch -f 'llvm-project/.+(CMakeLists\.txt|cmake)' -l 'message\("'` to find all locations.
* Reviewers were chosen by the most common authors of specific files. If there are more suitable reviewers for these CMake changes, please let me know.

Patch by: Christoph Siedentop

Reviewers: zturner, beanz, xiaobai, kbobyrev, lebedev.ri, sgraenitz

Reviewed By: sgraenitz

Subscribers: mgorny, lebedev.ri, #sanitizers, lldb-commits, llvm-commits

Tags: #sanitizers, #lldb, #llvm

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

llvm-svn: 363821
2019-06-19 15:25:32 +00:00
Pavel Labath
80b6b705f8 Stabilize TestGdbRemoteLibrariesSvr4Support
on some systems this test fails because the two methods it uses to
cross-reference the data don't match in the case of the vdso module. The
"read from /proc/%pid/maps" method returns "[vdso]", while the method
which reads it from the linker rendezvous structures returns
"linux-vdso.so.1". Neither of the two names match any actual file.

This restricts the test to only consider the libraries that we ourselves
have added to the test, minimizing the impact of system dependencies
that we cannot control.

llvm-svn: 363772
2019-06-19 08:41:13 +00:00
Pavel Labath
73a28f0643 Fix a dangling StringRef in FileCollector
FileSpec::GetPath returns a temporary std::string.

llvm-svn: 363770
2019-06-19 08:09:56 +00:00
Pavel Labath
67b45acefe DWARF: Make DIERefs always valid
Summary:
This patch makes the DIERef class always valid by default constructor
and operator bool. This allows one to express the validity of a DIERef
in the type system. Places which are working with potentially-invalid
DIERefs have been updated to use Optional<DIERef> instead.

The constructor taking a DWARFFormValue was not needed, as all places
which were constructing a DIERef this way were immediately converting it
into a DWARFDIE or a user_id. This can be done without constructing an
intermediate DIERef.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: arphaman, lldb-commits

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

llvm-svn: 363767
2019-06-19 07:32:39 +00:00
Antonio Afonso
a7335393f5 Add ReadCStringFromMemory for faster string reads
Summary:
This is the fifth patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499

Reading strings with ReadMemory is really slow when reading the path of the shared library. This is because we don't know the length of the path so use PATH_MAX (4096) and these strings are actually super close to the boundary of an unreadable page. So even though we use process_vm_readv it will usually fail because the read size spans to the unreadable page and we then default to read the string word by word with ptrace.

This new function is very similar to another ReadCStringFromMemory that already exists in lldb that makes sure it never reads cross page boundaries and checks if we already read the entire string by finding '\0'.

I was able to reduce the GetLoadedSharedLibraries call from 30ms to 4ms (or something of that order).

Reviewers: clayborg, xiaobai, labath

Reviewed By: labath

Subscribers: emaste, lldb-commits

Tags: #lldb

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

llvm-svn: 363750
2019-06-18 23:27:57 +00:00
Antonio Afonso
fda83c9b0b Implement xfer:libraries-svr4:read packet
Summary:
This is the fourth patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499

Implement the `xfer:libraries-svr4` packet by adding a new function that generates the list and then in Handle_xfer I generate the XML for it. The XML is really simple so I'm just using string concatenation because I believe it's more readable than having to deal with a DOM api.

Reviewers: clayborg, xiaobai, labath

Reviewed By: labath

Subscribers: emaste, mgorny, srhines, krytarowski, lldb-commits

Tags: #lldb

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

llvm-svn: 363707
2019-06-18 17:51:56 +00:00
Jonas Devlieghere
c470ac50a8 [Reproducers] Make reproducer relocatable
Before this patch, reproducers weren't relocatable. The reproducer
contained hard coded paths in the VFS mapping, as well in the yaml file
listing the different input files for the command interpreter. This
patch changes that:

 - Use relative paths for the DataCollector.
 - Use an overlay prefix for the FileCollector.

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

llvm-svn: 363697
2019-06-18 16:20:17 +00:00
Pavel Labath
afb17daedf Fix windows build for r363357
MSVC has trouble referencing the protected Compare class from from the
friend Entry operator<. Just delete that operator, as it's used only
once.

llvm-svn: 363653
2019-06-18 07:02:53 +00:00
Jonas Devlieghere
f9626f27c8 Add color to the default thread and frame format.
Now that we correctly ignore ASCII escape sequences when colors are
disabled (r362240), I'd like to change the default frame and thread
format to include color in their output, in line with the syntax
highlighting that Raphael added a while ago.

This patch adds highlighting for the stop reason, the file, line and
column number. With colors disabled, this of course is a no-op.

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

llvm-svn: 363608
2019-06-17 19:53:11 +00:00
Jan Kratochvil
8c82c41262 [lldb] [test] Extend D55859 symbols.enable-external-lookup=false for more testcases
D55859 <https://reviews.llvm.org/D55859> has no effect for some of the
testcases so this patch extends it even for (all?) other testcases known to me.
LLDB was failing when LLDB prints errors reading system debug infos
(`*-debuginfo.rpm`, DWZ-optimized) which should never happen as LLDB testcases
should not be affected by system debug infos.

`lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template` is
using only SB API which does not expose `ModuleList` so I had to call
`HandleCommand()` there.

`lldb-test.cpp` could also use `HandleCommand` and then there would be no need
for `ModuleListProperties::SetEnableExternalLookup()` but I think it is cleaner
with API and not on based on text commands.

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

llvm-svn: 363567
2019-06-17 14:46:17 +00:00
Michal Gorny
d3d2edf901 [lldb] [test] Watchpoint tests can be always run as root on NetBSD
llvm-svn: 363551
2019-06-17 12:32:09 +00:00
Michal Gorny
43cf5ae48a [lldb] [test] Skip watchpoint tests on NetBSD if userdbregs is disabled
Skip watchpoint tests if security.models.extensions.user_set_dbregs
is disabled.  This indicates that unprivileged processes are not allowed
to write to debug registers which is a prerequisite for using hardware
watchpoints.

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

llvm-svn: 363536
2019-06-17 09:49:05 +00:00
Pavel Labath
a71ce4f1e8 DWARF: Avoid storing DIERefs in long-lived containers
Summary:
A user_id_t carries the same information as a DIERef, but it takes up
less space.

Furthermore, DIERef::operator<'s implementation is very
questionable, as it does not take the cu_offset and section fields into
account. Using just the die offset was correct in the days when all
debug info lived in a single section, but since we started supporting
DWO debug info, this was no longer true. The comparison operator could
be fixed, but it seems like using the user_id_t for these purposes is a
better idea overall.

I think this did not cause any bugs, because the only place the
comparison operator was used is in m_function_scope_qualified_name_map,
and this one is local to a dwo file, but I am not 100% sure of that.

Reviewers: clayborg, JDevlieghere

Subscribers: aprantl, lldb-commits

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

llvm-svn: 363528
2019-06-17 07:32:56 +00:00
Antonio Afonso
f4335b8e3c Implement GetSharedLibraryInfoAddress
Summary:
This is the third patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499

Add functions to read the r_debug location to know where the linked list of loaded libraries are so I can generate the `xfer:libraries-svr4` packet.
I'm also using this function to implement `GetSharedLibraryInfoAddress` that was "not implemented" for linux.
Most of this code was inspired by the current ds2 implementation here: https://github.com/facebook/ds2/blob/master/Sources/Target/POSIX/ELFProcess.cpp.

Reviewers: clayborg, xiaobai, labath

Reviewed By: clayborg, labath

Subscribers: emaste, krytarowski, mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 363458
2019-06-14 21:15:08 +00:00
Greg Clayton
6df47ef22b Don't try to parse ObjC method if CU isn't ObjC
Improve manual indexing performance when indexing non objective C code. 

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

llvm-svn: 363441
2019-06-14 19:18:10 +00:00
Jonas Devlieghere
28defa70ea Remove stale comment and disabled code (NFC)
llvm-svn: 363438
2019-06-14 18:12:55 +00:00
Adrian Prantl
573ffd88a0 Python 3: decode string as utf-8 to avoid type mismatch.
rdar://problem/51464644

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

llvm-svn: 363413
2019-06-14 15:39:14 +00:00
Adrian Prantl
38be2c65b6 Make crashlog.py less noisy
For end-users there is no point in printing dSYM load errors for
system frameworks, since they will all fail and there's nothing they
can do about it. This patch hides them by default and shows them when
--verbose is present.

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

llvm-svn: 363412
2019-06-14 15:39:11 +00:00
Pavel Labath
2dd0053d3a EditlineTest: Improve error message
This test seems to occasionally fail because editline returns a
different number of lines. Rewrite the message in such a way that we
also see the actual lines when that happens (and not just their count).

Also, clean up the dependencies of the test while I'm in there.

llvm-svn: 363404
2019-06-14 14:33:04 +00:00
Pavel Labath
00e3968b8a DWARF: port debug_ranges/rnglists over to DWARFContext
llvm-svn: 363400
2019-06-14 14:12:25 +00:00
Pavel Labath
fe79fbc99d DWARF: Remove unused includes from DWARFDebugAranges.h/cpp
llvm-svn: 363382
2019-06-14 13:21:57 +00:00
Pavel Labath
6a2eb36710 Have DWARFUnit store a *reference* to SymbolFileDWARF
Previously it was storing a *pointer*, which left open the possibility
of this pointer being null. We never made use of that possibility (it
does not make sense), and most of the code was already assuming that.
However, there were a couple of null-checks scattered around the code.

This patch replaces the reference with a pointer, making the
non-null-ness explicit, and removes the remaining null-checks.

llvm-svn: 363381
2019-06-14 13:01:16 +00:00
Pavel Labath
78b2cf71f5 DWARFIndex: s/ReportInvalidDIEOffset/ReportInvalidDIERef
In a dwo/debug_types world, the die offset is not enough to uniquely
idendify a debug info entry. Pass the the entire DIERef object instead.

This is technically NFC, because only AppleIndex implemented this
method (and there, the die offset *is* enough for unique
identification). However, this makes the code simpler, and simplifies
some of the follow-up patches.

llvm-svn: 363373
2019-06-14 12:01:18 +00:00
Gauthier Harnisch
796ed03b84 [C++20] add Basic consteval specifier
Summary:
this revision adds Lexing, Parsing and Basic Semantic for the consteval specifier as specified by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1073r3.html

with this patch, the consteval specifier is treated as constexpr but can only be applied to function declaration.

Changes:
 - add the consteval keyword.
 - add parsing of consteval specifier for normal declarations and lambdas expressions.
 - add the whether a declaration is constexpr is now represented by and enum everywhere except for variable because they can't be consteval.
 - adapt diagnostic about constexpr to print constexpr or consteval depending on the case.
 - add tests for basic semantic.

Reviewers: rsmith, martong, shafik

Reviewed By: rsmith

Subscribers: eraman, efriedma, rnkovacs, cfe-commits

Tags: #clang

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

llvm-svn: 363362
2019-06-14 08:56:20 +00:00
Pavel Labath
d8aca8886f Make UniqueCStringMap work with non-default-constructible types and other improvements/cleanups
Summary:
The motivation for this was me wanting to make the validity of dwarf
DIERefs explicit (via llvm::Optional<DIERef>). This meant that the class
would no longer have a default constructor. As the DIERef was being
stored in a UniqueCStringMap, this meant that this container (like all
standard containers) needed to work with non-default-constructible types
too.

This part is achieved by removing the default constructors for the map
entry types, and providing appropriate comparison overloads so that we
can search for map entries without constructing a dummy entry. While
doing that, I took the opportunity to modernize the code, and add some
tests. Functions that were completely unused are deleted.

This required also some changes in the Symtab code, as it was default
constructing map entries, which was not impossible even though its
value type was default-constructible. Technically, these changes could
be avoided with some SFINAE on the entry type, but I felt that the code
is cleaner this way anyway.

Reviewers: JDevlieghere, sgraenitz

Subscribers: mgorny, aprantl, lldb-commits

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

llvm-svn: 363357
2019-06-14 06:33:31 +00:00
Jonas Devlieghere
77cc50ff7d Fixed typos in Log.h
Patch by: Yuya Fujita

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

llvm-svn: 363356
2019-06-14 06:06:47 +00:00
Alex Langford
347ec0faa7 [NFC] Replace a plugin header with a non-plugin header
llvm-svn: 363338
2019-06-13 23:40:34 +00:00
Stefan Granitz
a0781b6e3a [CMake] Fix generated Xcode-project ignoring output directory setting for LLDB.framework
Other generators honor the `LIBRARY_OUTPUT_DIRECTORY` target property, but apparently Xcode doesn't. So we call `set_output_directory()` as `llvm_add_library()` would do and this works.
Note that `LIBRARY_OUTPUT_DIRECTORY` is still necessary, because it's used to store and read the target's absolute build directory (while `LLDB_FRAMEWORK_BUILD_DIR` is relative!).

llvm-svn: 363280
2019-06-13 17:35:50 +00:00
Stefan Granitz
113320d3b6 [CMake] Fix lldb-dotest for single-config generators in standalone builds
Differential Revision: https://reviews.llvm.org/D62859

llvm-svn: 363279
2019-06-13 17:35:43 +00:00
Stefan Granitz
8f30e322ab [CMake] Add fallbacks for copying clang-resource-headers to LLDB.framework in standalone builds
llvm-svn: 363271
2019-06-13 15:07:56 +00:00
Pavel Labath
ad17e289f0 DWARF: Don't create lldb CompileUnits for DWARF type units
Summary:
Type units don't represent actual compilations and a lot of the
operations that we do with lldb compile units (getting their line
tables, variables, etc.) don't make sense for them. There is also a lot
more of them (sometimes over 100x), so making them more lightweight pays
off.

The main change in this patch is that we stop creating lldb CompileUnits
for DWARF type units. The trickiest part here is that the SymbolFile
interface requires that we assign consecutive sequence IDs to the
compile units we create. As DWARF type and compile units can come in any
order (in v5), this means we can no longer use 1-1 mapping between DWARF
and lldb compile units. Instead I build a translation table between the
two indices. To avoid pessimizing the case where there are no type
units, I build the translation table only in case we have at least one
type unit.

Additionaly, I also tried to strenghted type safete by replacing
DWARFUnit with DWARFCompileUnit where applicable. Though that was not
stricly necessary, I found it a good way to ensure that the
transformations I am doing here make sense. In the places where I was
changing the function signatures, and where it was obvious that the
objects being handled were not null, I also replaced pointers with
references.

There shouldn't be any major functional change with this patch. The only
change I observed is that now the types in the type units will not be
parsed when one calls Module::ParseAllDebugSymbols, unless they are
referenced from other compile units. This makes sense, given how
ParseAllDebugSymbols is implemented (it iterates over all compile
units), and it only matters for one hand-writted test where I did not
bother to reference the types from the compile units (which I now do).

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 363250
2019-06-13 11:22:47 +00:00
Jonas Devlieghere
2bf2568150 [Reproducers] Remove call to lldb_private::GetVersion()
Utility doesn't link against lldbBase so we cannot call GetVersion in
keep. I already added a string member m_version to deal with that, but
the call was still there.

llvm-svn: 363228
2019-06-13 05:14:25 +00:00
Jonas Devlieghere
c2e2df7f7a [Reproducers] Include lldb version in the reproducer root
Generally, reproducers are rev-locked to the version of LLDB, so it's
valuable to have the LLDB version in the reproducer. For now I just want
the information to be present, without enforcing it, but I envision
emitting a warning during replay in the future.

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

llvm-svn: 363225
2019-06-13 04:35:22 +00:00
Jonas Devlieghere
ef96e985fc [Reproducers] Simplify providers with nested Info struct (NFC)
This replaces the `info` typedef with a nested struct named Info. This
means we now have FooProvider and FooProvider::Info, instead of two
related but separate classes FooProvider and FooInfo. This change is
mostly cosmetic.

llvm-svn: 363211
2019-06-12 22:17:38 +00:00
Jason Molenda
0e197bcb6b Re-land r363103 ("When reading ObjC class table, use new SPI if it is avail")
with a call to snprintf() to find the size of the formatted string,
malloc memory, then snprintf again to format it into the buffer, instead
of calling asprintf.

Orig commit msg:

When reading ObjC class table, use new SPI if it is avail

In the latest OS betas, the objc runtime has a special interface
for the debugger, class_getNameRaw(), instead of the existing
class_getName(), which will return class names in their raw, unmangled
(in the case of swift) form.  When lldb can access the unmangled
names of classes, it won't need to fetch them out of the inferior
process after we run our "get the objc class table" expression.

If the new interface is absent (debugging a process on an older
target), lldb will fall back to class_getName and reading any class
names that it got back in demangled form, at a bit of a performance
cost on the first expression.

<rdar://problem/50688054> 

llvm-svn: 363206
2019-06-12 21:44:53 +00:00
Adrian Prantl
87f75ecd72 Skip failing test on older versions of clang.
llvm-svn: 363202
2019-06-12 21:30:00 +00:00
Alex Langford
5b99928ba8 [Expression] Add PersistentExpressionState::GetCompilerTypeFromPersistentDecl
Summary:
PersistentStateExpressions (e.g. ClangPersistentVariables) have the
ability to define types using expressions that persist throughout the
debugging session. GetCompilerTypeFromPersistentDecl is a useful
operation to have if you need to use any of those persistently declared types,
like in CommandObjectMemory.

This decouples clang from CommandObjectMemory and decouples Plugins from
Commands in general.

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

llvm-svn: 363183
2019-06-12 17:47:06 +00:00
Stefan Granitz
61a7ab7fdb [lldb] Ignore null frames in lldb.macosx crashlog
llvm-svn: 363172
2019-06-12 14:46:37 +00:00
Stefan Granitz
a866d3b2ee [CMake] Two extra FOLDER properties for debugserver
llvm-svn: 363171
2019-06-12 14:46:30 +00:00
Pavel Labath
ad805ef95a Recognise debug_types.dwo as a debug info section
This is a preparatory patch to allow reading type units from dwo files.

llvm-svn: 363146
2019-06-12 11:42:42 +00:00
Pavel Labath
ca9c3de17e DWARF: Share line tables of type units
Summary:
This patch creates a cache of file lists in line tables referenced by
type units.  This cache is used to avoid parsing a line table twice
(since a file list will generally be shared by many type units).

It also sets things up in a way that parsing of DW_AT_decl_file
attributes will keep working even when we stop creating lldb compile
units for dwarf type units, but it stops short of actually doing that.
This means that the request for files now go directly to SymbolFileDWARF
instead of being routed there indirectly via the
lldb_private::CompileUnit class.

As a result of this, a number of occurences of SymbolContext variables
in DWARFASTParserClang have become unused, so I remove them.

This patch reduces the number of times a file list is being parsed, but
the situation is still suboptimal, as the parsed list is being copied
multiple times. This will be fixed when we stop creating CompileUnits
for DWARF type units.

Reviewers: clayborg, aprantl, JDevlieghere

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 363143
2019-06-12 11:29:50 +00:00
David Carlier
f243ca4af8 [LLDB] Fix FreeBSD build
The auxiliary vector method had the wrong signature.

Reviewers: MaskRay, teemperor, aadsm

Reviewed By: MaskRay, teemperor

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

llvm-svn: 363135
2019-06-12 08:54:14 +00:00