Commit Graph

6295 Commits

Author SHA1 Message Date
Jason Molenda 34549b8f75 Change the x86 assembly instruction unwind parser to
step through the complete function looking for any epilogue
instructions.  If we find an epilogue sequence, re-instate
the correct unwind instructions if there is more code past
that epilogue -- this will correctly handle an x86 function
with multiple epilogues in it.

NB there is still a bug with the "eh_frame augmented" 
UnwindPlans and mid-function epilogues.  Looking at that next.

<rdar://problem/18863406> 

llvm-svn: 225770
2015-01-13 06:04:04 +00:00
Zachary Turner 3e7442b676 Add support for character option types.
This will allow, in a subsequent patch, the addition of a global
setting that allows the user to specify a single character that
LLDB will recognize as an escape character when processing arg
strings to accomodate differences in Windows/non-Windows path
handling.

Differential Revision: http://reviews.llvm.org/D6887
Reviewed by: Jim Ingham

llvm-svn: 225694
2015-01-12 20:44:02 +00:00
Jason Molenda 9e6d12b98c Add RegisterNumber.cpp.
llvm-svn: 225585
2015-01-10 10:39:27 +00:00
Jason Molenda a05677126d Hoist the RegisterNumber class out of RegisterContextLLDB and make
it more generally available. 

Add checks to UnwindAssembly_x86::AugmentUnwindPlanFromCallSite() so
that it won't try to augment an UnwindPlan that already describes
the function epilogue.

Add a test case for backtracing out of _sigtramp on Darwin systems.
This could probably be adapted to test the same thing on linux/bsd but 
the function names of sigtramp and kill are probably platform
specific and I'm not sure what they should be.

llvm-svn: 225578
2015-01-10 04:01:03 +00:00
Greg Clayton f44404407f Respect the fact that the result object claims it doesn't want to be interactive by not forwarding STDIN to the python invocation when it isn't desired.
This fixes an issue of running "script" commands via SBDebugger::HandleCommand(...) and SBCommandInterpreter::HandleCommand(...) deadlocking Xcode.

<rdar://problem/18075038>

llvm-svn: 225567
2015-01-10 00:42:12 +00:00
Zachary Turner f16ae603e8 Fix issues with LLDB's interpreter and MS ABI guard variables.
MS ABI guard variables end with @4IA, so this patch teaches the
interpreter about that.  Additionally, there was an issue with
TurnGuardLoadIntoZero which was causing some guard uses of a
variable to be missed.  This fixes that by calling
Instruction::replaceAllUsesWith() instead of trying to replicate
that function.

llvm-svn: 225547
2015-01-09 21:12:22 +00:00
Zachary Turner 898e10e4d3 Change int32_t to uint32_t to fix warnings.
Variable was being declared as signed, but treated as unsigned at
every point of use.

Patch by Dan Sinclair
Differential Revision: http://reviews.llvm.org/D6897

llvm-svn: 225540
2015-01-09 20:15:21 +00:00
Zachary Turner 225cc30afe Change auto to size_t to fix warning.
Patch by Dan Sinclair
Differential Revision: http://reviews.llvm.org/D6899

llvm-svn: 225539
2015-01-09 20:15:03 +00:00
Enrico Granata 3f7f2077c3 Make the list of synthetic children thread safe
I have been seeing a few crashes where LLDB tries to acquire a cached synthetic child by index, and crashes in the ClusterManager obtaining a shared_ptr for that ValueObject
That kind of crash most often means that I am holding on to a raw pointer to a ValueObject that was let go from the cluster

The main way that could happen is that the synthetic provider is being updated at the same time that some child is being accessed from the previous provider state

This fixes the problem by making the children be stored in a thread-safe map

Fixes rdar://18627964

llvm-svn: 225538
2015-01-09 19:47:45 +00:00
Greg Clayton b547278cae Fixed an issue where you couldn't delete a user defined regex, python, or multi-word command by adding a new "command delete" command.
This new command will delete user defined regular commands, but not aliases. We still have "command unalias" to remove aliases as they are currently in different buckets. Appropriate error messages are displayed to inform the user when "command unalias" is used on removable user defined commands that points users to the "command delete" command.

Added a test to verify we can remove user defined commands and also verify that "command unalias" fails when used on a user defined command.
<rdar://problem/18248300>

llvm-svn: 225535
2015-01-09 19:08:20 +00:00
Enrico Granata 9aa7e8e9ff Dynamic values have been around (and stable and reliable) for long enough that we can turn them on by default
Change the default of prefer-dynamic-value to eDynamicDontRunTarget (i.e. enable dynamic values, but do not run code to do so)

Of course, disable this for the test suite, since testing no-dynamic-values is actually valuable

Fixes rdar://17363061

llvm-svn: 225486
2015-01-09 00:47:24 +00:00
Enrico Granata 20c321caf8 This patch fixes my think-o in ValueObject::UpdateValueIfNeeded() about the right thing to assert()
It also comes with a (rudimentary) test case that gets itself in a failed update scenario, and checks that we don't crash
This is the easiest case I could think of that forces the failed update case Zachary was seeing

llvm-svn: 225463
2015-01-08 19:11:43 +00:00
Mohit K. Bhakkad c9335a3f22 [LLDB][MIPS] Adding SoftwareBreakpointTrapOpcode and RelocationJumpSlotType for MIPS
Patch by Bhushan Attarde

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: petarj, dsanders, mohit.bhakkad, lldb-commits

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

llvm-svn: 225436
2015-01-08 09:46:29 +00:00
Jason Molenda 4535ecb1f3 Have AssemblyParse_x86::get_non_call_site_unwind_plan track
which registers have been spilled (saved to the stack) - and
if we see that same register being saved to the stack again,
don't record that, it's something specific to this stack frame.

I found a code sequence for i386 where clang did a push %esi
and then later in the function it did movl %esi, -0x7c(%ebp)
and that second save of a scratch value overrode the original
push location.

<rdar://problem/19171178> 

llvm-svn: 225431
2015-01-08 06:41:12 +00:00
Jason Molenda 341f0e6ee0 Rearrange RegisterContextLLDB::SavedLocationForRegister a tiny bit
so that we will use the UnwindPlan's rule for providing the stack
pointer BEFORE we use the trick of using the callee's CFA address
as the stack pointer.  When we're in a _sigtramp frame, the CFA of
the _sigtramp stack frame is not the same as the stack pointer value
when the async interrupt occurred -- we need to use the eh_frame
rules for retrieving the correct value.

<rdar://problem/18913548> 

llvm-svn: 225427
2015-01-08 03:57:48 +00:00
Enrico Granata 1a4d078583 Fix a problem where a ValueObject could fail to update itself, but since it was previously valid, we'd have an old checksum to compare aginst no new checksum (because failure to update), and assert() and die. Fix the problem by only caring about this assertion logic if updates succeed
llvm-svn: 225418
2015-01-08 00:29:12 +00:00
Oleksiy Vyalov 0ddd41cd2d Make DynamicLoaderPOSIXDYLD::DidAttach to deduce a target executable by pid if no executable hasn't been assigned to a target so far.
http://reviews.llvm.org/D6740

llvm-svn: 225332
2015-01-07 01:28:37 +00:00
Vince Harron 3218c0fb94 Adds UriParser::Parse and unit tests
This can be used to parse URIs passed to 'platform connect'

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

llvm-svn: 225317
2015-01-06 23:38:24 +00:00
Greg Clayton 009597d048 Fix needed for the new terminal test I previously checked in. It was crashing due to a NULL dereference.
llvm-svn: 225316
2015-01-06 23:33:34 +00:00
Ed Maste b8602af602 Put FreeBSD note types in their own namespace
Note types are inherently OS-specific, but some note type names are
common to both FreeBSD and Linux. 

llvm-svn: 225299
2015-01-06 22:13:48 +00:00
Zachary Turner c8761f4807 Remove a lock acquisition from ProcessWindows::OnExitProcess.
This was causing a race condition where DoDestroy() would acquire
the lock and then initiate a shutdown and then wait for it to
complete.  But part of the shutdown involved acquiring the same
lock from a different thread.  So the main thread would timeout
waiting for the shutdown to complete and return too soon.

The end result of this is that SBProcess::Kill() was broken on
Windows.

llvm-svn: 225297
2015-01-06 20:56:12 +00:00
Greg Clayton ad7aa8147a More fixes to ensure if we are asked to launch a x86_64h process on darwin, that darwin-debug knows what to do and how to handle it.
llvm-svn: 225225
2015-01-06 00:25:18 +00:00
Greg Clayton 62f24e97bd Fix being able to get a thread result when calling HostThreadPosix::Join(). It was broken when initially checked in by getting the thread result into a temporary variable and never doing anything with it. Most threads in LLDB don't look at their thread results, but launching processes in a terminal window on MacOSX does require getting a thread result and this broke "process launch --tty" on darwin.
<rdar://problem/19308966>

llvm-svn: 225224
2015-01-06 00:21:29 +00:00
Siva Chandra 89ce955a32 Make array symbol reading resilient to incomplete DWARF.
Summary:
GCC emits DW_TAG_subrange_type for static member arrays, but with no
attributes. This in turn results in wrong type/value of the array when
printing with 'target variable <array var name>'. This patch fixes this
so that the array value is printed in this format:

    (<element type> []) <array var name> = {}

Earlier, the array was being interpreted to be of its element type.

Note: This does not fix anything to do with 'expr' or 'p' commands.
Those commands still error out complaining about incomplete types.

Test Plan: dotest.py -p TestStaticVariables

Reviewers: emaste, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 225219
2015-01-05 23:06:14 +00:00
Andy Gibbs 3acfe1a3d9 Fix trivial signed/unsigned comparison warnings
llvm-svn: 224932
2014-12-29 13:03:19 +00:00
Chandler Carruth 875d3bb538 [cmake/multilib] Teach LLDB to respect the multlib LLVM_LIBDIR_SUFFIX
variable (now provided both by the normal parent LLVM CMake files and by
the LLVMConfig.cmake file used by the standalone build).

This allows LLDB to build into and install into correctly suffixed
libdirs. This is especially significant for LLDB because the python
extension building done by CMake directly uses multilib suffixes when
the host OS does, and the host OS will not always look back and forth
between them. As a consequence, before LLVM, Clang, and LLDB (and every
other subproject) had support for using LLVM_LIBDIR_SUFFIX, you couldn't
build or install LLDB on a multilib system with its python extensions
enabled. With this patch (on top of all the others I have submitted
throughout the project), I'm finally able to build and install LLDB on
my system with Python support enabled. I'm also able to actually run the
LLDB test suite, etc. Now, a *huge* number of the tests still fail on my
Linux system, but hey, actually running them and them testing the
debugger is a huge step forward. =D

llvm-svn: 224930
2014-12-29 12:42:33 +00:00
Jason Molenda 19ba9fbf27 Add support for frameless function compact unwind encodings on x86_64/i386.
This completes the compact unwind support for x86 targets.  

I'm still skipping the UNWIND_X86_64_MODE_STACK_IND encodings for
x86_64 right now because clang was emitting bad data for this form
until it was fixed in r217020 circa Sep 2014.

arm64 parsing still needs to be added.

llvm-svn: 224698
2014-12-22 11:02:02 +00:00
Jason Molenda 5c45c541a2 Various unwinder work.
Most of the changes are to the FuncUnwinders class -- as we've added
more types of unwind information, the way this class was written was
making it a mess to maintain.  Instead of trying to keep one
"non-call site" unwind plan and one "call site" unwind plan, track
all the different types of unwind plans we can possibly retrieve for
each function and have the call-site/non-call-site accessor methods
retrieve those.

Add a real "fast unwind plan" for x86_64 / i386 -- when doing an
unwind through a function, this only has to read the first 4 bytes 
to tell if the function has a standard prologue sequence.  If so, 
we can use the architecture default unwind plan to backtrace 
through this function.  If we try to retrieve the save location for
other registers later on, a real unwind plan will be used.  This
one is just for doing fast backtraces.

Change the compact unwind plan importer to fill in the valid address
range it is valid for. 

Compact unwind, in theory, may have multiple entries for a single
function.  The FuncUnwinders rewrite includes the start of supporting
this correctly.  In practice compact unwind encodings are used for
the entire range of the function today -- in fact, sometimes the same
encoding is used for multiple functions that have the same unwind
rules.  But I want to handle a single function that has multiple
different compact unwind UnwindPlans eventually.

llvm-svn: 224689
2014-12-21 10:44:54 +00:00
Jason Molenda b12a136cdd Re-enable compact unwind use on Mac platforms.
When lldb has a binary with protected section contents,
don't use the on-disk representation of that compact 
uwnind -- read it only out of live memory where it has
been decrypted.

llvm-svn: 224670
2014-12-20 03:12:51 +00:00
Enrico Granata 7863991945 Cleanup some redundant code
llvm-svn: 224659
2014-12-20 01:41:27 +00:00
Oleksiy Vyalov ec8f582aec No need to call SetErrorToErrno when pipe2 succeeds.
http://reviews.llvm.org/D6743

llvm-svn: 224652
2014-12-19 23:52:46 +00:00
Jim Ingham 4aeb19893b Don't emit the "WARNING: no locations" message when breakpoints are set in
the dummy target.  Say they were set in the dummy target instead.

llvm-svn: 224606
2014-12-19 19:45:31 +00:00
Jim Ingham 4af5961caa Audit uses of ConstString::AsCString() to make sure they weren't assuming
they would always get a non-NULL string back.

<rdar://problem/19298575>

llvm-svn: 224602
2014-12-19 19:20:44 +00:00
Greg Clayton 3a95b5bce2 Fixed an issue that could cause GetPointeeData() to fail when passing in a non-zero index.
The issue was we had a global variable that was a pointer, and the address type of the children wasn't "load address" when it needed to be. Full details are in the comments of the changes.

<rdar://problem/15107937>

llvm-svn: 224559
2014-12-19 01:28:42 +00:00
Stephane Sezer b743a8034f Display local kernel version only when non-remote in PlatformLinux.
Summary:
This is part of the Linux remote platform work. Displaying the local
kernel information when remote debugging doesn't make sense, so we
should verify if we are in host mode before doing so.

Test Plan:
Connect to a remote linux platform mode daemon with `platform select
remote-linux` followed by `platform connect ...`, and look at the output
of `platform status`.

Reviewers: tfiala, clayborg, vharron, compnerd

Subscribers: lldb-commits

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

llvm-svn: 224540
2014-12-18 20:24:32 +00:00
Enrico Granata da04fbb535 We don't really handle printing embedded NULs in strings, but if we were to, we would need to have this logic inside the StringPrinter. So, add it.. For, you know, one day in the future where we might want to handle embedded NULs in strings...
llvm-svn: 224537
2014-12-18 19:43:29 +00:00
Zachary Turner 7ae4b6de1d Only compile RegisterContextWindows_x86.cpp for x86 host architecture.
This fixes compilation failures in the 64-bit build of LLDB on Windows.

Patch by Aidan Dodds

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

llvm-svn: 224528
2014-12-18 18:21:33 +00:00
Eric Christopher c9d1c27d48 Fix a format string warning by noting that StringIsBreakpointName
will set the error accordingly and so there's no need to set it
again.

llvm-svn: 224468
2014-12-17 22:26:32 +00:00
Eric Christopher f70824428e Fix initialization order to match that of the source.
llvm-svn: 224467
2014-12-17 22:25:37 +00:00
Enrico Granata 972be53f02 Provide CreateValueFromData,Expression at the SBTarget level as well as the SBValue level; and also make all the implenentations agree on using the matching ValueObject::Create instead of doing code copypastas
llvm-svn: 224460
2014-12-17 21:18:43 +00:00
Zachary Turner 0b9d3eefdb Enhance the Pipe interface for better portability.
This patch makes a number of improvements to the Pipe interface.

1) An interface (PipeBase) is provided which exposes pure virtual
   methods for any implementation of Pipe to override.  While not
   strictly necessary, this helps catch errors where the interfaces
   are out of sync.

2) All methods return lldb_private::Error instead of returning bool
   or void.  This allows richer error information to be propagated
   up to LLDB.

3) A new ReadWithTimeout() method is exposed in the base class and
   implemented on Windows.

4) Support for both named and anonymous pipes is exposed through the
   base interface and implemented on Windows.  For creating a new
   pipe, both named and anonymous pipes are supported, and for
   opening an existing pipe, only named pipes are supported.

New methods described in points #3 and #4 are stubbed out on posix,
but fully implemented on Windows.  These should be implemented by
someone on the linux / mac / bsd side.

Reviewed by: Greg Clayton, Oleksiy Vyalov
Differential Revision: http://reviews.llvm.org/D6686

llvm-svn: 224442
2014-12-17 18:02:19 +00:00
Jim Ingham 5e09c8c32c Add the ability to tag one or more breakpoints with a name. These
names can then be used in place of breakpoint id's or breakpoint id 
ranges in all the commands that operate on breakpoints.

<rdar://problem/10103959>

llvm-svn: 224392
2014-12-16 23:40:14 +00:00
Enrico Granata 395939a483 Improve the performance of the libc++ std::map formatter. This is not the full solution to the slowness of this formatter, but it's a 5% improvement in our testcase performance, which I am not going to complain too hard about.
llvm-svn: 224373
2014-12-16 21:28:16 +00:00
Enrico Granata b476743726 In C++, it's #include not #import
llvm-svn: 224352
2014-12-16 19:10:37 +00:00
Jason Molenda 0f479da711 Temporarily disable CompactUnwindInfo::GetCompactUnwindInfoForFunction.
The compact unwind importer is getting the wrong unwind info for one
case that I found.  I haven't been able to fix the problem tonight 
and I don't want to leave TOT behaving incorrectly, so just ignore
compact unwind until I can get to the bottom of this.

llvm-svn: 224321
2014-12-16 06:20:30 +00:00
Enrico Granata 3cfc49f5e9 Instead of rolling our own, use the C++11 sanctioned solution
llvm-svn: 224310
2014-12-16 02:34:13 +00:00
Greg Clayton a2162b3166 If a binary was stripped we sometimes didn't show the ivars of an Objective C class correctly. Now we do as we consult the runtime data for the class so we don't have to have a symbol in the symbol table.
Fixed:
1 - try the symbol table symbol for an ObjC ivar and use it if available
2 - fall back to using the runtime data since it is slower to gather via memory read
3 - Fixed our hidden ivars test case to test this to ensure we don't regress
4 - split out a test case in the hidden ivars to cover only the part that was failing so we don't have an expected failure for all of the other content in the test.

<rdar://problem/18882687>

llvm-svn: 224306
2014-12-16 01:33:17 +00:00
Stephane Sezer f2ef94e770 Make the platform process connect path less chatty.
Summary:
If a stream contains an empty string, no need to append it to the output
(otherwise we end up with a blank line). Also, no need to print a status
message when the state changes to connected, as this string brings no
information -- "Process 0" does not mean anything to the user, and the
process being connected has no meaning either.

Test Plan:
Connect to a remote linux platform mode daemon with `platform select
remote-linux` followed by `platform connect ...`, create a target and
run it, observe the output. Also, run the full test suite (dosep.py).

Before:
    (lldb) [...] connect, etc.
    (lldb) r
    Process 0 connected

    Process 5635 launched: '/Users/sas/Source/test' (x86_64)
    Process 5635 stopped

After:
    (lldb) [...] connect, etc.
    (lldb) r
    Process 5635 launched: '/Users/sas/Source/test' (x86_64)
    Process 5635 stopped

Reviewers: tfiala, vharron, clayborg

Subscribers: lldb-commits

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

llvm-svn: 224188
2014-12-13 05:23:51 +00:00
Enrico Granata dd6d24b253 Move a bunch of method implementations over to the C++ file; remove the need for a few includes. All in all, good stuff
llvm-svn: 224174
2014-12-13 02:07:50 +00:00
Keno Fischer f4b170d0da SyntheticChildrenFrontEnd::* should also be built when python is disabled
Summary:
This moves
- SyntheticChildrenFrontEnd::CreateValueObjectFromExpression
- SyntheticChildrenFrontEnd::CreateValueObjectFromAddress
- SyntheticChildrenFrontEnd::CreateValueObjectFromData
outside the `#ifndef LLDB_DISABLE_PYTHON` since it doesn't seem to depend on python being available and indeed breaks the build when python is disabled.

Reviewers: granata.enrico

Subscribers: lldb-commits

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

llvm-svn: 224170
2014-12-13 00:05:58 +00:00