Commit Graph

11206 Commits

Author SHA1 Message Date
Jonas Devlieghere 9bbba276e9 Change std::sort to llvm::sort to detect non-determinism.
LLVM added wrappers to std::sort (r327219) that randomly shuffle the
container before sorting. The goal is to uncover non-determinism due to
undefined sorting order of objects having the same key.

This can be enabled with -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON.

llvm-svn: 350679
2019-01-08 23:25:06 +00:00
Raphael Isemann 0e3299dc60 Fix unused private field warning.
Summary: The member is private and unused if HAVE_LIBCOMPRESSION is undefined, which triggers Clang's -Wunused-private-field warning.

Subscribers: lldb-commits

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

llvm-svn: 350675
2019-01-08 22:55:02 +00:00
Jonas Devlieghere dadbb45f34 [BreakpointList] Simplify/modernize BreakpointList (NFC)
I was looking at the code in BreakpointList.cpp and found it deserved a
quick cleanup.

  -  Use std::vector instead of a std::list.
  -  Extract duplicate code for notifying.
  -  Remove code duplication when returning a const value.
  -  Use range-based for loop.
  -  Use early return in loops.

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

llvm-svn: 350659
2019-01-08 22:07:42 +00:00
Jonas Devlieghere 6107eda03c [PdbAstBuilder] Remove unused functions
PdbAstBuilder.cpp:273:20: warning: unused function 'GetParentUniqueName' [-Wunused-function]
PdbAstBuilder.cpp:267:13: warning: unused function 'IsUniqueNameEnumTag' [-Wunused-function]

llvm-svn: 350652
2019-01-08 20:58:54 +00:00
Adrian Prantl 6ea33bc19b Convert to LLDB coding style (NFC)
llvm-svn: 350651
2019-01-08 20:48:40 +00:00
Pavel Labath 8e55ddef8c ProcessLaunchInfo: Remove Target reference
Summary:
The target was being used in FinalizeFileActions to provide default
values for stdin/out/err. Also, most of the logic of this function was
very specific to how the lldb's Target class wants to launch processes,
so I, move it to Target::FinalizeFileActions, inverting the dependency.
The only piece of logic that was useful elsewhere (lldb-server) was the
part which sets up a pty and relevant file actions. I've kept this part
as ProcessLaunchInfo::SetUpPtyRedirection.

This makes ProcessLaunchInfo independent of any high-level lldb constructs.

Reviewers: zturner, jingham, teemperor

Subscribers: lldb-commits

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

llvm-svn: 350617
2019-01-08 11:55:19 +00:00
Jonas Devlieghere 8edd8e31eb [SymbolContext] Remove dead code
Removes two methods from SymbolContextList that aren't referenced.

llvm-svn: 350599
2019-01-08 01:35:00 +00:00
Adrian Prantl c5e0c58875 Simplify code.
llvm-svn: 350577
2019-01-07 23:08:16 +00:00
Adrian Prantl 511d7d1fc1 Clarify comment and variable names. (NFC)
llvm-svn: 350576
2019-01-07 23:02:28 +00:00
Adrian Prantl 95280c948d Rename DWARFDIE::GetDWOContext() -> GetDeclContext() (NFC)
Despite the name, this function has nothing to do with the DWO format.

llvm-svn: 350575
2019-01-07 22:47:17 +00:00
Jorge Gorbe Moya 347b0804bc [lldb] Fix -Wstring-plus-int warning in POSIX-DYLD/AuxVector.cpp
llvm-svn: 350570
2019-01-07 21:04:12 +00:00
Leonard Mosescu 0d05790030 Use the minidump exception record if present
If the minidump contains a saved exception record use it automatically.

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

llvm-svn: 350546
2019-01-07 17:55:42 +00:00
Pavel Labath ed42ea4707 ObjectFileBreakpad: Implement sections
Summary:
This patch allows ObjectFileBreakpad to parse the contents of Breakpad
files into sections. This sounds slightly odd at first, but in essence
its not too different from how other object files handle things. For
example in elf files, the symtab section consists of a number of
"records", where each record represents a single symbol. The same is
true for breakpad's PUBLIC section, except in this case, the records will be
textual instead of binary.

To keep sections contiguous, I create a new section every time record
type changes. Normally, the breakpad processor will group all records of
the same type in one block, but the format allows them to be intermixed,
so in general, the "object file" may contain multiple sections with the
same record type.

Reviewers: clayborg, zturner, lemo, markmentovai, amccarth

Subscribers: lldb-commits

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

llvm-svn: 350511
2019-01-07 11:14:08 +00:00
Pavel Labath cb8c699802 ProcessLaunchInfo: remove Debugger reference
Summary:
The Debuffer object was being used in "GetListenerForProcess" to provide
a default listener object if one was not specified in the launch_info
object.

Since all the callers of this function immediately passed the result to
Target::CreateProcess, it was easy to move this logic there instead.

This brings us one step closer towards being able to move the LaunchInfo
classes to the Host layer (which is there the launching code that
consumes them lives).

Reviewers: zturner, jingham, teemperor

Subscribers: lldb-commits

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

llvm-svn: 350510
2019-01-07 10:59:57 +00:00
Jan Kratochvil 005a43e7c4 Fix symbols.enable-external-lookup description wording
D55859 changed "external tools or libraries" to "external sources" according to
Pavel Labath.  Now it is changed sort of back to "external tools and
repositories" according to Adrian Prantl.
	https://reviews.llvm.org/D55859#1345881

llvm-svn: 350479
2019-01-05 21:39:03 +00:00
Davide Italiano ff92a1a7cf [Scalar] Simplify comparison operators and add coverage.
llvm-svn: 350428
2019-01-04 19:23:52 +00:00
Stefan Granitz f9ef9e0c19 [CMake] Python bindings generation polishing
Summary:
Simplify SWIG invocation and handling of generated files.

The `swig_wrapper` target can generate `LLDBWrapPython.cpp` and `lldb.py` in its own binary directory, so we can get rid of a few global variables and their logic. We can use the swig_wrapper's BINARY_DIR target property to refer to it and liblldb's LIBRARY_OUTPUT_DIRECTORY to refer to the framework/shared object output directory.

Reviewers: JDevlieghere, aprantl, stella.stamenova, beanz, zturner, xiaobai

Reviewed By: aprantl

Subscribers: mgorny, lldb-commits, #lldb

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

llvm-svn: 350393
2019-01-04 12:47:02 +00:00
Stefan Granitz f126ce6881 [CMake] Revised LLDB.framework builds
Summary:
Add features to LLDB CMake builds that have so far only been available in Xcode. Clean up a few inconveniences and prepare further improvements.

Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed dummy targets)

Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle

Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, clayborg, labath

Reviewed By: aprantl

Subscribers: friss, mgorny, lldb-commits, #lldb

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

llvm-svn: 350391
2019-01-04 12:46:50 +00:00
Pavel Labath 232ab01e6b Symtab: Remove one copy of symbol size computation code
Summary:
The implementation in CalculateSymbolSizes has been made redundant in
D19004, as this patch added another copy of size computation code into
InitAddressIndexes (which is called by CalculateSymbolSizes).

Reviewers: clayborg, jasonmolenda, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 350384
2019-01-04 10:11:25 +00:00
Pavel Labath 0611642f3a RangeMap.h: merge RangeDataArray and RangeDataVector
Summary:
The main difference between the classes was supposed to be the fact that
one is backed by llvm::SmallVector, and the other by std::vector.
However, over the years, they have accumulated various other differences
too.

This essentially removes the std::vector version, as that is pretty much
identical to llvm::SmallVector<T, 0>, and combines their interfaces. It
does not attempt to do a more significant refactoring, even though there
is still a lot of duplication in this file, as it is hard to tell which
quirk of some API is depended on by somebody (and, a previous, more
ambitious attempt at this in D16769 has failed).

I also add some tests, including one which demonstrates one of the
quirks/bugs of the API I have noticed in the process.

Reviewers: clayborg, teemperor, tberghammer

Subscribers: mgorny, JDevlieghere, lldb-commits

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

llvm-svn: 350380
2019-01-04 07:14:17 +00:00
Kuba Mracek 961fbf21c6 [lldb] Fix ObjCExceptionRecognizedStackFrame to populate the list of recognized arguments
Differential Revision: https://reviews.llvm.org/D56027

llvm-svn: 350376
2019-01-04 00:25:08 +00:00
Kuba Mracek 19d1f20927 [lldb] Check SafeToCallFunctions before calling functions in GetExceptionObjectForThread
Differential Revision: https://reviews.llvm.org/D56115

llvm-svn: 350375
2019-01-04 00:20:52 +00:00
Jan Kratochvil 4c993ce187 symbols.enable-external-lookup=false on all hosts (not just OSX)
There is already in use:
	lit/lit-lldb-init:
		settings set symbols.enable-external-lookup false
	packages/Python/lldbsuite/test/lldbtest.py:
		self.runCmd('settings set symbols.enable-external-lookup false')

But those are not in effect during MI part of the testsuite. Another problem is
that symbols.enable-external-lookup (read by GetEnableExternalLookup) has been
currently read only by LocateMacOSXFilesUsingDebugSymbols and therefore it had
no effect on Linux.

On Red Hat platforms (Fedoras, RHEL-7) there is DWZ in use and so
MiSyntaxTestCase-test_lldbmi_output_grammar FAILs due to:
	AssertionError: error: inconsistent pattern ''^.+?\n'' for state 0x5f
	(matched string: warning: (x86_64) /lib64/libstdc++.so.6 unsupported
	DW_FORM values: 0x1f20 0x1f21
It is the only testcase with this error. It happens due to:
	(lldb) target create "/lib64/libstdc++.so.6"
	Current executable set to '/lib64/libstdc++.so.6' (x86_64).
	(lldb) b main
	warning: (x86_64) /lib64/libstdc++.so.6 unsupported DW_FORM values: 0x1f20 0x1f21
	Breakpoint 1: no locations (pending).
	WARNING:  Unable to resolve breakpoint to any actual locations.
which happens only with gcc-base-debuginfo rpm installed (similarly for other packages).

It should also speed up the testsuite as it no longer needs to read
/usr/lib/debug symbols which have no effect (and should not have any effect) on
the testsuite results.

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

llvm-svn: 350368
2019-01-03 23:11:06 +00:00
Pavel Labath 31d7305258 PECOFF: Remove tabs introduced accidentally in r350094
llvm-svn: 350298
2019-01-03 12:07:38 +00:00
Pavel Labath f760f5aef4 Simplify ObjectFile::GetArchitecture
Summary:
instead of returning the architecture through by-ref argument and a
boolean value indicating success, we can just return the ArchSpec
directly. Since the ArchSpec already has an invalid state, it can be
used to denote the failure without the additional bool.

Reviewers: clayborg, zturner, espindola

Subscribers: emaste, arichardson, JDevlieghere, lldb-commits

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

llvm-svn: 350291
2019-01-03 10:37:19 +00:00
Aaron Smith c28daec5b2 Check that a pointer is valid and fix a log message on Windows
llvm-svn: 350281
2019-01-03 00:54:08 +00:00
Zachary Turner 489cfbd9c5 Try to fix Green Dragon bot.
It doesn't like this std::tie() for some reason, hopefuly this
fixes it.

llvm-svn: 350262
2019-01-02 21:04:22 +00:00
Zachary Turner 10ac299a9d Use map::insert instead of try_emplace.
try_emplace is C++17.

llvm-svn: 350244
2019-01-02 18:53:11 +00:00
Zachary Turner 225663308d [NativePDB] Implement ParseDeclsForContext.
This is a first step towards getting lldb-test symbols working
with the native plugin.  There is a remaining issue, which is
that the plugin expects that ParseDeclsForContext will also
create lldb symbols rather than just the decls, but the native
pdb plugin doesn't currently do this.  This will be addressed
in a followup patch.

llvm-svn: 350243
2019-01-02 18:33:54 +00:00
Zachary Turner b3130b4fdf [NativePDB] Fix setting breakpoint by file and line.
There were several problems preventing this from working.  The
first is that when the PDB had an absolute path to the main
source file, we would construct an invalid path by prepending the
compilation directory to it anyway.  So we needed to check if the
path is already absolute first.

Second, LLDB assumes that the zero'th item in the support file list
is the main compilation unit.  We were respecting this requirement,
but LLDB *also* requires that file to appear somewhere in the list
starting from index 1 as well.  So the main compilation file should
appear in the support file list twice.  And when parsing a line
table, it expects the LineEntry records to be constructed using
the 1-based index.  With these two fixes we can now set breakpoints
by file and line using the native PDB reader.

llvm-svn: 350240
2019-01-02 18:32:50 +00:00
Davide Italiano 05f484ff55 [DWARFUnit] Remove commented out code. NFCI.
llvm-svn: 350177
2018-12-31 18:45:30 +00:00
Jonas Devlieghere 76c6feafac [CommandInterpreter] Simplify PreprocessCommand. (NFCI)
Simplify some code in PreprocessCommand. This change improves
consistency, reduces the indentation and makes the code easier to follow
overall.

llvm-svn: 350166
2018-12-30 17:56:30 +00:00
Davide Italiano e4c9120499 [Type] Simplify operator!=. NFC.
llvm-svn: 350164
2018-12-30 15:08:51 +00:00
Davide Italiano 9470c66ced [TypeName] Simplify operator!=. NFCI.
llvm-svn: 350163
2018-12-30 15:07:25 +00:00
Davide Italiano db057e7792 [RegisterValue] Rewrite operator!= in terms of operator==. NFCI.
llvm-svn: 350149
2018-12-29 05:05:23 +00:00
Davide Italiano 223032f72e [CompilerType] Simplify operator!=. NFCI.
llvm-svn: 350148
2018-12-29 05:00:33 +00:00
Davide Italiano e70af020f4 [CompilerType] Remove dead code. NFCI.
llvm-svn: 350147
2018-12-29 04:59:07 +00:00
Davide Italiano d22327080c [SymbolContext] Rewrite operator== to be more concise.
And probably, less error prone. NFCI.

llvm-svn: 350146
2018-12-29 04:57:00 +00:00
Pavel Labath ffec31e462 Remove unused variable from ClangASTContext
llvm-svn: 350121
2018-12-28 13:34:44 +00:00
Pavel Labath 88a2c2a41b Reduce indentation in ObjectFilePECOFF::CreateSections via an early return
llvm-svn: 350094
2018-12-27 15:16:44 +00:00
Pavel Labath 796984d6c0 Fix "default argument for lambda parameter" (-Wpedantic) warning
llvm-svn: 350089
2018-12-27 09:44:32 +00:00
Pavel Labath 4870fa9a40 Delete lldb_utility::Range
This class is unused, and there is already a lldb_private::Range
(defined in lldb/Core/RangeMap.h), which has similar functionality.

llvm-svn: 350088
2018-12-27 09:44:27 +00:00
Pavel Labath 3eba3f1a13 DWARF: Fix a bug in array size computation
Summary:
r346165 introduced a bug, where we would fail to parse the size of an
array if that size happened to match an existing die offset.

The logic was:
if (DWARFDIE count = die.GetReferencedDie(DW_AT_count))
  num_elements = compute_vla_size(count);
else
  num_elements = die.GetUsigned(DW_AT_count); // a fixed-size array

The problem with this logic was that GetReferencedDie did not take the
form class of the attribute into account, and would happily return a die
reference for any form, if its value happened to match some die.

As this behavior is inconsistent with how llvm's DWARFFormValue class
operates, I chose to fix the problem by making our version of this class
match the llvm behavior. For this to work, I had to add an explicit form
class check to the .apple_XXX tables parsing code, because they do
(incorrectly?) use data forms as die references.

Reviewers: aprantl, clayborg

Subscribers: JDevlieghere, lldb-commits

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

llvm-svn: 350086
2018-12-27 09:25:34 +00:00
Jonas Devlieghere 8d20cfdfc6 [NFC] Replace `compare` with (in)equality operator where applicable.
Using compare is verbose, bug prone and potentially inefficient (because
of early termination). Replace relevant call sites with the (in)equality
operator.

llvm-svn: 349972
2018-12-21 22:46:10 +00:00
Davide Italiano 18a0ce9813 [Scalar] Implement operator!= using operator==.
Summary: Adding some test coverage while I'm around.

Reviewers: JDevlieghere, aprantl, zturner, clayborg, jingham

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

llvm-svn: 349970
2018-12-21 22:42:00 +00:00
Jonas Devlieghere aa2dc6bfec [ExpressionParser] Reserve size before copying over args
We already know the final size here so we might as well reserve it so we
don't have to re-allocate during the loop.

llvm-svn: 349967
2018-12-21 22:16:10 +00:00
Greg Clayton 57577c0634 Don't duplicate the logic that detects if a section can/should be loaded (NFC)
Prior to this there were 3 places that were duplicating the logic to detect if a section can/should be loaded and some were doing things a bit differently. Now it is all centralized in one place and it is done correctly.

llvm-svn: 349926
2018-12-21 17:04:18 +00:00
Jim Ingham 79d8105fc8 "help finish" tells you it is an alias. "help fin" doesn't.
They both run the same command, and people get used to typing the shortest
string they can, so we should support alias info on shortened strings as well.

<rdar://problem/46859207>

llvm-svn: 349874
2018-12-21 01:45:28 +00:00
Jonas Devlieghere 34fb64d661 Fix stack-buffer-overflow in lldb_private::Host::FindProcesses (2/2)
This fixes the second call at line 640 that I missed in r349858.

llvm-svn: 349869
2018-12-21 01:22:58 +00:00
Adrian Prantl 5255094b3e Add an assertion to aid in tracking down a bug
llvm-svn: 349865
2018-12-21 01:09:15 +00:00
Jonas Devlieghere 6679bc15ca Fix stack-buffer-overflow in lldb_private::Host::FindProcesses
Found by the address sanitizer on GreenDragon:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-sanitized/1628/console

llvm-svn: 349858
2018-12-20 23:45:26 +00:00
Kuba Mracek 4c7f5d5c5a [lldb] Add a "display-recognized-arguments" target setting to show recognized arguments by default
Differential Revision: https://reviews.llvm.org/D55954

llvm-svn: 349856
2018-12-20 23:38:19 +00:00
Zachary Turner 3790029d97 [NativePDB] Create VarDecls for global variables.
Previously we would create these for local variables but not for
global variables.

Also updated existing tests which created global variables to check
for them in the resulting AST.

llvm-svn: 349854
2018-12-20 23:32:37 +00:00
Jonas Devlieghere 3447077a28 [API] Remove redundants get() from smart pointers. NFC
Removes redundant calls to ::get() from smart pointers in the source/API
directory..

llvm-svn: 349821
2018-12-20 21:02:55 +00:00
Tatyana Krasnukha 92e5e36004 Overload GetMemoryRegions for the ProcessMinidump
Differential Revision: https://reviews.llvm.org/D55841

llvm-svn: 349767
2018-12-20 15:05:43 +00:00
Tatyana Krasnukha 36788bbb32 Replace MemoryRegionInfoSP with values and cleanup related code
Differential Revision: https://reviews.llvm.org/D55472

llvm-svn: 349766
2018-12-20 15:02:58 +00:00
Kuba Mracek c9e1190a27 [lldb] Retrieve currently handled Obj-C exception via __cxa_current_exception_type and add GetCurrentExceptionBacktrace SB ABI
This builds on https://reviews.llvm.org/D43884 and https://reviews.llvm.org/D43886 and extends LLDB support of Obj-C exceptions to also look for a "current exception" for a thread in the C++ exception handling runtime metadata (via call to __cxa_current_exception_type). We also construct an actual historical SBThread/ThreadSP that contains frames from the backtrace in the Obj-C exception object.

The high level goal this achieves is that when we're already crashed (because an unhandled exception occurred), we can still access the exception object and retrieve the backtrace from the throw point. In Obj-C, this is particularly useful because a catch+rethrow is very common and in those cases you currently don't have any access to the throw point backtrace.

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

llvm-svn: 349718
2018-12-20 02:01:59 +00:00
Adrian Prantl 03bd183883 Simplify code for readability. (NFC)
llvm-svn: 349700
2018-12-19 23:48:40 +00:00
Zachary Turner 51f88af359 [NativePDB] Fix a use after free and enable corresponding native test.
We had a use after free where we were assigning the result of a function
that returned a string to a StringRef.  After fixing this use after
free, one of the DIA PDB tests now passes with the native PDB reader,
so we enable the test under native mode as well.  The goal is to
eventually make all the tests pass under both, at which point we can
disable them all under DIA mode.

llvm-svn: 349673
2018-12-19 19:45:30 +00:00
Greg Clayton da9c5dba96 Show the memory region name if there is one in the output of the "memory region" command
Prior to this change we would show the name of the section that a memory region belonged to but not its actual region name. Now we show this,. Added a test that reuses the regions-linux-map.dmp minidump file to test this and verify the correct region names for various memory regions.

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

llvm-svn: 349658
2018-12-19 18:16:52 +00:00
Jan Kratochvil 9a33a15766 refactor testsuite spawnLldbMi args->exe+args
Currently spawnLldbMi accepts both lldb-mi options and executable to debug as
a single parameter. Split them.

As in D55859 we will need to execute one lldb-mi command before loading the
exe. Therefore we can no longer use the exe as lldb-mi command-line parameter
as then there is no way to execute a command before loading exe specified as
lldb-mi command-line parameter.

LocateExecutableSymbolFileDsym should be static, that is also a little
refactorization.

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

llvm-svn: 349607
2018-12-19 08:57:10 +00:00
Jason Molenda 8460bb0583 Don't forget to free the libcompression scratch buffer in the dtor.
llvm-svn: 349580
2018-12-18 23:45:45 +00:00
Zachary Turner cb67fad44a [NativePDB] Correctly reconstruct DeclContext for nested enums.
We reconstruct the AST hierarchy by trying to hack up a mangled
name for the parent type using the child type's mangled name.
This was failing for enums because their tag type is represented
with two letters ("W4") instead of one letter ("T", "U", etc) as
it is with classes, structs, and unions.  After accounting for
this we can now correctly determine when an enum is nested
inside of a namespace or a class.

llvm-svn: 349565
2018-12-18 23:12:08 +00:00
Jason Molenda 4a793c846f Force libcompression calls to be enabled when building on Darwin
systems.  It has been available in the OS over over three years
now.  If lldb doesn't link against -lcompression, it should be an
error.

Allocate a scratch buffer for libcompression to use when decoding
packets, instead of it having to allocate & free one on every call.

Fix a typeo with the size of the buffer that compression_decode_buffer()
is expanding into.

<rdar://problem/41601084> 

llvm-svn: 349563
2018-12-18 23:02:50 +00:00
Pavel Labath 0d38e4fd2c ELF: Don't create sections for section header index 0
Summary:
The first section header does not define a real section. Instead it is
used for various elf extensions. This patch skips creation of a section
for index 0.

This has one furtunate side-effect, in that it allows us to use the section
header index as the Section ID (where 0 is also invalid). This way, we
can get rid of a lot of spurious +1s in the ObjectFileELF code.

Reviewers: clayborg, krytarowski, joerg, espindola

Subscribers: emaste, lldb-commits, arichardson

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

llvm-svn: 349498
2018-12-18 15:56:45 +00:00
Luke Cheeseman 307839cca9 Fix typo in r349473
llvm-svn: 349474
2018-12-18 11:05:43 +00:00
Luke Cheeseman 9f236d85d9 Update CallFrameString API to account for r349472
- CallFrameString now takes an Arch parameter to account for multiplexing
  overlapping CFI directives

llvm-svn: 349473
2018-12-18 10:39:19 +00:00
Jim Ingham 362d022d60 Call DeleteCurrentProcess before we replace the old process.
We need to ensure that Finalize gets called before we start
to destroy the old Process or the weak_ptr->shared_ptr link
from Threads to Target gets broken before the threads are 
destroyed.

<rdar://problem/43586979>

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

llvm-svn: 349435
2018-12-18 01:49:02 +00:00
Greg Clayton 48a28c1665 Add "dump" command as a custom "process plugin" subcommand when ProcessMinidump is used.
Each process plug-in can create its own custom commands. I figured it would be nice to be able to dump things from the minidump file from the lldb command line, so I added the start of the some custom commands.

Currently you can dump:

minidump stream directory
all linux specifc streams, most of which are strings
each linux stream individually if desired, or all with --linux
The idea is we can expand the command set to dump more things, search for data in the core file, and much more. This patch gets us started.

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

llvm-svn: 349429
2018-12-18 00:50:11 +00:00
Jason Molenda f47c734e49 A few small updates to the testsuite for running against an iOS device.
Remove the expected-fails for 34538611; using an alternate platform
implementation handles these correctly.

llvm-svn: 349417
2018-12-17 23:33:40 +00:00
Zachary Turner b6bc1c5ba3 Fix case of source file in CMakeLists.txt
llvm-svn: 349399
2018-12-17 21:33:08 +00:00
Zachary Turner 594c85e95f [NativePDB] Decouple AST reconstruction from lldb Symbol creation.
Previously the code that parsed debug info to create lldb's Symbol
objects such as Variable, Type, Function, etc was tightly coupled
to the AST reconstruction code.  This made it difficult / impossible
to implement functions such as ParseDeclsForContext() that were only
supposed to be operating on clang AST's.  By splitting these apart,
the logic becomes much cleaner and we have a clear separation of
responsibilities.

llvm-svn: 349383
2018-12-17 19:43:33 +00:00
Zachary Turner 1639c6bbb1 [Clang AST Context] Add a few helper functions.
The first one allows us to add an enumerator to an enum if we
already have an APSInt, since ultimately the implementation just
constructs one anyway.  The second is just a general utility
function to covert a CompilerType to a clang::TagDecl.

llvm-svn: 349360
2018-12-17 16:15:13 +00:00
Pavel Labath 62a8254f29 ELF: more section creation cleanup
Summary:
This patch attempts to move as much code as possible out of the
CreateSections function to make room for future improvements there. Some
of this may be slightly over-engineered (VMAddressProvider), but I
wanted to keep the logic of this function very simple, because once I
start taking segment headers into acount (as discussed in D55356), the
function is going to grow significantly.

While in there, I also added tests for various bits of functionality.

This should be NFC, except that I changed the order of hac^H^Heuristicks
for determining section type slightly. Previously, name-based deduction
(.symtab -> symtab) would take precedence over type-based (SHT_SYMTAB ->
symtab) one. In fact we would assert if we ran into a .text section with
type SHT_SYMTAB. Though unlikely to matter in practice, this order
seemed wrong to me, so I have inverted it.

Reviewers: clayborg, krytarowski, espindola

Subscribers: emaste, arichardson, lldb-commits

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

llvm-svn: 349268
2018-12-15 13:45:38 +00:00
Pavel Labath c8e364e80d Remove /proc/pid/maps parsing code from NativeProcessLinux
A utility function doing this was added in r349182, so use that instead.

llvm-svn: 349267
2018-12-15 13:38:16 +00:00
Jonas Devlieghere a6682a413d Simplify Boolean expressions
This patch simplifies boolean expressions acorss LLDB. It was generated
using clang-tidy with the following command:

run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD

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

llvm-svn: 349215
2018-12-15 00:15:33 +00:00
Greg Clayton 026e1bf56a Cache memory regions in ProcessMinidump and use the linux maps as the source of the information if available
Breakpad creates minidump files that sometimes have:
- linux maps textual content
- no MemoryInfoList

Right now unless the file has a MemoryInfoList we get no region information.

This patch:

- reads and caches the memory region info one time and sorts it for easy subsequent access
- get the region info from the best source in this order:
  - linux maps info (if available)
  - MemoryInfoList (if available)
  - MemoryList or Memory64List
- returns memory region info for the gaps between regions (before the first and after the last)

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

llvm-svn: 349182
2018-12-14 19:36:01 +00:00
Pavel Labath 181b823b04 Move Broadcaster+Listener+Event combo from Core into Utility
Summary:
These are general purpose "utility" classes, whose functionality is not
debugger-specific in any way. As such, I believe they belong in the
Utility module.

This doesn't break any particular dependency (yet), but it reduces the
number of Core dependencies across the board.

Reviewers: zturner, jingham, teemperor, clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 349157
2018-12-14 15:59:49 +00:00
Richard Trieu f03e8023b7 Remove unused variable.
llvm-svn: 349128
2018-12-14 05:40:30 +00:00
Zachary Turner d3d2b9b891 [NativePDB] Add support for local variables.
This patch adds support for parsing and evaluating local variables.
using the native pdb plugin.

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

llvm-svn: 349067
2018-12-13 18:17:51 +00:00
Greg Clayton e55979b1e2 Fix MinidumpParser::GetFilteredModuleList() and test it
The MinidumpParser::GetFilteredModuleList() code was attempting to iterate through the entire module list and if it found more than one entry for a given module name, it wanted to pick the MinidumpModule with the lowest address. A bug existed where it wasn't doing that due to "exists" variable being inverted. "exists" was set to true if it was inserted, not if it existed. Furthermore, the order of the modules would be modified by sorting all modules from low address to high address (using MinidumpModule::base_of_image). This fix also maintains the original order which means your executable is at index 0 as intended instead of some random shared library.

Tests were added to ensure this functionality doesn't regress.

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

llvm-svn: 349062
2018-12-13 17:24:30 +00:00
Tatyana Krasnukha 98fc54870a Add missing Initialize/Terminate for Architecture plugins
llvm-svn: 349036
2018-12-13 14:28:25 +00:00
Mikael Nilsson 8b3bf6c173 Fix for clang interface update
FunctionProtoType.TypeQuals is now a Qualifiers object instead of an
integer.

The related clang commit: r349019

llvm-svn: 349020
2018-12-13 10:17:26 +00:00
Jonas Devlieghere 65e5e2781f [NFC] Small code cleanups in utility.
Fix a few small annoyances in Utility I ran into.

llvm-svn: 348996
2018-12-13 00:15:17 +00:00
Greg Clayton 71970b722b NFC: fix compiler warning about code never being executed when compiling on non windows platform.
llvm-svn: 348951
2018-12-12 18:14:27 +00:00
Zachary Turner 6753d2d180 [ast] CreateParameterDeclaration should use an appropriate DeclContext.
Previously CreateParameterDeclaration was always using the translation
unit DeclContext.  We would later go and add parameters to the
FunctionDecl, but internally clang makes a copy when you do this, and
we'd end up with ParmVarDecl's at the global scope as well as in the
function scope.

This fixes the issue.  It's hard to say whether this will introduce
a behavioral change in name lookup, but I know there have been several
hacks introduced in previous years to deal with collisions between
various types of variables, so there's a chance that this patch could
obviate one of those hacks.

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

llvm-svn: 348941
2018-12-12 17:17:53 +00:00
Pavel Labath ef8683abec ELF: Clean up section type computation
Move code into a separate function, and replace the if-else chain with
llvm::StringSwitch.

A slight behavioral change is that now I use the section flags
(SHF_TLS) instead of the section name to set the thread-specific
property. There is no explanation in the original commit introducing
this (r153537) as to why that was done this way, but the new behavior
should be more correct.

llvm-svn: 348936
2018-12-12 15:46:18 +00:00
Pavel Labath 5ea7ecdb5e ELF: Simplify program header iteration
Instead of GetProgramHeaderCount+GetProgramHeaderByIndex, expose an
ArrayRef of all program headers, to enable range-based iteration.
Instead of GetSegmentDataByIndex, expose GetSegmentData, taking a
program header (reference).

This makes the code simpler by enabling range-based loops and also
allowed to remove some null checks, as it became locally obvious that
some pointers can never be null.

llvm-svn: 348928
2018-12-12 14:20:28 +00:00
Pavel Labath d1e3fe2190 Rename ObjectFile::GetHeaderAddress to GetBaseAddress
Summary:
This function was named such because in the case of MachO files, the
mach header is located at this address. However all (most?) usages of
this function were not interested in that fact, but the fact that this
address is used as the base address for expressing various relative
addresses in the object file.

For other object file formats, this name is not appropriate (and it's
probably the reason why this function was not implemented in these
classes). In the ELF case the ELF header will usually end up at this
address, but this is a result of the linker optimizing the file layout
and not a requirement of the spec. For COFF files, I believe the is no
header located at this address either.

Reviewers: clayborg, jasonmolenda, amccarth, lemo, stella.stamenova

Subscribers: lldb-commits

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

llvm-svn: 348849
2018-12-11 15:21:15 +00:00
Zachary Turner 9d76e42014 Fix undefined behavior in Variable.h
m_loc_is_constant_data was uninitialized, so unless someone
explicitly called SetLocIsConstantData(), this would be UB.

I think every existing call-site would always call the proper
function to initialize the value, so there were no existing
bugs, but I encountered this when I tried to use it without
calling this function and encountered this.

llvm-svn: 348813
2018-12-11 00:15:03 +00:00
Shafik Yaghmour 99bc2b2132 [DataFormatters] Fixes to libc++ std::function formatter to deal with ABI change see
https://reviews.llvm.org/D55045

llvm-svn: 348810
2018-12-10 23:26:38 +00:00
Frederic Riss ff5f5087e6 Reflow a multi-line string and add a newline
llvm-svn: 348805
2018-12-10 22:30:19 +00:00
Pavel Labath 871f2b65c1 Fix r348773
It's not sufficient to implement the CreateMemoryInstance function, one
has to use it too.

llvm-svn: 348780
2018-12-10 18:17:53 +00:00
Jonas Devlieghere 046c390356 [Host] Use FileSystem wrapper
Fixes Host.mm to use the FileSystem class instead of making native calls
to check if a file exists.

llvm-svn: 348779
2018-12-10 18:17:39 +00:00
Stella Stamenova b3f44ad9c2 Do not use PATH_MAX with SmallString
Summary: Instead use a more reasonable value to start and rely on the fact that SmallString will resize if necessary.

Reviewers: labath, asmith

Reviewed By: labath

Subscribers: lldb-commits

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

llvm-svn: 348775
2018-12-10 17:23:28 +00:00
Pavel Labath 1f6b247717 Re-commit "Introduce ObjectFileBreakpad"
This re-commits r348592, which was reverted due to a failing test on
macos.

The issue was that I was passing a null pointer for the
"CreateMemoryInstance" callback when registering ObjectFileBreakpad,
which caused crashes when attemping to load modules from memory. The
correct thing to do is to pass a callback which always returns a null
pointer (as breakpad files are never loaded in inferior memory).

It turns out that there is only one test which exercises this code path,
and it's mac-only, so I've create a new test which should run everywhere
(except windows, as one cannot delete an executable which is being run).
Unfortunately, this test still fails on linux for other reasons, but at
least it gives us something to aim for.

The original commit message was:
This patch adds the scaffolding necessary for lldb to recognise symbol
files generated by breakpad. These (textual) files contain just enough
information to be able to produce a backtrace from a crash
dump. This information includes:
- UUID, architecture and name of the module
- line tables
- list of symbols
- unwind information

A minimal breakpad file could look like this:
MODULE Linux x86_64 0000000024B5D199F0F766FFFFFF5DC30 a.out
INFO CODE_ID 00000000B52499D1F0F766FFFFFF5DC3
FILE 0 /tmp/a.c
FUNC 1010 10 0 _start
1010 4 4 0
1014 5 5 0
1019 5 6 0
101e 2 7 0
PUBLIC 1010 0 _start
STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
STACK CFI 1014 .cfa: $rbp 16 +

Even though this data would normally be considered "symbol" information,
in the current lldb infrastructure it is assumed every SymbolFile object
is backed by an ObjectFile instance. So, in order to better interoperate
with the rest of the code (particularly symbol vendors).

In this patch I just parse the breakpad header, which is enough to
populate the UUID and architecture fields of the ObjectFile interface.
The rough plan for followup patches is to expose the individual parts of
the breakpad file as ObjectFile "sections", which can then be used by
other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
information.

Reviewers: clayborg, zturner, lemo, amccarth

Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits

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

llvm-svn: 348773
2018-12-10 17:16:38 +00:00
Frederic Riss 60b88127c5 Revert a hunk that shouldn't have been included in the last commit.
I've seen this line trigger UB, but that's obviously not the correct fix...

llvm-svn: 348711
2018-12-09 02:38:04 +00:00
Frederic Riss f5debe2259 Remove some UB in RegisterContextDarwin_arm64.cpp
llvm-svn: 348710
2018-12-09 02:35:19 +00:00
Zachary Turner a42bbe3981 [NativePDB] Reconstruct function declarations from debug info.
Previously we would create an lldb::Function object for each function
parsed, but we would not add these to the clang AST. This is a first
step towards getting local variable support working, as we first need an
AST decl so that when we create local variable entries, they have the
proper DeclContext.

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

llvm-svn: 348631
2018-12-07 19:34:02 +00:00
Shafik Yaghmour 48c7b4f0b6 Revert "Introduce ObjectFileBreakpad"
This reverts commit 5e056e624cc57bb22a4c29a70b522783c6242293.

Reverting because this lldb cmake bot: http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/13712/

llvm-svn: 348629
2018-12-07 18:59:00 +00:00
Pavel Labath d6e6e232ec Introduce ObjectFileBreakpad
Summary:
This patch adds the scaffolding necessary for lldb to recognise symbol
files generated by breakpad. These (textual) files contain just enough
information to be able to produce a backtrace from a crash
dump. This information includes:
- UUID, architecture and name of the module
- line tables
- list of symbols
- unwind information

A minimal breakpad file could look like this:
MODULE Linux x86_64 0000000024B5D199F0F766FFFFFF5DC30 a.out
INFO CODE_ID 00000000B52499D1F0F766FFFFFF5DC3
FILE 0 /tmp/a.c
FUNC 1010 10 0 _start
1010 4 4 0
1014 5 5 0
1019 5 6 0
101e 2 7 0
PUBLIC 1010 0 _start
STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
STACK CFI 1014 .cfa: $rbp 16 +

Even though this data would normally be considered "symbol" information,
in the current lldb infrastructure it is assumed every SymbolFile object
is backed by an ObjectFile instance. So, in order to better interoperate
with the rest of the code (particularly symbol vendors).

In this patch I just parse the breakpad header, which is enough to
populate the UUID and architecture fields of the ObjectFile interface.
The rough plan for followup patches is to expose the individual parts of
the breakpad file as ObjectFile "sections", which can then be used by
other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
information.

Reviewers: clayborg, zturner, lemo, amccarth

Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits

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

llvm-svn: 348592
2018-12-07 14:20:27 +00:00
Jim Ingham 29ae65946a Handle detecting exec for DynamicLoaderMacOS with older debugservers
that don't send reason:exec.

<rdar://problem/43756823>

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

llvm-svn: 348559
2018-12-07 01:18:40 +00:00
Jason Molenda eb9902ad7e Change the amount of data that Platform::PutFile will try to transfer
in one packet from 1k bytes to 16k bytes.  Sending a large file to an
iOS device directly connected by USB cable, to lldb-server running in
platform mode, this speeds up the file xfer by 77%.  Sending the file
in 32k blocks speeds up the file xfer by 80% versus 1k blocks, starting
with 16k to make sure we don't have any problems with android testing.

We may not have the same perf characteristics over ethernet, but with
USB it's faster to send fewer larger packets than many small packets.

llvm-svn: 348557
2018-12-07 00:35:26 +00:00
Stella Stamenova d408819aaf [pecoff] Use PATH_MAX instead of MAX_PATH
PATH_MAX is defined on all platforms while MAX_PATH is Windows-specific

llvm-svn: 348542
2018-12-06 23:22:46 +00:00
Aaron Smith 037ed1befd [pecoff] Implement ObjectFilePECOFF::GetDependedModules()
Summary:
This parses entries in pecoff import tables for imported DLLs and
is intended as the first step to allow LLDB to load a PE's shared
modules when creating a target on the LLDB console. 


Reviewers: rnk, zturner, aleksandr.urakov, lldb-commits, labath, asmith

Reviewed By: labath, asmith

Subscribers: labath, lemo, clayborg, Hui, mgorny, mgrang, teemperor

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

llvm-svn: 348527
2018-12-06 21:36:39 +00:00
Nathan Lanza 488214fe84 Implement WindowsDYLD::DidAttach for use with gdb-server attach
Summary:
Windows lldb debugging currently uses a process plugin to handle
launching and attaching to a process. Launching a process via a debug
server (e.g. ds2) and attaching to it with `gdb-remote port` currently
doesn't communicate address information of the executable properly.

Implement DynamicLoaderWindowsDYLD::DidAttach which allow us to
obtain the proper executable load address.

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

llvm-svn: 348526
2018-12-06 21:13:03 +00:00
Zachary Turner a93458b050 [PDB] Move some code around. NFC.
llvm-svn: 348505
2018-12-06 17:49:15 +00:00
Zachary Turner 579264bd59 Support skewed stream arrays.
VarStreamArray was built on the assumption that it is backed by a
StreamRef, and offset 0 of that StreamRef is the first byte of the first
record in the array.

This is a logical and intuitive assumption, but unfortunately we have
use cases where it doesn't hold. Specifically, a PDB module's symbol
stream is prefixed by 4 bytes containing a magic value, and the first
byte of record data in the array is actually at offset 4 of this byte
sequence.

Previously, we would just truncate the first 4 bytes and then construct
the VarStreamArray with the resulting StreamRef, so that offset 0 of the
underlying stream did correspond to the first byte of the first record,
but this is problematic, because symbol records reference other symbol
records by the absolute offset including that initial magic 4 bytes. So
if another record wants to refer to the first record in the array, it
would say "the record at offset 4".

This led to extremely confusing hacks and semantics in loading code, and
after spending 30 minutes trying to get some math right and failing, I
decided to fix this in the underlying implementation of VarStreamArray.
Now, we can say that a stream is skewed by a particular amount. This
way, when we access a record by absolute offset, we can use the same
values that the records themselves contain, instead of having to do
fixups.

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

llvm-svn: 348499
2018-12-06 16:55:00 +00:00
Adrian Prantl 7b8a03751c Add a unit test for ArchSpec matching to document how it behaves (and test it).
llvm-svn: 348440
2018-12-06 00:43:55 +00:00
Saleem Abdulrasool 92e5273c73 gdb-remote: use elaborated type specifier for `Module`
When building with MSVC, the type `Module` is ambiguous due to both the
lldb_private and llvm namespaces being used.  Use the elaborated type
instead to resolve the ambiguity.

llvm-svn: 348332
2018-12-05 04:04:14 +00:00
Jonas Devlieghere c2820bf23e [Reproducers] Only creaate the bottom-most dir
As Pavel noted on the mailing list we should only create the bottom-most
directory if it doesn't exist. This should also fix the test case on
Windows as we can use lit's temp directory.

llvm-svn: 348289
2018-12-04 18:16:49 +00:00
Jonas Devlieghere edaf2bcc77 [FileSystem] Migrate CommandCompletions
Make use of the convenience helpers from FileSystem.

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

llvm-svn: 348287
2018-12-04 17:58:21 +00:00
Aleksandr Urakov f335188925 [Expr] Check the language before ignoring Objective C keywords
Summary:
This patch adds the check of the language before ignoring names like `id` or
`Class`, which are reserved in Objective C, but are allowed in C++. It is needed
to make it possible to evaluate expressions in a C++ program containing names
like `id` or `Class`.

Reviewers: jingham, zturner, labath, clayborg

Reviewed By: jingham, clayborg

Tags: #lldb

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

llvm-svn: 348240
2018-12-04 09:51:29 +00:00
Jonas Devlieghere 55840d10f5 [PlatformDarwin] Simplify logic and use FileSystem
Simplify code path by using the FileSystem.

llvm-svn: 348232
2018-12-04 02:23:16 +00:00
Jonas Devlieghere 0bbe9a7a98 [FileSystem] Migrate MonitoringProcessLauncher
Use the FileSystem helpers instead of using the file system directly.

llvm-svn: 348207
2018-12-03 22:41:32 +00:00
Jonas Devlieghere 15eacd741f [Reproducers] Change how reproducers are initialized.
This patch changes the way the reproducer is initialized. Rather than
making changes at run time we now do everything at initialization time.
To make this happen we had to introduce initializer options and their SB
variant. This allows us to tell the initializer that we're running in
reproducer capture/replay mode.

Because of this change we also had to alter our testing strategy. We
cannot reinitialize LLDB when using the dotest infrastructure. Instead
we use lit and invoke two instances of the driver.

Another consequence is that we can no longer enable capture or replay
through commands. This was bound to go away form the beginning, but I
had something in mind where you could enable/disable specific providers.
However this seems like it adds very little value right now so the
corresponding commands were removed.

Finally this change also means you now have to control this through the
driver, for which I replaced --reproducer with --capture and --replay to
differentiate between the two modes.

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

llvm-svn: 348152
2018-12-03 17:28:29 +00:00
Aleksandr Urakov a5235af980 [PDB] Support PDB-backed expressions evaluation (+ fix stuck test)
Summary:
This patch contains several small fixes, which makes it possible to evaluate
expressions on Windows using information from PDB. The changes are:
- several sanitize checks;
- make IRExecutionUnit::MemoryManager::getSymbolAddress to not return a magic
  value on a failure, because callers wait 0 in this case;
- entry point required to be a file address, not RVA, in the ObjectFilePECOFF;
- do not crash on a debuggee second chance exception - it may be an expression
  evaluation crash. Also fix detection of "crushed" threads in tests;
- create parameter declarations for functions in AST to make it possible to call
  debugee functions from expressions;
- relax name searching rules for variables, functions, namespaces and types. Now
  it works just like in the DWARF plugin;
- fix endless recursion in SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc.

Reviewers: zturner, asmith, stella.stamenova

Reviewed By: stella.stamenova, asmith

Tags: #lldb

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

llvm-svn: 348136
2018-12-03 13:31:13 +00:00
Stella Stamenova 975814a7c7 [windows] Fix two minor bugs on Windows
1. In ProcessWindows if we fail to allocate memory, we need to return LLDB_INVALID_ADDRESS rather than 0 or nullptr as that is the invalid address that LLDB looks for
2. In RegisterContextWindows in ReadAllRegisterValues, always create a new buffer. This is what the other platforms do and data_sp is always null in all tested scenarios on Windows as well

llvm-svn: 348055
2018-12-01 00:18:19 +00:00
Stella Stamenova 9a3686b208 Revert "[PDB] Support PDB-backed expressions evaluation"
This reverts commit dec87759523b2f22fcff3325bc2cd543e4cda0e7.

This commit caused the tests on Windows to run forever rather than complete.
Reverting until the commit can be fixed to not stall.

llvm-svn: 348009
2018-11-30 17:29:54 +00:00
Aleksandr Urakov 9b087d2ce6 [Target] Do not skip a stop on a breakpoint if a plan was completed
Summary:
This patch fixes the next situation. On Windows clang-cl makes no stub before
the main function, so the main function is located exactly on module entry
point. May be it is the same on other platforms. So consider the following
sequence:

- set a breakpoint on main and stop there;
- try to evaluate expression, which requires a code execution on the debuggee
  side. Such an execution always returns to the module entry, and the plan waits
  for it there;
- the plan understands that it is complete now and removes its breakpoint. But
  the breakpoint site is still there, because we also have a breakpoint on
  entry;
- StopInfo analyzes a situation. It sees that we have stopped on the breakpoint
  site, and it sees that the breakpoint site has owners, and no one logical
  breakpoint is internal (because the plan is already completed and it have
  removed its breakpoint);
- StopInfo thinks that it's a user breakpoint and skips it to avoid recursive
  computations;
- the program continues.

So in this situation the program continues without a stop right after
the expression evaluation. To avoid this an additional check that
the plan was completed was added.

Reviewers: jingham, zturner, boris.ulasevich

Reviewed by: jingham

Tags: #lldb

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

llvm-svn: 347974
2018-11-30 09:45:52 +00:00
Aleksandr Urakov e0366d1db5 [PDB] Support PDB-backed expressions evaluation
Summary:
This patch contains several small fixes, which makes it possible to evaluate
expressions on Windows using information from PDB. The changes are:
- several sanitize checks;
- make IRExecutionUnit::MemoryManager::getSymbolAddress to not return a magic
  value on a failure, because callers wait 0 in this case;
- entry point required to be a file address, not RVA, in the ObjectFilePECOFF;
- do not crash on a debuggee second chance exception - it may be an expression
  evaluation crash;
- create parameter declarations for functions in AST to make it possible to call
  debugee functions from expressions;
- relax name searching rules for variables, functions, namespaces and types. Now
  it works just like in the DWARF plugin;
- fix endless recursion in SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc.

Reviewers: zturner, asmith, stella.stamenova

Reviewed By: stella.stamenova, asmith

Tags: #lldb

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

llvm-svn: 347962
2018-11-30 07:12:22 +00:00
Aleksandr Urakov 8cfb12b9bd [Symbol] Search symbols with name and type in a symbol file
Summary:
This patch adds possibility of searching a public symbol with name and type in
a symbol file, not only in a symtab. It is helpful when working with PE, because
PE's symtabs contain only imported / exported symbols only. Such a search is
required for e.g. evaluation of an expression that calls some function of
the debuggee.

Reviewers: zturner, asmith, labath, clayborg, espindola

Reviewed By: clayborg

Subscribers: davide, emaste, arichardson, aleksandr.urakov, jingham,
             lldb-commits, stella.stamenova

Tags: #lldb

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

llvm-svn: 347960
2018-11-30 06:56:37 +00:00
George Rimar c1d3f71344 [LLDB] - Improve the support of .debug_str_offsets/.debug_str_offsets.dwo
A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
that points to the first string offset of the CU contribution to the
.debug_str_offsets. At the same time, when we use split dwarf,
the corresponding split debug unit also
may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo.
In that case, DWO does not contain DW_AT_str_offsets_base, but LLDB
still need to know and skip the .debug_str_offsets.dwo section header to
access the offsets.

The patch implements the support of DW_AT_str_offsets_base.

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

llvm-svn: 347859
2018-11-29 12:44:10 +00:00
George Rimar 4e520107c1 [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.
The issue happens because starting from DWARF v5
DW_AT_addr_base attribute should be used
instead of DW_AT_GNU_addr_base. LLDB does not do that and
we end up reading the .debug_addr header as section content
(as addresses) instead of skipping it and reading the real addresses.
Then LLDB is unable to match 2 similar locations and
thinks they are different.

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

llvm-svn: 347842
2018-11-29 08:16:07 +00:00
Kuba Mracek e60bc53b46 [lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes
This adds new APIs and a command to deal with exceptions (mostly Obj-C exceptions): SBThread and Thread get GetCurrentException API, which returns an SBValue/ValueObjectSP with the current exception for a thread. "Current" means an exception that is currently being thrown, caught or otherwise processed. In this patch, we only know about the exception when in objc_exception_throw, but subsequent patches will expand this (and add GetCurrentExceptionBacktrace, which will return an SBThread/ThreadSP containing a historical thread backtrace retrieved from the exception object. Currently unimplemented, subsequent patches will implement this).

Extracting the exception from objc_exception_throw is implemented by adding a frame recognizer.

This also add a new sub-command "thread exception", which prints the current exception.

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

llvm-svn: 347813
2018-11-28 22:01:52 +00:00
Hans Wennborg 30ce962732 Revert r347673 "Catch up with EvaluateAsInt() clang API change."
r347417 was re-committed in Clang.

llvm-svn: 347758
2018-11-28 14:30:18 +00:00
Alex Langford 73b2c8faeb Remove dead code from IOHandler
This has been dead since 2014 according to the blame

llvm-svn: 347721
2018-11-27 23:37:47 +00:00
Jonas Devlieghere 68ed93d252 [Reproducers] Improve reproducer API and add unit tests.
When I landed the initial reproducer framework I knew there were some
things that needed improvement. Rather than bundling it with a patch
that adds more functionality I split it off into this patch. I also
think the API is stable enough to add unit testing, which is included in
this patch as well.

Other improvements include:

 - Refactor how we initialize the loader and generator.
 - Improve naming consistency: capture and replay seems the least ambiguous.
 - Index providers by name and make sure there's only one of each.
 - Add convenience methods for creating and accessing providers.

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

llvm-svn: 347716
2018-11-27 22:11:02 +00:00
Tatyana Krasnukha 3f166e48d1 [CMake] Pass full libedit path to linker
Otherwise, linker fails with "cannot find -ledit" in case of custom libedit installation.

llvm-svn: 347693
2018-11-27 19:41:30 +00:00
Davide Italiano 6b2f3e07c6 Catch up with EvaluateAsInt() clang API change.
llvm-svn: 347673
2018-11-27 16:40:21 +00:00
Jonas Devlieghere 010b56be0d Move time cast to SymbolFileDWARFDebugMap
When trying to fix the bots we expected that the cast would be needed in
different places. Ultimately it turned out only the
SymbolFileDWARFDebugMap was affected so, as Pavel correctly notes, it
makes more sense to do the cast just there instead of in teh FS.

llvm-svn: 347660
2018-11-27 15:25:58 +00:00
Bruce Mitchener b8233f8c06 Add support for the Dylan language to ClangASTContext
Summary:
This change adds eLanguageTypeDylan to the set of languages supported
by ClangASTContext. Debug info generated by the Open Dylan compiler's
LLVM back-end was designed to be compatible with C debug info.

Patch by Peter Housel.

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: brucem, lldb-commits, aprantl

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

llvm-svn: 347637
2018-11-27 05:37:27 +00:00
Jonas Devlieghere 2765b067d2 [FileSystem] Ignore nanoseconds when comparing oso_mod_time
After a recent change in LLVM the TimePoint encoding become more
precise, exceeding the precision of the TimePoint obtained from the
DebugMap. This patch adds a flag to the GetModificationTime helper in
the FileSystem to return the modification time with less precision.

Thanks to Davide for bisecting this failure on the LLDB bots.

llvm-svn: 347615
2018-11-26 23:40:52 +00:00
Gabor Marton b795ed9381 [ASTImporter] Set MustBuildLookupTable on PrimaryContext
Summary: SetMustBuildLookupTable() must always be called on a primary context.

Reviewers: labath, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411

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

llvm-svn: 347575
2018-11-26 17:09:50 +00:00
Luke Cheeseman 2ed41a7952 Revert r347491 as it's llvm counterpart breaks buildbots
llvm-svn: 347500
2018-11-23 17:13:47 +00:00
Luke Cheeseman 2d1e9a6f6b Revert r343342 together with LLVM commit 347490.
llvm-svn: 347491
2018-11-23 11:03:00 +00:00
Bill Wendling d7656dec98 Update call to EvaluateAsInt() to the new syntax.
llvm-svn: 347418
2018-11-21 20:44:38 +00:00
Nico Weber 1742ba5a2d Revert 347365, its prerequisite 347364 got reverted.
llvm-svn: 347391
2018-11-21 12:50:13 +00:00
Bill Wendling 8c8bdbe441 Update call to EvaluateAsInt() to the new syntax.
llvm-svn: 347365
2018-11-20 23:24:18 +00:00
Benjamin Kramer 2775b5caae Remove unused variable. NFC.
llvm-svn: 347188
2018-11-19 10:59:12 +00:00
Zachary Turner f8610fc4e7 Revert "Implement basic DidAttach and DidLaunch for DynamicLoaderWindowsDYLD"
This breaks many tests on Windows, which now all fail with an error such
as "Unable to read memory at address <xxxxxxxx>".

llvm-svn: 347174
2018-11-18 20:48:25 +00:00
Davide Italiano 9413be9423 [Cocoa] Prefer llvm::SignExtend64. Pointed out by zturner.
llvm-svn: 347087
2018-11-16 19:53:00 +00:00
Davide Italiano 9974417203 [SymbolFile] Remove unused function. NFCI.
llvm-svn: 347084
2018-11-16 19:48:23 +00:00
Henry Wong 831be096c7 [lldb] NFC: Remove the extra ';'
Summary:
Remove extra `;` to eliminate the following pedantic warning.

```
warning: extra ';' [-Wpedantic]

```

Reviewers: shafik

Reviewed By: shafik

Subscribers: abidh, lldb-commits

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

llvm-svn: 347047
2018-11-16 13:01:57 +00:00
Zachary Turner 9fbf93508c Don't use uniform initialization syntax.
llvm-svn: 347020
2018-11-16 03:16:27 +00:00
Zachary Turner 6284aee9f8 [NativePDB] Rewrite the PdbSymUid to use our own custom namespacing scheme.
Originally we created our 64-bit UID scheme by using the first byte as
sort of a "tag" to represent what kind of symbol this was, and we
re-used the PDB_SymType enumeration for this.  For native pdb support,
this is not really the right abstraction layer, because what we really
want is something that tells us *how* to find the symbol.  This means,
specifically, is in the globals stream / public stream / module stream /
TPI stream / etc, and for whichever one it is in, where is it within
that stream?

A good example of why the old namespacing scheme was insufficient is
that it is more or less impossible to create a uid for a field list
member of a class/struction/union/enum that tells you how to locate
the original record.

With this new scheme, the first byte is no longer a PDB_SymType enum
but a new enum created specifically to identify where in the PDB
this record lives.  This gives us much better flexibility in
what kinds of symbols the uids can identify.

llvm-svn: 347018
2018-11-16 02:42:32 +00:00
Nathan Lanza 04f9d0a0c3 Implement basic DidAttach and DidLaunch for DynamicLoaderWindowsDYLD
Summary:
This commit implements basic DidAttach and DidLaunch for the windows
DynamicLoader plugin which allow us to load shared libraries from the
inferior.

Reviewers: sas, zturner

Reviewed By: zturner

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

llvm-svn: 346994
2018-11-15 20:58:09 +00:00
Zachary Turner 95997f6110 Fix a use-after-free of the ABI plugin.
This was introduced in r346775.  Previously the ABI shared_ptr
was declared as a function local static meaning it would live
forever.  After the change, someone has to create a strong
reference to it or it will go away.  In this code, we were
calling ABI::FindPlugin(...).get(), so it was being immediately
destroyed and we were holding onto a dangling pointer.

llvm-svn: 346932
2018-11-15 05:06:59 +00:00
Jonas Devlieghere acaffc5c97 Fix copy/paste mistake for r346919.
llvm-svn: 346921
2018-11-15 01:18:16 +00:00
Jonas Devlieghere e103ae92ef Add setting to require hardware breakpoints.
When debugging read-only memory we cannot use software breakpoint. We
already have support for hardware breakpoints and users can specify them
with `-H`. However, there's no option to force LLDB to use hardware
breakpoints internally, for example while stepping.

This patch adds a setting target.require-hardware-breakpoint that forces
LLDB to always use hardware breakpoints. Because hardware breakpoints
are a limited resource and can fail to resolve, this patch also extends
error handling in thread plans, where breakpoints are used for stepping.

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

llvm-svn: 346920
2018-11-15 01:18:15 +00:00
Jonas Devlieghere df14b94243 [reproducer] Post-commit cleanup
After committing the initial reproducer feature I noticed a few small
issues which warranted addressing here. It fixes incorrect documentation
in the command object and extract some duplicated code into the debugger
object.

llvm-svn: 346919
2018-11-15 01:05:40 +00:00
Zachary Turner fca18e94e1 Fix some compilation failures introduced in recent patches.
This fixes two compilation failures:

  1) Designated initializers are C++20.  We can't use them in LLVM.
  2) thread_result_t is not a pointer type on all platforms, so
     returning nullptr is an error.

llvm-svn: 346873
2018-11-14 17:22:09 +00:00
George Rimar 004bcb78ed [LLDB] - Recommit r346848 "[LLDB] - Support the single file split DWARF.".
Test cases were updated to not use the local compilation dir which
is different between development pc and build bots.

Original commit message:

[LLDB] - Support the single file split DWARF.

DWARF5 spec describes a single file split dwarf case
(when .dwo sections are in the .o files).

Problem is that LLDB does not work correctly in that case.
The issue is that, for example, both .debug_info and .debug_info.dwo
has the same type: eSectionTypeDWARFDebugInfo. And when code searches
section by type it might find the regular debug section
and not the .dwo one.

The patch fixes that. With it, LLDB is able to work with
output compiled with -gsplit-dwarf=single flag correctly.

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

llvm-svn: 346855
2018-11-14 13:01:15 +00:00
George Rimar 7cdb22b1ef Revert r346848 "[LLDB] - Support the single file split DWARF."
It broke BB:
http://green.lab.llvm.org/green/job/lldb-cmake/12522/testReport/junit/LLDB/Breakpoint/single_file_split_dwarf_test/

llvm-svn: 346853
2018-11-14 12:04:31 +00:00
Pavel Labath 18e9864501 Fix a crash when parsing incorrect DWARF
Summary:
While parsing a childless compile unit DIE we could crash if the DIE was
followed by any extra data (such as a superfluous end-of-children
marker). This happened because the break-on-depth=0 check was performed
only when parsing the null DIE, which was not correct because with a
childless root DIE, we could reach the end of the unit without ever
encountering the null DIE.

If the compile unit contribution ended directly after the CU DIE,
everything would be fine as we would terminate parsing due to reaching
EOF. However, if the contribution contained extra data (perhaps a
superfluous end-of-children marker), we would crash because we would
treat that data as the begging of another compile unit.

This fixes the crash by moving the depth=0 check to a more generic
place, and also adds a regression test.

Reviewers: clayborg, jankratochvil, JDevlieghere

Subscribers: lldb-commits

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

llvm-svn: 346849
2018-11-14 11:12:40 +00:00
George Rimar 98963db57d [LLDB] - Support the single file split DWARF.
DWARF5 spec describes a single file split dwarf case
(when .dwo sections are in the .o files).

Problem is that LLDB does not work correctly in that case.
The issue is that, for example, both .debug_info and .debug_info.dwo
has the same type: eSectionTypeDWARFDebugInfo. And when code searches
section by type it might find the regular debug section
and not the .dwo one.

The patch fixes that. With it, LLDB is able to work with
output compiled with -gsplit-dwarf=single flag correctly.

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

llvm-svn: 346848
2018-11-14 10:35:14 +00:00
Haojian Wu 59fa37da87 Suppress a "-Wliteral-conversion" compiler warning.
error: implicit conversion from 'double' to 'uint64_t' (aka 'unsigned long') changes value from -0 to 0 [-Werror,-Wliteral-conversion]
llvm-svn: 346841
2018-11-14 09:53:45 +00:00
Haojian Wu 01b098840f Fix the "make_unique is ambiguous" compiler error.
llvm-svn: 346839
2018-11-14 09:42:28 +00:00
Adrian Prantl 874e32dcf2 Fix a bug in the parsing of the LC_BUILD_VERSION Mach-O load command.
LC_BUILD_VERSION records are of variable length. The original code
would use uninitialized memory when the size of a record was exactly 24.

rdar://problem/46032185

llvm-svn: 346812
2018-11-13 23:14:37 +00:00
Zachary Turner 2af3416618 [NativePDB] Add support for S_CONSTANT records.
clang-cl does not emit these, but MSVC does, so we need to be able to
handle them.

Because clang-cl does not generate them, it was a bit hard to write a
test. So what I had to do was get an PDB file with some S_CONSTANT
records in using cl and link, dump it using llvm-pdbutil dump -globals
-sym-data to get the bytes of the records, generate the same object file
using clang-cl but with -S to emit an assembly file, and replace all the
S_LDATA32 records with the bytes of the S_CONSTANT records. This way, we
can compile the file using llvm-mc and link it with lld-link.

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

llvm-svn: 346787
2018-11-13 20:07:57 +00:00
Zachary Turner 03a24052f3 [NativePDB] Improved support for nested type reconstruction.
In a previous patch, we pre-processed the TPI stream in order to build
the reverse mapping from nested type -> parent type so that we could
accurately reconstruct a DeclContext hierarchy.

However, there were some issues. An LF_NESTTYPE record is really just a
typedef, so although it happens to be used to indicate the name of the
nested type and referring to the global record which defines the type,
it is also used for every other kind of nested typedef. When we rebuild
the DeclContext hierarchy, we want it to be as accurate as possible,
which means that if we have something like:

  struct A {
    struct B {};
    using C = B;
  };

We don't want to create two CXXRecordDecls in the AST each with the
exact same definition. We just want to create one for B and then
define C as an alias to B. Previously, however, it would not be able
to distinguish between the two cases and it would treat A::B and
A::C as being two classes each with separate definitions. We address
the first half of improving the pre-processing logic so that only
actual definitions are treated this way.

Later, in a followup patch, we can handle the case of nested
typedefs since we're already going to be enumerating the field list
anyway and this patch introduces the general framework for
distinguishing between the two cases.

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

llvm-svn: 346786
2018-11-13 20:07:32 +00:00
Davide Italiano cdcfa5d07f [Cocoa] Implement formatter for the new NSDate representation.
<rdar://problem/46002786>

llvm-svn: 346783
2018-11-13 19:43:43 +00:00
Jonas Devlieghere 9e046f02e3 Add GDB remote packet reproducer.
llvm-svn: 346780
2018-11-13 19:18:16 +00:00
Jim Ingham 7716ddf18d Since ABI's now hold a process WP, they should be handed
out one per process rather than keeping a single global instance.

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

llvm-svn: 346775
2018-11-13 18:18:32 +00:00
Kuba Mracek 377912845e [lldb] Add synthetic frontend for _NSCallStackArray
An Obj-C array type _NSCallStackArray is used in NSException backtraces. This patch adds a synthetic frontend for _NSCallStackArray, which now correctly returns frame PCs.

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

llvm-svn: 346708
2018-11-12 21:26:03 +00:00
Jonas Devlieghere 87e403aa4f Re-land "Extract construction of DataBufferLLVM into FileSystem"
This fixes some UB in isLocal detected by the sanitized bot.

llvm-svn: 346707
2018-11-12 21:24:50 +00:00
Kuba Mracek c3f1e62920 [lldb] Extract more fields from NSException values
This patch teaches LLDB about more fields on NSException Obj-C objects, specifically we can now retrieve the "name" and "reason" of an NSException. The goal is to eventually be able to have SB API that can provide details about the currently thrown/caught/processed exception.

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

llvm-svn: 346695
2018-11-12 19:12:31 +00:00
Davide Italiano 9a89d93d62 Revert "Extract construction of DataBufferLLVM into FileSystem"
It broke the lldb sanitizer bots.

llvm-svn: 346694
2018-11-12 19:08:19 +00:00
Kuba Mracek b4ade53320 [lldb] Refactor ObjC/NSException.cpp (cleanup, avoid code duplication). NFC.
- Refactor reading of NSException fields into ExtractFields method to avoid code duplication.
- Remove "m_child_ptr" field, as it's not used anywhere.
- Clang-format.

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

llvm-svn: 346679
2018-11-12 17:25:23 +00:00
Kuba Mracek b2413ea9d3 [lldb] Fix "code requires global destructor" warning in g_architecture_mutex
Differential Revision: https://reviews.llvm.org/D44060

llvm-svn: 346673
2018-11-12 16:52:58 +00:00
Aleksandr Urakov 1dc51db757 [ClangASTContext] Extract VTable pointers from C++ objects
This patch processes the case of retrieving a virtual base when the object is
already read from the debuggee memory.

To achieve that ValueObject::GetCPPVTableAddress was removed and was
reimplemented in ClangASTContext (because access to the process is needed to
retrieve the VTable pointer in general, and because this is the only place that
used old version of ValueObject::GetCPPVTableAddress).

This patch allows to use real object's VTable instead of searching virtual bases
by offsets restored by MicrosoftRecordLayoutBuilder. PDB has no enough info to
restore VBase offsets properly, so we have to read real VTable instead.

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

llvm-svn: 346669
2018-11-12 16:23:50 +00:00
Stefan Granitz 73ee35eefc [CMake] Fix: add_host_subdirectory source/Host/macosx
Summary: Typo introduced with https://reviews.llvm.org/D47929

Reviewers: teemperor

Subscribers: mgorny, friss, lldb-commits

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

llvm-svn: 346667
2018-11-12 16:22:24 +00:00
Alexander Kornienko 87ab8f316f Fix an unused variable warning. NFC
llvm-svn: 346651
2018-11-12 13:41:42 +00:00
Jonas Devlieghere ceff6644bb Remove header grouping comments.
This patch removes the comments grouping header includes. They were
added after running IWYU over the LLDB codebase. However they add little
value, are often outdates and burdensome to maintain.

llvm-svn: 346626
2018-11-11 23:17:06 +00:00
Jonas Devlieghere 672d2c1255 Remove comments after header includes.
This patch removes the comments following the header includes. They were
added after running IWYU over the LLDB codebase. However they add little
value, are often outdates and burdensome to maintain.

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

llvm-svn: 346625
2018-11-11 23:16:43 +00:00
Jonas Devlieghere f8d480b12c Add missing include
llvm-svn: 346599
2018-11-10 22:54:44 +00:00
Jonas Devlieghere 1cc0714c68 Extract construction of DataBufferLLVM into FileSystem
This moves construction of data buffers into the FileSystem class. Like
some of the previous refactorings we don't translate the path yet
because the functionality hasn't been landed in LLVM yet.

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

llvm-svn: 346598
2018-11-10 22:44:06 +00:00
Jason Molenda ff6a4edc26 Unbreak the linux bot from the previous commit. Fred needed to use
some of the macros from mach/exc_resource.h to decode EXC_RESOURCE,
but that header doesn't exist on non-apple platforms and
StopInfoMachException.cpp needs to build on those systems.
EXC_RESOURCE won't be decoded when lldb is built on non-darwin systems.

llvm-svn: 346573
2018-11-10 00:25:45 +00:00
Jason Molenda a9796ede39 Enable listening for EXC_RESOURCE events, and format mach
event as a thread stop reason if we receive one, using 
some macros to decode the payload.  

Patch originally written by Fred Riss, with a few small changes
by myself.

Writing a test for this is a little tricky because the 
mach exception data interpretation relies on header macros
or function calls - it may change over time and writing
a gdb_remote_client test for this would break as older 
encoding interpretation is changed.  I'll tak with Fred
about this more, but neither of us has been thrilled with
the kind of tests we could write for it.

<rdar://problem/13097323>, <rdar://problem/40144456> 

llvm-svn: 346571
2018-11-10 00:14:14 +00:00
Jason Molenda c0e793d654 Work with a gdb-remote target that doesn't handle the
qWatchpointSupportInfo packet correctly.  

In GDBRemoteCommunicationClient::GetWatchpointSupportInfo,
if the response to qWatchpointSupportInfo does not
include the 'num' field, then we did not get an answer
we understood, mark this target as not supporting that
packet.

In Target.cpp, rename the very confusingly named
CheckIfWatchpointsExhausted to CheckIfWatchpointsSupported,
and check the error status returned by 
Process::GetWatchpointSupportInfo.  If we cannot determine
what the number of supported watchpoints are, assume that
they will work.  We'll handle the failure
later when we try to create/enable the watchpoint if the
Z2 packet isn't supported.

Add a gdb_remote_client test case.

<rdar://problem/42621432> 

llvm-svn: 346561
2018-11-09 22:33:26 +00:00
Zachary Turner 12abab5717 [NativePDB] Fix completion of enum types.
This was originally submitted in a patch which fixed two unrelated
bugs at the same time.  This portion of the fix was reverted because
it broke several other things.  However, the fix employed originally
was totally wrong, and attempted to change something in the ValueObject
printer when actually the bug was in the NativePDB plugin.  We need
to mark forward enum decls as having external storage, otherwise
we won't be asked to complete them when the time comes.  This patch
implements the proper fix, and updates tests accordingly.

llvm-svn: 346517
2018-11-09 17:08:26 +00:00
Zachary Turner d2ee4c6ddb [NativePDB] Add support for bitfield records.
Bitfields are represented as LF_MEMBER records whose TypeIndex
points to an LF_BITFIELD record that describes the bit width,
bit offset, and underlying type of the bitfield.  All we need to
do is resolve these when resolving record types.

llvm-svn: 346511
2018-11-09 16:29:19 +00:00
Zachary Turner 9cad24a7ee Resubmit "Fix bug in PE/COFF plugin."
The original commit was actually 2 unrelated bug fixes, but it turns
out the second bug fix wasn't quite correct, so the entire patch was
reverted.  Resubmitting this half of the patch by itself, then will
follow up with a new patch which fixes the rest of the issue in a
more appropriate way.

llvm-svn: 346505
2018-11-09 16:06:44 +00:00
Jonas Devlieghere 72787ac661 Revert "[FileSystem] Make use of FS in TildeExpressionResolver"
The whole point of this change was making it possible to resolve paths
without depending on the FileSystem, which is not what I did here. Not
sure what I was thinking...

llvm-svn: 346466
2018-11-09 01:59:28 +00:00
Jonas Devlieghere 9560f353ed [FileSystem] Make use of FS in TildeExpressionResolver
In order to call real_path from the TildeExpressionResolver we need
access to the FileSystem. Since the resolver lives under utility we have
to pass in the FS.

llvm-svn: 346457
2018-11-09 00:50:50 +00:00
Adrian Prantl e884ccb1cb Fix CMake build when building with -fmodules-local-submodule-visibility.
llvm-svn: 346456
2018-11-09 00:49:18 +00:00
Jonas Devlieghere 7010ef34d5 Update FileSpec constructor signature
llvm-svn: 346449
2018-11-08 23:21:00 +00:00
Davide Italiano ca591dea10 Revert "Fix bug in PE/COFF plugin and ValueObjectVariable."
It breaks some tests on MacOS.

llvm-svn: 346444
2018-11-08 22:47:40 +00:00
Jorge Gorbe Moya a6e6c18ade [lldb] Silence unhandled enums warning.
The warning was introduced by r346392, which introduces new builtin
types (to support cl_intel_device_side_avc_motion_estimation OpenCL
extension).

Note that this patch only inserts empty cases to silence the warning and
unblock our integrate, does not aim to add support for the new types in
lldb.

llvm-svn: 346441
2018-11-08 22:04:58 +00:00
Jorge Gorbe Moya d17315d898 [lldb] Fix initialization order warnings.
Moved the declaration of m_kind below the declaration of cvclass,
cvunion and cvenum. This order is necessary because in one of the
constructors the initialization of m_kind depends on the value of
cvclass.

third_party/llvm/llvm/tools/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp:50:7: error: field 'cvclass' will be initialized after field 'm_kind' [-Werror,-Wreorder]
    : cvclass(std::move(c)),
      ^
third_party/llvm/llvm/tools/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp:51:14: error: field 'cvclass' is uninitialized when used here [-Werror,-Wuninitialized]
      m_kind(cvclass.Kind == TypeRecordKind::Struct ? Struct : Class) {}

llvm-svn: 346435
2018-11-08 19:57:59 +00:00
Zachary Turner 91dbd52890 Fix bug in PE/COFF plugin and ValueObjectVariable.
There are two bugs here.  The first is that MSVC and clang-cl
emit their bss section under the name '.data' instead of '.bss'
but with the size and file offset set to 0.  ObjectFilePECOFF
didn't handle this, and would only recognize a section as bss
if it was actually called '.bss'.  The effect of this is that
if we tried to print the value of a variable that lived in BSS
we would fail.

The second bug is that ValueObjectVariable was only returning
the forward type, which is insufficient to print the value of an
enum.  So we bump this up to the layout type.

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

llvm-svn: 346430
2018-11-08 18:50:31 +00:00
Zachary Turner 056e4ab497 [NativePDB] Higher fidelity reconstruction of AST from Debug Info.
In order to accurately put a type into the correct location in the AST
we construct from debug info, we need to be able to determine what
DeclContext (namespace, global, nested class, etc) that it goes into.
PDB doesn't contain this mapping.  It does, however, contain the reverse
mapping.  That is, for a given class type T, you can determine all
classes Q1, Q2, ..., Qn that are nested inside of T.  We need to know,
for a given class type Q, what type T is it nested inside of.

This patch builds this map as a pre-processing step when we first
load the PDB by scanning every type.  Initial tests show that while
this can be slow in debug builds of LLDB, it is quite fast in release
builds (less than 2 seconds for a ~1GB PDB, and it only needs to happen
once).

Furthermore, having this pre-processing step in place allows us to
repurpose it for building up other kinds of indexing to it down the
line.  For the time being, this gives us very accurate reconstruction
of the DeclContext hierarchy.

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

llvm-svn: 346429
2018-11-08 18:50:11 +00:00
Shafik Yaghmour 8c5ec1ff46 Refactor ClangASTContext::AddEnumerationValueToEnumerationType() to remove redundant parameter which can be calculated from other parameter.
rdar://problem/43822994

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

llvm-svn: 346428
2018-11-08 18:42:00 +00:00
Jonas Devlieghere 3a58d89819 [FileSystem] Add convenience method to check for directories.
Replace calls to LLVM's is_directory with calls to LLDB's FileSytem
class. For this I introduced a new convenience method that, like the
other methods, takes either a path or filespec. This still uses the LLVM
functions under the hood.

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

llvm-svn: 346375
2018-11-08 00:14:50 +00:00
Eric Christopher c7f57aa885 Add a break to avoid an unannotated fall-through.
llvm-svn: 346294
2018-11-07 05:17:31 +00:00
Jason Molenda b1abf9e670 Compiler warning pointed out a mistake - fix it.
llvm-svn: 346283
2018-11-07 00:25:02 +00:00
Davide Italiano b37f1ec861 [ObjectFileELF] Fix misaligned read/writes caught by UBSan.
llvm-svn: 346244
2018-11-06 17:11:34 +00:00
Pavel Labath e0d2733bf6 CPlusPlusLanguage: Use new demangler API to implement type substitution
Summary:
Now that llvm demangler supports more generic customization, we can
implement type substitution directly on top of this API. This will allow
us to remove the specialized hooks which were added to the demangler to
support this use case.

Reviewers: sgraenitz, erik.pilkington, JDevlieghere

Subscribers: lldb-commits

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

llvm-svn: 346233
2018-11-06 15:41:37 +00:00
Benjamin Kramer 98d9647d55 Add parens to silence warning
MSVCUndecoratedNameParser.cpp:25:36: warning: '&&' within '||' [-Wlogical-op-parentheses]

llvm-svn: 346220
2018-11-06 10:13:37 +00:00
Aleksandr Urakov c1e530ee92 [PDB] Introduce `MSVCUndecoratedNameParser`
This patch introduces the simple MSVCUndecoratedNameParser. It is needed for
parsing names of PDB symbols corresponding to template instantiations. For
example, for the name `operator<<A>'::`2'::B::operator> we can't just split the
name with :: (as it is implemented for now) to retrieve its scopes. This parser
processes such names in a more correct way.

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

llvm-svn: 346213
2018-11-06 08:02:55 +00:00
Nathan Lanza 6868d2dd65 Add a relocation to ObjectFileELF::ApplyRelocations and a test
Summary:
pcm files can end up being processed by lldb with relocations to be
made for the .debug_info section. When a R_AARCH64_ABS64 relocation
was required lldb would hit an `assert(false)` and die.

Add R_AARCH64_ABS64 relocations to the S+A 64 bit width code path. Add
a test for R_AARCH64_ABS64 and R_AARCH64_ABS32 .rela.debug_info
relocations in a pcm file.

Reviewers: sas, xiaobai, davide, javed.absar, espindola

Reviewed By: davide

Subscribers: labath, zturner, emaste, mgorny, arichardson, kristof.beyls

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

llvm-svn: 346171
2018-11-05 22:18:00 +00:00
Adrian Prantl eca07c592a Fix (and improve) the support for C99 variable length array types
Clang recently improved its DWARF support for C VLA types. The DWARF
now looks like this:

0x00000051:         DW_TAG_variable [4]
                     DW_AT_location( fbreg -32 )
                     DW_AT_name( "__vla_expr" )
                     DW_AT_type( {0x000000d3} ( long unsigned int ) )
                     DW_AT_artificial( true )
...
0x000000da:     DW_TAG_array_type [10] *
                 DW_AT_type( {0x000000cc} ( int ) )

0x000000df:         DW_TAG_subrange_type [11]
                     DW_AT_type( {0x000000e9} ( __ARRAY_SIZE_TYPE__ ) )
                     DW_AT_count( {0x00000051} )

Without this patch LLDB will naively interpret the DIE offset 0x51 as
the static size of the array, which is clearly wrong.  This patch
extends ValueObject::GetNumChildren to query the dynamic properties of
incomplete array types.

See the testcase for an example:

   4   int foo(int a) {
   5   	     int vla[a];
   6   	       for (int i = 0; i < a; ++i)
   7   	           vla[i] = i;
   8
-> 9            pause(); // break here
   10  		return vla[a-1];
   11   }

(lldb) fr v vla
(int []) vla = ([0] = 0, [1] = 1, [2] = 2, [3] = 3)
(lldb) quit

rdar://problem/21814005

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

llvm-svn: 346165
2018-11-05 20:49:07 +00:00
Jonas Devlieghere 454057da2a Remove OCaml debugger plugin
In January Davide sent an e-mail to the mailing list to suggest removing
unmaintained language plugins such as Go and Java. The plan was to have
some cool down period to allow users to speak up, however after that the
plugins were never actually removed.

This patch removes the OCaml debugger plugin.

The plugin can be added again in the future if it is mature enough both
in terms of testing and maintenance commitment.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013171.html

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

llvm-svn: 346159
2018-11-05 19:34:03 +00:00
Jonas Devlieghere 0b8c5c9e13 Remove Java debugger plugin
In January Davide sent an e-mail to the mailing list to suggest removing
unmaintained language plugins such as Go and Java. The plan was to have
some cool down period to allow users to speak up, however after that the
plugins were never actually removed.

This patch removes the Java debugger plugin.

The plugin can be added again in the future if it is mature enough both
in terms of testing and maintenance commitment.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013171.html

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

llvm-svn: 346158
2018-11-05 19:34:02 +00:00
Jonas Devlieghere 77198bc79b Remove Go debugger plugin
In January Davide sent an e-mail to the mailing list to suggest removing
unmaintained language plugins such as Go and Java. The plan was to have
some cool down period to allow users to speak up, however after that the
plugins were never actually removed.

This patch removes the Go debugger plugin.

The plugin can be added again in the future if it is mature enough both
in terms of testing and maintenance commitment.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013171.html

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

llvm-svn: 346157
2018-11-05 19:33:59 +00:00
Zachary Turner 115209ece5 Properly cast from DeclContext to Decl.
Apparently there's a special procedure for doing this.  Not
following this silently breaks builds.

llvm-svn: 346156
2018-11-05 19:25:39 +00:00
Zachary Turner 4911023fe3 Add a target modules dump ast command.
This is useful for investigating the clang ast as you reconstruct
it via by parsing debug info.  It can also be used to write tests
against.

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

llvm-svn: 346149
2018-11-05 17:40:28 +00:00
David Carlier 511e1cf1ef [LLDB] Fix FreeBSD/Darwin build
Reviewers: JDevlieghere, tatyana-krasnukha

Reviwed By: tatyana-krasnukha

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

llvm-svn: 346109
2018-11-04 23:19:25 +00:00
Kamil Rytarowski a0a44e9c78 Fix NetBSD build after "Move path resolution logic out of FileSpec"
D53915

llvm-svn: 346100
2018-11-04 16:53:16 +00:00
Pavel Labath b075bbd9da Fix log statement in r346093
Thanks to Dávid Bolvanský for pointing that out.

llvm-svn: 346094
2018-11-04 12:54:29 +00:00
Pavel Labath be828518c9 NativeProcessProtocol: Simplify breakpoint setting code
Summary:
A fairly simple operation as setting a breakpoint (writing a breakpoint
opcode) at a given address was going through three classes:
NativeProcessProtocol which called NativeBreakpointList, which then
called SoftwareBrekpoint, only to end up again in NativeProcessProtocol
to do the actual writing itself. This is unnecessarily complex and can
be simplified by moving all of the logic into NativeProcessProtocol
class itself, removing a lot of boilerplate.

One of the reeasons for this complexity was that (it seems)
NativeBreakpointList class was meant to hold both software and hardware
breakpoints. However, that never materialized, and hardware breakpoints
are stored in a separate map holding only hardware breakpoints.
Essentially, this patch makes software breakpoints follow that approach
by replacing the heavy SoftwareBraekpoint with a light struct of the
same name, which holds only the data necessary to describe one
breakpoint. The rest of the logic is in the main class. As, at the
lldb-server level, handling software and hardware breakpoints is very
different, this seems like a reasonable state of things.

Reviewers: krytarowski, zturner, clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 346093
2018-11-04 10:58:08 +00:00
Zachary Turner 513472a7c5 Fix some windows-specific fallout from the FileSpec change.
llvm-svn: 346058
2018-11-03 00:07:03 +00:00
Jim Ingham ab639986cf Add an SBExpressionOptions setting mirroring the "exec" command's --allow-jit.
<rdar://problem/44809176>

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

llvm-svn: 346053
2018-11-02 23:42:40 +00:00
Jonas Devlieghere 50bc1ed290 [FileSystem] Open File instances through the FileSystem.
This patch modifies how we open File instances in LLDB. Rather than
passing a path or FileSpec to the constructor, we now go through the
virtual file system. This is needed in order to make things work with
the VFS in the future.

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

llvm-svn: 346049
2018-11-02 22:34:51 +00:00
Davide Italiano 407c6910d4 Revert "[Symbol] Search symbols with name and type in a symbol file"
It broke MacOS buildbots.

llvm-svn: 346045
2018-11-02 21:59:14 +00:00
Jonas Devlieghere 12950118c9 [FileSystem] Remove `SetFileSystem` method.
This is no longer relevant with the new way we initialize the
FileSystem.

llvm-svn: 346003
2018-11-02 17:34:17 +00:00
Jonas Devlieghere d7c2b798be [FileSystme] Move ::open abstraction into FileSystem.
This moves the abstraction around ::open into the FileSystem, as is
already the case for ::fopen.

llvm-svn: 346002
2018-11-02 17:34:16 +00:00
George Rimar 5497f6580e [LLDB] - Add support for DW_FORM_rnglistx and relative DW_RLE_* entries.
This adds support for DW_RLE_base_addressx, DW_RLE_startx_endx,
DW_RLE_startx_length, DW_FORM_rnglistx.

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

llvm-svn: 345958
2018-11-02 09:03:25 +00:00
Aleksandr Urakov 15da7684db [Symbol] Search symbols with name and type in a symbol file
Summary:
This patch adds possibility of searching a public symbol with name and type in a
symbol file. It is helpful when working with PE, because PE's symtabs contain
only imported / exported symbols only. Such a search is required for e.g.
evaluation of an expression that calls some function of the debuggee.

Reviewers: zturner, asmith, labath, clayborg, espindola

Reviewed By: clayborg

Subscribers: emaste, arichardson, aleksandr.urakov, jingham, lldb-commits, stella.stamenova

Tags: #lldb

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

llvm-svn: 345957
2018-11-02 08:54:35 +00:00
Aleksandr Urakov 54bb316185 [Windows] Fix Windows build after be053dd5a384a03da5a77552686900ddc7bfc178
llvm-svn: 345956
2018-11-02 08:47:33 +00:00
Jonas Devlieghere 73ed607180 [File] Remove static method to get permissions.
This patch removes the static accessor in File to get a file's
permissions. Permissions should be checked through the FileSystem class.

llvm-svn: 345901
2018-11-01 22:46:49 +00:00
Jonas Devlieghere a1f048d2ab [FileSystem] Update SetFile signature.
llvm-svn: 345898
2018-11-01 22:16:34 +00:00
Jonas Devlieghere 2ac403e25a [FileSystem] Change FileSpec constructor signature (2/2)
Fix breakage due to the recent FileSpec change that extracts the path
resultion logic into FileSystem for the FreeBSD host.

llvm-svn: 345895
2018-11-01 21:26:58 +00:00
Jonas Devlieghere 99f2b9949d [FileSystem] Change FileSpec constructor signature.
Fix breakage due to the recent FileSpec change that extracts the path
resultion logic into FileSystem for the Android host.

llvm-svn: 345891
2018-11-01 21:18:25 +00:00
Jonas Devlieghere 8f3be7a32b [FileSystem] Move path resolution logic out of FileSpec
This patch removes the logic for resolving paths out of FileSpec and
updates call sites to rely on the FileSystem class instead.

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

llvm-svn: 345890
2018-11-01 21:05:36 +00:00
Reid Kleckner 4dc0b1ac60 Fix clang -Wimplicit-fallthrough warnings across llvm, NFC
This patch should not introduce any behavior changes. It consists of
mostly one of two changes:
1. Replacing fall through comments with the LLVM_FALLTHROUGH macro
2. Inserting 'break' before falling through into a case block consisting
   of only 'break'.

We were already using this warning with GCC, but its warning behaves
slightly differently. In this patch, the following differences are
relevant:
1. GCC recognizes comments that say "fall through" as annotations, clang
   doesn't
2. GCC doesn't warn on "case N: foo(); default: break;", clang does
3. GCC doesn't warn when the case contains a switch, but falls through
   the outer case.

I will enable the warning separately in a follow-up patch so that it can
be cleanly reverted if necessary.

Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu

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

llvm-svn: 345882
2018-11-01 19:54:45 +00:00
Jonas Devlieghere 49996c1d99 [FileSystem] Fix typo in ProcessFreeBSD
llvm-svn: 345860
2018-11-01 17:46:31 +00:00
Jonas Devlieghere 60cf3f82fd [FileSystem] Fix Exists call sites
There were some calls left to Exists() on non-darwin platforms (Windows,
Linux and FreeBSD) that weren't yet updated to use the FileSystem.

llvm-svn: 345857
2018-11-01 17:35:31 +00:00
Jonas Devlieghere dbd7fabaa0 [FileSystem] Remove Exists() from FileSpec
This patch removes the Exists method from FileSpec and updates its uses
with calls to the FileSystem.

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

llvm-svn: 345854
2018-11-01 17:09:25 +00:00
Jonas Devlieghere 2c22c800a0 [FileSystem] Remove ResolveExecutableLocation() from FileSpec
This patch removes the ResolveExecutableLocation method from FileSpec
and updates its uses with calls to the FileSystem.

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

llvm-svn: 345853
2018-11-01 17:09:22 +00:00
Jonas Devlieghere 0bca15a35a [FileSystem] Improve assert and add Terminate in unit test.
Speculative fix for the Xcode bots where we were seeing the assertion
being triggered because we would re-initialize the FileSystem without
terminating it.

llvm-svn: 345849
2018-11-01 16:43:34 +00:00
Zachary Turner 544a66d8bb [NativePDB] Get LLDB types from PDB function types.
This adds basic support for getting function signature types
into LLDB's type system, including into clang's AST.  There are
a few edge cases which are not correctly handled, mostly dealing
with nested classes, but this isn't specific to functions and
apply equally to variable types.  Note that no attempt has been
made yet to deal with member function types, which will happen
in subsequent patches.

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

llvm-svn: 345848
2018-11-01 16:37:29 +00:00
Jonas Devlieghere 7c5310bbd3 [FileSystem] Remove GetPermissions() and Readable() from FileSpec
This patch removes the GetPermissions and GetReadable methods from
FileSpec and updates its uses with calls to the FileSystem.

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

llvm-svn: 345843
2018-11-01 15:47:33 +00:00
Aleksandr Urakov 9d5b2d4adc [Windows] A basic implementation of memory allocations in a debuggee process
Summary:
This patch adds a basic implementation of `DoAllocateMemory` and
`DoDeallocateMemory` for Windows processes. For now it considers only the
executable permission (and always allows reads and writes).

Reviewers: zturner, asmith, stella.stamenova, labath, clayborg

Reviewed By: zturner

Subscribers: Hui, vsk, jingham, aleksandr.urakov, clayborg, abidh, teemperor, lldb-commits

Tags: #lldb

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

llvm-svn: 345815
2018-11-01 08:54:38 +00:00
Jonas Devlieghere 59b78bcba2 [FileSystem] Remove GetByteSize() from FileSpec
This patch removes the GetByteSize method from FileSpec and updates its
uses with calls to the FileSystem.

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

llvm-svn: 345812
2018-11-01 04:45:28 +00:00
Jonas Devlieghere 35e4c84c1f [FileSystem] Move EnumerateDirectory from FileSpec to FileSystem.
This patch moves the EnumerateDirectory functionality and related enum
and typedef from FileSpec to FileSystem.

This is part of a set of patches that extracts file system related
convenience methods from FileSpec. The long term goal is to remove this
method altogether and use the iterators directly, but for introducing
the VFS into LLDB this change is sufficient.

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

llvm-svn: 345800
2018-11-01 00:33:27 +00:00
Jonas Devlieghere 9ca491da2f [FileSystem] Re-add EnumerateDirectory
Re-enable EnumerateDirectory now that no_push is available in llvm (r345793).

llvm-svn: 345799
2018-11-01 00:26:09 +00:00
Jonas Devlieghere fd9461f5e4 [FileSystem] Remove EnumerateDirectory
The new implementation of EnumerateDirectory relies on `::no_push()`
being implemented for the VFS recursive directory iterators. However
this patch (D53465) hasn't been landed yet.

llvm-svn: 345787
2018-10-31 22:09:58 +00:00
Jonas Devlieghere 46376966ea [FileSystem] Extend file system and have it use the VFS.
This patch extends the FileSystem class with a bunch of functions that
are currently implemented as methods of the FileSpec class. These
methods will be removed in future commits and replaced by calls to the
file system.

The new functions are operated in terms of the virtual file system which
was recently moved from clang into LLVM so it could be reused in lldb.
Because the VFS is stateful, we turned the FileSystem class into a
singleton.

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

llvm-svn: 345783
2018-10-31 21:49:27 +00:00
David Bolvansky 8f81aed12d [NFC] Fixed -Wsign-compare warning
llvm-svn: 345755
2018-10-31 18:03:36 +00:00
George Rimar 0f46e34f74 [LLDB] - Regroup the switch entries in DWARFFormValue::ExtractValue. NFC.
This is NFC to clean up the `DWARFFormValue::ExtractValue`.
It groups similar `DW_FORM_*` and removes an excessive
assignment of `ref_addr_size` (it was assigned right after in any case).

llvm-svn: 345733
2018-10-31 16:12:29 +00:00
George Rimar 103a0559b7 [LLDB] - Removed unused variable. NFC.
Introduced in r344119.

Thanks to Dávid Bolvanský fo reporting.

llvm-svn: 345720
2018-10-31 13:49:31 +00:00
George Rimar c3e5dec0b0 [LLDB] - Add support for DW_FORM_addrx[1-4]? forms.
This adds the support for DW_FORM_addrx, DW_FORM_addrx1, 
DW_FORM_addrx2, DW_FORM_addrx3, DW_FORM_addrx4 forms.

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

llvm-svn: 345706
2018-10-31 10:14:03 +00:00
Kuba Mracek f80d265551 Fixup the Python-less build of ScriptedRecognizedStackFrame
llvm-svn: 345694
2018-10-31 04:43:09 +00:00
Kuba Mracek 41ae8e7445 [lldb] Introduce StackFrameRecognizer [take 3]
This patch introduces a concept of "frame recognizer" and "recognized frame". This should be an extensible mechanism that retrieves information about special frames based on ABI, arguments or other special properties of that frame, even without source code. A few examples where that could be useful could be 1) objc_exception_throw, where we'd like to get the current exception, 2) terminate_with_reason and extracting the current terminate string, 3) recognizing Objective-C frames and automatically extracting the receiver+selector, or perhaps all arguments (based on selector).

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

llvm-svn: 345693
2018-10-31 04:00:22 +00:00
Kuba Mracek cb3628bcc0 Revert r345686 due to build failures
llvm-svn: 345688
2018-10-31 01:22:48 +00:00
Kuba Mracek 8fddd98185 [lldb] Introduce StackFrameRecognizer [take 2]
This patch introduces a concept of "frame recognizer" and "recognized frame". This should be an extensible mechanism that retrieves information about special frames based on ABI, arguments or other special properties of that frame, even without source code. A few examples where that could be useful could be 1) objc_exception_throw, where we'd like to get the current exception, 2) terminate_with_reason and extracting the current terminate string, 3) recognizing Objective-C frames and automatically extracting the receiver+selector, or perhaps all arguments (based on selector).

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

llvm-svn: 345686
2018-10-31 00:36:20 +00:00
Kuba Mracek 377f9f9b3f Revert r345678 (build failure on Linux machines).
llvm-svn: 345680
2018-10-31 00:29:17 +00:00
Kuba Mracek ac0ba8c524 [lldb] Introduce StackFrameRecognizer
This patch introduces a concept of "frame recognizer" and "recognized frame". This should be an extensible mechanism that retrieves information about special frames based on ABI, arguments or other special properties of that frame, even without source code. A few examples where that could be useful could be 1) objc_exception_throw, where we'd like to get the current exception, 2) terminate_with_reason and extracting the current terminate string, 3) recognizing Objective-C frames and automatically extracting the receiver+selector, or perhaps all arguments (based on selector).

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

llvm-svn: 345678
2018-10-31 00:21:03 +00:00
Erik Pilkington fa98390b3c NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)
We haven't supported compiling ObjC1 for a long time (and never will again), so
there isn't any reason to keep these separate. This patch replaces
LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC.

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

llvm-svn: 345637
2018-10-30 20:31:30 +00:00