Commit Graph

19629 Commits

Author SHA1 Message Date
Pavel Labath 15fec3a69c Fix some signed/unsigned comparison warnings
llvm-svn: 362784
2019-06-07 09:43:53 +00:00
Pavel Labath 62c905a2e6 DWARF: Simplify SymbolFileDWARF::GetDWARFCompileUnit
Summary:
The DWARFCompileUnit is set as the "user data" of the lldb compile unit
directly in the constructor (see ParseCompileUnit).

This means that instead of going through unit indexes, we can just fetch
the DWARF unit directly from there.

Reviewers: clayborg, JDevlieghere

Subscribers: aprantl, jdoerfert, lldb-commits

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

llvm-svn: 362783
2019-06-07 09:43:47 +00:00
Davide Italiano ecf3ae4a70 [NativeProcessDarwin] Remove dead code. NFCI.
llvm-svn: 362639
2019-06-05 20:23:03 +00:00
Antonio Afonso 5659b36c15 [DynamicLoader] Make sure we always set the rendezvous breakpoint
Summary:
Once we've attached to the process we load all current modules and also set a breakpoint at the rendezvous break address.
However, we don't do this if we already have a load address for the image info address (e.g.: DT_DEBUG on ELF). This code was added 4 years ago when adding support for `$qXfer:Libraries:` packet (https://reviews.llvm.org/D9471) but its intention is not 100% clear to me. It seems to me we're using that check to know if the modules have already been loaded (which they have if `$qXfer:Libraries:` is supported by the gdb server) and skip loading the modules again in the following `if` block. The problem is that we also skip setting the Rendezvous breakpoint so we stop knowing when the process loads new modules.
I fix this by moving the call to set the breakpoint to the end of the function so we always call it as long as we have a valid executable.

Reviewers: ADodds, clayborg, eugene, labath

Reviewed By: eugene, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 362619
2019-06-05 16:22:33 +00:00
Stefan Granitz c769462438 [CMake] Add configuration dirs as potential locations for llvm-lit and llvm-tblgen in standalone builds
Summary:
If the provided LLVM build-tree used a multi-configuration generator like Xcode, `LLVM_TOOLS_BINARY_DIR` will have a generator-specific placeholder to express `CMAKE_CFG_INTDIR`. Thus `llvm-lit` and `llvm-tblgen` won't be found.
D62878 exports the actual configuration types so we can fix the path and add them to the search paths for `find_program()`.

Reviewers: xiaobai, labath, stella.stamenova

Reviewed By: xiaobai, stella.stamenova

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 362589
2019-06-05 08:31:50 +00:00
Pavel Labath da7f033693 Ignore DIEs in the skeleton unit in a DWO scenario
Summary:
r362103 exposed a bug, where we could read incorrect data if a skeleton
unit contained more than the single unit DIE. Clang emits these kinds of
units with -fsplit-dwarf-inlining (which is also the default).

Changing lldb to handle these DIEs is nontrivial, as we'd have to change
the UID encoding logic to be able to reference these DIEs, and fix up
various places which are assuming that all DIEs come from the separate
compile unit.

However, it turns out this is not necessary, as the DWO unit contains
all the information that the skeleton unit does. So, this patch just
skips parsing the extra DIEs if we have successfully found the DWO file.
This enforces the invariant that the rest of the code is already
operating under.

This patch fixes a couple of existing tests, but I've also included a
simpler test which does not depend on execution of binaries, and would
have helped us in catching this sooner.

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: probinson, dblaikie, lldb-commits

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

llvm-svn: 362586
2019-06-05 07:29:55 +00:00
Fangrui Song ff918fb487 Fix -Wsign-compare by explicit cast after r362557
llvm-svn: 362570
2019-06-05 01:49:06 +00:00
Jason Molenda c93b99589f Call abs to avoid signed/unsigned comparison warning.
llvm-svn: 362557
2019-06-04 22:46:20 +00:00
Alex Langford 29975a2a5d [Target] Remove Process::GetCPPLanguageRuntime
Summary:
I want to remove this method because I think that Process should be
language agnostic, or at least, not have knowledge about specific language
runtimes. There is "GetLanguageRuntime()" which should be used instead. If the
caller a CPPLanguageRuntime, they should cast it as needed. Ideally, this
should only happen in plugins that need C++ specific knowledge.

The next step I would like to do is remove "GetObjCLanguageRuntime()" as well.
There are a lot more instances of that function being used, so I wanted to
upload this one first to get the general reception to this idea.

Reviewers: compnerd, davide, JDevlieghere, jingham, clayborg, labath, aprantl

Subscribers: lldb-commits

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

llvm-svn: 362544
2019-06-04 20:14:33 +00:00
Alex Langford a03e2b25ab [ABI] Fix SystemV ABI to handle nested aggregate type returned in register
Add a function to flatten the nested aggregate type

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

Patch by Wanyi Ye <kusmour@gmail.com>

llvm-svn: 362543
2019-06-04 19:29:59 +00:00
James Y Knight dbb4322e51 [lldb] Fix out-of-bounds read after c3ea7c66fe
"Add support for mid-function epilogues on x86 that end in a non-local jump."

Detected by asan.

llvm-svn: 362510
2019-06-04 15:27:19 +00:00
Stefan Granitz e4ad1b7bbe [CMake] Move and add settings to Apple-lldb-base cache script
llvm-svn: 362500
2019-06-04 14:21:48 +00:00
Alex Langford b978f72058 [Target] Generalize some behavior in Target::SymbolsDidLoad
Summary:
SymbolsDidLoad is currently only implemented for ObjCLanguageRuntime,
but that doesn't mean that it couldn't be useful for other Langauges. Although
this change seems like it's generalizing for the sake of purity, this removes
Target's dependency on ObjCLanguageRuntime.

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

llvm-svn: 362461
2019-06-03 23:12:11 +00:00
Alex Langford 1f8030630b [Target] Move ObjCLanguageRuntime::LookupRuntimeSymbol into LanguageRuntime
Summary:
LookupRuntimeSymbol seems like a general LanguageRuntime method.
Although no other language runtime currently implements this, there's no
reason another language runtime couldn't use this.

Additionally, this breaks IRExecutionUnit's dependency on
ObjCLanguageRuntime.

Reviewers: compnerd, labath, JDevlieghere, davide

Subscribers: lldb-commits

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

llvm-svn: 362458
2019-06-03 22:41:48 +00:00
Jason Molenda c3ea7c66fe Add support for mid-function epilogues on x86 that end in a non-local jump.
The x86 assembly inspection engine has code to support detecting a
mid-function epilogue that ends in a RET instruction; add support for 
recognizing an epilogue that ends in a JMP, and add a check that the
unwind state has been restored to the original stack setup; reinstate
the post-prologue unwind state after this JMP instruction.

The assembly inspection engine used for other architectures, 
UnwindAssemblyInstEmulation, detects mid-function epilogues by 
tracking branch instructions within the function and "forwards"
the current unwind state to the targets of the branches.  If
an epilogue unwinds the stack and exits, followed by a branch
target, we get back to the correct unwind state.  The x86 
unwinder should move to this same algorithm, or possibly even
look at implementing an x86 instruction emulation plugin and
get UnwindAssemblyInstEmulation to work for x86 too.  I added
a branch instruction recognizier method that will be necessary
if we want to switch the algorithm.

Differential Revision: https://reviews.llvm.org/D62764
<rdar://problem/51074422> 

llvm-svn: 362456
2019-06-03 22:34:12 +00:00
Alexandre Ganea 18ca8a2233 Silence 'warning C4305: 'initializing': truncation from 'double' to 'float'' with MSVC 19.16.27021.1 (VS2017 15.9.12)
llvm-svn: 362437
2019-06-03 18:46:30 +00:00
Antonio Afonso dab879d7c8 [lldb-server unittest] Add missing teardown logic
Summary:
This test base class is missing the teardown making the second set of tests extending it to fail in an assertion in the FileSystem::Initialize() (as it's being initialized twice).
Not sure why this isn't failing the build bots.. (unless they're running without asserts?).

With this fix `ninja LLDBServerTests && ./tools/lldb/unittests/tools/lldb-server/tests/LLDBServerTests` successfully runs and passes all tests.

Reviewers: clayborg, xiaobai, labath

Reviewed By: xiaobai, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 362406
2019-06-03 15:18:15 +00:00
Tom Tan 382320ea02 [COFF, ARM64] Fix CodeView API change for getRegisterNames
Change rL362280 changed CodeView API getRegisterNames() by adding an input
parameter in CPUType. It is called in LLDB and needs to be updated.

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

llvm-svn: 362349
2019-06-03 00:48:16 +00:00
Alex Langford fde26d222d [Commands] Remove unused header
llvm-svn: 362339
2019-06-02 21:11:21 +00:00
Alex Langford 591ede411d [Target] Adjust header in Thread
llvm-svn: 362318
2019-06-02 06:03:05 +00:00
Alexandre Ganea 5a2a054028 Silence 'warning: extra ‘;’ [-Wpedantic]' with GCC 7.3
llvm-svn: 362306
2019-06-01 21:47:44 +00:00
Alex Langford e8ee5b9351 [Commands] Stop hardcoding languages in CommandObjectType
llvm-svn: 362268
2019-05-31 22:15:29 +00:00
Alex Langford 4dc0acc915 [Target] Remove ABI's dependence on ExpressionParser
llvm-svn: 362259
2019-05-31 20:17:21 +00:00
Jonas Devlieghere a33964b570 [FormatEntity] Ignore ASCII escape sequences when colors are disabled.
This patch makes the FormatEntity honor the debugger's color settings by
not inserting ASCII escape sequences when colors are disabled.

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

llvm-svn: 362240
2019-05-31 16:27:44 +00:00
Richard Trieu 30935ef0bc Fix problem with r362192
The string returned only sometimes ends in NULL.  Explicitly check for the NULL
and pop off the NULL if it is there.

llvm-svn: 362194
2019-05-31 05:55:07 +00:00
Richard Trieu c9e27be585 Fix off-by-one error.
The created string is one char too large, so it pulls the terminating NULL as
the last character of the string.  This later causes SocketTest.cpp to fail.

llvm-svn: 362192
2019-05-31 05:06:54 +00:00
Adrian Prantl 4a585a3edd Make CPlusPlusNameParser robust against nullptr StringRefs.
There is likely also an underlying bug in all code that calls
CPlusPlusNameParser with nullptrs, but this patch can also stand for
itself.

rdar://problem/49072829

llvm-svn: 362177
2019-05-31 00:18:42 +00:00
Antonio Afonso d556095135 Make ConnectionFileDescription work with all sockets
Summary:
My main goal here is to make lldb-server work with Android Studio.

This is currently not the case because lldb-server is started in platform mode listening on a domain socket. When Android Studio connects to it lldb-server crashes because even though it's listening on a domain socket as soon as it gets a connection it asserts that it's a TCP connection, which will obviously fails for any non-tcp connection.

To do this I came up with a new method called GetConnectURI() in Socket that returns the URI needed to connect to the connected portion of the socket.

Reviewers: labath, clayborg, xiaobai

Reviewed By: labath

Subscribers: mgorny, jfb, lldb-commits

Tags: #lldb

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

llvm-svn: 362173
2019-05-30 23:30:35 +00:00
Alex Langford e5a7a858f5 [Target] Generalize language-specific behavior in ThreadPlanStepThrough
Summary:
When creating a ThreadPlan to step through a trampoline, we ask the
ObjC language runtime and the CPP language runtime to come up with such a thread
plan if the dynamic loader fails to give us one. I don't see why this behavior
can't be language agnostic.

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

llvm-svn: 362164
2019-05-30 22:00:18 +00:00
Alex Langford 41dc5526a6 [Target] Generalize Process::IsPossibleDynamicValue
llvm-svn: 362154
2019-05-30 21:03:53 +00:00
Greg Clayton aeae786bfe Code and comment cleanups [NFC]
Changes:
- update comments to detail the info can come from .debug_info or .debug_types
- Rename "debug_info_data" to "data" now that we can get data from .debug_info or .debug_types.
- Also call DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr(...) instead of manually grabbing abbreviation.

llvm-svn: 362116
2019-05-30 17:03:35 +00:00
J. Ryan Stinnett d45eaf9405 [Docs] Modernize references to macOS
Summary:
This updates all places in documentation that refer to "Mac OS X", "OS X", etc.
to instead use the modern name "macOS" when no specific version number is
mentioned.

If a specific version is mentioned, this attempts to use the OS name at the time
of that version:

* Mac OS X for 10.0 - 10.7
* OS X for 10.8 - 10.11
* macOS for 10.12 - present

Reviewers: JDevlieghere

Subscribers: mgorny, christof, arphaman, cfe-commits, lldb-commits, libcxx-commits, llvm-commits

Tags: #clang, #lldb, #libc, #llvm

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

llvm-svn: 362113
2019-05-30 16:46:22 +00:00
Antonio Afonso 7316670ef0 Remove length modifier when using assignment suppression in TimerTest
Summary:
This is useless and it's giving warnings in the build bots:
/home/motus/netbsd8/netbsd8/llvm/tools/lldb/unittests/Utility/TimerTest.cpp:67:43: warning: use of assignment suppression and length modifier together in gnu_scanf format [-Wformat=]

Reviewers: xiaobai

Subscribers: krytarowski, lldb-commits

Tags: #lldb

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

llvm-svn: 362107
2019-05-30 15:38:05 +00:00
Greg Clayton e6ddde57e2 Fix a regression in DWARF access speed caused by svn revision 356190
The issue was caused by the error checking code that was added. It was incorrectly adding an extra abbreviation when DWARFEnumState::Complete was received since it would push an extra abbreviation onto the list with the abbreviation code of zero. This cause m_idx_offset in each DWARFAbbreviationDeclarationSet to be set to UINT32_MAX. This valid indicates we must linearly search for attributes, not access them in O(1) time. This caused every DWARFDebugInfoEntry that would try to get its DWARFAbbreviationDeclaration from the CU's DWARFAbbreviationDeclarationSet to always linearly search the abbreviation set for a given abbreviation code. Easy to see why this would cause things to be slow.

This regression was caused by: https://reviews.llvm.org/D59370. I asked to ensure there was no regression is parsing or access speed, but that must not have been done. In my test with 40 DWARF files trying to set a breakpoint by function name and in a header file, I see a 8% speed improvement with this fix.

There was no regression in correctness, just very inefficient access.

Added full unit testing for DWARFAbbreviationDeclarationSet parsing to ensure this doesn't regress.

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

llvm-svn: 362105
2019-05-30 15:32:33 +00:00
Greg Clayton 202c3ffcbf Improve DWARF parsing and accessing by 1% to 2%
When LLDB first started we didn't have our mmap of the DWARF data done correctly and if the backing file would change we would get live changes as the file changed and it would cause problems. We now mmap correctly and do not run into these issues. There was legacy code in DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr(...) that would always extract the abbrev index each time the function was called to verify that DWARF data hadn't changed and a warning was emitted if it did. We no longer need this and the code was removed. The other thing this function did when it parsed the abbrev index was give us the offset of the first attribute bytes by adding the LEB128 size to the offset. This required an extra parameter to DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr(...) which is now removed. I added "lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const" which calculates this when we need it and modified all sites that need the offset to call it.

Now that we aren't decoding and verifying the abbrev index, it speeds up DWARF access by 1% to 2%.

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

llvm-svn: 362103
2019-05-30 15:21:23 +00:00
Pavel Labath c767011329 DWARFASTParserClang: Delete dead code
This removes places where DW_AT_decl_file/line/column was being parsed,
but not used.

llvm-svn: 362086
2019-05-30 11:24:16 +00:00
Pavel Labath 7e4d62a8dd DWARFASTParserClang: Move attribute parsing into a single function
Summary:
The ParseTypeFromDWARF function consists of a huge switch on the kind of
type being parsed. Each case in this switch starts with parsing the
attributes of the current DIE. A lot of these attributes are specific to
one kind of a type, but a lot of them are common too, leading to code
duplication.

This patch reduces the duplication (and the size of ParseTypeFromDWARF)
by moving the attribute parsing to a separate function. It creates a
struct (ParsedTypeAttributes), which contains a parsed form of all
attributes which are useful for parsing any kind of a type. The parsing
code for a specific type kind can then access the fields which are
relevant for that specific case.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 362075
2019-05-30 09:39:36 +00:00
Pavel Labath 833dba01d9 Make CompileUnit::GetSupportFiles return a const list
There's no reason for anyone to modify a list from outside of a symbol
file (as that would break a lot of invariants that symbol files depend
on).

Make the function return a const FileSpecList and fix up a couple of
places that were needlessly binding non-const references to the result
of this function.

llvm-svn: 362069
2019-05-30 08:21:25 +00:00
Pavel Labath f04b3635c4 [lldb-server] Support 'g' packets
Differential Revision: https://reviews.llvm.org/D62221
Patch by Guilherme Andrade <guiandrade@google.com>.

llvm-svn: 362063
2019-05-30 07:25:22 +00:00
Fangrui Song a05fda68bc DWARFDebugInfoEntry: delete unused Extract() and rename FastExtract() to Extract()
The function Extract() is almost a duplicate of FastExtract() but is not used.
Delete it and rename FastExtract() to Extract().

Reviewed By: JDevlieghere

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

llvm-svn: 362049
2019-05-30 01:51:16 +00:00
Davide Italiano 192dd7df2f [crashlog] Add a missing call to decode.
<rdar://problem/51139357>

llvm-svn: 362044
2019-05-30 00:35:43 +00:00
Alex Langford 43ae5c5974 [Commands] Remove commented out code
llvm-svn: 362042
2019-05-29 23:25:44 +00:00
Richard Trieu c8f2efe065 Use correct format specifier to silence -Wformat warning.
llvm-svn: 362035
2019-05-29 21:25:15 +00:00
Greg Clayton 46631dffc4 Fix Xcode project lldb unit test target so it compiles.
llvm-svn: 362033
2019-05-29 21:22:54 +00:00
Alex Langford 7d3e97fbe6 [Target] Sink some asserts into Process::GetLanguageRuntime
llvm-svn: 362032
2019-05-29 21:07:53 +00:00
Alex Langford 03e1a82f52 [Target] Introduce Process::GetLanguageRuntimes
Summary:
Currently there's not really a good way to iterate over the language runtimes a
process has. This is sometimes desirable (as seen in my change to Thread).
Additionally, there's not really a good reason to iterate over every available
language, but rather only over languages for which we have a plugin loaded.

Reviewers: JDevlieghere, davide, jingham

Subscribers: lldb-commits

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

llvm-svn: 361999
2019-05-29 18:08:22 +00:00
Greg Clayton 5a0e13c4d6 Fixed source header [NFC]
llvm-svn: 361995
2019-05-29 17:25:03 +00:00
Antonio Afonso 78337420cd Add more information to the log timer dump
Summary:
The `log timer dump` is showing the time of the function itself minus any function that is called from this one that also happens to be timed. However, this is really not obvious and it also makes it hard to understand the time spent in total and also which children are actually taking the time.
To get a better reading of the timer dump I added the total, children (which I named child) and also the hit count. I used these timers to figure out a performance issue and only after adding this things were more clear to me.

It looks like this:
```
(lldb) log timer dump
35.447713617 sec (total: 35.449s; child: 0.001s; count: 1374) for void SymbolFileDWARF::Index()
29.717921481 sec (total: 29.718s; child: 0.000s; count: 8230500) for const lldb_private::ConstString &lldb_private::Mangled::GetDemangledName(lldb::LanguageType) const
21.049508865 sec (total: 24.683s; child: 3.633s; count: 1399) for void lldb_private::Symtab::InitNameIndexes()
...
```

Reviewers: clayborg, teemperor, labath, espindola, xiaobai

Reviewed By: labath, xiaobai

Subscribers: emaste, mgorny, arichardson, eraman, MaskRay, jdoerfert, labath, davide, teemperor, aprantl, erik.pilkington, jfb, abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 361987
2019-05-29 16:31:32 +00:00
Fangrui Song 898aaf1cb8 Clean up DWARFDebugInfoEntry
llvm-svn: 361962
2019-05-29 14:36:11 +00:00
Pavel Labath 377c1cfe94 Revert "D11003: Tolerate DWARF compile unit without filename."
Summary:
This code is modifying a support file list after it has been created.
This makes it hard to share the file list between type units and
compile units in DWARF. It's not a total showstopper, but supporting
this while also sharing the lists would make things more complicated.

Given that this was added to support a project which never fully
materialised, and that even back then there were some concerns about the
correctness of this approach (according to D11003#200772 the compile
unit name is not guaranteed to be the first one in the support file
list), I think we should just delete this workaround.

Reviewers: clayborg, tberghammer, dsrbecky

Subscribers: aprantl, lldb-commits

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

llvm-svn: 361948
2019-05-29 11:28:35 +00:00
Stefan Granitz 72e05d0aa4 [CMake] Remove lldb-server from LLDB.framework
Summary: The LLDB test suite doesn't need lldb-server in the framework bundle anymore.

Reviewers: JDevlieghere, jasonmolenda, xiaobai

Reviewed By: JDevlieghere

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 361947
2019-05-29 11:28:11 +00:00
Stefan Granitz 5dc9036746 [CMake] LLDB.framework tools handling
Summary:
Modify the way LLDB.framework tools are collected. This allows for better fine-tuning of the install behavior downstream. Each target calls `lldb_add_to_framework()` individually. When entering the function, the target exists and we can tweak its very own post-build and install steps. This was not possible with the old `LLDB_FRAMEWORK_TOOLS` approach.

No function change otherwise.
This is a reduced follow-up from the proposal in D61952.

Reviewers: xiaobai, compnerd, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: clayborg, friss, ki.stfu, mgorny, lldb-commits, labath, #lldb

Tags: #lldb

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

llvm-svn: 361946
2019-05-29 11:26:06 +00:00
Pavel Labath d2042d3dd7 DWARFASTParserClang: Unify compilation unit language handling
Summary:
The function was not being consistent in how it retrieved the language
of the current compile unit. Sometimes it did so from the lldb CU
object, and sometimes from the DWARF die. This patch unifies the
handling on the latter. The reason for choosing the DWARF method is
because I'd eventually like to stop creating lldb CUs for dwarf type
units (and so this code needs to would need to work without them).

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 361939
2019-05-29 09:32:59 +00:00
Pavel Labath 78cfe1e6fe DWARF: Fix address range support in mixed 4+5 scenario
Summary:
debug_ranges got renamed to debug_rnglists in DWARF 5. Prior to this
patch lldb was just picking the first section it could find in the file,
and using that for all address ranges lookups. This is not correct in
case the file contains a mixture of compile units with various standard
versions (not a completely unlikely scenario).

In this patch I make lldb support reading from both sections
simulaneously, and decide the correct section to use based on the
version number of the compile unit. SymbolFileDWARF::DebugRanges is
split into GetDebugRanges and GetDebugRngLists (the first one is renamed
mainly so we can catch all incorrect usages).

I tried to structure the code similarly to how llvm handles this logic
(hence DWARFUnit::FindRnglistFromOffset/Index), but the implementations
are still relatively far from each other.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: lldb-commits

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

llvm-svn: 361938
2019-05-29 09:22:36 +00:00
Saleem Abdulrasool 99e040b3c9 build: only search for the needed python type
Windows has different types of runtime libraries which are ABI
incompatible with one another.  This requires that the debug build of
lldb link against the debug build of python.  Adjust the python search
to search for only the required type of python.  This permits building a
release build of lldb against just the release build of python.

llvm-svn: 361915
2019-05-29 02:26:29 +00:00
Antonio Afonso 3da8e5f920 Fix IPv6 support on lldb-server platform
Summary:
This is a general fix for the ConnectionFileDescriptor class but my main motivation was to make lldb-server working with IPv6.
The connect URI can use square brackets ([]) to wrap the interface part of the URI (e.g.: <scheme>://[<interface>]:<port>). For IPv6 addresses this is a must since its ip can include colons and it will overlap with the port colon otherwise. The URIParser class parses the square brackets correctly but the ConnectionFileDescriptor doesn't generate them for IPv6 addresses making it impossible to connect to the gdb server when using this protocol.

How to reproduce the issue:
```
$ lldb-server p --server --listen [::1]:8080
...
$ lldb
(lldb) platform select remote-macosx
(lldb) platform connect connect://[::1]:8080
(lldb) platform process -p <pid>
error: unable to launch a GDB server on 'computer'
```

The server was actually launched we were just not able to connect to it. With this fix lldb will correctly connect. I fixed this by wrapping the ip portion with [].

Reviewers: labath

Reviewed By: labath

Subscribers: xiaobai, mgorny, jfb, lldb-commits, labath

Tags: #lldb

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

llvm-svn: 361898
2019-05-28 23:26:32 +00:00
Jonas Devlieghere d02da8f42c [SymbolFileDWARF] Remove unused member (NFC)
Removes the unused debug line instance.

llvm-svn: 361886
2019-05-28 22:33:30 +00:00
Alexandre Ganea 2076fb28f1 Fix 'warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]' with GCC 7.3
See: https://github.com/google/googletest/issues/1119
llvm-svn: 361862
2019-05-28 18:36:35 +00:00
Alexandre Ganea cf950b46c8 Fix 'warning: format specifies type 'int' but the argument has type 'MIuint' (aka 'unsigned long long') [-Wformat]' with Clang 8.0
llvm-svn: 361861
2019-05-28 18:36:11 +00:00
Jonas Devlieghere 04a087ace7 [DWARFExpression] Remove ctor that takes just a compile unit.
Like many of our DWARF classes, the DWARFExpression can be initialized
in several ways. One such way was through a constructor that takes just
the compile unit. This constructor is used to initialize both empty
DWARFExpressions, and DWARFExpression that will be populated later.

To make the distinction more clear, I changed the constructor to a
default constructor and updated its call sites. Where the
DWARFExpression was being populated later, I replaced that with a call
to the copy assignment constructor.

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

llvm-svn: 361849
2019-05-28 17:34:05 +00:00
Stefan Granitz a3388e5f9e [CMake] Folder structure for generated Xcode project to cover more targets
llvm-svn: 361799
2019-05-28 09:29:05 +00:00
Pavel Labath 11e0549145 DWARFDebugArangeSet: Remove references to SymbolFileDWARF
This class does not depend on SymbolFileDWARF. Instead, include more
appropriate low-level headers.

llvm-svn: 361765
2019-05-27 14:16:15 +00:00
Pavel Labath 5a500fd2c5 XFAIL prefer-debug-over-eh-frame.test on darwin
debug_frame does not seem to work on darwin, so there is nothing to
prefer.

Adding `-g` to the compiler command line is enough to get the
__debug_frame section added to the dsym file. Though lldb then finds the
section, and correctly assigns the section type to it, this does not
seem to be enough to get lldb to actually use this section for
unwinding.

llvm-svn: 361760
2019-05-27 13:43:01 +00:00
Pavel Labath 2b5f340bcb DWARF: Add a simple test exercising debug_loc parsing
llvm-svn: 361759
2019-05-27 13:23:23 +00:00
Pavel Labath ae4ec62cc9 FuncUnwinders: prefer debug_frame over eh_frame
The two sections usually contain the same information, and we rarely
have both kinds of entries for a single function. However, in theory the
debug_frame plan can be more complete, whereas eh_frame is only required
to be correct at places where exceptions can be thrown.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits

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

llvm-svn: 361758
2019-05-27 11:53:24 +00:00
Pavel Labath 519ef6afdf DWARF: Remove cu_idx variables from parsing functions
These variables were useful when looking up the compile unit index
required a binary search. Now that we can look up a compile unit index
in constant time, they are no longer needed.

llvm-svn: 361754
2019-05-27 10:10:59 +00:00
Greg Clayton 78a6ae738c Revert Xcode scheme changes from 361675
llvm-svn: 361676
2019-05-24 22:12:01 +00:00
Greg Clayton 6aad81cd96 Cleanup fixed form sizes.
The fix form sizes use to have two arrays: one for 4 byte addresses and in for 8 byte addresses. The table had an issue where DW_FORM_flag_present wasn't being represented as a fixed size form because its actual size _is_ zero and zero was used to indicate the form isn't fixed in size. Any code that needed to quickly access the DWARF had to get a FixedFormSizes instance using the address byte size.

This fix cleans things up by adding a DWARFFormValue::GetFixedSize() both as a static method and as a member function on DWARFFormValue. It correctly can indicate if a form size is zero. This cleanup is a precursor to a follow up patch where I hope to speed up DWARF parsing.

I verified performance doesn't regress by loading hundreds of DWARF files and setting a breakpoint by file and line and by name in files that do not have DWARF indexes. Performance remained consistent between the two approaches.


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

llvm-svn: 361675
2019-05-24 22:08:50 +00:00
Alex Langford b77a60ce40 [Target] Make Processes' GetLanguageRuntime non-virtual
llvm-svn: 361673
2019-05-24 21:27:37 +00:00
Jonas Devlieghere 7c67dec9b8 [DWARFExpression] Remove commented-out code (NFC)
llvm-svn: 361672
2019-05-24 21:26:30 +00:00
Alex Langford 96f02a8db8 [Process] Clean up some logic around LanguageRuntimes
llvm-svn: 361666
2019-05-24 19:39:50 +00:00
Pavel Labath 1a0312ca0b [FuncUnwinders] Use "symbol file" unwind plans for unwinding
Summary:
Previous patch (r360409) introduced the "symbol file unwind plan"
concept, but that plan wasn't used for unwinding yet. With this patch,
we start to consider the new plan as a possible strategy for both
synchronous and asynchronous unwinding. I also add a test that asserts
that unwinding via breakpad STACK CFI info works end-to-end.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits, amccarth, markmentovai

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

llvm-svn: 361618
2019-05-24 09:54:39 +00:00
Pavel Labath f750842c8b DWARF: Implement DW_AT_signature lookup for type unit support
Summary:
This patch implements the main feature of type units. When completing a
type, if we encounter a DW_AT_signature attribute, we use it's value to
lookup the complete definition of the type in the relevant type unit.

To enable this lookup, we build up a map of all type units in a symbol
file when parsing the units. Then we consult this map when resolving the
DW_AT_signature attribute.

I include add a couple of tests which exercise the type lookup feature,
including one that ensure we do something reasonable in case we fail to
lookup the type.

A lot of the ideas in this patch have been taken from D32167 and D61505.

Reviewers: clayborg, JDevlieghere, aprantl, alexshap

Subscribers: mgrang, lldb-commits

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

llvm-svn: 361603
2019-05-24 08:11:12 +00:00
Pavel Labath 8ac0bc9832 DWARFContext: Make loading of sections thread-safe
Summary:
SymbolFileDWARF used to load debug sections in a thread-safe manner.
When we moved to DWARFContext, we dropped the thread-safe part, because
we thought it was not necessary.

It turns out this was only mostly correct.

The "mostly" part is there because this is a problem only if we use the
manual index, as that is the only source of intra-module paralelism.
Also, this only seems to occur for extremely simple files (like the ones
I've been creating for tests lately), where we've managed to start
indexing before loading the debug_str section. Then, two threads start
to load the section simultaneously and produce wrong results.

On more complex files, something seems to be loading the debug_str section
before we start indexing, as I haven't been able to reproduce this
there, but I have not investigated what it is.

I've tried to come up with a test for this, but I haven't been able to
reproduce the problem reliably. Still, while doing so, I created a way
to generate many compile units on demand. Given that most of our tests
work with only one or two compile units, it seems like this could be
useful anyway.

Reviewers: aprantl, JDevlieghere, clayborg

Subscribers: arphaman, lldb-commits

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

llvm-svn: 361602
2019-05-24 08:04:03 +00:00
Jonas Devlieghere 0ee23c958b [Utility] Small improvements to the Broadcaster class (NFC)
I touched the Broadcaster class earlier today (r361544) and noticed a
few things that could be improved. This patch includes variety of small
fixes: use early returns, use LLDB_LOG macro, use doxygen comments and
finally format the class.

llvm-svn: 361597
2019-05-24 04:41:47 +00:00
Jonas Devlieghere ecd111533d Revert "[lldb] followup fix for https://reviews.llvm.org/D62305"
This fails on the Windows bot:

cannot convert from 'initializer list' to 'lldb::thread_result_t'

llvm-svn: 361583
2019-05-24 01:08:54 +00:00
Jonas Devlieghere 09ad8c8f73 Fix integer literals which are cast to bool
This change replaces built-in types that are implicitly converted to
booleans.

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

llvm-svn: 361580
2019-05-24 00:44:33 +00:00
Konrad Kleine 342571e8d6 [lldb] followup fix for https://reviews.llvm.org/D62305
Summary:
Fixing this error on windows build bot:

```
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(21): error C2440: 'initializing': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(21): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(21): error C2439: 'lldb_private::HostNativeThreadBase::m_result': member could not be initialized
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\include\lldb/Host/HostNativeThreadBase.h(48): note: see declaration of 'lldb_private::HostNativeThreadBase::m_result'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(24): error C2440: 'initializing': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(24): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(24): error C2439: 'lldb_private::HostNativeThreadBase::m_result': member could not be initialized
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\include\lldb/Host/HostNativeThreadBase.h(48): note: see declaration of 'lldb_private::HostNativeThreadBase::m_result'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(40): error C2440: '=': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(40): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(50): error C2440: '=': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Host\common\HostNativeThreadBase.cpp(50): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
```

see http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/5050/steps/build/logs/stdio

Reviewers: stella.stamenova, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 361565
2019-05-23 22:39:13 +00:00
J. Ryan Stinnett b4cb7d8045 [NFC] Add blank line (test commit)
llvm-svn: 361555
2019-05-23 21:13:50 +00:00
Jonas Devlieghere edb52e2e7d [Process] Fix another thread_result_t & nullptr incompatibility.
llvm-svn: 361548
2019-05-23 20:25:49 +00:00
Jorge Gorbe Moya 56d69ef8ca [lldb] Make sure RegularExpression constructors always initialize member variables
The copy constructor of RegularExpression doesn't initialize m_comp_err. This causes an use-of-initialized-value error when a RegularExpression is copied: the copy constructor calls Compile, which calls Free to free the existing regex if needed, which in turn reads m_comp_err to check if there's any regex to be freed.

This change calls the default constructor from the other constructors to make sure members are always initialized with sensible values. This also avoids duplicating init logic, like the RegularExpression(llvm:StringRef) constructor does, which is error prone.

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

llvm-svn: 361546
2019-05-23 20:11:17 +00:00
Jonas Devlieghere 266b65f840 [Utility] Avoid a few unnecessary copies (NFC)
Avoid unnecessary copies by either passing by const-reference or moving
the argument.

llvm-svn: 361544
2019-05-23 20:05:21 +00:00
Jonas Devlieghere a83bf47770 [gdb-remote] Fix more issues with thread_result_t
More fixes needed to un-break the Windows bot.

llvm-svn: 361539
2019-05-23 19:32:46 +00:00
Antonio Afonso 517e3cb0a5 Test commit access by removing a empty line
llvm-svn: 361531
2019-05-23 18:35:54 +00:00
Jonas Devlieghere a21d5ab369 [HostNativeThreadBase] Undo nullptr changes
The thread result type is an unsigned instead of a pointer on windows,
so we shouldn't replace 0 with nullptr here.

llvm-svn: 361528
2019-05-23 18:15:43 +00:00
Konrad Kleine 85200645c6 [lldb] fix cannot convert from 'nullptr' to 'lldb::thread_result_t'
Summary:
On Windows `lldb::thread_result_t` resolves to `typedef unsigned thread_result_t;` and on other platforms it resolves to `typedef void *thread_result_t;`.
 Therefore one cannot use `nullptr` when returning from a function that returns `thread_result_t`.

I've made this change because a windows build bot fails with these errors:

```
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Communication.cpp(362): error C2440: 'return': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Communication.cpp(362): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
```

and

```
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1619): error C2440: 'return': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1619): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1664): error C2440: 'return': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1664): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
```

This is the failing build: http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/5035/steps/build/logs/stdio

Reviewers: JDevlieghere, teemperor, jankratochvil, labath, clayborg, RKSimon, courbet, jhenderson

Reviewed By: labath, clayborg

Subscribers: labath, lldb-commits

Tags: #lldb

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

llvm-svn: 361503
2019-05-23 15:17:39 +00:00
Konrad Kleine 248a13057a [lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]

This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.

This is the command I ran and I to fix and format the code base:

```
run-clang-tidy.py \
	-header-filter='.*' \
	-checks='-*,modernize-use-nullptr' \
	-fix ~/dev/llvm-project/lldb/.* \
	-format \
	-style LLVM \
	-p ~/llvm-builds/debug-ninja-gcc
```

NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.

NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.

Reviewers: martong, espindola, shafik, #lldb, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits

Tags: #lldb, #llvm

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

llvm-svn: 361484
2019-05-23 11:14:47 +00:00
Pavel Labath f95b05c3df Add REQUIRES: lld to debug-types-address-ranges.s
This should fix the green dragon bots.

llvm-svn: 361481
2019-05-23 10:46:35 +00:00
Pavel Labath 691502f61e DWARFASTParserClang: Reduce indentation
by two levels via early returns.

llvm-svn: 361471
2019-05-23 09:41:39 +00:00
Pavel Labath 324396466c DWARF: Don't compute address ranges for type units
Summary:
Type units don't describe any code, so they should never be the result
of any address lookup queries.

Previously, we would compute the address ranges for the type units for
via the line tables they reference because the type units looked a lot
like line-tables-only compile units. However, this is not correct, as
the line tables are only referenced from type units so that other
declarations can use the file names contained in them.

In this patch I make the BuildAddressRangeTable function virtual, and
implement it only for compile units.

Testing this was a bit tricky, because the behavior depends on the order
in which we add things to the address range map. This rarely caused a
problem with DWARF v4 type units, as they are always added after all
CUs. It happened more frequently with DWARF v5, as there clang emits the
type units first. However, this is still not something that it is
required to do, so for testing I've created an assembly file where I've
deliberately sandwiched a compile unit between two type units, which
should isolate us from both changes in how the compiler emits the units
and changes in the order we process them.

Reviewers: clayborg, aprantl, JDevlieghere

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 361465
2019-05-23 09:07:51 +00:00
Jan Kratochvil 19a3c30731 Simplify `GetName`+`AppendTypeName` by `DWARFDIE`
In D61502#1503247 @clayborg suggested that DWARFUnit *+dw_offset_t can be now
replaced by DWARFDIE.

It is moved from DWARFDebugInfoEntry to DWARFDIE as noted by @clayborg.

I have also removed return type as (1) it was wrong in one case and (2) no
existing caller used the return type. I also refactored the deep nesting noted
by @JDevlieghere.

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

llvm-svn: 361463
2019-05-23 08:00:49 +00:00
Jonas Devlieghere 202dc1291e [Reproducer] Pass FileSpec by const-ref. (NFC)
Fix two functions where we were passing FileSpecs by value, while we
could pass by const reference.

llvm-svn: 361459
2019-05-23 05:45:49 +00:00
Jonas Devlieghere 24374aef1b [Utility] Modernize C-style cats
Replaces the remaining C-style casts with explicit casts in Utility. The
motivation is that they are (1) easier to spot and (2) don't have
multiple meanings.

llvm-svn: 361458
2019-05-23 05:12:11 +00:00
Jim Ingham ab43d1d888 Remove unused const version of CommandInterpreter::GetCommandHistory.
llvm-svn: 361455
2019-05-23 01:40:33 +00:00
Omair Javaid 772176dad1 [ARM64][AArch64] Update disassembler attributes to ARMv8.5 ISA with SVE extensions
This patch updates assembler attributes for AArch64 targets so we can disassemble newer instructions supported in ISA version 8.5 and SVE extensions.

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

llvm-svn: 361451
2019-05-23 00:46:34 +00:00
Jim Ingham 020d7f1abb Ack, added DWARFTypeUnit to the wrong target...
LLDB -> liblldbcore.a

llvm-svn: 361447
2019-05-23 00:12:45 +00:00
Jorge Gorbe Moya 33dbab8271 [lldb] Fix use-of-uninitialized-value in Driver
The driver passes by reference an uninitialized num_errors variable to
RunCommandInterpreter. This should be fine, as it's supposed to be
an output argument, but the reproducer instrumentation reads it in order
to record the value of all the arguments to the function.

This change fixes it by initializing num_errors to 0 before calling
RunCommandInterpreter.

llvm-svn: 361444
2019-05-22 23:37:48 +00:00
Saleem Abdulrasool 2956127f5b Expression: correct relocation model for Windows
The Windows Code Generation model cannot generation code with the PIC relocation
model - all code is implicitly position independent due to the DLL load slide
that occurs if it is not loaded at the preferred base address.  Invert the
condition and inline the single use of the variable.  This should also aid the
WASM target.  This significantly improves the state of the (swift) repl on
Windows (and should aid in expression evaluation on Windows).

llvm-svn: 361443
2019-05-22 23:23:39 +00:00
Alex Langford 74eb76f6c3 [Target] Protect Processes' language runtimes map with a mutex
Summary:
From what I understand, it's possible for multiple threads to request
a specific language runtime (e.g. CPPLanguageRuntime). This leads to a data
race.

Reviewers: jingham, JDevlieghere, compnerd, clayborg

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

llvm-svn: 361442
2019-05-22 23:01:18 +00:00
Frederic Riss bb2b52769b Actaully lock accesses to OptionValueFileSpecList objects
The patch in r359029 missed a few accessors and mutators. This patch
also changes the lock to a recursive one as OptionValueFileSpecList::Clear()
can be invoked from some of the other methods.

llvm-svn: 361440
2019-05-22 21:58:52 +00:00