Commit Graph

8716 Commits

Author SHA1 Message Date
Greg Clayton 23c12ca922 Make sure that we succeed in starting a definition before we complete it and emit an error if we fail to start the definition.
ClangASTContext::StartTagDeclarationDefinition(...) was starting definitions for any TagType instances that have TagDecl, but ClangASTContext::CompleteTagDeclarationDefinition(...) was getting the type to a CXXRecordDecl with:

    clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
    
The problem is that getAsCXXRecordDecl() might dig a bit deeper into a type and dig out a different decl, which means we might call ClangASTContext::StartTagDeclarationDefinition(...), but it might not do anything, and then we might call ClangASTContext::CompleteTagDeclarationDefinition(...) and it might try to complete something that didn't have its definition started and this will crash.

This change fixes that, and also makes sure that starting a definition succeeds before any calls to ClangASTContext::CompleteTagDeclarationDefinition().
                                                    
<rdar://problem/24091798>

llvm-svn: 270891
2016-05-26 19:24:02 +00:00
Greg Clayton 6c42e06312 Guard against the C++ destructor chain by not letting the debugger list clean up after itself in the C++ destructor chain.
If users call "static void lldb::SBDebugger::Terminate()" we will clean up the debugger list, and users can individually destroy debugger instances with "static void lldb::SBDebugger::Destroy(SBDebugger &)". But if we let the C++ destructor chain tear down this list, other threads that might still be running as the main thread exits can now crash if they access the debugger list. We stop this by leaking the debugger list and its mutex.

<rdar://problem/26372169>

llvm-svn: 270869
2016-05-26 16:51:23 +00:00
Jason Molenda 0bc8994a4c Small further refinement to the check in ObjectFileMachO::ParseSymtab
which looks for binaries missing an LC_FUNCTION_STARTS section because
it was stripped/not emitted.  If we see a normal user process binary
(executable, dylib, framework, bundle) without LC_FUNCTION_STARTS, that
is unusual and we should disallow instruction emulation because that
binary has likely been stripped a lot.

If this is a non-user process binary -- a kernel, a standalone bare-board
binary, a kernel extension (kext) -- and there is no LC_FUNCTION_STARTS,
we should not assume anything about the binary and allow instruction
emulation as we would normally do.

<rdar://problem/26453952> 

llvm-svn: 270818
2016-05-26 04:22:47 +00:00
Greg Clayton a61d0a5b01 Make sure to try and take the process stop lock when calling:
uint32_t SBProcess::GetNumQueues();
SBQueue SBProcess::GetQueueAtIndex (size_t index);

Otherwise this code will run when the process is running and cause problems.

<rdar://problem/26482744>

llvm-svn: 270803
2016-05-26 00:08:39 +00:00
Enrico Granata fee0aba006 It has been brought to my attention that, given two variables
T x;
U y;

doing

x = *((T*)y)

is undefined behavior, even if sizeof(T) == sizeof(U), due to pointer aliasing rules

Fix up a couple of places in LLDB that were doing this, and transform them into a defined and safe memcpy() operation

Also, add a test case to ensure we didn't regress by doing this w.r.t. tagged pointer NSDate instances

llvm-svn: 270793
2016-05-25 23:19:01 +00:00
Enrico Granata acfe8fadaa Add logging to ValueObjectSyntheticFilter such that one can trace through the creation of synthetic children
llvm-svn: 270770
2016-05-25 21:38:32 +00:00
Enrico Granata f02be230f6 Fix an issue where LLDB would crash if one tried to 'frame variable' an unordered_map more than once in a stop due to the synthetic provider not properly caching the ValueObjects it was returning for the child elements
Fixes rdar://26470909

llvm-svn: 270752
2016-05-25 20:38:33 +00:00
Jason Molenda b667c20222 Add support for arm64 compact unwind tables, used on darwin arm64
systems (ios, tvos, watchos).  It's a simple format to use now that
I have i386/x86_64 supported already.

The unwind instructions are only valid at call sites -- that is,
when lldb is unwinding a frame in the middle of the stack.  It
cannot be used for the currently executing frame; it has no information
about prologues/epilogues/etc.

<rdar://problem/12062336> 

llvm-svn: 270658
2016-05-25 04:20:28 +00:00
Enrico Granata 34c77c3c93 Fix an issue where the NSDate data formatter was not using the proper alignment on watchOS targets
Fixes rdar://problem/23298264

llvm-svn: 270621
2016-05-24 22:11:57 +00:00
Jason Molenda 63294b730d Ach, editing too many files at once. Make this file compile again.
llvm-svn: 270620
2016-05-24 22:05:22 +00:00
Jason Molenda 94ddce2c0e In r268475 I made a change to ObjectFileMachO so that if it is
missing an LC_FUNCTION_STARTS section, we assume it has been
aggressively stripped (it is *very* unusual for anyone to strip
LC_FUNCTION_STARTS) so we disable assembly instruction unwind plan
creation.

Kernel extensions (kexts) don't have LC_FUNCTION_STARTS, but we
almost always have good symbol bounds just with the linker symbols.
So add an exception to allow assembly instruction unwind plan
creation for kexts even though they lack LC_FUNCTION_STARTS.

<rdar://problem/26453952> 

llvm-svn: 270618
2016-05-24 21:46:23 +00:00
Kuba Brecka 042975183e Reword the "Happened at" TSan-reported thread to contain a thread id.
llvm-svn: 270608
2016-05-24 20:35:28 +00:00
Jim Ingham 3cc425837d Lock out Process::RunThreadPlan so only one can be in flight at a time.
What with all sorts of folks (TSAN, ASAN, queue detection, etc...) trying to
gather info by calling functions down in the lower layers of lldb, we've started
to see people running expressions simultaneously.  The expression evaluation part
is okay, but only one RunThreadPlan can be active at a time.  I added a lock to
enforce that.

<rdar://problem/26431072>

llvm-svn: 270593
2016-05-24 18:29:36 +00:00
Francis Ricci 15a2165d64 Skip leading spaces when decoding hex values
Summary:
The StringExtractor functions using stroull will already
skip leading whitespace (ie GetU64). Make sure that the manual
hex parsing functions also skip leading whitespace.

This is important for members of the gdb protocol which are defined
as using whitespace separators (ie qfThreadInfo, qC, etc). While
lldb-server does not use the whitespace separators, gdb-remotes
should work if they do, as the whitespace is defined by the gdb-remote
protocol.

Reviewers: vharron, jasonmolenda, clayborg

Subscribers: sas, lldb-commits

Differential Revision: http://reviews.llvm.org/D20509

llvm-svn: 270592
2016-05-24 18:19:45 +00:00
Oleksiy Vyalov 3154e77795 Replace file system forbidden symbols in the hostname which passed to the ModuleCache.
http://reviews.llvm.org/D20548

llvm-svn: 270590
2016-05-24 18:09:05 +00:00
Kuba Brecka 6602e692ef Improve wording in TSan reports involving global variables. Don't repeat hex addresses that are the same.
llvm-svn: 270588
2016-05-24 17:47:23 +00:00
Pavel Labath 4f23d1e27c Add a missing include to ItaniumABILanguageRuntime.h
some (I'm not sure why only some, actually) implementations of std::map require the value type to
be a fully specified type when declaring then. This make sure TypeAndOrName is.

llvm-svn: 270570
2016-05-24 15:32:40 +00:00
Sagar Thakur ad5b55a277 [LLDB][MIPS] Fix floating point handling in case of thread step-out
Patch by Nitesh Jain.

Summary: These patch fix thread step-out for hard and soft float.

Reviewers: jaydeep, bhushan, clayborg
Differential Revision: http://reviews.llvm.org/D20416

llvm-svn: 270564
2016-05-24 14:52:50 +00:00
Greg Clayton c226778768 We have many radars showing that stepping through C++ code can result in slow steps.
One of the things slowing us down is that ItaniumABILanguageRuntime class doesn't cache vtable to types in a map. This causes us, on every step, for every variable, to read the first pointer in a C++ type that could be dynamic and lookup the symbol, possibly in every symbol file (some symbols files on Darwin can end up having thousands of .o files when using DWARF in .o files, so thousands of .o files are searched each time). 

This fix caches lldb_private::Address (the resolved vtable symbol address in section + offset format) to TypeAndOrName instances inside the one ItaniumABILanguageRuntime in a process. This allows caching of dynamic types and stops us from always doing deep searches in each file.

<rdar://problem/18890778>

llvm-svn: 270488
2016-05-23 20:37:24 +00:00
Sean Callanan 5ba3215fe3 Removed the m_decl_objects map from ClangASTContext.
m_decl_objects is problematic because it assumes that each VarDecl has a unique
variable associated with it.  This is not the case in inline contexts.

Also the information in this map can be reconstructed very easily without
maintaining the map.  The rest of the testsuite passes with this cange, and I've
added a testcase covering the inline contexts affected by this.

<rdar://problem/26278502>

llvm-svn: 270474
2016-05-23 18:30:59 +00:00
Enrico Granata 64c034da2b SBValue::CreateValueFromData didn’t check whether the SBType passed into it is in fact a valid type - this can lead to LLDB crashing upon access
Committing on behalf of Sebastian Theophil

llvm-svn: 270456
2016-05-23 17:11:14 +00:00
Saleem Abdulrasool 3b0bde2c2c SymbolFile: remove an unused variable
Address a -Wunused-but-set-variable warning from gcc.  NFC.

llvm-svn: 270377
2016-05-22 20:16:53 +00:00
Kuba Brecka 1a349b8d65 Reword ThreadSanitizer messages to use a lowercase 't' in thread names when in the middle of a sentence.
llvm-svn: 270365
2016-05-22 14:56:33 +00:00
Kuba Brecka 52ded8072a Reword ThreadSanitizer message for invalid mutex reports.
llvm-svn: 270364
2016-05-22 14:32:45 +00:00
Kuba Brecka 00d7c563d2 A better fix of incorrectly used locking in HistoryThread and HistoryUnwind.
llvm-svn: 270363
2016-05-22 14:19:11 +00:00
Kuba Brecka d9b228128b Revert r270358 ("Fix an incorrectly used locking in HistoryThread and HistoryUnwind").
llvm-svn: 270359
2016-05-22 14:05:28 +00:00
Kuba Brecka 7380f25d29 Fix an incorrectly used locking in HistoryThread and HistoryUnwind, where unique_lock's release() was called causing the mutex to stay locked.
llvm-svn: 270358
2016-05-22 12:24:38 +00:00
Greg Clayton 259d786065 Adopt mmap flags that allow mmap'ed memory to be less crash prone.
On Darwin if a mmap file is code signed and the code signature is invalid, it used to crash. If we specify the MAP_RESILIENT_CODESIGN mmap flag when mapping a file for reading, we can avoid crashing.

Another mmap flag named MAP_RESILIENT_MEDIA allows us to survive if we mmap files that are on removable media like network servers or removable hard drives. If a file was mapped and later the media that had the file became unavailable, we would crash when we would touch the next page that wasn't paged in. Now it will return zeroes and stop of from us from crashing.

<rdar://problem/25918698>

llvm-svn: 270254
2016-05-20 19:18:20 +00:00
Tamas Berghammer 216963a723 Revert rL270207: "[LLDB][MIPS] Fix floating point handling in case of thread step-out"
The CL causes a build breakage on platforms where sizeof(double) == sizeof(long double)
and it incorrectly assumes that sizeof(double) and sizeof(long double) is the same
on the host and the target.

llvm-svn: 270214
2016-05-20 13:07:16 +00:00
Sagar Thakur b189db627c [LLDB][MIPS] Fix Floating point Registers Encoding
Patch by Nitesh Jain.

Summary: Currently floating point regsiters has eEncodingUint encoding. Hence register write  '1.25' will failed. This patch add eEncodingIEEE754 encoding for floating point registers( - ). This patch will fix test_fp_register_write in TestRegisters.py

Reviewers: clayborg, sagar
Subscribers: mohit.bhakkad, jaydeep, bhushan, sdardis, lldb-commits
Differential: D18853
llvm-svn: 270208
2016-05-20 12:11:52 +00:00
Sagar Thakur 71b1decd72 [LLDB][MIPS] Fix floating point handling in case of thread step-out
Patch by Nitesh Jain.

Summary: These patch fix thread step-out for hard and soft float.

Reviewers: clayborg, bhushan, jaydeep
Subscribers: mohit.bhakkad, sagar, sdardis
Differential: D20416
llvm-svn: 270207
2016-05-20 12:07:27 +00:00
Jason Molenda 1ebb2c92f2 Some changes to prevent searching down the stack for saved register
values for the pc or return address register.

On ios with arm64 and a binary that has multiple functions without 
individual symbol boundaries, we end up with an assembly profile
unwind plan that says lr=<same> - that is, the link register contents
are unmodified from the caller's value.  This gets the unwinder in
a loop.  

When we're off the 0th frame, we never want to look to a caller for
a pc or return-address register value.

Add checks to ReadGPRValue and ReadRegister to prevent both the pc
and ra register values from recursing.

If this causes problems with backtraces on android, let me know or
back it out and I'll look into it -- but I think these are
straightforward and don't expect problems.

<rdar://problem/24610365> 

llvm-svn: 270162
2016-05-20 00:16:14 +00:00
Jim Ingham d9e02c4f3c Remove a should have been deleted extra assignment to a variable.
Also fix up the formatting a bit, it looks like something was inserting
actual tabs.  Replace with 4 spaces.

llvm-svn: 270148
2016-05-19 22:22:57 +00:00
Sean Callanan 37e2664f30 Fixed a crash if a FunctionDecl couldn't be imported.
llvm-svn: 270097
2016-05-19 19:23:37 +00:00
Bryan Chan 01319e93ab Avoid an assertion failure when a bit field is extracted from a value of the same size.
Summary: One of the cases handled by ValueObjectChild::UpdateValue() uses the entire width of the parent's scalar value as the size of the child, and extracts the child by calling Scalar::ExtractBitfield(). This seems valid but APInt::trunc(), APInt::sext() and APInt::zext() assert that the bit field must not have the same size as the parent scalar. Replacing those calls with sextOrTrunc(), zextOrTrunc(), sextOrSelf() and zextOrSelf() fixes the assertion failures.

Reviewers: uweigand, labath

Subscribers: labath, lldb-commits

Differential Revision: http://reviews.llvm.org/D20355

llvm-svn: 270062
2016-05-19 13:51:20 +00:00
Tamas Berghammer 87530300cd Fix build after rL270009
llvm-svn: 270040
2016-05-19 10:53:10 +00:00
Saleem Abdulrasool bb19a13c0b second pass over removal of Mutex and Condition
llvm-svn: 270024
2016-05-19 05:13:57 +00:00
Jim Ingham 906d91e762 Fix error propagation from the Z0 packet in gdb-remote breakpoint setting.
The error was not getting propagated to the caller, so the higher layers thought the breakpoint
was successfully set & resolved.

I added a testcase, but it assumes 0x0 is not a valid place to set a breakpoint.  On most systems
that is true, but if it isn't true of your system, either find another good place and add it to the
test, or x-fail the test.

<rdar://problem/26345962>

llvm-svn: 270014
2016-05-19 02:13:44 +00:00
Saleem Abdulrasool 16ff860469 remove use of Mutex in favour of std::{,recursive_}mutex
This is a pretty straightforward first pass over removing a number of uses of
Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there
are interfaces which take Mutex::Locker & to lock internal locks. This patch
cleans up most of the easy cases. The only non-trivial change is in
CommandObjectTarget.cpp where a Mutex::Locker was split into two.

llvm-svn: 269877
2016-05-18 01:59:10 +00:00
Greg Clayton 2920b36401 Make sure we notify that the section module was loaded when SBTarget::SetSectionLoadAddress() is called. Also make sure that the section module is unloaded when SBTarget::ClearSectionLoadAddress() or SBTarget::ClearModuleLoadAddress() is called.
<rdar://problem/25119335>

llvm-svn: 269707
2016-05-16 21:14:44 +00:00
Greg Clayton 58b794ae50 Don't crash when OS plug-in returns None from any of the functions we might call.
<rdar://problem/24489419>

llvm-svn: 269686
2016-05-16 20:07:38 +00:00
Enrico Granata 429e1f9b1d Make LLDB print out an explicit marker when it's displaying formatters that are part of a disabled category
Fixes rdar://26202006

llvm-svn: 269673
2016-05-16 17:27:26 +00:00
Pavel Labath 204ef66540 Bump up adb timeout more
still seeing very rare timeouts on the buildbot.

llvm-svn: 269648
2016-05-16 11:41:36 +00:00
Pavel Labath 57a77118ba Remove Mutex from NativeProcessLinux
NPL now assumes it is running from a single thread now, so its thread-safety is untested
anyway (and if that assumption is broken, we'll have bigger problems (due to ptrace restrictions)
than a couple of missing mutexes).

llvm-svn: 269640
2016-05-16 09:18:30 +00:00
Saleem Abdulrasool f431e683ee Symbol: fix -Wcovered-switch warning
Add the Float128 type to the enumeration.  Float128 is covered under IEEE754 as
a quad precision floating point value.

llvm-svn: 269599
2016-05-15 18:18:16 +00:00
Saleem Abdulrasool abdfc21a8f Fix a few -Wformat-pedantic warnings
Clean up some newly introduced -Wformat-pedantic warnings (%p expects a void *).

llvm-svn: 269598
2016-05-15 18:18:13 +00:00
Renato Golin 15cb0bd080 [LLDB] Adding lldb_private namespace to DiagnosticSeverity. NFC.
This is a fix due to the addition of the new DiagnosticSeverity in
LLVMContext.h. This may warrant a change in name to be LLDB specific
but I leave that to the LLDB experts to refactor.

llvm-svn: 269562
2016-05-14 13:14:39 +00:00
Zachary Turner 4fd6a96008 Clean up test results on Windows.
Remove XFAIL from some tests that now pass.
Add XFAIL to some tests that now fail.
Fix a crasher where a null pointer check isn't guarded.
Properly handle all types of errors in SymbolFilePDB.

llvm-svn: 269454
2016-05-13 18:26:30 +00:00
Ed Maste 718e2968f8 Disable HostThread::Cancel assertion on FreeBSD
It is still used by ProcessMonitor::StopMonitoringChildProcess and
ProcessMonitor::StopOpThread.

llvm-svn: 269434
2016-05-13 17:01:59 +00:00
Ed Maste d589a75595 Remove unused variable
llvm-svn: 269421
2016-05-13 14:49:38 +00:00