Commit Graph

4640 Commits

Author SHA1 Message Date
Jan Kratochvil b14f1da23c Fix LLDB crash accessing unknown DW_FORM_* attributes
Current LLDB (that is without DWZ support) crashes accessing Fedora debug info:
READ of size 8 at 0x60200000ffc8 thread T0
    #0 in DWARFDebugInfoEntry::BuildAddressRangeTable(SymbolFileDWARF*, DWARFCompileUnit const*, DWARFDebugAranges*) const tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:1336

Greg Clayton: We will need a warning to be emitted in
SymbolFileDWARF::CalculateAbilities() stating we won't parse the DWARF due to
"unsupported DW_FORM value of 0x1f20".

Patch has been mostly written by Greg Clayton.

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

llvm-svn: 309581
2017-07-31 17:02:52 +00:00
Tamas Berghammer 15cf379519 Add support for base address entries in the .debug_ranges section
Summary:
Clang recently started to emit base address entries into the
.debug_ranges section to reduce the number of relocations needed. Lets
make sure LLDB can read them.

llvm-svn: 309554
2017-07-31 10:26:19 +00:00
Chris Bieneman 8c01cc54eb [CMake] Add checks for libcompression
This enables libcompression when available in the CMake build system.

llvm-svn: 309395
2017-07-28 15:39:51 +00:00
Nitesh Jain d055b8f808 [LLDB][MIPS] Fix emulation of Instruction for MIPS64R6 target.
Subscribers: jaydeep, bhushan, lldb-commits, slthakur
llvm-svn: 309250
2017-07-27 05:34:33 +00:00
Adrian Prantl 4b2113036d Improve the fix for PR33875 by not hardcoding the section name.
This is a follow-up to r308905.

llvm-svn: 309019
2017-07-25 20:12:25 +00:00
Greg Clayton ea5df1049b Don't allow .debug_types to be parsed as LLDB can crash when enums are not able to be found.
Differential Revision: https://reviews.llvm.org/D35734

llvm-svn: 308911
2017-07-24 18:40:33 +00:00
Adrian Prantl 8bbb130793 RFix PR33875 by distinguishing between DWO and clang modules.
This reapplies https://reviews.llvm.org/D35740 with a tweak to find
the section by name rather than type. Section types don't distinguish
between regular sections and their DWO counterparts.

llvm-svn: 308905
2017-07-24 18:06:39 +00:00
Adrian Prantl ed6f69c111 Revert "Fix PR33875 by distinguishing between DWO and clang modules"
This reverts commit r308850.

llvm-svn: 308851
2017-07-23 20:24:41 +00:00
Adrian Prantl 651166c2d2 Fix PR33875 by distinguishing between DWO and clang modules
The DWO handling code can get confused by clang modules which also use
skeleton CUs to point to the object file with the full debug
info. This patch detects whether an object is a "real" DWO or a clang
module and prevents LLDB from interpreting clang modules as DWO. This
fixes the regression in TestWithModuleDebugging.

http://llvm.org/bugs/show_bug.cgi?id=33875

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

llvm-svn: 308850
2017-07-23 17:59:07 +00:00
Saleem Abdulrasool f76e099ca7 silence a couple of -Wqual-cast warning from GCC (NFC)
Cast to `const uint8_t *` instead of `uint8_t *` to avoid the warning
from GCC.

  EmulationStateARM.cpp:206:34: warning: cast from type 'const void*' to type 'uint8_t* {aka unsigned char*}' casts away qualifiers [-Wcast-qual]

Cast to `const uint32_t *` and the explicitly cast away the const-ness
of the value.  This seems pretty sketchy as the `DataExtractor` holds a
const reference to the data.  However, this is no worse than before.

  ObjectFilePECOFF.cpp:540:78: warning: cast from type 'const uint8_t* {aka const unsigned char*}' to type 'uint32_t* {aka unsigned int*}' casts away qualifiers [-Wcast-qual]

llvm-svn: 308489
2017-07-19 15:46:21 +00:00
Pavel Labath f40f8fc415 Fix NetBSD/FreeBSD build after r308304
llvm-svn: 308307
2017-07-18 14:03:47 +00:00
Pavel Labath b6dbe9a99c Clean up lldb-types.h
Summary:
It defined a couple of types (condition_t) which we don't use anymore,
as we have c++11 goodies now. I remove these definitions.

Also it unnecessarily included a couple of headers which weren't
necessary for it's operation. I remove these, and place the includes in
the relevant files (usually .cpp, usually in Host code) which use them.
This allows us to reduce namespace pollution in most of the lldb files
which don't need the OS-specific definitions.

Reviewers: zturner, jingham

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 308304
2017-07-18 13:14:01 +00:00
Pavel Labath 4e138e1d8c Fix linux arm and mips builds broken by r308282
llvm-svn: 308292
2017-07-18 10:42:36 +00:00
Pavel Labath 82abefa4b1 Remove shared pointer from NativeProcessProtocol
Summary:
The usage of shared_from_this forces us to separate construction and
initialization phases, because shared_from_this() is not available in
the constructor (or destructor). The shared semantics are not necessary,
as we always have a clear owner of the native process class
(GDBRemoteCommunicationServerLLDB object). Even if we need shared
semantics in the future (which I think we should strongly avoid),
reverting this will not be necessary -- the owners can still easily
store the native process object in a shared pointer if they really want
to -- this just prevents the knowledge of that from leaking into the
class implementation.

After this a NativeThread object will hold a reference to the parent
process (instead of a weak_ptr) -- having a process instance always
available allows us to simplify some logic in this class (some of it was
already simplified because we were asserting that the process is
available, but this makes it obvious).

Reviewers: krytarowski, eugene, zturner

Subscribers: lldb-commits

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

llvm-svn: 308282
2017-07-18 09:24:48 +00:00
Eugene Zemtsov 20d28a168e Fixing LLDB build after refactoring of clang's MacroInfo
llvm-svn: 308219
2017-07-17 20:50:21 +00:00
Jim Ingham 055e65f0d4 Enable parsing C++ names generated by lambda functions.
https://reviews.llvm.org/D34911 from Weng Xuetian.

llvm-svn: 307944
2017-07-13 19:48:43 +00:00
Kuba Mracek b244c2bafe Upstreaming a patch from Github: When evaluation user expressions, ignore InstrumentationRuntime breakpoints. (#235)
llvm-svn: 307881
2017-07-13 04:35:27 +00:00
Ravitheja Addepally dab1d5f3cd Adding Support for Error Strings in Remote Packets
Summary:
This patch adds support for sending strings along with
error codes in the reply packets. The implementation is
based on the feedback recieved in the lldb-dev mailing
list. The patch also adds an extra packet for the client
to query if the server has the capability to provide
strings along with error replys.

Reviewers: labath, jingham, sas, lldb-commits, clayborg

Reviewed By: labath, clayborg

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

llvm-svn: 307768
2017-07-12 11:15:34 +00:00
Tim Hammerquist 95c003b96f switch on enum should be exhaustive and warning-free
Summary:
Testing the value of type_code against the closed enum TypeCodes
provides statically verifiable completeness of testing. However, one
branch assigns to type_code by casting directly from a masked integer
value. This is currently handled by adding a default: case after
checking each TypeCodes instance. This patch introduces a bool variable
containing the "default" state value, allowing the switch to be
exhaustive, protect against future instances not being handled in the
switch, and preserves the original logic.

This addresses the warning:
warning: default label in switch which covers all enumeration values
[-Wcovered-switch-default]

As an issue of maintainability, the bitmask on line 524 handles the
current values of TypeCodes enum, but this will be invalid if the enum
is extended. This patch does not address this, and a more closed
conversion from cfinfoa -> TypeCodes would help protect against this.

Reviewers: spyffe, lhames, sas

Reviewed By: sas

Subscribers: sas, lldb-commits

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

llvm-svn: 307712
2017-07-11 21:06:20 +00:00
Pavel Labath 21a365ba59 NativeProcessLinux: Fix handling of raise(SIGTRAP)
In NativeProcessLinux::MonitorSIGTRAP we were asserting that the si_code
value is one of the codes we know about. However, that list was very
incomplete -- for example, we were not handling SI_TKILL/SI_USER,
generated by raise(SIGTRAP). A cursory examination show there are at
least a dozen codes like these that an app can generate, and more can be
added at any point.

So, instead of trying to play catchup, I change the default behavior to
treat an unknown si_code like an ordinary signal. The only reason we
needed to inspect si_code in the first place is because
watchpoint/breakpoints are notified as SIGTRAP, but we already know
about those, and us starting to use a new debug event is far less likely
than somebody introducing a new non-debug event.

I add a test case to TestRaise to verify we are handling raise(SIGTRAP)
in an application properly.

llvm-svn: 307644
2017-07-11 10:38:40 +00:00
Pavel Labath 993f2a4299 NativeProcessLinux: Fix some compiler warnings
llvm-svn: 307636
2017-07-11 09:03:38 +00:00
Pavel Labath cc72ede081 [LLDB][ppc64le] Rename enums in AuxVector
Summary:
On linux on ppc64le some of the enums in AuxVector have the same name
as macros defined in the system.

Reviewers: mikesart, labath

Reviewed By: labath

Subscribers: joerg, gut, krytarowski, lldb-commits

Differential Revision: https://reviews.llvm.org/D35065
Patch by Bruno Rosa <bruno.rosa@eldorado.org.br>

llvm-svn: 307632
2017-07-11 08:39:44 +00:00
Zachary Turner ac43c1bb87 Don't access Python objects while not holding the GIL.
Patch by Tatyana Krasnukha
Differential Revision: https://reviews.llvm.org/D34942

llvm-svn: 307512
2017-07-09 23:32:15 +00:00
Kuba Mracek e21b03daea Update message that Main Thread Checker produces.
llvm-svn: 307464
2017-07-08 05:18:19 +00:00
Jason Molenda f62080451c The x86 instruction unwinder can be asked to disassemble non-instruction
blocks of memory, and if the final bytes of that block look like a long
x86 instruction, it can cause the llvm disassembler to read past the end
of the buffer.  Use the maximum allowed instruction length that we pass
to the llvm disassembler as a way to limit this to the size of the buffer.

An example of how to trigger this is when lldb does a function call, it
puts a breakpoint on the beginning of main() and uses that as the return
address from the function call.  When we stop at that location, lldb may
try to find the first frame up the stack.  Because this is on the first
instruction of a function, it will get the word-size value at the stack
pointer and assume that this was the caller's pc value.  But this is random
stack memory and could point to anything - an object in memory, something
in the data section, whatever.  And if we have a symbol for that thing,
we'll try to disassemble it.

This was leading to infrequent crashes in customer scenarios; figured out
what was happening with address sanitizer.

<rdar://problem/30463256> 

llvm-svn: 307454
2017-07-08 00:12:15 +00:00
Pavel Labath 96e600fcf5 Add a NativeProcessProtocol Factory class
Summary:
This replaces the static functions used for creating
NativeProcessProtocol instances with a factory pattern, and modernizes
the interface of the new class in the process -- I use llvm::Expected
instead of the Status+value combo. I also move some of the common code
(like the Delegate registration into the base class). The new
arrangement has multiple benefits:
- it removes the NativeProcess*** dependency from Process/gdb-remote
  (which for example means that liblldb no longer pulls in this code).
- it enables unit testing of the GDBRemoteCommunicationServerLLGS class
  (by providing a mock Native Process).
- serves as another example on how to use the llvm::Expected class (I
  couldn't get rid of the Initialize-type functions completely here
  because of the use of shared_from_this, but that's the next thing on
  my list here)

Tests still pass on Linux and I've made sure NetBSD compiles after this.

Reviewers: zturner, eugene, krytarowski

Subscribers: srhines, lldb-commits, mgorny

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

llvm-svn: 307390
2017-07-07 11:02:19 +00:00
Pavel Labath ef7aff507b Fix assorted compiler warnings (mismatched signedness and printf specifiers)
llvm-svn: 307161
2017-07-05 14:54:46 +00:00
Pavel Labath d37c946991 Fix "process load" on new android targets
Summary:
On older android targets, we needed a dlopen rename workaround to get
"process load" working. Since API 26 this is not required as the targets
have a proper libdl so with the function names one would expect.

To make this work I've had to remove the const qualifier from the
GetLibdlFunctionDeclarations function (as now the declarations can
depend on the connected target). Since I was already modifying the
prototype (and the lower levels were already converted to StringRef) I
took the oportunity to convert this function as well.

llvm-svn: 307160
2017-07-05 14:54:41 +00:00
Ravitheja Addepally f4ffae91cb Fixing warnings for unused variables and copy ellision
Summary:
The std::move was preventing copy ellision when compiled with
clang, the patch fixes the warning along with rearranging code
to remove unused variables warnings on Linux machines with
older perf_event interface.

Reviewers: labath, ted

Reviewed By: labath

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

llvm-svn: 307030
2017-07-03 15:07:36 +00:00
Pavel Labath c1a6b128c7 Use llvm::sys::RetryAfterSignal instead of a manual while errno!=EINTR loop
Reviewers: zturner, eugene, krytarowski

Subscribers: emaste, mgorny, lldb-commits

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

llvm-svn: 307009
2017-07-03 09:25:55 +00:00
Sean Callanan 48bccc9448 [Data formatters] Make NSSetM support both old- and new-style representation
NSSetM has two in-memory representations depending on what Foundation version is in use.
This patch separates the two.

rdar://33057292

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

llvm-svn: 306773
2017-06-30 00:39:17 +00:00
Tim Hammerquist 0a94072e4d Fix some type-based warnings
llvm-svn: 306765
2017-06-29 23:33:40 +00:00
Pavel Labath 480907248e Fix Mac build for the Timer move
llvm-svn: 306686
2017-06-29 15:24:38 +00:00
Pavel Labath 38d0632e6a Move Timer and TraceOptions from Core to Utility
Summary:
The classes have no dependencies, and they are used both by lldb and
lldb-server, so it makes sense for them to live in the lowest layers.

Reviewers: zturner, jingham

Subscribers: emaste, mgorny, lldb-commits

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

llvm-svn: 306682
2017-06-29 14:32:17 +00:00
Pavel Labath 8996346bba [UnwindAssembly/x86] Add support for "lea imm(%ebp), %esp" pattern
Summary:
The instruction pattern:
and $-16, %esp
sub $imm, %esp
...
lea imm(%ebp), %esp

appears when the compiler is realigning the stack (for example in
main(), or almost everywhere with -mstackrealign switch). The "and"
instruction is very difficult to model, but that's not necessary, as
these frames are always %ebp-based (the compiler also needs a way to
restore the original %esp). Therefore the plans we were generating for
these function were almost correct already. The only place we were doing
it wrong were the last instructions of the epilogue (usually just
"ret"), where we had to revert to %esp-based unwinding, as the %ebp had
been popped already.

This was wrong because our "distance of esp from cfa" counter had picked
up the "sub" instruction (and incremented the counter) but it had not
seen that the register was reset by the "lea" instruction.

This patch fixes that shortcoming, and adds a test for handling
functions like this.

I have not been able to tickle the compiler into producing a 64-bit
function with this pattern, but I don't see a reason why it couldn't
produce it, if it chose to, so I add a x86_64 test as well.

Reviewers: jasonmolenda, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 306666
2017-06-29 12:40:13 +00:00
Jason Molenda 7f5bd34b18 Fix two places in RegisterContextLLDB::InitializeNonZerothFrame where
I'm not running the saved pc through FixCodeAddress as soon as I should.

<rdar://problem/30686307> 

llvm-svn: 306634
2017-06-29 03:02:24 +00:00
Jason Molenda 43294c9f48 Change the ABI class to have a weak pointer to its Process;
some methods in the ABI need a Process to do their work.
Instead of passing it in as a one-off argument to those
methods, this patch puts it in the base class and the methods
can retrieve if it needed.

Note that ABI's are sometimes built without a Process 
(e.g. SBTarget::GetStackRedZoneSize) so it's entirely
possible that the process weak pointer will not be
able to reconsistitue into a strong pointer.

<rdar://problem/32526754> 

llvm-svn: 306633
2017-06-29 02:57:03 +00:00
Pavel Labath 3f2a08183f [DWARFCallFrameInfo] Add Type enum to differentiate eh/debug_frame sections
Summary:
instead of using a boolean to differentiate between the two section
types, use an enum to make the intent clearer.

I also remove the RegisterKind argument from the constructor, as this
can be deduced from the Type argument.

Reviewers: clayborg, jasonmolenda

Subscribers: lldb-commits

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

llvm-svn: 306521
2017-06-28 09:09:19 +00:00
Ravitheja Addepally 99e376956d Implementation of Intel(R) Processor Trace support for Linux
Summary:
This patch implements support for Intel(R) Processor Trace
in lldb server. The changes have support for
starting/stopping and reading the trace data. The code
is only available on Linux versions where the perf
attributes for aux buffers are available.

The patch also consists of Unit tests for testing the
core buffer reading function.

Reviewers: lldb-commits, labath, clayborg, zturner, tberghammer

Reviewed By: labath, clayborg

Subscribers: mgorny

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

llvm-svn: 306516
2017-06-28 07:58:31 +00:00
Pavel Labath f2a8bccf85 Move StructuredData from Core to Utility
Summary:
It had a dependency on StringConvert and file reading code, which is not
in Utility. I've replaced that code by equivalent llvm operations.

I've added a unit test to demonstrate that parsing a file still works.

Reviewers: zturner, jingham

Subscribers: kubamracek, mgorny, lldb-commits

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

llvm-svn: 306394
2017-06-27 10:45:31 +00:00
Pavel Labath 2a1c09fee9 Shorten sanitizer plugin names
Summary:
The new UndefinedBehaviorSanitizer plugin was breaking file path length
limits, because it's (fairly long name) appears multiple times in the
path. Cmake ends up putting the object file at path
tools/lldb/source/Plugins/InstrumentationRuntime/UndefinedBehaviorSanitizer/CMakeFiles/lldbPluginInstrumentationRuntimeUndefinedBehaviorSanitizer.dir/UndefinedBehaviorSanitizerRuntime.cpp.obj
which is 191 characters long and very dangerously close to the 260
character path limit on windows systems (also, just the include line for
that file was breaking the 80 character line limit).

This renames the sanitizer plugins to use shorter names (asan, ubsan,
tsan). I think this will still be quite understandable to everyone as
those are the names everyone uses to refer to them anyway.

Reviewers: zturner, kubamracek, jingham

Subscribers: lldb-commits, mgorny

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

llvm-svn: 306278
2017-06-26 08:13:22 +00:00
Sean Callanan f40da17288 Updated the NSArray and NSDictionary formatters to support new storage formats.
Also un-xfailed a testcase that was affected by this.  Thanks to Jason Molenda for the patch.

<rdar://problem/32827216>

llvm-svn: 306180
2017-06-23 23:15:03 +00:00
Mehdi Amini d16a6e32fb Fix typo: using && instead of & when evaluating a mask
Summary: Reported by coverity, I don't know how to provide a test.

Reviewers: zturner

Subscribers: lldb-commits, emaste

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

llvm-svn: 306134
2017-06-23 18:20:13 +00:00
Kamil Rytarowski 4bb744156b Correct syntax mistake hidden in assert(3)
wait_status cannot be compared with WaitStatus::Stop,
go for wait_status.type.

llvm-svn: 305794
2017-06-20 13:51:06 +00:00
Pavel Labath df1a0d1180 [linux] Change the way we load vdso pseudo-module
Summary:
This is basically a revert of D16107 and parts of D10800, which were
trying to get vdso loading working. They did this by implementing a
generic load-an-elf-file from memory approach, which is not correct,
since we cannot assume that an elf file is loaded in memory in full (it
usually isn't, as there's no need to load section headers for example).
This meant that we would read garbage instead of section sizes, and if
that garbage happened to be a large number, we would crash while trying
to allocate a buffer to accomodate the hypothetical section.

Instead of this, I add a bit of custom code to load the vdso to
DynamicLoaderPOSIXDYLD (which already needed to handle the vdso
specially). I determine the size of the memory to read using
Process::GetMemoryRegionInfo, which is information coming from the OS,
and cannot be forged by a malicious/misbehaving application.

Reviewers: eugene, clayborg

Subscribers: lldb-commits, ravitheja, tberghammer, emaste

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

llvm-svn: 305780
2017-06-20 08:11:47 +00:00
Sean Callanan 18b5d9268c Updated NSNumber formatter for new internal representation.
<rdar://problem/32780109>

llvm-svn: 305727
2017-06-19 18:32:22 +00:00
Pavel Labath 3508fc8cc5 Add pretty-printer for wait(2) statuses and modernize the code handling them
Summary:
A number of places were trying to decode the result of wait(). Add a simple
utility function that does that and a struct that encapsulates the
decoded result. Then also provide a pretty-printer for that class.

Reviewers: zturner, krytarowski, eugene

Subscribers: lldb-commits, mgorny

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

llvm-svn: 305689
2017-06-19 12:47:50 +00:00
Pavel Labath 9376007af7 Tweak SysV_arm64 function entry unwind plan
Summary:
The motivation for this is to make sure the first row of the plan
compares equal to the first row of a generic debug_frame unwind plan.
Right now, the code in FuncUnwinders::GetUnwindPlanAtNonCallSite
considers them unequal because they specify the return address in a
different way (SetReturnAddressRegister(LR) vs. an explicit PC=LR rule).
This means that FuncUnwinders would always choose the debug_frame unwind
plan, which is not correct, as that one is usually not correct at all
locations.

Right now this is basically a noop because we don't have parse any
debug_frame plans, but it fixes some test failures when merging D33504
in.

I have to say I don't understand the full implications of the switch to
SetReturnAddressRegister() way of doing things, but given that all of
our other unwind plans (eh_frame, instruction profiling) do it this way,
it sounds like the right thing to do.

Reviewers: tberghammer, jasonmolenda, omjavaid

Subscribers: aemerson, javed.absar, kristof.beyls, lldb-commits

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

llvm-svn: 305687
2017-06-19 12:39:34 +00:00
Kuba Mracek 3abb10268d Fix the CMake files for the new InstrumentationRuntime plugins.
llvm-svn: 305594
2017-06-16 21:18:28 +00:00
Kuba Mracek ef45d8bcd2 Upstreaming the UndefinedBehaviorSanitizerRuntime and MainThreadCheckerRuntime plugins.
llvm-svn: 305589
2017-06-16 20:59:08 +00:00