Commit Graph

14635 Commits

Author SHA1 Message Date
Greg Clayton 940f425a43 Add missing #include for linux.
<rdar://problem/25501013>

llvm-svn: 272445
2016-06-10 23:53:06 +00:00
Greg Clayton 88f86b60ca On MacOSX, the threads can appear out of order at times depending on the order in which the kernel returns thread IDs to debugserver. To avoid thread lists changing order between stops, ProcessGDBRemote now makes sure the thread list stays sorted by thread index ID.
<rdar://problem/25501013> 

llvm-svn: 272444
2016-06-10 23:23:34 +00:00
Greg Clayton 9e3ee13a1c Fixed C++ template integer parameter types to work correctly when the integer type is signed.
Prior to this we would display the typename for "TestObj<-1>" as "TestObj<4294967295>" when we showed the type. Expression parsing could also fail because we would fail to find the mangled name when evaluating expressions.

The issue was we were losing the signed'ness of the template integer parameter in DWARFASTParserClang.cpp.

<rdar://problem/25577041>

llvm-svn: 272434
2016-06-10 20:56:09 +00:00
Greg Clayton 6c42aa777e Fixed a few places that were building a regex from an identifier without escaping the identifier text.
<rdar://problem/26090553> 

llvm-svn: 272423
2016-06-10 20:09:33 +00:00
Jim Ingham b2e7d28ed6 SBThread also had some places where it got the ExecutionContext w/o
taking the API lock.

llvm-svn: 272407
2016-06-10 17:22:26 +00:00
Jim Ingham c481c7eeb4 Make all the SBFrame API's take the target lock.
For some reason, the conversion to taking the target lock when acquiring
the ExecutionContext was only done for some of the functions here. That was
allowing lock inversion in some complex uses.

<rdar://problem/26705635>

llvm-svn: 272354
2016-06-10 00:37:44 +00:00
Greg Clayton 4e26dd34a0 Fix "frame variable" to show all variables defined in functions and any contained lexical blocks, even if they are static variables.
For code like:

int g_global = 234;
int g_static = 345;
int main(int argc, char **argv)
{                     
    int a = 22333;
    static int g_int = 123;
    return g_global + g_static + g_int + a;
}


If we stop at the "return" statement, we expect to see "argc", "argv", "a" and "g_int" when we type "frame variable" since "g_int" is a locally defined static variable, but we don't expect to see "g_global" or "g_static" unless we add the -g option to "frame variable".

llvm-svn: 272348
2016-06-09 23:56:12 +00:00
Pavel Labath b519f9fa61 Enable some tests on linux
This enables a couple of tests which have been shown to run reliably on the
linux x86 buildbot. If you see a failure after this commit, feel free to add
the xfail back, but please make it as specific as possible (i.e., try to make
it not cover i386/x86_64 with clang-3.5, clang-3.9 or gcc-4.9).

llvm-svn: 272326
2016-06-09 22:39:36 +00:00
Greg Clayton 60adaf5394 Fixed an issue in the ProcessMachCore where segments are not always contiguous in mach-o core files. We have core files that have segments like:
Address    Size       File off   File size
           ---------- ---------- ---------- ----------
LC_SEGMENT 0x000f6000 0x00001000 0x1d509ee8 0x00001000 --- ---   0 0x00000000 __TEXT
LC_SEGMENT 0x0f600000 0x00100000 0x1d50aee8 0x00100000 --- ---   0 0x00000000 __TEXT
LC_SEGMENT 0x000f7000 0x00001000 0x1d60aee8 0x00001000 --- ---   0 0x00000000 __TEXT

Any if the user executes the following command:

(lldb) mem read 0xf6ff0

We would attempt to read 32 bytes from 0xf6ff0 but would only get 16 unless we loop through consecutive memory ranges that are contiguous in the address space, but not in the file data.   
                          
This fixes the ProcessMachCore::DoReadMemory() to do the right thing.

<rdar://problem/19729287> 

llvm-svn: 272322
2016-06-09 22:26:49 +00:00
Sean Callanan b37674dca0 Fixed a problem in IRMemoryMap where the flag to zero out memory was ignored.
llvm-svn: 272320
2016-06-09 22:22:40 +00:00
Sean Callanan f3df7e86b4 Updated the FindSpace() algorithm to avoid the 0 page when it's unsafe.
Previously we eliminated the randomized scheme for finding memory when the
underlying process cannot allocate memory, and replaced it with an algorithm
that starts the allocations at 00x.

This was more determinstic, but runs into problems on embedded targets where the
pages near 0x0 are in fact interesting memory.  To deal with those cases, this
patch does two things:

- It makes the default fallback be an address that is less likely than 0x0 to
  contain interesting information.

- Before falling back to this, it adds an algorithm that consults the
  GetMemoryRegionInfo() API to see if it can find an unmapped area.

This should eliminate the randomness (and unpredictable memory accesseas) of the
previous scheme while making expressions more likely to return correct results.

<rdar://problem/25545573>

llvm-svn: 272301
2016-06-09 20:22:25 +00:00
Greg Clayton 3efb6b290b Fix a no newline at end of file warning.
llvm-svn: 272284
2016-06-09 18:06:09 +00:00
Greg Clayton 00b385e3a5 Some core files on MacOSX don't have permissions setup correctly on the LC_SEGMENT load commands. Assume read + execute if the permissions are not set.
<rdar://problem/26720522> 

llvm-svn: 272281
2016-06-09 17:52:02 +00:00
Greg Clayton 3385fa08bf Since our expression parser needs to locate areas of memory that are not in use when you have a process that can't JIT code, like core file debugging, the core file process plug-ins should be able to override the Process::GetMemoryRegionInfo(...) function.
In order to make this happen, I have added permissions to sections so that we can know what the permissions are for a given section, and modified both core file plug-ins to override Process::GetMemoryRegionInfo() and answer things correctly.

llvm-svn: 272276
2016-06-09 16:34:06 +00:00
Jim Ingham 19e88c1ff6 Add a test for the failure described by pr28055. Mark it as xfail.
llvm-svn: 272189
2016-06-08 19:06:00 +00:00
Jim Ingham 203451742f Revive the error message from "process load" and SBProcess::LoadImage.
IsPointedCString has problems with ValueObjects of type eTypeHostAddress.  We should
figure out the right thing to do in that case, but the test is silly here because we're
reading a type we've defined, so we know it is a const char *, and if the memory is good, 
we won't be able to read any characters, when we do ReadPointedString.

<rdar://problem/26612812>

llvm-svn: 272087
2016-06-08 01:29:21 +00:00
Greg Clayton 32c940de37 Now that there are no cycles that cause leaks in the disassembler/instruction classes, we can get rid of the FIXME lines that were working around this issue.
<rdar://problem/26684190>

llvm-svn: 272071
2016-06-07 23:19:00 +00:00
Greg Clayton 4a9d83a55e Fix a memory leak in InstructionLLVMC where it held onto a strong reference to the DisassemblerLLVMC which in turn had a vector of InstructionSP causing the strong cycle. This is fixed now.
Rules are as follows for internal code using lldb::DisassemblerSP and lldb::InstructionSP:
1 - The disassembler needs to stay around as long as instructions do as the Instruction subclass now has a weak pointer to the disassembler
2 - The public API has been fixed so that if you get a SBInstruction, it will hold onto a strong reference to the disassembler in a new InstructionImpl class

This will keep code like like: 

inst = lldb.target.ReadInstructions(frame.GetPCAddress(), 1).GetInstructionAtIndex(0)
inst.GetMnemonic()

Working as expected (not the SBInstructionList() that was returned by SBTarget.ReadInstructions() is gone, but "inst" has a strong reference inside of it to the disassembler and the instruction.
                                                     
All code inside the LLDB shared library was verified to correctly hold onto the disassembler instance in all places.

<rdar://problem/24585496>

llvm-svn: 272069
2016-06-07 22:56:40 +00:00
Pavel Labath f0f62d8451 Revert "Make lldbinline.py regenerate the Makefile each time it builds."
This reverts commit r272024 as it is not windows-compatible.

llvm-svn: 272062
2016-06-07 21:29:46 +00:00
Pavel Labath 5de59348fe Don't use SO_REUSEADDR for *client* sockets
Summary:
In the case of client sockets, we are not binding to a specific port, so we
should be able to just request a new one. Disregarding refactors, this code
has been here since the initial LLDB checkin, so I was unable to figure out
whether it was added as a fix for a specific problem, or just for symmetry
with server sockets, but I see no side-effect from removing it now. I was
still able to create 10000 connections within a couple of seconds, so I think
it's unlikely we will exhaust the port space (previously, I would get an
error after a couple thousand connections).

This fixes an occasional issue with connecting to the android debug bridge
deamon on OSX when running the test suite, which would occasionaly fail with
EADDRINUSE. My best guess is that this was happening because two processes
were assigned the same client port number, and then things blew up because
they were both trying to connect to the same ADB server port. I have not
observed this issue happening on Linux or Windows.

Reviewers: clayborg

Subscribers: tberghammer, danalbert, lldb-commits

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

llvm-svn: 272041
2016-06-07 18:36:38 +00:00
Greg Clayton c11e249bfd LLDB is leaking memory in Editline.cpp on MacOSX.
When USE_SETUPTERM_WORKAROUND is enabled, we were calling setupterm() multiple times and leaking memory on each subsequent call. This is now fixed by calling setupterm() once in the constructor and tracking if we have already setup a terminal for a file descriptor.

Calls to "el_set (m_editline, EL_ADDFN, ..." were leaking memory. If we switch over to call el_wset with wide strings when LLDB_EDITLINE_USE_WCHAR is set, then we no longer leak memory each time we construct a new Editline object.

The calls to "el_set (m_editline, EL_ADDFN, ..." were changed over to call "el_wset (m_editline, EL_ADDFN, ...". Note that when LLDB_EDITLINE_USE_WCHAR is not defined, then el_wset is #define'ed to el_set. All strings are wrapped in EditLineConstString which will use wide strings when needed, and normal C strings when LLDB_EDITLINE_USE_WCHAR is not defined.

<rdar://problem/26677627>

llvm-svn: 272036
2016-06-07 18:16:39 +00:00
Sean Callanan 968bb72f58 Make lldbinline.py regenerate the Makefile each time it builds.
If a lldbinline test's source file changed language, then the Makefile wasn't
updated.  This was a problem if the Makefile was checked into the repository.

Now lldbinline.py always regenerates the Makefile and asserts if the
newly-generated version is not the same as the one already there.  This ensures
that the repository will never be out of date without a buildbot failing.

http://reviews.llvm.org/D21032

llvm-svn: 272024
2016-06-07 17:22:18 +00:00
Jason Molenda c7afda5a09 Add support for using armv7 compact unwind information
as an asynchronous unwind plan source.

Two small fixes to the compact unwind dumper tool for
armv7 encodings.

A change to DWARFCallFrameInfo to strip the 0th bit on
addresses in eh_frame sections when armv7.  In the 
clang generated examples I have, the 0th bit is set for
thumb functions and that's causing the unwinder to pick
the wrong function for eh_frame info.

llvm-svn: 271970
2016-06-07 02:19:54 +00:00
Francis Ricci 80dbd154fa Don't remove PIE executables when using svr4 packets
Summary:
Because PIE executables have an e_type of llvm::ELF::ET_DYN,
they are not of type eTypeExecutable, and were being removed
when svr4 packets were used.

Reviewers: clayborg, ADodds, tfiala, sas

Subscribers: lldb-commits

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

llvm-svn: 271899
2016-06-06 15:00:50 +00:00
Carlo Kok 490d18b3c5 (Minor tweak) Make RegisterContextWindows_x86/x64::GetRegisterInfoAtIndex
return NULL for an invalid register.

The unwind logic asks for the "return address register" which doesn't exist
on x86/x86_64, returns -1 and calls this with -1 as a parameter, ends up 
out of scope of the array bounds for g_register_infos and later SIGSEGVs 
on accessing. This now matches the other GetRegisterInfoAtIndex for
other platforms.

llvm-svn: 271876
2016-06-06 09:40:27 +00:00
Stephane Sezer 04a89fd826 Fix function name lookup in IRExecutionEngine.cpp.
Summary:
Without this commit, when `log enable lldb expr` is enabled, the
disassembly of JIT'ed code is never displayed.

Reviewers: spyffe, clayborg

Subscribers: lldb-commits

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

llvm-svn: 271863
2016-06-06 02:50:46 +00:00
Jason Molenda 159ccb49b3 Add armv7 compact unwind printing to the compact-unwind-dumper.c tool
as a prototype for adding armv7 compact unwind reading to lldb.

llvm-svn: 271774
2016-06-04 04:10:15 +00:00
Greg Clayton 6e85115272 Fix a printf warning.
llvm-svn: 271716
2016-06-03 19:45:05 +00:00
Greg Clayton 73cc4c4ced Add support in debug LLDB builds (if LLDB_CONFIGURATION_DEBUG is defined) where we can set an environment variable named LLDB_DWARF_DONT_COMPLETE_TYPENAMES that can contain one or more typenames separated by ';' characters. This will cause us to not complete any types whose names match and can help us to try and reproduce issues we see in bugs.
So you can launch LLDB with the environment variable:

% LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo;Bar;Baz lldb

llvm-svn: 271696
2016-06-03 17:59:26 +00:00
Tamas Berghammer 50ce381a5c Fix makefile for TestExternCSymbols
llvm-svn: 271618
2016-06-03 01:03:04 +00:00
Sean Callanan 34ab28a470 Fixed a problem where we couldn't call extern "C" functions.
Some compilers do not mark up C++ functions as extern "C" in the DWARF, so LLDB
has to fall back (if it is about to give up finding a symbol) to using the base
name of the function.

This fix also ensures that we search by full name rather than "auto," which
could cause unrelated C++ names to be found.  Finally, it adds a test case.

<rdar://problem/25094302>

llvm-svn: 271551
2016-06-02 17:59:47 +00:00
Greg Clayton 218b3b9ac5 LLDB needs to be able to handle DW_AT_GNU_dwo_name that are relative to the DW_AT_comp_dir when using -gmodules with DWARF in .o files on darwin.
<rdar://problem/26590227> 

llvm-svn: 271545
2016-06-02 17:22:42 +00:00
Greg Clayton 93c99cf059 Fixed a problem where -gmodules debug info would be loaded by the DWO file support accidentally and cause 1000s of files to be mapped into LLDB's address space for each .o file that reference a module.
<rdar://problem/26580266> -gmodules causes LLDB.framework to map hundreds of copies of the same .pcm file

llvm-svn: 271543
2016-06-02 17:19:39 +00:00
Tamas Berghammer 858aba0666 Fix JavaArraySyntheticFrontEnd for non-reference ValueObject.
Summary: Fix missing return after checking that m_backend is not a pointer or reference type.

Reviewers: clayborg, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 271453
2016-06-02 00:45:38 +00:00
Devin Coughlin a10ab76b16 [tsan] Prefer mangled name looking up variable declaration for racy address
For Thread Sanitizer reports, LLDB tries to find a global variable declaration
corresponding to the racy address in order to provide a filename and line
number. This commit changes the lookup of the variable to use the mangled
name for lookup and fall back to the demangled version if unavailable. This
is needed to report locations of races on Swift global variables.

I've also added a test to make sure we look up C++ globals correctly.

rdar://problem/26459401

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

llvm-svn: 271433
2016-06-01 21:32:45 +00:00
Greg Clayton 892fa7dbcb Add more verification on consectutive bitfields otherwise clang will assert.
We need to verify that consecutive bitfields have higher offsets and don't overlap. The issues was found by running a broken version of recent clangs where the bitfield offsets were being emitted incorrectly. To guard against this we now verify and toss out any invalid bitfields and print a message that indicates to file a bug against the compiler.

<rdar://problem/25737621>

llvm-svn: 271343
2016-05-31 22:29:56 +00:00
Chris Bieneman c12cabb4f4 [CMake] Update to requiring CMake 3.4.3
Summary:
This is as per the discussions on developer lists:

http://lists.llvm.org/pipermail/llvm-dev/2016-April/098780.html
http://lists.llvm.org/pipermail/llvm-dev/2016-May/100058.html

Subscribers: lldb-commits

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

llvm-svn: 271328
2016-05-31 20:21:44 +00:00
Todd Fiala 7aa4d977ea Implement ProcessInfo::Dump(), log gdb-remote stub launch
This change implements dumping the executable, triple,
args and environment when using ProcessInfo::Dump().

It also tweaks the way Args::Dump() works so that it prints
a configurable label rather than argv[{index}]={value}. By
default it behaves the same, but if the Dump() method with
the additional arg is provided, it can be overridden. The
environment variables dumped as part of ProcessInfo::Dump()
make use of that.

lldb-server has been modified to dump the gdb-remote stub's
ProcessInfo before launching if the "gdb-remote process" channel
is logged.

llvm-svn: 271312
2016-05-31 18:32:20 +00:00
Cameron Desrochers 64f6c6644e [LLDB] Make sure that indexing is done before clearing DIE info
"ClearDIEs()" was being called too soon, before everyone was done using the DIEs.

This fix delays the calls to ::ClearDIEs() until all compile units have been indexed.

1 - Call "::ExtractDIEsIfNeeded()" on all compile units on separate threads. See if each CU has the DIEs parsed and remember this.
2 - Index all compile units on separate threads.
3 - Clear any DIEs in any compile units that didn't have their DIEs parsed after all compile units have been indexed.

Patch by phlav

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

llvm-svn: 271209
2016-05-30 15:32:51 +00:00
Todd Fiala 873a2ab4be fix up lldb-server platform on Apple hosts
r259714 introduces the transport method into the
URL passed to the gdb-remote stub.  On debugserver,
this is not supported and prevented debugserver from
being launched by lldb-server in platform mode.

This change skips the transport method addition from
r259714 when on Apple hosts.

llvm-svn: 270961
2016-05-27 04:04:52 +00:00
Greg Clayton 4141c7af82 Add a new "lldb" log channel named "demangle". If we have crashes that are related to demangling, we now can enable this logging and we will be able to reproduce demangler crashes (usually due to overflowing the stack) without needing someone's project.
<rdar://problem/25221899>                                                                     

llvm-svn: 270941
2016-05-27 00:17:18 +00:00
Jim Ingham 1cf8f5937a Lock the access to the BreakpointLocationCollection.
I was investigating an odd crash in lldb when the breakpoint site
goes to bump the hit counts of the locations it implements.  I noticed
that the BreakpointLocationCollection wasn't locking itself for access and
modification.  I don't see how that can cause the crash I'm seeing, but still
this is the right thing to do...

<rdar://problem/25178205>

llvm-svn: 270939
2016-05-26 23:55:04 +00:00
Jim Ingham 13683c65cd Don't cache the stret/vrs. non-stret code pointer as static data in the runtime.
It belongs in the instance, since then when you change architectures it can be adjusted
appropriately.

<rdar://problem/26308079>

llvm-svn: 270938
2016-05-26 23:49:49 +00:00
Greg Clayton ceeb521127 With -gmodules, we have been having a harder time always finding a type when we need one.
We have seen cases where we have been unable to find an argument type for a function, or we find one from another language, and then we try to create a function type by calling:

lldb_private::ClangASTContext::CreateFunctionType(clang::ASTContext*, lldb_private::CompilerType const&, lldb_private::CompilerType const*, unsigned int, bool, unsigned int)

This fix will ensure that all arguments to lldb_private::ClangASTContext::CreateFunctionType() are in order by checking:
- AST is valid
- if arguments are specified we have a valid argument array
- return type is valid
- return type is a clang type
- all argument types are valid
- all argument types are clang types

If any of these fail, we return an invalid CompilerType. If we don't return an invalid type, clang will crash anyway, and LLDB must not crash even in the presence of bad or missing debug info.

<rdar://problem/25172715>

llvm-svn: 270932
2016-05-26 22:33:25 +00:00
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
Pavel Labath a0adeb69ab [cmake] Remove the LLDB versions of the exception-controlling variables
Summary:
One can still use the LLVM variables to control this: LLVM_ENABLE_EH, LLVM_ENABLE_RTTI. It's not
clear to me why one would want to control these at lldb level and it's generally not even a good
idea to compile parts of the same binary with different values of these flags.

Reviewers: zturner, tfiala

Subscribers: lldb-commits

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

llvm-svn: 270863
2016-05-26 16:11:04 +00:00
Pavel Labath 95d6c7731c [cmake] Add a big warning about a libstdc++ issue
Summary:
Recent increase in the usage of std::weak_ptr has caused us to rediscover an issue in libstdc++
versions prior to 4.9 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59656>, which make this class
unusable without exceptions in the presence of multiple threads. It's virtualy impossible to work
around this issue without implementing our own shared_ptr/weak_ptr substitutes, which does not
seem like a good idea.

Therefore, I am adding a big CMake warning which warns you about this issue if you're attempting
a to do a build which is suceptible to this problem and suggests possible alternatives. Right
now, nothing spectacular will happen if you ignore this warning (all the crashes I have seen
occur during process shutdown), but there's no guarantee the situation will not change in the
future.

Reviewers: tberghammer, tfiala, nitesh.jain, omjavaid, emaste, krytarowski

Subscribers: lldb-commits

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

llvm-svn: 270854
2016-05-26 15:16:11 +00:00
Todd Fiala 94eb010fe9 Add "-gmodules" support to the test suite.
This change adds the capability of building test inferiors
with the -gmodules flag to enable module debug info support.
Windows is excluded per @zturner.

Reviewers: granata.enrico, aprantl, zturner, labath

Subscribers: zturner, labath, lldb-commits

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

llvm-svn: 270848
2016-05-26 13:57:03 +00:00
Pavel Labath 23ef3695d4 [cmake] Add ability to customize (and skip) debugserver codesign
Summary:
This adds the ability to customize the debugserver codesign process via cmake cache variable. The
user can set the codesign indentity (with the default being the customary lldb_codesign), and if
the identity is set to a empty string, the codesign step is skipped completely.

We needed the last feature to enable building lldb on buildservers which do not have the right
certificates installed.

Reviewers: sas, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 270832
2016-05-26 08:38:10 +00:00