Commit Graph

14726 Commits

Author SHA1 Message Date
Jim Ingham 4ac8e93a4e Add an API to unwind from a hand-called expression.
This is just an SB API way of doing "thread return -x".
<rdar://problem/27110360>

llvm-svn: 274822
2016-07-08 02:12:05 +00:00
Greg Clayton 87c550324c Fix it so that we only grab the typedef from the module DWARF file if the type that is typedef'ed is a declaration. This fixes the following bugs:
<rdar://problem/26870890> [PR28156] TestWithModuleDebugging.py: failing on macOS
https://llvm.org/bugs/show_bug.cgi?id=27412
https://llvm.org/bugs/show_bug.cgi?id=28156

llvm-svn: 274809
2016-07-07 23:57:39 +00:00
Greg Clayton 19a21d62bf Fix DWARF 4 bitfield support in LLDB to support the DW_AT_data_bit_offset attribute.
<rdar://problem/26321896>

llvm-svn: 274788
2016-07-07 19:44:14 +00:00
Jim Ingham 3a45e03442 Check whether Sema::CreateBuiltinUnaryOp returns an empty result.
If it does, calling AddInitializerToDecl will crash, so we should
abort the result synthesis in this case.

<rdar://problem/27205383>

llvm-svn: 274787
2016-07-07 19:06:37 +00:00
Jim Ingham bed6779c7a Add an "experimental" setting to disable injecting local variables into expressions.
This feature was added to solve a lookup problem in expressions when local variables
shadow ivars.  That solution requires fully realizing all local variables to evaluate
any expression, and can cause significant performance problems when evaluating 
expressions in frames that have many complex locals.

Until we get a better solution, this setting mitigates the problem when you don't
have local variables that shadow ivars.

<rdar://problem/27226122>

llvm-svn: 274783
2016-07-07 18:25:48 +00:00
Luke Drummond 3db0491966 Respect ANDROID_SERIAL environment variable used by ADB
When multiple Android devices are attached, the default behaviour of ADB
is to resolve a device number based on the presence of ANDROID_SERIAL if
the serial number is not explicitly passed by the -s parameter. This patch
emulates that behaviour in lldb's ADB platform connector

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

llvm-svn: 274776
2016-07-07 18:02:44 +00:00
Pavel Labath ca92aed5dc [LLGS] Work around an adb bug on Android <=M
On android M it can happen that we get a ETXTBSY, when we try to launch the inferior. Sleeping
and retrying should help us get more stable results.

llvm-svn: 274763
2016-07-07 15:46:00 +00:00
Pavel Labath 613cce835f Bump up timeout in TestCallWithTimeout
remote targets need a bit more time to get their act together

llvm-svn: 274762
2016-07-07 15:45:57 +00:00
Ravitheja Addepally b3b972a5a8 Fix for PrintStackTraces
Summary:
The issue arises due to the wrong unwinder used for the first
stack frame, where the default unwinder returns erroneous frame
whereas the fallback would have given the correct frame had it
been used.
The following fix consists of two parts ->
 1) The first part changes the unwinding strategy, earlier the
    default unwinder was used to get 2 more stack frames and if it
    failed a fallback unwinder was used. Now we try to obtain as many
    frames (max 10) as we can get from default unwinder and also
    fallback unwinder and use the one that gives more number of frames.
    
 2) Normally unwindplans are assosciated with functions and the
    row to be used is obtained from the offset (obtained from the low_pc
    of the function symbol). Sometimes it may occur that the unwindplan
    is assosciated to the complete Elf section in which case the offset
    calculation would be wrong as the debugger uses the same offset originally
    obtained from the function symbol. Hence this offset is recalculated.

Reviewers: tberghammer, lldb-commits, labath, jasonmolenda

Subscribers: jingham

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

llvm-svn: 274750
2016-07-07 13:00:29 +00:00
Tamas Berghammer 130802b339 Try to fix the OSX build with old SDK after r274725
llvm-svn: 274743
2016-07-07 10:38:05 +00:00
Howard Hellyer ad00756301 Implement GetMemoryRegions() for Linux and Mac OSX core files.
Summary:
This patch fills in the implementation of GetMemoryRegions() on the Linux and Mac OS core file implementations of lldb_private::Process (ProcessElfCore::GetMemoryRegions and ProcessMachCore::GetMemoryRegions.) The GetMemoryRegions API was added under: http://reviews.llvm.org/D20565

The patch re-uses the m_core_range_infos list that was recently added to implement GetMemoryRegionInfo in both ProcessElfCore and ProcessMachCore to ensure the returned regions match the regions returned by Process::GetMemoryRegionInfo(addr_t load_addr, MemoryRegionInfo &region_info).

Reviewers: clayborg

Subscribers: labath, lldb-commits

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

llvm-svn: 274741
2016-07-07 08:21:28 +00:00
Jason Molenda df8aef434d debugserver will now report the minimum version load command
os name and version # from the mach-o binary as it scans the
header/load commands from memory and sends the details back
in the jGetLoadedDynamicLibrariesInfos response.  lldb isn't
using these fields yet but I have a suspicion I'm going to 
need them soon.

<rdar://problem/25251243> 

llvm-svn: 274725
2016-07-07 03:12:01 +00:00
Jason Molenda a2992311a2 Add support to debugserver for some new ways to interact with dyld
to find the solibs loaded in a process.  Support two new ways of
sending the jGetLoadedDynamicLibrariesInfos packet to debugserver
and add a new jGetSharedCacheInfo packet.  Update the documentation
for these packets as well.  The changes to lldb to use these will
be a separate commit.

<rdar://problem/25251243> 

llvm-svn: 274718
2016-07-07 01:09:23 +00:00
Greg Clayton df62e731ea "frame variable" and "target variable" shouldn't allow us to get the address of bitfields.
"frame variable" and "target variable" are trying to emulate the expression parser when doing things like:

(lldb) frame variable &my_struct.my_bitfield

And since the expression parser doesn't allow this, we shouldn't allow "frame variable" or "target variable" to succeed.

<rdar://problem/27208607> 

llvm-svn: 274703
2016-07-06 23:16:24 +00:00
Greg Clayton 12261ecae4 LLDB reads incorrect memory ranges when displaying bitfields when reading bits from file memory.
Bitfields were not correctly describing their offsets within the integer that they are contained within. If we had a bitfield like:

struct MyStruct {
  uint32_t a:8;
  uint32_t b:8;
};
        
ClangASTContext::GetChildCompilerTypeAtIndex would say that child a and b had the following values in their respective ValueObjectChild objects:

name byte-size bit-size bit-offset byte-offset-from-parent
==== ========= ======== ========== =======================
"a"  4         8        0          0
"b"  4         8        0          1

So if we had a "MyStruct" at address 0x1000, we would end up reading 4 bytes from 0x1000 for "a", and 4 bytes from 0x1001 for "b". The fix for this is to fix the "child_byte_offset" and "child_bitfield_bit_offset" values returned by ClangASTContext::GetChildCompilerTypeAtIndex() so that now the table looks like:

name byte-size bit-size bit-offset byte-offset-from-parent
==== ========= ======== ========== =======================
"a"  4         8        0          0
"b"  4         8        8          0

Then we don't run into a problem when reading data from a file's section info using "target variable" before running. It will also stop us from not being able to display a bitfield values if the bitfield is in the last bit of memory before an unmapped region. (Like if address 0x1004 was unmapped and unreadable in the example above, if we tried to read 4 bytes from 0x1001, the memory read would fail and we wouldn't be able to display "b").

<rdar://problem/27208225> 

llvm-svn: 274701
2016-07-06 23:11:13 +00:00
Jason Molenda 0ecfe44092 Enhance FuncUnwinders::GetUnwindPlanAtNonCallSite to detect when we
may be in a function that is non-ABI conformant, and the eh_frame
instructions correctly describe how to unwind out of this function,
but the assembly parsing / arch default unwind plans would be 
incorrect.

This is to address a problem that Ravitheja Addepally reported in
http://reviews.llvm.org/D21221 - I wanted to try handling the problem
with this approach which I think may be more generally helpful, 
Ravitheja tested it and said it solves the problem on Linux/FreeBSD.
Ravi has a test case in http://reviews.llvm.org/D21221 that will
be committed separately.

Thanks for all the help on this one, Ravi.

llvm-svn: 274700
2016-07-06 23:06:19 +00:00
Enrico Granata 14cb4f96a0 Fix the installation of the vector<bool> data formatters in order to restore functionality
llvm-svn: 274697
2016-07-06 22:35:34 +00:00
Enrico Granata 106aae5108 Because of our lifetime rules w.r.t. ValueObjects and ClusterManagers, synthetic children caching is a tricky area:
- if a synthetic child comes from the same hierarchy as its parent object, then it can't be cached by SharedPointer inside the synthetic provider, or it will cause a reference loop;
- but, if a synthetic child is made from whole cloth (e.g. from an expression, a memory region, ...), then it better be cached by SharedPointer, or it will be cleared out and cause an assert() to fail if used at a later point

For most cases of self-rooted synthetic children, we have a flag we set "IsSyntheticChildrenGenerated", but we were not using it to track caching. So, what ended up happening is each provider would set up its own cache, and if it got it wrong, a hard to diagnose crash would ensue

This patch fixes that by centralizing caching in ValueObjectSynthetic - if a provider returns a self-rooted child (as per the flag), then it gets cached centrally by the ValueObject itself
This cache is used only for lifetime management and not later retrieval of child values - a different cache handles that (because we might have a mix of self-rooted and properly nested child values for the same parent, we can't trivially use this lifetime cache for retrieval)

Fixes rdar://26480007

llvm-svn: 274683
2016-07-06 21:24:28 +00:00
Oleksiy Vyalov d6a143fcbf Fix ADB client disconnect issues.
http://reviews.llvm.org/D22029

llvm-svn: 274638
2016-07-06 17:02:42 +00:00
Tamas Berghammer dba6503a9b Add oat symbolization support for odex files
Differential revision: http://reviews.llvm.org/D22040

llvm-svn: 274635
2016-07-06 16:40:09 +00:00
Pavel Labath 0c4f01d44b [LLGS] Log more precise errors during inferior launch
Summary:
We are seeing infrequent failures to launch the inferior process on android. The failing call
seems to be execve(). This adds more logging to see the actual error reported by the call.

Reviewers: tberghammer

Subscribers: tberghammer, lldb-commits, danalbert

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

llvm-svn: 274624
2016-07-06 13:18:50 +00:00
Kuba Brecka c359d5ca08 In AddressSanitizer and ThreadSanitizer, let's explicitly set the language of the expression we're evaluating.
llvm-svn: 274621
2016-07-06 11:46:20 +00:00
Tamas Berghammer 9c6c8e9991 Add data formatter for libstdc++ shared_ptr and weak_ptr
Differential revision: http://reviews.llvm.org/D21984

llvm-svn: 274617
2016-07-06 09:50:00 +00:00
Oleksiy Vyalov 58dedd8144 Fix Linux build.
llvm-svn: 274594
2016-07-06 02:20:39 +00:00
Jim Ingham 8b57dcf829 Allows "experimental" settings that will either route to their containing
settings or raise no error if not found.

From time to time it is useful to add some setting to work around or enable
a transitory feature.  We've been reluctant to remove them later because then
we will break folks .lldbinit files.  With this change you can add an "experimental"
node to the settings.  If you later decide you want to keep the option, just move
it to the level that contained the "experimental" setting and it will still be
found.  Or just remove it - setting it will then silently fail and won't halt
the .lldbinit file execution.

llvm-svn: 274593
2016-07-06 01:27:33 +00:00
Greg Clayton ad2b63cbaa Warning about debugging optimized code was not happening without dSYMs. Now it works for DWARF in .o files on Darwin.
I changed "m_is_optimized" in lldb_private::CompileUnit over to be a lldb::LazyBool so that it can be set to eLazyBoolCalculate if it needs to be parsed later. With SymbolFileDWARFDebugMap, we don't actually open the DWARF in the .o files for each compile unit until later, and we can't tell if a compile unit is optimized ahead of time. So to avoid pulling in all .o right away just so we can answer the questions of "is this compile unit optimized" we defer it until a point where we will have the compile unit parsed.

<rdar://problem/26068360> 

llvm-svn: 274585
2016-07-05 23:01:20 +00:00
Sean Callanan 8ba1654d48 Fixed a bug where we report a single type multiple times in namespaces.
Also added a testcase.

<rdar://problem/22786569>

llvm-svn: 274580
2016-07-05 22:06:01 +00:00
Greg Clayton d458c4de36 Fix "lldb.SBProcess.is_stopped" and "lldb.SBProcess.is_running" to do the right thing.
https://llvm.org/bugs/show_bug.cgi?id=28428

llvm-svn: 274568
2016-07-05 18:19:43 +00:00
Pavel Labath 97ef14c64b Split TestTemplateIntegerArgs test into two
Summary:
One of the tests there does not work with gcc, so I'm spinning that off into a separate test, so
that we can XFAIL it with more granularity.

I am also renaming the test to reflect the fact that it no longer tests only integer arguments.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 274505
2016-07-04 13:49:46 +00:00
Tamas Berghammer c662533d05 Ignore oatdata and oatexec symbols more widely
These are artifical symbols inside android oat files without any value
for the user while causing a significant perfoamce hit inside the
unwinder. We were already ignoring it inside system@framework@boot.oat
bot they have to be ignored in every oat file. Considering that oat
files are only used on android this have no effect on any other
platfrom.

llvm-svn: 274500
2016-07-04 13:31:57 +00:00
Pavel Labath 140b8d1ecd Remove SIGPIPE handler in LLGS
It is sufficient to set the handeler to SIG_IGN, to get the desired behaviour. Also, the handler
calling a lot of signal-unsafe functions.

llvm-svn: 274499
2016-07-04 13:07:35 +00:00
Pavel Labath 7cf00d191a Enable test log collection from remote debug servers (take 2)
Summary:
This is a slightly reworked version of D16322, which I had reverted because it did not do what it
advertised. Differences from the previous version are:
- moved the code for cleaning up the remote working dir to a later point as it was removing the
  log file before we could get to it.
- specialised log downloading code for gdb-remote tests is not needed, as this will cover that
  use case as well.

Reviewers: tfiala

Subscribers: lldb-commits

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

llvm-svn: 274491
2016-07-04 09:59:45 +00:00
Pavel Labath abb79683bb Join TestTlsGlobal tests again and use the proper decorator
llvm-svn: 274490
2016-07-04 09:27:53 +00:00
Tamas Berghammer 4721a55e4d Fix the libc++ pretty printers for the android NDK
The libc++ shipped with the android NDK is shipped using a different
internal namespace then the upstream libc++ (__ndk1 vs. __1) to avoid
an ODR violation between the platform and the user application. This
change fixes our pretty printers to be able to work with the types
from the android NDK libc++.

Differential revision: http://reviews.llvm.org/D21680

llvm-svn: 274489
2016-07-04 09:13:10 +00:00
Tamas Berghammer 40aac2b8ae Fix ClangASTContext after some clang API changes
llvm-svn: 274488
2016-07-04 09:11:08 +00:00
Greg Clayton 591ff8376b Fixed thread local storage test case to run normally with no expected fail for Darwin, always skip on windows, and expected fail for all other OSs while mentioning the new bug I filed to track fixing TLS variables: https://llvm.org/bugs/show_bug.cgi?id=28392
llvm-svn: 274393
2016-07-01 22:33:13 +00:00
Greg Clayton c7bb34f6ec Thread local storage was already broken on Linux and the tests were passing because there was a dectorator:
@unittest2.expectedFailure("rdar://7796742")
    
Which was covering up the fact this was failing on linux and hexagon. I added back a decorator so we don't break any build bots.

llvm-svn: 274388
2016-07-01 21:25:20 +00:00
Greg Clayton 0ba05f1835 Revert fix that didn't work. I will need to debug this on linux to figure things out.
llvm-svn: 274377
2016-07-01 18:55:55 +00:00
Greg Clayton a89746907f Try to fix Ubuntu buildbots after I broke thread local variables with 274366.
llvm-svn: 274374
2016-07-01 18:22:01 +00:00
Greg Clayton 63a27afae3 Added support for thread local variables on all Apple OS variants.
We had support that assumed that thread local data for a variable could be determined solely from the module in which the variable exists. While this work for linux, it doesn't work for Apple OSs. The DWARF for thread local variables consists of location opcodes that do something like:

DW_OP_const8u (x)
DW_OP_form_tls_address

or 

DW_OP_const8u (x)
DW_OP_GNU_push_tls_address

The "x" is allowed to be anything that is needed to determine the location of the variable. For Linux "x" is the offset within the TLS data for a given executable (ModuleSP in LLDB). For Apple OS variants, it is the file address of the data structure that contains a pthread key that can be used with pthread_getspecific() and the offset needed. 

This fix passes the "x" along to the thread:

virtual lldb::addr_t
lldb_private::Thread::GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr);

Then this is passed along to the DynamicLoader::GetThreadLocalData():

virtual lldb::addr_t
lldb_private::DynamicLoader::GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr);

This allows each DynamicLoader plug-in do the right thing for the current OS.

The DynamicLoaderMacOSXDYLD was modified to be able to grab the pthread key from the data structure that is in memory and call "void *pthread_getspecific(pthread_key_t key)" to get the value of the thread local storage and it caches it per thread since it never changes.

I had to update the test case to access the thread local data before trying to print it as on Apple OS variants, thread locals are not available unless they have been accessed at least one by the current thread.

I also added a new lldb::ValueType named "eValueTypeVariableThreadLocal" so that we can ask SBValue objects for their ValueType and be able to tell when we have a thread local variable.

<rdar://problem/23308080>

llvm-svn: 274366
2016-07-01 17:17:23 +00:00
Francis Ricci 7f9fbec3e8 Skip TestDisassembleRawData when remote
Summary:
As this test will create a new target, it will cause all following tests
to fail when running in platform mode, if the new target does not match
the existing architecture (for example, x86 vs x86_64).

Reviewers: zturner, spyffe, clayborg

Subscribers: lldb-commits

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

llvm-svn: 274364
2016-07-01 16:47:44 +00:00
Adrian McCarthy 1341d4cde1 Fix for Windows builds.
llvm-svn: 274277
2016-06-30 20:55:50 +00:00
Oleksiy Vyalov 6e181cf341 Improve ADB utilization within Android platform.
http://reviews.llvm.org/D21770

llvm-svn: 274256
2016-06-30 18:10:27 +00:00
Sean Callanan 3696f86188 Removed the redundant "%d errors parsing expression" error. Nobody keeps score.
<rdar://problem/24306284>

llvm-svn: 274254
2016-06-30 18:00:32 +00:00
Omair Javaid fbfc7170fe Correct watchpoint size test failure on certain devices
I overlooked the possibility of certain targets translating increment statement into a read and write.
In this case we replace increment statement with an assignment.

llvm-svn: 274215
2016-06-30 07:09:46 +00:00
Enrico Granata 8ea99cd86f Add NSTaggedPointerString to the table of data formatters
Fixes rdar://27002512

llvm-svn: 274164
2016-06-29 21:00:18 +00:00
Enrico Granata dadf7b293d Validate the option index before trying to access an array element using it - OptionArgElement can potentially use negative indices to mean interesting, but non option, states
llvm-svn: 274159
2016-06-29 20:23:03 +00:00
Pavel Labath f17635375a Remove platform plugins from lldb-server
Summary:
This removes the last usage of Platform plugins in lldb-server -- it was used for launching child
processes, where it can be trivially replaced by Host::LaunchProces (as lldb-server is always
running on the host).

Removing platform plugins enables us to remove a lot of other unused code, which was pulled in as
a transitive dependency, and it reduces lldb-server size by 4%--9% (depending on build type and
architecture).

Reviewers: clayborg

Subscribers: tberghammer, danalbert, srhines, lldb-commits

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

llvm-svn: 274125
2016-06-29 13:58:27 +00:00
Sagar Thakur 067b6edc1f [LLDB][MIPS] Check if libatomic needs to be specified explicitly
Patch by Nitesh Jain.

Summary : The problem appears while linking liblldb.so. The class Address contain atomic variable m_offset. The loading and storing of variable is access via atomic_load_8 and atomic_store_8 functions. Some target fail to implicitly link libatomic, which cause undefine reference to atomic_store_8/atomic_load_8. This patch uses http://reviews.llvm.org/D20896 to check if libatomic need to be explicitly link.

Reviewed by labath.
Differential: D20464

llvm-svn: 274121
2016-06-29 12:30:18 +00:00
Pavel Labath 7cbd742e3b XFAIL tests which fail with gcc on linux
llvm-svn: 274116
2016-06-29 10:16:14 +00:00