Commit Graph

19158 Commits

Author SHA1 Message Date
Raphael Isemann 12886f04ea Prevent unnecessary conversion from StringRef to C-string [NFC]
There is an alternative method to GetConstCStringWithLength that
takes a StringRef. GetConstCStringWithLength also calls this
method in the end, so directly calling the StringRef saves
us from a unnecessary conversion to a C-string.

llvm-svn: 358357
2019-04-14 14:01:49 +00:00
Michal Gorny fb70bc65fe [lldb] [lit/SymbolFile] Avoid -nostdlib in target-symbols-add-unwind.test
Do not use -nostdlib in target-symbols-add-unwind.test.  NetBSD uses
startup files to provide obligatory ELF notes in executables,
and therefore using -nostdlib requires providing specially tailored
input.  Otherwise, kernel rejects the result as invalid executable.

The replacement was suggested by Pavel Labath.

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

llvm-svn: 358329
2019-04-13 09:49:39 +00:00
Pavel Labath ce0a88a5e1 Fix compiler warning introduced by r358261
Add a virtual destructor to the class with virtual methods.

llvm-svn: 358284
2019-04-12 13:48:01 +00:00
Pavel Labath 539b7e65b4 Make TestPrintStackTraces deterministic
This test contained an incredibly complicated inferior, but in reality,
all it was testing was that we can backtrace up to main and see main's
arguments.

However, the way this was implemented (setting a breakpoint on a
separate thread) meant that each time the test would run, it would stop
in a different location on the main thread. Most of the time this
location would be deep in some libc function, which meant that the
success of this test depended on our ability to backtrace out of a
random function of the c library that the user happens to have
installed.

This makes the test unpredictable. Backtracing out of a libc function is
an important functionality, but this is not the way to test it. Often it
is not even our fault that we cannot backtrace out because the C library
contains a lot of assembly routines that may not have correct unwind
info associated with them.

For this reason the test has accumulated numerous @expectedFail/Flaky
decorators. In this patch, I replace the inferior with one that does not
depend on libc functions. Instead I create a couple of stack frames of
user code, and have the test verify that. I also simplify the test by
using lldbutil.run_to_source_breakpoint.

llvm-svn: 358266
2019-04-12 08:02:28 +00:00
Aaron Smith 4b0931bc17 [lldb-server] Update tests to use std::thread/mutex for all platforms
Summary:
Some cleanup suggested when bringing up lldb-server on Windows. 
Thanks to Hui Huang for the patch.

Reviewers: zturner, labath, jfb, Hui

Reviewed By: labath

Subscribers: clayborg, dexonsmith, lldb-commits

Tags: #lldb

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

llvm-svn: 358265
2019-04-12 07:48:49 +00:00
Pavel Labath 85ce053d7e PDBFPO: Improvements to the AST visitor
Summary:
This patch attempts to solve two issues made this code hard to follow
for me.

The first issue was that a lot of what these visitors do is mutate the
AST. The visitor pattern is not particularly good for that because by
the time you have performed the dynamic type dispatch, it's too late to
go back to the parent node, and change its pointer. The previous code
dealt with that relatively elegantly, but it still meant that one had to
perform manual type checks, which is what the visitor pattern is
supposed to avoid.

The second issue was not being able to return values from the Visit
functions, which meant that one had to store function results in member
variables (a common problem with visitor patterns).

Here, I solve both problems by making the visitor use a type switch
instead of going through double dispatch on the visited object.  This
allows one to parameterize the visitor based on the return type and pass
function results as function results. The mutation is fascilitated by
having each Visit function take two arguments -- a reference to the
object itself (with the correct dynamic type), and a reference to the
parent's pointer to this object.

Although this wasn't my explicit goal here, the fact that we're not
using virtual dispatch anymore  allows us to make the AST nodes
trivially destructible, which is a good thing, since we were not
destroying them anyway.

Reviewers: aleksandr.urakov, amccarth

Subscribers: lldb-commits

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

llvm-svn: 358261
2019-04-12 07:19:00 +00:00
Fangrui Song 35861f216b [IRMemoryMap] Fix -Wimplicit-fallthrough in -DLLVM_ENABLE_ASSERTIONS=off build
llvm-svn: 358249
2019-04-12 02:38:17 +00:00
Michal Gorny a318a7f665 [lldb] [lit/Register] XFAIL on Darwin
llvm-svn: 358224
2019-04-11 20:44:40 +00:00
Jonas Devlieghere bb6e3f6be7 [test] Fix & re-enable CommandScriptImmediateOutputFile on Windows
Apparently the shlex module produces garbage on Windows. I've added a
hand rolled split instead that should suffice for this test.

llvm-svn: 358216
2019-04-11 19:36:53 +00:00
Jonas Devlieghere 1fefee6a6e [test] Disable CommandScriptImmediateOutputFile on Windows
Somehow the path gets messed up. The command looks correct, but the
python path is not.

(lldb) mywrite
E:\build_slave\lldb-x64-windows-ninja\build\tools\lldb\lit\Commands\
  CommandScriptImmediateOutput\Output\
  CommandScriptImmediateOutputFile.test.tmp.read.txt r

No such file or directory:
'E:build_slavelldb-x64-windows-ninjabuildtoolslldblitCommands
  CommandScriptImmediateOutputOutput
  CommandScriptImmediateOutputFile.test.tmp.read.txt'

Maybe the shlex module is escaping it?

llvm-svn: 358213
2019-04-11 19:18:40 +00:00
Michal Gorny b971b59709 [lldb] [lit/Register] Mark x86-mm-xmm-read XFAIL on Windows
llvm-svn: 358188
2019-04-11 16:06:14 +00:00
Michal Gorny 53373432cf [lldb] [lit/Register] Fix test to use %clangxx
llvm-svn: 358184
2019-04-11 15:13:17 +00:00
Jonas Devlieghere d843da6218 [test] Convert CommandScriptImmediateOutput from pexpect to lit
This converts the CommandScriptImmediateOutput test from a python test
using pexpect to a lit test.

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

llvm-svn: 358180
2019-04-11 15:03:07 +00:00
Michal Gorny 40733618bd [lldb] [Process/NetBSD] Fix wrongly mapping mm* registers
Fix mistake that mapped mm* registers into the space for xmm* registers,
rather than the one shared with st* registers.  In other words,
'register read mmN' now correctly shows the mmN register rather than
part of xmmN.

Includes a minimal lit regression test.

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

llvm-svn: 358178
2019-04-11 14:58:48 +00:00
Pavel Labath 71b88b91f7 Minidump: extend UUID byte-swapping to windows platform
Summary:
D59433 added code to swap bytes UUIDs coming from minidump files, but
only enabled it for apple platforms. Based on my research, I believe
this is the correct thing to do for windows as well, as the natural way
of printing U(G)UIDs on this platforms is to print the first three
components as (4 or 2)-byte integers printed in natural (big-endian)
order. This makes the UUID string coming out of lldb match the strings
produced by other windows tools.

The decision to byte-swap the age field is somewhat arbitrary, because
the age field is usually printed separately from the file GUID (and
often in decimal). However, for our purposes (telling whether two files
are identical), including it in the UUID is correct, and printing it in
big-endian makes it easier to recognize the age value.

This also makes the UUIDs generated here (almost) match up with the
UUIDs computed for breakpad symbol files
(BreakpadRecords.cpp:parseModuleId), which already implemented the
byte-swapping. The "almost" is here because ObjectFileBreakpad does not
swap the age field, but I'll fix that in a follow-up.

There is no UUID support in ObjectFileCOFF at the moment, but ideally
the algorithms used here and in ObjectFileCOFF should be in sync so that
object file matching works correctly.

Reviewers: clayborg, amccarth, markmentovai, asmith

Subscribers: lldb-commits

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

llvm-svn: 358169
2019-04-11 14:14:07 +00:00
Adrian Prantl 3cc634d093 Fix undefined behavior in DWARFASTParser::ParseChildArrayInfo()
PR40827: https://bugs.llvm.org/show_bug.cgi?id=40827
<rdar://problem/48729057>

llvm-svn: 358137
2019-04-10 21:18:44 +00:00
Jonas Devlieghere 8b3af63b89 [NFC] Remove ASCII lines from comments
A lot of comments in LLDB are surrounded by an ASCII line to delimit the
begging and end of the comment.

Its use is not really consistent across the code base, sometimes the
lines are longer, sometimes they are shorter and sometimes they are
omitted. Furthermore, it looks kind of weird with the 80 column limit,
where the comment actually extends past the line, but not by much.
Furthermore, when /// is used for Doxygen comments, it looks
particularly odd. And when // is used, it incorrectly gives the
impression that it's actually a Doxygen comment.

I assume these lines were added to improve distinguishing between
comments and code. However, given that todays editors and IDEs do a
great job at highlighting comments, I think it's worth to drop this for
the sake of consistency. The alternative is fixing all the
inconsistencies, which would create a lot more churn.

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

llvm-svn: 358135
2019-04-10 20:48:55 +00:00
Jonas Devlieghere 6a7412a893 [testsuite] Split Obj-C foundation test
TestObjCMethods2.py was the third-longest running test on Darwin. By
splitting it up, lit can exploit parallelism to reduce the total wall
clock time.

llvm-svn: 358088
2019-04-10 14:30:00 +00:00
Pavel Labath 139e9f247a Minidump: Use llvm parser for reading the ModuleList stream
In this patch, I just remove the structure definitions for the
ModuleList stream and the associated parsing code. The rest of the code
is converted to work with the definitions in llvm. NFC.

llvm-svn: 358070
2019-04-10 11:07:28 +00:00
Pavel Labath f5f45f21d8 Docstringify some comments in the swig interface files
Without these, the comments don't end up in the generated python code.

llvm-svn: 358055
2019-04-10 07:55:04 +00:00
Aaron Smith f8a74c18ec [lldb-server] Introduce Socket::Initialize and Terminate to simply WSASocket setup
Reviewers: zturner, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 358044
2019-04-10 04:57:18 +00:00
Pavel Labath 26ca5a57bc Remove unneeded #ifdef SWIGs
Summary:
Some of these were present in files which should never be read by swig
(and we also had one in the interface file, which is only read by swig).
They are probably leftovers from the time when we were running swig over
lldb headers directly.

While writing this patch, I noticed that some of the #ifdefs were
guarding public functions that were operating on lldb_private data
types. While it wasn't strictly necessary for this patch, I made these
private, as nobody should really be accessing them. This can potentially
break existing code if it happened to use these methods, though it will
only break at build time -- if someone builds against an old header, he
should still be able to link to a new lldb library, since the functions
are still there.

We could keep these public for backward compatbility, but I would argue
that if anyone was actually using these functions for anything, his code
is already broken.

Reviewers: JDevlieghere, clayborg, jingham

Subscribers: lldb-commits

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

llvm-svn: 357984
2019-04-09 09:03:43 +00:00
Jonas Devlieghere 7e01ce2ed1 Fix doxygen warning about function argument
This fixes the following doxygen warning when building the lldb-cpp-doc
target.

This commit fixes:
  SBStructuredData.h:94 warning: Found unknown command `\dst'
  SBStructuredData.h:97 warning: Found unknown command `\dst'
  SBStructuredData.h:98 warning: Found unknown command `\dst'
  SBStructuredData.h:100 warning: Found unknown command `\dst'
  SBStructuredData.h:104 warning: Found unknown command `\dst'

Patch by: Konrad Kleine

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

llvm-svn: 357983
2019-04-09 09:03:30 +00:00
Jonas Devlieghere 721b8d1557 Add missing space between \btrue
There was a space missing in some the documentation for
lldb::BreakpointsWriteToFile.

This fixes the following doxygen error when building the lldb-cpp-doc
target:

  llvm-project/lldb/include/lldb/API/SBTarget.h:775 warning: Found
  unknown command `\btrue'

Patch by: Konrad Kleine

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

llvm-svn: 357980
2019-04-09 08:34:07 +00:00
Pavel Labath ff12913b63 Minidump: use string parsing functionality from llvm
llvm-svn: 357977
2019-04-09 08:28:27 +00:00
Pavel Labath 9837f54843 Breakpad: Parse Stack CFI records
Summary:
This patch adds support for parsing STACK CFI records from breakpad
files. The expressions specifying the values of registers are not
parsed.The idea is that these will be handed off to the postfix
expression -> dwarf compiler, once it is extracted from the internals of
the NativePDB plugin.

Reviewers: clayborg, amccarth, markmentovai

Subscribers: aprantl, lldb-commits

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

llvm-svn: 357975
2019-04-09 08:05:11 +00:00
Jim Ingham b78094abcf Get the run locker before you ask if your thread is valid.
I have occasional crashes coming from SBThread::GetExtendedBacktraceThread.  The 
symptom is that we got true back from HasThreadScope - so we should have a valid
live thread, but then when we go to use the thread, it is not good anymore and we
crash.
I can't spot any obvious cause for this crash, but in looking for same I noticed
that in the current code we check that the thread is valid, THEN we take the stop 
locker.  We really should do that in the other order, and ensure that the process 
will stay stopped before we check our thread is still good.  That's what this patch does.

<rdar://problem/47478205>

llvm-svn: 357963
2019-04-09 01:33:23 +00:00
Jason Molenda 1724a179e7 Rename Target::GetSharedModule to Target::GetOrCreateModule.
Add a flag to control whether the ModulesDidLoad notification is
called when a module is added.  If the notifications are disabled,
the caller must call ModulesDidLoad after adding all the new modules,
but postponing this notification until they're all batched up can
allow for better efficiency than notifying one-by-one.

Change the name of the ModuleList notifier functions that a subclass
can implement to start with 'Notify' to make it clear what they are.
Add a NotifyModulesRemoved.

Add header documentation for the changed/updated methods.

Added defaulted-value 'notify' argument to ModuleList Append,
AppendIfNeeded, and Remove because callers working with a local
ModuleList don't have an obvious idea of what notify means in this
context.  When the ModuleList is a part of the Target class, the
notify behavior matters.

DynamicLoaderDarwin has been updated so that libraries being
added/removed are correctly batched up before notifications are
sent.  Added the TestModuleLoadedNotifys.py test to run on 
Darwin to test this.

<rdar://problem/48293064> 

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

llvm-svn: 357955
2019-04-08 23:03:02 +00:00
Adrian Prantl e794752bdf Experiment with a larger packet timeout.
This is a follow-up to r357829 (https://reviews.llvm.org/D60340) to
see whether increasing the packet timeout for non-asan builds could
also positively affect the stability of non-asan bots.

llvm-svn: 357954
2019-04-08 23:02:11 +00:00
Adrian Prantl 1a0c0ffa9d Fix a stack buffer overflow found by ASAN.
llvm::StringRef host_and_port is not guaranteed to be null-terminated.
Generally, it is not safe at all to convert a StringRef into a char *
by calling data() on it.

<rdar://problem/49698580>

llvm-svn: 357948
2019-04-08 21:58:36 +00:00
Pavel Labath 7b30751acb MinidumpParser: parse SystemInfo stream via llvm
I also update the tests for SystemInfo parsing to use the yaml2minidump
capabilities in llvm instead of relying on checked-in binaries.

llvm-svn: 357896
2019-04-08 09:53:03 +00:00
Pavel Labath 1beeda682b PDBFPO: add dyn_cast support
This adds the necessary glue so we can use llvm::dyn_cast, instead of
doing a manual type-check followed by a cast. NFC.

llvm-svn: 357895
2019-04-08 09:52:57 +00:00
Pavel Labath fbe91ffb7b Fix signed-unsigned comparison warning in Driver.cpp
llvm-svn: 357893
2019-04-08 09:17:56 +00:00
Pavel Labath f2348c88f1 modify-python-lldb.py: Remove ifdef SWIG-removing code
There are no patterns like that in the generated swig files (there
probably were some back in the days when we were running swig over the
header files directly), so this is dead code and has no effect on the
generated file.

llvm-svn: 357890
2019-04-08 08:43:07 +00:00
Adrian Prantl 4c03ea14f2 Unify random timeouts throughout LLDB and make them configurable.
Since these timeouts guard against catastrophic error in debugserver,
I also increased all of them to the maximum value among them.

The motivation for this test was the observation that an asanified
LLDB would often exhibit seemingly random test failures that could be
traced back to debugserver packets getting out of sync. With this path
applied I can no longer reproduce the one particular failure mode that
I was investigating.

rdar://problem/49441261

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

llvm-svn: 357829
2019-04-05 22:43:42 +00:00
Jonas Devlieghere 9388c4703b [testsuite] Split Objective-C new syntax test
This splits the second longest test into separate test cases. Similar to
what we did for the Objective-C data formatters in r357786.

llvm-svn: 357824
2019-04-05 22:06:53 +00:00
Alex Langford 7e7f79ccb1 [CMake] Don't explicitly use LLVM_LIBRARY_DIR in standalone builds
Summary:
This line is unnecessary because add_llvm_executable will handle
linking the correct LLVM libraries for you. LLDB standalone builds are totally
fine without this.

In the best case, having this line here is harmless. In the worst case it can
cause link issues.

If you build lldb-server for android using the standalone build, this line
will cause LLVM_LIBRARY_DIR to be the first place you look for libraries.
This is an issue because if you built libc++, it will try to link against
that one instead of the one from the android NDK.  Meanwhile, the LLVM libraries
you're linking against were linked against the libc++ from the NDK.

Ideally, we would take advantage of the AFTER option for link_directories(), but
that was not available in LLDB's minimum supported version of CMake (CMake 3.4.3).

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

llvm-svn: 357817
2019-04-05 21:01:50 +00:00
Jonas Devlieghere 944c20c05b [Test] Remove no_debug_info_test decorator from Obj-C data formatters.
As discussed in https://reviews.llvm.org/D60300.

llvm-svn: 357813
2019-04-05 20:37:52 +00:00
Jonas Devlieghere ab5471cfe2 Add .noindex to the gitignore
The .noindex suffix is used on macOS to prevent Spotlight from indexing
its contents. These folders contain test output from dotest.py and
should be ignored when dotest is run from the LLDB source directory.

llvm-svn: 357787
2019-04-05 17:57:42 +00:00
Jonas Devlieghere ff75262f70 [testsuite] Split Objective-C data formatter
The testcase for objective-c data formatters is very big as it checks a
bunch of stuff. This is annoying when using the lit test driver, because
it prevents us from running the different cases in parallel. As a
result, it's always one of the last few tests that complete. This patch
splits the test into multiple files that share a common base class. This
way lit can run the different tests in parallel.

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

llvm-svn: 357786
2019-04-05 17:57:40 +00:00
Pavel Labath 78a514bf9d modify-python-lldb.py: Insert initialization code with swig instead
This is the last functional change to the generated python module being
done by modify-python-lldb.py. The remaining code just deals with
reformatting of comments.

llvm-svn: 357755
2019-04-05 09:56:55 +00:00
Pavel Labath 98edcd9b9c MinidumpParser: use minidump parser in llvm/Object
This patch removes the lower layers of the minidump parsing code from
the MinidumpParser class, and replaces it with the minidump parser in
llvm.

Not all functionality is already avaiable in the llvm class, but it is
enough for us to be able to stop enumerating streams manually, and rely
on the minidump directory parsing code from the llvm class.

This also removes some checked-in binaries which were used to test error
handling in the parser, as the error handling is now done (and tested)
in llvm. Instead I just add one test that ensures we correctly propagate
the errors reported by the llvm parser. The input for this test can be
written in yaml instead of a checked-in binary.

llvm-svn: 357748
2019-04-05 07:56:39 +00:00
Pavel Labath 546bccf61c TestVCCode_step: replace assertTrue with more specific assertions
When this test fails (flakes) all we get is an error message like "False
is not True". This replaces patterns like assertTrue(a == b) with
assertEqual(a, b), so we get a better error message (and hopefully a
hint as to why the test is flaky).

llvm-svn: 357747
2019-04-05 07:56:26 +00:00
Pavel Labath 94cd066763 PDBFPO: Use references instead of pointers, where possible
Summary:
The code was passing pointers around, expecting they would be not null.
In c++ it is possible to convey this notion explicitly by using a
reference instead.

Not all uses of pointers could be converted to references (e.g. one
can't store references in a container), but this will at least make it
locally obvious that code is dealing with nonnull pointers.

Reviewers: aleksandr.urakov, amccarth

Subscribers: lldb-commits

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

llvm-svn: 357744
2019-04-05 07:28:52 +00:00
Pavel Labath dfaafbcf4c Breakpad: Refine record classification code
Previously we would classify all STACK records into a single bucket.
This is not really helpful, because there are three distinct types of
records beginning with the token "STACK" (STACK CFI INIT, STACK CFI,
STACK WIN). To be consistent with how we're treating other records, we
should classify these as three different record types.

It also implements the logic to put "STACK CFI INIT" and "STACK CFI"
records into the same "section" of the breakpad file, as they are meant
to be read together (similar to how FUNC and LINE records are treated).

The code which performs actual parsing of these records will come in a
separate patch.

llvm-svn: 357691
2019-04-04 13:23:25 +00:00
Pavel Labath e090389c4a modify-python-lldb.py: (Re)move __len__ and __iter__ support
Summary:
This patch moves the modify-python-lldb code for adding new functions to
the SBModule class into the SBModule interface file. As this is the last
class using this functionality, I also remove all support for this kind
of modifications from modify-python-lldb.py.

Reviewers: amccarth, clayborg, jingham

Subscribers: zturner, lldb-commits

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

llvm-svn: 357680
2019-04-04 10:13:59 +00:00
Jan Kratochvil d0157b3b07 Add dropped ManualDWARFIndex assert()
D47253 dropped this assertion.

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

llvm-svn: 357678
2019-04-04 09:24:02 +00:00
Reid Kleckner e10d00419a [codeview] Remove Type member from CVRecord
Summary:
Now CVType and CVSymbol are effectively type-safe wrappers around
ArrayRef<uint8_t>. Make the kind() accessor load it from the
RecordPrefix, which is the same for types and symbols.

Reviewers: zturner, aganea

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 357658
2019-04-04 00:28:48 +00:00
Stella Stamenova e51c12430f Un-xfail one of the TestMiniDumpUUID tests on Windows
The test is passing on Windows and the windows bot is failing because of the unexpected pass

llvm-svn: 357641
2019-04-03 21:57:41 +00:00
Jonas Devlieghere 306809f292 [Reproducers] Capture return values of functions returning by ptr/ref
For some reason I had convinced myself that functions returning by
pointer or reference do not require recording their result. However,
after further considering I don't see how that could work, at least not
with the current implementation. Interestingly enough, the reproducer
instrumentation already (mostly) accounts for this, though the
lldb-instr tool did not.

This patch adds the missing macros and updates the lldb-instr tool.

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

llvm-svn: 357639
2019-04-03 21:31:22 +00:00