Commit Graph

18321 Commits

Author SHA1 Message Date
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
Jason Molenda c14a6ae4a7 Add a description of the similar packets defined in the
gdb-remote serial protocol documentation, call out the 
incompatability of lldb's vFile:open: packet as it stands
today.  Need to think about whether to change lldb's
enum values (breaking any existing lldb-server's out there)
or create a different packet and abandon vFile:open: at
least for a while.

llvm-svn: 349316
2018-12-16 18:44:54 +00:00
Jason Molenda 65b60ba8b2 Clarify a few minor details.
llvm-svn: 349313
2018-12-16 18:33:58 +00:00
Jason Molenda fbdb8b2e1c Update the vFile:open: description to note that the flags
in the packet are lldb enum values, not the open(2) oflags -- 
forgot about that wrinkle.  Also added a comment to File.h 
noting that the existing values cannot be modified or we'll
have a compatibilty break with any alternative platform
implementations, or older versions of lldb-server.

llvm-svn: 349282
2018-12-15 18:40:38 +00:00
Pavel Labath d211d1a59c lldb-test: Improve newline handling
Summary:
Previously lldb-test's LinePrinter would output the indentation spaces
even on completely empty lines. This is not nice, as trailing spaces get
flagged as errors in some tools/editors, and it prevents FileCheck's
CHECK-EMPTY from working.

Equally annoying was the fact that the LinePrinter did not terminate
it's output with a newline (instead it would leave the unterminated hanging
indent from the last NewLine() command), which meant that the shell prompt
following the lldb-test command came out wrong.

This fixes both issues by changing how newlines are handled. NewLine(),
which was ending the previous line ('\n') *and* begging the next line by
printing the indent, is now "demoted" to just printing literal "\n".
Instead, lines are now delimited via a helper Line object, which makes
sure the line is indented and terminated in an RAII fashion. The typical
usage would be:
Printer.line() << "This text will be indented and terminated";
If one needs to do more work than it will fit into a single statement,
one can also assign the result of the line() function to a local
variable. The line will then be terminated when that object goes out of
scope.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 349269
2018-12-15 13:49:25 +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
Jason Molenda 4e67b0a61a Ah, forgot qModuleInfo. Need to look that one up
and finish filling this in.

llvm-svn: 349232
2018-12-15 02:51:01 +00:00
Jason Molenda f1127d5224 A brief outline of the packets that need to be implemented
to write an lldb platform server that doesn't link against
LLDB.framework to be able to fully run the lldb testsuite
on a remote system.  The platform packets weren't covered 
in the existing lldb-gdb-remote.txt doc, so I wanted to 
jot them down in one place.

llvm-svn: 349231
2018-12-15 02:36:39 +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
Jim Ingham d81b96ece8 Fix the unittests for the move of Listener & Broadcaster
from Core to Utility.

llvm-svn: 349211
2018-12-14 23:27:08 +00:00
Tatyana Krasnukha 0127883373 Update a comment according to r255360 "Remove -r and -R options from dotest.py"
llvm-svn: 349208
2018-12-14 23:02:41 +00:00
Adrian Prantl 8f06d10291 Remove the Disassembly benchmarks.
While I was out hunting for remaining pexpect-based tests, I came
across these tests that can't possibly work an any modern system, as
they rely on having gdb available in /Developer.

This patch simply removes the test without replacement.

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

llvm-svn: 349194
2018-12-14 21:06:00 +00:00
Greg Clayton baaf2cc7ba Add missing .dmp files to test inputs.
llvm-svn: 349183
2018-12-14 19:38:08 +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
Greg Clayton 82694abac7 Fix Xcode project for MIPS architecture plug-in and move of Event, Listener and Broadcaster to Utility.
llvm-svn: 349180
2018-12-14 19:22:24 +00:00
Zachary Turner 298e268155 [NativePDB] Fix local-variables.cpp test.
Since we're actually running an executable on the host now, different
versions of Windows could load different system libraries, so we need
to regex out the number of loaded modules.

llvm-svn: 349175
2018-12-14 18:43:42 +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
Pavel Labath eed7b2eeca Fix minidump unit test failures from r349062
This commit added new test inputs, but it did not add them to the cmake
files. This caused the test to fail at runtime.

While in there, I also sorted the list of minidump test inputs.

llvm-svn: 349154
2018-12-14 14:41:04 +00:00
Pavel Labath 091fcdb10b Fix build with older (<3.0) swigs
It turns out it wasn't the compilers, but swig who had issues with my
previous patch -- older versions do not recognise the "constexpr"
keyword.

Fortunately, that can be fixed the same way we fix all other swig
incompatibilities: #ifndef SWIG.

llvm-svn: 349153
2018-12-14 14:25:20 +00:00
Pavel Labath b3ce98ac7c Mark Permissions as a bitmask enum
this allows one to use bitwise operators on the variables of this type
without complicated casting.

The gotcha here is that the combinations of these enums were being used
in some constexpr contexts such as case labels (case
ePermissionsWritable | ePermissionsExecutable:), which is not possible
if the user-defined operator| is not constexpr.

So, this commit also marks these operators as constexpr. I am committing
this as a small standalone patch so it can be easily reverted if some
compiler has an issue with this.

llvm-svn: 349149
2018-12-14 13:51:20 +00:00
Richard Trieu f03e8023b7 Remove unused variable.
llvm-svn: 349128
2018-12-14 05:40:30 +00:00
Greg Clayton 918adb56d8 Fix test failures that depended on module order
llvm-svn: 349122
2018-12-14 03:07:15 +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
Pavel Labath 1a4e2cc27a Classify tests in lit/Modules
We've recently developed a convention where the tests are placed into
subfolders according to the object file type. This applies that
convention to existing tests too.

llvm-svn: 349027
2018-12-13 12:13:29 +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 280d2e8179 lldb-test: Add ability to dump subsections
Previously, lldb-test would only print top-level sections. However, in
lldb, sections can contain other sections. This teaches lldb-test to
print nested sections too.

llvm-svn: 348924
2018-12-12 12:35:25 +00:00
Pavel Labath 4b94a3064a build.py: Implement "gcc" builder
Summary:
This implements the gcc builder in build.py script to allow it to
compile host executables when running on a non-windows host. Where it
made sense, I tried to share code with the msvc builder by moving stuff
to the base class.

Reviewers: zturner

Subscribers: mehdi_amini, dexonsmith, lldb-commits

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

llvm-svn: 348918
2018-12-12 08:54:14 +00:00
Jonas Devlieghere c67768fe23 Remove unused file
I removed the dotest-style reproducer test but forgot to delete the
source file. Thanks Jim for the heads up!

llvm-svn: 348901
2018-12-11 22:46:56 +00:00
Jonas Devlieghere fb3e58920d [Driver] Simplify OptionData. NFC
Hopefully this makes the option data easier to understand and maintain.

 - Group the member variables.
 - Do the initialization in the header as it's less error prone.
 - Rename the Clean method. It was called only once and was
   re-initializing some but not all (?) members. The only useful thing it
   does is dealing with the local lldbinit file so keep that and make the
   name reflect that.

llvm-svn: 348894
2018-12-11 20:19:53 +00:00
Jim Ingham fed6740374 Add ObjectFileBreakpad.{cpp,h} to the Xcode project.
llvm-svn: 348890
2018-12-11 19:25:03 +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
Adrian Prantl 0bc587a128 Rewrite pexpect-based test in LIT/FileCheck.
pexecpt-based tests are flakey because they involve timeouts and this
test is eprfectly serializable.

llvm-svn: 348808
2018-12-10 22:57:47 +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
Stella Stamenova edddab9fac [lit] Fix case-insensitive test
The test still only passes when not run from VS because the previous patch did not remove the original build commands.... This also simplifies the build command by removing some defaults

llvm-svn: 348664
2018-12-07 23:30:38 +00:00