Commit Graph

6378 Commits

Author SHA1 Message Date
Enrico Granata 986fa5f4eb Extend ValueObject::GetExpressionPath() to do something reasonable for synthetic children
Because of the way they are created, synthetic children cannot (in general) have a sane expression path

A solution to this would be letting the parent front-end generate expression paths for its children
Doing so requires a significant amount of refactoring, and might not always lead to better results (esp. w.r.t. C++ templates)

This commit takes a simpler approach:
- if a synthetic child is of pointer type and it's a target pointer, then emit *((T)value)
- if a synthetic child is a non-pointer, but its location is in the target, then emit *((T*)loadAddr)
- if a synthetic child has a value, emit ((T)value)
- else, don't emit anything

Fixes rdar://18442386

llvm-svn: 223836
2014-12-09 21:41:16 +00:00
Sean Callanan 7375f3e30e Fixed ValueObject::UpdateValueIfNeeded to keep
track of the checksum of the object so we can
track if it is modified.  This fixes a testcase
(test/expression_command/issue_11588) on OS X.

Patch by Enrico Granata.

llvm-svn: 223830
2014-12-09 21:18:59 +00:00
Jason Molenda 28737d8db9 Change AddressSanitzierRuntime to print its info message via
the Debugger's output stream instead of logging to the module.

http://reviews.llvm.org/D6577

llvm-svn: 223826
2014-12-09 20:52:26 +00:00
Enrico Granata e29df230cd This patch does a few things:
- adds a new flag to mark ValueObjects as "synthetic children generated"
- vends new Create functions as part of the SyntheticChildrenFrontEnd that set the flag automatically
- moves synthetic child providers over to using these new functions

No visible feature change, but preparatory work for feature change

llvm-svn: 223819
2014-12-09 19:51:20 +00:00
Zachary Turner c8d9748c06 Create a valid stop info for all non-breakpoint exceptions.
llvm-svn: 223812
2014-12-09 19:13:50 +00:00
Stephane Sezer 8e6ec453f1 Implement remote process listing in Linux platform.
Summary:

Test Plan: Connect to a remote implementing the platform protocol (ds2 in this case), run `platform process list` and see processes being displayed.

Reviewers: vharron, tfiala, clayborg

Subscribers: lldb-commits

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

llvm-svn: 223752
2014-12-09 03:18:09 +00:00
Oleksiy Vyalov 53c038a581 Add Linux support for HostInfo::GetOSBuildString and HostInfo::GetOSKernelDescription.
llvm-svn: 223737
2014-12-09 02:13:05 +00:00
Enrico Granata 0c10a85000 Add the ability for an SBValue to create a persisted version of itself.
Such a persisted version is equivalent to evaluating the value via the expression evaluator, and holding on to the $n result of the expression, except this API can be used on SBValues that do not obviously come from an expression (e.g. are the result of a memory lookup)

Expose this via SBValue::Persist() in our public API layer, and ValueObject::Persist() in the lldb_private layer

Includes testcase

Fixes rdar://19136664

llvm-svn: 223711
2014-12-08 23:13:56 +00:00
Zachary Turner 270e99ab0a Fix some posix assumptions related to running shell commands.
This is a resubmit of r223548, which was reverted due to breaking
tests on Linux and Mac.

This resubmit fixes the reason for the revert by adding back some
accidentally removed code which appends -c to the command line
when running /bin/sh.

This resubmit also differs from the original patch in that it sets
the architecture on the ProcessLaunchInfo.  A follow-up patch will
refactor this to separate the logic for different platforms.

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

Reviewed By: Greg Clayton

llvm-svn: 223695
2014-12-08 21:36:42 +00:00
Zachary Turner 818a3676aa Remove use of GCC-style intrinsics, as they are non-portable.
Differential Revision: http://reviews.llvm.org/D6567

llvm-svn: 223687
2014-12-08 20:00:33 +00:00
Jason Molenda e589e7e336 The lldb unwinder can now use the unwind information from the compact-unwind
section for x86_64 and i386 targets on Darwin systems.  Currently only the
compact unwind encoding for normal frame-using functions is supported but it
will be easy handle frameless functions when I have a bit more free time to
test it.  The LSDA and personality routines for functions are also retrieved
correctly for functions from the compact unwind section.

This new code is very fresh -- it passes the lldb testsuite and I've done
by-hand inspection of many functions and am getting correct behavior for all
of them.  There may need to be some bug fixing over the next couple weeks as
I exercise and test it further.  But I think it's fine right now so I'm
committing it.

<rdar://problem/13220837> 

llvm-svn: 223625
2014-12-08 03:09:00 +00:00
Sean Callanan 957a872cb1 Fixed an unfortunate reversed conditional that
resulted in hard-to-track-down crashes.  Sigh.

llvm-svn: 223575
2014-12-06 02:31:49 +00:00
Kate Stone 641e9f8c69 Improvements to FastDemangler to correct parsing of <local-name> encodings for string literal and parameter/entity cases. Patch courtesy of slydiman.
llvm-svn: 223569
2014-12-06 01:42:41 +00:00
Jim Ingham 4623b9d3e2 Reverting r223548 which broke running in the shell on OS X.
llvm-svn: 223568
2014-12-06 01:41:10 +00:00
Jim Ingham 33df7cd345 Add the ability to set breakpoints with conditions, commands, etc,
in the "dummy-target".  The dummy target breakpoints prime all future
targets.  Breakpoints set before any target is created (e.g. breakpoints
in ~/.lldbinit) automatically get set in the dummy target.  You can also
list, add & delete breakpoints from the dummy target using the "-D" flag,
which is supported by most of the breakpoint commands.

This removes a long-standing wart in lldb...

<rdar://problem/10881487>

llvm-svn: 223565
2014-12-06 01:28:03 +00:00
Sean Callanan ceeb74e606 Now that we get types from modules, we occasionally
encounter clang::ExternalASTSources that are not instances
of ClangExternalASTSourceCommon.  We used to blithely
assume that all are, and so we could use static_cast<>.
That's no longer the case, so we have to have these AST
sources register themselves.

llvm-svn: 223560
2014-12-06 01:03:30 +00:00
Jim Ingham 67d7af9c34 Fix a type (MAX_PATH instead of PATH_MAX) and remove an unused variable.
llvm-svn: 223559
2014-12-06 01:03:17 +00:00
Sean Callanan 498ff1c1b8 Add new-lines after module compiler errors so
they are readable.

llvm-svn: 223557
2014-12-06 00:56:43 +00:00
Zachary Turner 00cdc98b7f Fix some posix assumptions related to running shell commands.
Differential Revision: http://reviews.llvm.org/D6553

Reviewed By: Greg Clayton

llvm-svn: 223548
2014-12-06 00:14:24 +00:00
Zachary Turner 22ac8711a5 Fix some uninitialized variables in ClangExpressionParser.
Reviewed by: Sean Callanan

llvm-svn: 223541
2014-12-05 22:54:56 +00:00
Enrico Granata 2f02fe0bd3 Add commands
type format info
type summary info
type synthetic info

These commands all take an expression, evaluate it, and show which of the respective formatter (if any) applies to the result of the expression

Fixes rdar://12059317

llvm-svn: 223511
2014-12-05 20:59:08 +00:00
Eric Christopher 73d15f2127 Fix a bunch of [-Werror,-Winconsistent-missing-override] warnings.
llvm-svn: 223501
2014-12-05 19:21:49 +00:00
Eric Christopher 3a078aefb6 Fix a few default label in switch which covers all
enumeration values [-Werror,-Wcovered-switch-default]
warnings.

llvm-svn: 223499
2014-12-05 19:09:02 +00:00
Zachary Turner 0a526eb855 Subtract the size of the breakpoint opcode from the PC when getting the bp site.
llvm-svn: 223498
2014-12-05 18:46:14 +00:00
Zachary Turner 301d184784 Load / unload modules in the target when the OS events occur.
This causes all deferred breakpoints to be correctly resolved as
the modules that they reside in are loaded.

llvm-svn: 223497
2014-12-05 18:46:04 +00:00
Zachary Turner cfd3b1ae6f Implement an empty DynamicLoader plugin for Windows.
llvm-svn: 223496
2014-12-05 18:45:53 +00:00
Zachary Turner b88ec656b5 Fix compilation errors after clang modules checkin.
llvm-svn: 223484
2014-12-05 17:38:20 +00:00
Sean Callanan 221262996a Added CMake support so all the Clang modules code
will at least be built by non-OS X builders. This
should head off some build breakage at the pass.

llvm-svn: 223437
2014-12-05 01:31:55 +00:00
Sean Callanan c8278afc9f Changes to the expression parser to actually use
the types that we find in Clang modules.

llvm-svn: 223436
2014-12-05 01:27:35 +00:00
Sean Callanan c631b64fab Additional changes required by r223433.
llvm-svn: 223435
2014-12-05 01:26:42 +00:00
Sean Callanan 9998acd004 This is the meat of the code to add Clang modules
support to LLDB.  It includes the following:

- Changed DeclVendor to TypeVendor.
- Made the ObjCLanguageRuntime provide a DeclVendor
  rather than a TypeVendor.
- Changed the consumers of TypeVendors to use
  DeclVendors instead.
- Provided a few convenience functions on
  ClangASTContext to make that easier.

llvm-svn: 223433
2014-12-05 01:21:59 +00:00
Sean Callanan 5dc2981cf8 Added support to Platform to indicate (1) whether the
current platform supports Clang modules, and (2) what
options to pass to Clang so it can load those Clang
modules.

llvm-svn: 223431
2014-12-05 01:16:31 +00:00
Sean Callanan b1e1c62fac Add support for embedding Clang compiler headers
like tgmath.h and stdarg.h into the LLDB installation,
and then finding them through the Host infrastructure.

Also add a script to actually do this on Mac OS X.

llvm-svn: 223430
2014-12-05 01:15:04 +00:00
Zachary Turner be5e1e5c9b Fix a minor error where I forgot to declare a variable.
llvm-svn: 223393
2014-12-04 22:07:02 +00:00
Zachary Turner 9b69327b43 Revert "Use timeout when reading debugserver's port from a named pipe."
This reverts commit 4a5ad2c077166cc3d6e7ab4cc6e3dcbbe922af86.

Windows doesn't support select() for pipe objects, and this also fails
to compile on Windows.  Reverting this until we can get it sorted out
to keep the windows build working.

llvm-svn: 223392
2014-12-04 22:06:42 +00:00
David Majnemer b313e46cc6 Revert "Fix a build breakage. Looks like the LLVM side of this change has been reverted"
This reverts commit r223375.  We need to use unique_ptr to build with
LLVM r223183.

llvm-svn: 223388
2014-12-04 21:26:25 +00:00
Enrico Granata 20675c8478 We should not pretend that an int is a valid ObjC pointer. If your number truly is a pointer, po (id)myNumber is a better alternative. Fixes rdar://16585032
llvm-svn: 223379
2014-12-04 19:31:51 +00:00
Greg Clayton 2e644415ba Remove dead code from SymbolFileDWARF:
lldb::TypeSP 
SymbolFileDWARF::FindDefinitionTypeForDIE (
    DWARFCompileUnit* dwarf_cu, 
    const DWARFDebugInfoEntry *die, 
    const lldb_private::ConstString &type_name);

This function isn't used as it has been replaced by:

lldb::TypeSP
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (
    const DWARFDeclContext &die_decl_ctx);

I am about to change the way we resolve C/C++ class/struct/union types and want to clean up SymbolFileDWARF before I start.

llvm-svn: 223376
2014-12-04 18:49:24 +00:00
Enrico Granata c5d32d751e Fix a build breakage. Looks like the LLVM side of this change has been reverted
llvm-svn: 223375
2014-12-04 18:39:40 +00:00
Zachary Turner b3ff719b04 Manually call ModulesDidLoad when the executable is loaded.
This is a temporary workaround to get deferred breakpoint
resolution working until Bug 21720 is addressed.  Even with this
workaround, it will only resolve deferred breakpoints in the
executable module, and not in a shared library.

llvm-svn: 223273
2014-12-03 22:04:31 +00:00
Zachary Turner c6a6653ebb Correctly shutdown when DoDestroy is called with an active exception.
Previously if we got a DoDestroy while stopped at a breakpoint, we
would detach and then say the process had exited.  This is completely
wrong, as it resulted in the python script incorrectly assuming that
the process had actually exited and trying to delete the image, when
in fact it had done no such thing.

The fix employed here is that when we get a DoDestroy, we do 3 steps:

1) initiate a termination sequence on the process
2) If we were stopped handling an exception of any kind, mask it and
   let the program resume, causing the program to see the termination
   request and exit on its own.
3) Let the program exit normally, and close all of our handles before
   returning control back to DoDestroy.

This fixes Bug 21722 and Bug 21723.

llvm-svn: 223272
2014-12-03 22:04:18 +00:00
Oleksiy Vyalov e8fb6937ba Use timeout when reading debugserver's port from a named pipe.
http://reviews.llvm.org/D6490

llvm-svn: 223251
2014-12-03 18:19:16 +00:00
Jason Molenda 286fd1aaac Update setMCJITMemoryManager call to keep in line with llvm r223183.
Patch from Ryan Goodfellow.

llvm-svn: 223196
2014-12-03 04:02:03 +00:00
Jason Molenda 22f58dffeb Mark the armv7 q0-q3 and q8-q15 registers as volatile (not callee
preserved) in the ABI.

Realistically lldb isn't able to track register saves of any of
the neon regs right now so we should probably mark all of the 
regs as unavailable when you're not on stack frame 0...

<rdar://problem/19115127> 

llvm-svn: 223174
2014-12-02 23:21:05 +00:00
Jason Molenda 98b3fde8ac Fix the behavior of ${current-pc-arrow} in the default disassembly
format for the not-current-stack-frame.  This was causing
test/functionalities/inferior-assert to fail.

Also document the new additions to the format specifications used
in the disassembly-format changes to formats.html.

<rdar://problem/19102757> 

llvm-svn: 223096
2014-12-02 00:26:21 +00:00
Zachary Turner e0d93f523b Enable enabling and disabling breakpoints on Windows.
llvm-svn: 223089
2014-12-01 23:13:52 +00:00
Zachary Turner c7a17ed460 Only normalize FileSpec paths *after* resolving them.
Normalizing paths before resolving them can cause the path to
become denormalized after resolution.

llvm-svn: 223087
2014-12-01 23:13:32 +00:00
Greg Clayton afa91e339b lldb can deadlock when launched with an non-existing executable:
% lldb /bin/nonono
(lldb) target create "/bin/nonono"
error: unable to find executable for '/usr/bin/nonono'
<deadlock>

The problem was the initial commands 'target create "/bin/nonono"' were put into a pipe and the command interpreter was being run with:

void
CommandInterpreter::RunCommandInterpreter(bool auto_handle_events,
                                          bool spawn_thread,
                                          CommandInterpreterRunOptions &options)
{
    // Always re-create the command intepreter when we run it in case
    // any file handles have changed.
    bool force_create = true;
    m_debugger.PushIOHandler(GetIOHandler(force_create, &options));
    m_stopped_for_crash = false;
    
    if (auto_handle_events)
        m_debugger.StartEventHandlerThread();
    
    if (spawn_thread)
    {
        m_debugger.StartIOHandlerThread();
    }
    else
    {
        m_debugger.ExecuteIOHanders();
        
        if (auto_handle_events)
            m_debugger.StopEventHandlerThread();
    }
    
}

If "auto_handle_events" was set to true and "spawn_thread" was false, we would execute:

m_debugger.StartEventHandlerThread();
m_debugger.ExecuteIOHanders();
m_debugger.StopEventHandlerThread();


The problem was there was no synchonization in Debugger::StartEventHandlerThread() to ensure the event handler was listening to events and the the call to "m_debugger.StopEventHandlerThread()" would do:

void
Debugger::StopEventHandlerThread()
{
    if (m_event_handler_thread.IsJoinable())
    {
        GetCommandInterpreter().BroadcastEvent(CommandInterpreter::eBroadcastBitQuitCommandReceived);
        m_event_handler_thread.Join(nullptr);
    }
}

The problem was that the event thread might not be listening for the CommandInterpreter::eBroadcastBitQuitCommandReceived event yet.

The solution is to make sure the Debugger::DefaultEventHandler() is listening to events before we return from Debugger::StartEventHandlerThread(). Once we have this synchonization we remove the race condition.

This fixes radar:

<rdar://problem/19041192>

llvm-svn: 223083
2014-12-01 22:41:27 +00:00
Greg Clayton d90ac932d9 Added a new regular expression to the "_regexp-break" command ("b" by default):
(lldb) b /break here/

This will set a source level regular expression breakpoint on any text between the first '/' and the last '/'. The equivalent command will be:

(lldb) breakpoint set --source-pattern-regexp 'break here'

llvm-svn: 223082
2014-12-01 22:34:03 +00:00
Vince Harron 6eddf8df2a Added StringExtractor::DecodeHexU8 && GetHexBytesAvail
DecodeHexU8 returns a decoded hex character pair, returns -1 if a
valid hex pair is not available.

GetHexBytesAvail decodes all available hex pairs.

llvm-svn: 223081
2014-12-01 22:19:33 +00:00
Oleksiy Vyalov e13d71c57c Refactor SocketAddress::getaddrinfo - avoid calling IsValid if ::getaddrinfo has failed.
Otherwise, IsValid crashes on assertation in GetFamilyLength.

llvm-svn: 222862
2014-11-27 00:32:54 +00:00
Zachary Turner 807eb55b08 When a process stops, set the StopInfo object on Windows.
llvm-svn: 222776
2014-11-25 19:03:19 +00:00
Zachary Turner 82da55fe57 Disable GetSTDOUT, GetSTDERR, and PutSTDIN on Windows.
These methods are difficult / impossible to implement in a way
that is semantically equivalent to the expectations set by LLDB
for using them.  In the future, we should find an alternative
strategy (for example, i/o redirection) for achieving similar
functionality, and hopefully deprecate these APIs someday.

llvm-svn: 222775
2014-11-25 19:03:08 +00:00
Greg Clayton 54166af611 Fixed an issue where a DW_FORM_ref{2,4,8} might be extracted incorrectly because the wrong compile unit was being used to calculate the compile unit relative offset.
This was fixed by making the DWARFFormValue contain the compile unit that it needs so it can decode its form value correctly. Any form value that requires a compile unit will now assert. If any of the assertions that were added are triggered, then code that led to the extraction of the form value without properly setting the compile unit must be fixed immediately. 

<rdar://problem/19035440>

llvm-svn: 222602
2014-11-22 01:58:59 +00:00
Jason Molenda cea6d634a5 When a RegisterContext produces an invalid CFA address, change
UnwindLLDB::AddOneMoreFrame to try the fallback unwind plan on
that same stack frame before it tries the fallback unwind plan
on the "next" or callee frame.

In RegisterContextLLDB::TryFallbackUnwindPlan, when we're
trying the fallback unwind plan to see if it is valid, make
sure we change all of the object ivars that might be used in
the process of fetching the CFA & caller's saved pc value 
and restore those if we decide not to use the fallback 
unwindplan.

<rdar://problem/19035079> 

llvm-svn: 222601
2014-11-22 01:52:03 +00:00
Jim Ingham 893c932acf This is the first step of making lldb able to create target-specific things
(e.g. breakpoints, stop-hooks) before we have any targets - for instance in 
your ~/.lldbinit file.  These will then get copied over to any new targets 
that get created.  So far, you can only make stop-hooks.

Breakpoints will have to learn to move themselves from target to target for
us to get them from no-target to new-target.

We should also make a command & SB API way to prime this ur-target.

llvm-svn: 222600
2014-11-22 01:42:44 +00:00
Zachary Turner e5bd103621 [ProcessWindows] Clean up the register definitions array.
llvm-svn: 222597
2014-11-22 00:37:14 +00:00
Enrico Granata 7e4df56aae Enable Python summaries to use custom SBTypeSummaryOptions if the user is so inclined. Updates to the webdoc will follow
llvm-svn: 222593
2014-11-22 00:02:47 +00:00
Enrico Granata 49a6746942 Per off-list feedback, this API returns the *first* value with a given name, not the *only* one. Rename it to reflect that
llvm-svn: 222582
2014-11-21 22:23:08 +00:00
Enrico Granata e9a09c74fa Add an API on SBValueList to find the first value with a given name stored in the list
llvm-svn: 222576
2014-11-21 21:45:03 +00:00
Enrico Granata a126e462c2 Do some cleanup of DumpValueObjectOptions. The whole concept of raw printing was split between feature-specific flags, and an m_be_raw flag, which then drove some other changes in printing behavior. Clean that up, so that each functionality has its own flag .. oh, and make the bools all go in a bitfield since I may want to add more of those over time
llvm-svn: 222548
2014-11-21 18:47:26 +00:00
Oleksiy Vyalov ff9a07203e Extend PipePosix with child_processes_inherit support - to control whether pipe handles should be inherited by a child process.
http://reviews.llvm.org/D6348

llvm-svn: 222541
2014-11-21 16:18:57 +00:00
Jason Molenda c6127dd653 Change CommandObjectTargetModulesLoad so that the filename argument
is treated as a string instead of a FileSpec.

OptionValueFileSpec::SetValueFromCString() passes the c string to
FileSpec::SetFile(str, true /* resolve */) - and with Zachary's
changes to FileSpec we're using llvm::sys::fs::make_absolute() to
do that "resolve" action now, where we used to use realpath().

One important difference between llvm::sys::fs::make_absolute and
realpath is that when they're handed a filename (no directory),
realpath prepends the current working directory *and if the file exists*,
returns that full path.  If that file doesn't exist, the caller 
uses the basename only.

llvm::sys::fs::make_absolute prepends the current working directory
regardless of whether it exists or not. 

I considered having FileSpec::SetFile save the initial pathname,
call FileSpec::Resolve, and then check to see if the Resolve return
path exists - and if not, go back to the original one.

But instead I just went with changing 'target modules load' to treat its 
filename argument as a string instead of a FileSpec.  This brings it
in line with how 'target modules list' works.

<rdar://problem/18955416> 

llvm-svn: 222498
2014-11-21 02:25:15 +00:00
Zachary Turner 7f013bcd60 Rename lldb registers to contain lldb_ prefix.
LLDB supports many different register numbering schemes, and these
are typically prefixed with an indicator that lets the user know
what numbering scheme is used.  The gcc numbering scheme is
prefixed with gcc, and there are similar ones for dwarf, gdb,
and gcc_dwarf.

LLDB also contains its own internal numbering scheme, but the enum
for LLDB's numbering scheme was prefixed differently.  This patch
changes the names of these enums to use the same naming scheme for
the enum values as the rest of the register kinds by removing gpr_
and fpu_ prefixes, and instead using lldb_ prefixes for all enum
values.

Differential Revision: http://reviews.llvm.org/D6351
Reviewed by: Greg Clayton

llvm-svn: 222495
2014-11-21 02:00:21 +00:00
Zachary Turner 7b1534e452 Remove duplicated enum, use the authoritative one.
Running a diff against lldb-x86-register-enums.h and the file
modified in this patch, the two enums were completely identical.

Deleting one of them to reduce code noise.

llvm-svn: 222478
2014-11-20 23:19:40 +00:00
Zachary Turner 17f383d498 [ProcessWindows] Implement a RegisterContextWindows for x86.
This implements the skeleton of a RegisterContext for Windows.
In particular, this implements support only for x86 general purpose
registers.

After this patch, LLDB on Windows can perform basic debugging
operations in a single-threaded inferior process (breakpoint,
register inspection, frame select, unwinding, etc).

Differential Revision: http://reviews.llvm.org/D6322
Reviewed by: Greg Clayton

llvm-svn: 222474
2014-11-20 22:47:32 +00:00
Jim Ingham c0b4d5a1f6 "nexti" should not step over inlined functions.
<rdar://problem/16705325>

llvm-svn: 222459
2014-11-20 22:04:45 +00:00
Oleksiy Vyalov 5d06474b29 Add test for denied process attach by pid and fix found bugs in Process/ProcessPOSIX.cpp
and FreeBSD/ProcessMonitor.

http://reviews.llvm.org/D6240

llvm-svn: 222372
2014-11-19 18:27:45 +00:00
Oleksiy Vyalov b92935b444 Fix broken build after removing StringMap::GetOrCreateValue in favor of StringMap::insert.
llvm-svn: 222370
2014-11-19 17:24:58 +00:00
Jason Molenda 51a4511b72 Add additional checks to the SavedLocationForRegister method
where it is retrieving the Return Address register contents
on a target where that's a thing.  If we fail to get a valid
RA, we force a switch to the fallback unwind plan.  This patch
adds a sanity check for that fallback unwind plan -- it must
get a valid CFA for this frame in addition to being able to
retrieve the caller's PC -- and it correctly marks the unwind
rules as failing if the fallback unwind plan fails.

<rdar://problem/19010211> 

llvm-svn: 222301
2014-11-19 02:29:52 +00:00
Enrico Granata 49bfafb510 Shuffle APIs around a little bit, so that if you pass custom summary options, we don't end up caching the summary hence obtained. You may want to obtain an uncapped summary, but this should not be reflected in the summary we cache. The drawback is that we don't cache as aggressively as we could, but at least you get to have different summaries with different options without having to reset formatters or the SBValue at each step
llvm-svn: 222280
2014-11-18 23:36:25 +00:00
Enrico Granata 34042212b2 Add the ability for the NSString and libc++ std::string formatters to retrieve uncapped data
llvm-svn: 222277
2014-11-18 22:54:45 +00:00
Eric Christopher b0a1814ff3 More override warning cleanup.
llvm-svn: 222271
2014-11-18 22:40:27 +00:00
Jim Ingham 7d8555c413 Patch from dawn@burble.org to make the --silent-run do what it says, not the opposite of what it says.
llvm-svn: 222243
2014-11-18 19:12:13 +00:00
Jason Molenda ae3e40dd61 Fix up the code in the FuncUnwinders class that
retrieves the personality routine addr and the
LSDA addr.  Don't bother checking with the
"non-call site" unwind plan - this kind of
information is only going to come from the 
call site unwind plan.

llvm-svn: 222226
2014-11-18 05:57:42 +00:00
Jason Molenda e9c7ecf66e Read the LSDA and Personality Routine function address out of the
eh_frame data.  These two pieces of information are used in the
process of exception handler unwinding on SysV ABI systems.

This patch reads the data from the eh_frame section 
(DWARFCallFrameInfo.cpp), allows for it to be saved & read out
of a given UnwindPlan (UnwindPlan.h, UnwindPlan.cpp) - as well
as printing the information in the UnwindPlan::Dump method - and
adds methods to the FuncUnwinders object so that higher levels
can query if a given function has an LSDA / personality routine
defined.

It's only lightly tested, but seems to be working correctly as long
as your have this information in eh_frame.  Does not address getting
this information from compact unwind yet on Darwin systems.

<rdar://problem/18742797> 

llvm-svn: 222214
2014-11-18 02:27:42 +00:00
Greg Clayton ea508635de Have CommandObjectCommandsAddRegex inherit from IOHandlerDelegateMultiline so it will not immediately terminate after the first regular expression in "command regex <name>" commands.
Fixed the prompt to not include non-printable characters as it was hosing up the prompt when you ran "command regex foo" and entered multi-line editing mode.

Fixed error strings to include more complete descriptions when bad regular expressions are entered.

Removed the old IOHandlerLinesUpdated function as it is no longer needed (inheriting from IOHandlerDelegateMultiline takes care of what this function used to do).

llvm-svn: 222207
2014-11-18 00:43:17 +00:00
Enrico Granata 099263b487 Fix a problem where the StringPrinter could be mistaking an empty string for a read error, and reporting spurious 'unable to read data' messages. rdar://19007243
llvm-svn: 222190
2014-11-17 23:14:11 +00:00
Enrico Granata 6cd8e0c9b0 Add APIs on SBFunction and SBCompileUnit to inquire about the language type that the function/compile unit is defined in
llvm-svn: 222189
2014-11-17 23:06:20 +00:00
Eric Christopher e0569982db Fix override/virtual warnings.
llvm-svn: 222186
2014-11-17 22:55:13 +00:00
Zachary Turner c30189921e Change HostThread::GetNativeThread() to return a derived reference.
Previously using HostThread::GetNativeThread() required an ugly
cast to most-derived type.  This solves the issue by simply returning
the derived type directly.

llvm-svn: 222185
2014-11-17 22:42:57 +00:00
Oleksiy Vyalov 5453933867 Fix broken NativeProcessLinux.cpp after signature change of ResolveExecutable.
llvm-svn: 222184
2014-11-17 22:42:28 +00:00
Oleksiy Vyalov 6edef20405 Fix broken Linux build after signature change of ResolveExecutable.
llvm-svn: 222182
2014-11-17 22:16:42 +00:00
Zachary Turner 1019695b38 Move the thread logic around to fit better into LLDB's process model.
Previously we were directly updating the thread list and stopping
and restarting the process every time threads were created.  With
this patch, we queue up thread launches and thread exits, resolve
these all internally, and only update the threads when we get an
UpdateThreadList call.  We now only update the private state on
an actual stop (i.e. breakpoint).

llvm-svn: 222178
2014-11-17 21:31:30 +00:00
Zachary Turner d553d00c79 Disable Editline on Windows.
Editline does not work correctly on Windows.  This goes back at
least to r208369, and as a result r210105 was submitted to disable
libedit at runtime on Windows.

More recently, r222163 was submitted which re-writes editline
entirely, but makes the situation even worse on Windows, to the
point that it doesn't even compile.  While it would be easy to
fix the compilation failure, this patch simply stops compiling
Editline entirely on Windows, as the simple compilation fix would
still result in a broken use of select on Windows, and as such a
broken implementation of Editline.

Since Editline was already disabled to begin with on Windows, we
don't attempt to fix the compilation failure or the underlying
issues, and instead just disable it "even more".

llvm-svn: 222177
2014-11-17 21:31:18 +00:00
Zachary Turner 05d77c8b71 Fix broken build after signature change of ResolveExecutable.
llvm-svn: 222176
2014-11-17 21:30:58 +00:00
Jason Molenda 557109377d Small tweaks to make the editline sources match the lldb
source layout.

llvm-svn: 222171
2014-11-17 20:10:15 +00:00
Greg Clayton 8012cadbf3 Fixed more fallout from running the test suite remotely on iOS devices.
Fixed include:
- Change Platform::ResolveExecutable(...) to take a ModuleSpec instead of a FileSpec + ArchSpec to help resolve executables correctly when we have just a path + UUID (no arch).
- Add the ability to set the listener in SBLaunchInfo and SBAttachInfo in case you don't want to use the debugger as the default listener. 
- Modified all places that use the SBLaunchInfo/SBAttachInfo and the internal ProcessLaunchInfo/ProcessAttachInfo to not take a listener as a parameter since it is in the launch/attach info now
- Load a module's sections by default when removing a module from a target. Since we create JIT modules for expressions and helper functions, we could end up with stale data in the section load list if a module was removed from the target as the section load list would still have entries for the unloaded module. Target now has the following functions to help unload all sections a single or multiple modules:

    size_t
    Target::UnloadModuleSections (const ModuleList &module_list);

    size_t
    Target::UnloadModuleSections (const lldb::ModuleSP &module_sp);

llvm-svn: 222167
2014-11-17 19:39:20 +00:00
Kate Stone e30f11d9ee Complete rewrite of interactive editing support for single- and multi-line input.
Improvements include:
* Use of libedit's wide character support, which is imperfect but a distinct improvement over ASCII-only
* Fallback for ASCII editing path
* Support for a "faint" prompt clearly distinguished from input
* Breaking lines and insert new lines in the middle of a batch by simply pressing return
* Joining lines with forward and backward character deletion
* Detection of paste to suppress automatic formatting and statement completion tests
* Correctly reformatting when lines grow or shrink to occupy different numbers of rows
* Saving multi-line history, and correctly preserving the "tip" of history during editing
* Displaying visible ^C and ^D indications when interrupting input or sending EOF
* Fledgling VI support for multi-line editing
* General correctness and reliability improvements

llvm-svn: 222163
2014-11-17 19:06:59 +00:00
Zachary Turner 119767db85 [ProcessWindows] Create a TargetThreadWindows class.
This creates a TargetThreadWindows class and updates the thread
list of the Process with the main thread.  Additionally, we
fill out a few more overrides of Process base class methods.  We
do not yet update the thread list as threads are created and/or
destroyed, and we do not yet propagate stop reasons to threads as
their states change.

llvm-svn: 222148
2014-11-17 17:46:43 +00:00
Zachary Turner a2fc3a4090 [ProcessWindows] Implement read / write process memory.
llvm-svn: 222147
2014-11-17 17:46:27 +00:00
Jim Ingham 96a1596a7a For some reason, sometimes the directory paths that clang emits have internal
relative paths, like:

/whatever/llvm/lib/Sema/../../include/llvm/Sema/

That causes problems with our type uniquing, since we use the declaration file
and line as one component of the uniquing, and different ways of getting to the
same file will have different directory spellings, though they are functionally
equivalent.  We end up with two copies of the exact same type because of this, 
and that makes the expression parser give "duplicate type" errors.

I added a method to resolve paths with ../ in them and used that in the FileSpec::Equals,
for comparing Declarations and for doing Breakpoint compares as well, since they also
suffer from this if you specify breakpoints by full path (since nobody knows what
../'s to insert...)

<rdar://problem/18765814>

llvm-svn: 222075
2014-11-15 01:54:26 +00:00
Enrico Granata e65a28f36f Removed a couple of static helpers in the data formatters, replaced with new general logic in StringLexer
llvm-svn: 222058
2014-11-14 22:58:11 +00:00
Oleksiy Vyalov 477e42a6fb Apply SOCK_CLOEXEC flag to socket API functions in order to avoid handle leakage to a forked child process.
http://reviews.llvm.org/D6204

llvm-svn: 222004
2014-11-14 16:25:18 +00:00
Vince Harron 01e87d3fe2 fix minor comment typo
llvm-svn: 221950
2014-11-13 23:45:59 +00:00
Greg Clayton bf702ceed1 Fixed "SBTarget SBDebugger::CreateTarget (const char *filename)" to use the same semantics as other SBDebugger::CreateTarget() functions.
The issues were:
- If you called this function with any arch other than the default target architecture, creating the target would fail because the Target::GetDefaultArchitecture() would not match the single architecture in the file specified. This caused running the test suite remotely with lldb-platform to fail many many tests due to the bad target.
- It would specify the currently selected platform which might not work for the specified platform

All other SBDebugger::CreateTarget calls do not assume an architecture or platform and if they aren't specified, they don't auto select the wrong one for you.

With this fix, SBTarget SBDebugger::CreateTarget (const char *filename) now behaves like the other SBDebugger::CreateTarget() variants.

llvm-svn: 221908
2014-11-13 18:30:06 +00:00
Greg Clayton 14418e0409 Remove extra "/" character from paths resolved in iOS SDKs and also be sure to update the SDK directory infos if needed before we start using m_sdk_directory_infos.
llvm-svn: 221907
2014-11-13 18:25:33 +00:00
Oleksiy Vyalov 1339b5e8ae Refactor NativeProcessLinux::AttachToProcess in order to avoid reinterpret_cast from NativeProcessProtocol* to NativeProcessLinux*.
llvm-svn: 221906
2014-11-13 18:22:16 +00:00
Jason Molenda 22975a28ac A pretty big overhaul of the TryFallbackUnwindPlan method in
RegisterContextLLDB.  I have core files of half a dozen tricky
unwind situations on x86/arm and they're all working pretty much
correctly at this point, but we'll need to keep an eye out for
unwinder regressions for a little while; it's tricky to get these
heuristics completely correct in all unwind situations.

<rdar://problem/18937193> 

llvm-svn: 221866
2014-11-13 07:31:45 +00:00
Jason Molenda d8cc6bc325 Use PRIx64 when printing addr_t's. Don't need to force full-width 0 padding
with addresses that aren't designed to be column-aligned across multiple lines.

llvm-svn: 221810
2014-11-12 19:51:43 +00:00
Zachary Turner a32d2cecba [ProcessWindows] Improve support for launching processes.
This sends notifications for module load / unload to the process
plugin, and also manages the state more accurately during the
loading sequence.

Similar work by Virgile Bello was referenced during the
implementation of this patch.

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

llvm-svn: 221807
2014-11-12 19:31:56 +00:00
Zachary Turner d6a7b63f26 [ProcessWindows] Simplify the DebugDelegate interface.
Due to a previous multi-threaded design involving message
passing, we used message classes to pass event information
to the delegate.  Since the multi-threaded design has gone
away, we simplify this by passing event arguments as direct
function parameters, which is more clear and easier to
understand.

llvm-svn: 221806
2014-11-12 19:31:39 +00:00
Ed Maste b5363110c7 Avoid crash in InitializeNonZerothFrame if no module found
After r221575 TestCallStopAndContinue and TestCallThatRestarts started
crashing on FreeBSD with a null temporary_module_sp in
RegisterContextLLDB::InitializeNonZerothFrame().

llvm-svn: 221805
2014-11-12 18:49:54 +00:00
Justin Hibbits 62cf35b8a3 FIx a bug with PC-register handling in a RA register.
The addition of RegisterNumber introduced a bug where if the PC is stored in a
return address register, such as on ARM and PowerPC, this register number is
retrieved and used, but never checked in the row if it's saved.  Correct this by
setting the variable that's used to the new register number.

Patch by Jason Molenda.

llvm-svn: 221790
2014-11-12 15:14:12 +00:00
Justin Hibbits 89e6f3851e Improve PowerPC unwind support
Summary:
Taking advantage of the new 'CFAIsRegisterDereferenced' CFA register type, add
full stack unwind support to the PowerPC/PowerPC64 ABI.  Also, add a new
register set for powerpc32-on-64, so the register sizes are correct.  This also
requires modifying the ProcessMonitor to add support for non-uintptr_t-sized
register values.

Reviewers: jasonmolenda, emaste

Subscribers: emaste, lldb-commits

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

llvm-svn: 221789
2014-11-12 15:14:08 +00:00
Justin Hibbits 43bcdbde4a Add an alternative CFA type.
Summary:
PowerPC handles the stack chain with the current stack pointer being a pointer
to the backchain (CFA).  LLDB currently has no way of handling this, so this
adds a "CFA is dereferenced from a register" type.

Discussed with Jason Molenda, who also provided the initial patch for this.

Reviewers: jasonmolenda

Reviewed By: jasonmolenda

Subscribers: emaste, lldb-commits

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

llvm-svn: 221788
2014-11-12 15:14:03 +00:00
Jason Molenda 4b0c118713 Enable armv7 core file writing for Mach-O binaries.
The problems with the dyld all image infos struct 
seems to be specific to arm64.

llvm-svn: 221760
2014-11-12 02:39:14 +00:00
Rafael Espindola 434df0a18c Update for llvm API change.
llvm-svn: 221752
2014-11-12 02:04:31 +00:00
Duncan P. N. Exon Smith 68caa7d34d Revert "Update for LLVM API change in r221024"
This reverts commit r221073 to match upstream revert in r221711.

llvm-svn: 221749
2014-11-12 01:59:53 +00:00
Jason Molenda 229525848a Sketch out the armv7 and arm64 core file writing support in
ObjectFileMachO.  It's close but we seem to be missing some
of the memory region segments - not exactly sure how that's
happening.  The register context writing into the LC_THREAD
load commands is working correctly though.

Slightly reordered the arm64 definitions in ArchSpec.cpp so
when we look for an arm64 core file definiton we're getting
a cpu subtype of CPU_ANY which we can't put in the mach
header of a core file.  Make the first definition we find by
linear search have the currently correct '1' cpu subtype.

llvm-svn: 221743
2014-11-12 01:11:36 +00:00
Enrico Granata 944547deab Move a bunch of summary formatters to oneliner mode. This makes more cases eligible for oneline printing, and fixes rdar://18120906
llvm-svn: 221701
2014-11-11 19:52:12 +00:00
Jason Molenda d20359d810 Add support for 32-bit core file dumping. Add support for i386 process core file dumping.
llvm-svn: 221683
2014-11-11 10:59:15 +00:00
Jason Molenda 466ffa5676 Put the current pc arrow back into the default disassembly format.
I went back and forth on removing this - and tried dropping it for
a few weeks.  But when you're working at an assembly language, it
really is helpful to have this displayed to show where the current
pc is.

llvm-svn: 221682
2014-11-11 10:32:04 +00:00
Jason Molenda d158db0f63 Add an operator== to the RegisterNumber class; it simplifies
RegisterContextLLDB a bit more in a few places.

llvm-svn: 221677
2014-11-11 08:26:44 +00:00
Sean Callanan a0d5643610 Made the expression parser more resilient against
being asked about symbols it doesn't know about.  If
it's asked about a symbol by mangled name and it finds
nothing, then it will try again with the demangled
base name.

llvm-svn: 221660
2014-11-11 02:49:44 +00:00
Sean Callanan 7db93f70fb Ignore templated aggregates in the Objective-C
runtime.  This eliminates potential confusion
when the compiler has to deal with these weird
types later on.

One day I'd like to actually generate the proper
templates, but this is not the day that I write
the parser code to do that.

<rdar://problem/18887634>

llvm-svn: 221658
2014-11-11 02:27:22 +00:00
Sean Callanan f37ccc181d Fixed two issues in the type encoding parser:
- A correctness issue: with assertions disabled,
  ReadQuotedString would misbehave; and

- A performance issue: BuildType used a long
  chain of if()s; I changed that to two switch
  statements.  That also makes the code much
  nicer to step through when debugging it.

llvm-svn: 221651
2014-11-11 00:50:10 +00:00
Shawn Best 50d60be3ce Fix error handling in NativeProcessLinux::AttachToInferior: http://reviews.llvm.org/D6158
llvm-svn: 221647
2014-11-11 00:28:52 +00:00
Sean Callanan 7eb9091e42 Added a testcase that checks that fairly complicated
structures are parsed safely by the Objective-C runtime.

Also made some modifications to the way we parse structs
in the runtime to avoid mis-parsing @ followed by the name
of the next field.

<rdar://problem/18887634>

llvm-svn: 221643
2014-11-11 00:14:00 +00:00
Zachary Turner dcd80377f3 [ProcessWindows] Implement breakpoint stop / resume on Windows.
This patch implements basic support for stopping at breakpoints
and resuming later.  While a breakpoint is stopped at, LLDB will
cease to process events in the debug loop, effectively suspending
the process, and then resume later when ProcessWindows::DoResume
is called.

As a side effect, this also correctly handles the loader breakpoint
(i.e. the initial stop) so that LLDB goes through the correct state
sequence during the initial process launch.

llvm-svn: 221642
2014-11-11 00:00:14 +00:00
Sean Callanan 5c35f7cfd1 Cleaned up the StringLexer a little bit. It turns
out we only want to roll back text that was in the
buffer to begin with, so it's not necessary to
provide a pushback stack.

I'm going to use this slightly cleaner API to perform
lookahead for the Objective-C runtime type parser.

llvm-svn: 221640
2014-11-10 23:20:52 +00:00
Zachary Turner 3985f891a3 [ProcessWindows] Notify process plugin when the launch succeeds.
llvm-svn: 221637
2014-11-10 22:32:18 +00:00
Zachary Turner ba80da60c8 Fix some compiler warnings, one of which was a legit bug.
MSVC warns that not all control paths return a value when a switch
doesn't have a default case handler.  Changed explicit value checks
to a default check.

Also, it caught a case where bitwise AND was being used instead of
logical AND.  I'm not sure what this fixes, but presumably it is
not covered by any kind of test case.

llvm-svn: 221636
2014-11-10 22:31:51 +00:00
Greg Clayton 45f4f8bd7e Fix comments to match the current reality.
llvm-svn: 221633
2014-11-10 21:48:12 +00:00
Greg Clayton bd549169d7 Fix selectors not being objc-uniquified in the expression parser after a recent renaming in clang (clang change for revision 221451). This broke all objective C expressions in LLDB.
llvm-svn: 221632
2014-11-10 21:45:59 +00:00
Jason Molenda bd07fd57f6 Add a RegisterNumber class to RegisterContextLLDB.h and start using
it in RegisterContext.cpp.

There's a lot of bookkeeping code in RegisterContextLLDB where it has
to convert between different register numbering schemes and it makes 
some methods like SavedLocationForRegister very hard to read or
maintain.  Abstract all of the details about different register numbering
systems for a given register into this new class to make it easier 
to understand what the method is doing.

Also add register name printing to all of the logging -- that's easy to
get now that I've got an object to represent the register numbers.

There were some gnarly corner cases of this method that I believe
I've translated correctly - initial testing looks good but it's
possible I missed a corner case, especially with architectures which
uses a link-register aka return address register like arm32/arm64.
Basic behavior is correct but there are a lot of corner casese that are
handled in this method ...

llvm-svn: 221577
2014-11-08 08:09:22 +00:00
Jason Molenda cf29675d95 Fix a corner case with the handling of noreturn functions.
If a noreturn function was the last function in a section,
we wouldn't correctly back up the saved-pc value into the
correct section leading to us showing the wrong function in
the backtrace.

Also add a backtrace test with an attempt to elicit this 
particular layout.  It happens to work out with clang -Os
but other compilers may not quite get the same layout I'm
getting at that opt setting.  We'll still be exercising the
basic noreturn handling in the unwinder even if we don't get
one function at the very end of a section.

<rdar://problem/16051613> 

llvm-svn: 221575
2014-11-08 05:38:17 +00:00
Shawn Best 8da0bf3b7c LLGS Android target support - for Andy Chien : http://reviews.llvm.org/D6166
llvm-svn: 221570
2014-11-08 01:41:49 +00:00
Zachary Turner 02862bc83a Remove the top-level DebugDriverThread in ProcessWindows.
Originally the idea was that we would queue requests to a master
thread that would dispatch them to other slave threads each
responsible for debugging an individual process.  This might make
some scenarios more scalable and responsive, but for now it seems
to be unwarranted complexity for no observable benefit.

llvm-svn: 221561
2014-11-07 23:44:13 +00:00
Enrico Granata 52ab271878 This was meant to be count, not m_count
llvm-svn: 221541
2014-11-07 20:37:17 +00:00
Rafael Espindola 97ae14e166 Use llvm::StringRefMemoryObject NFC.
llvm-svn: 221509
2014-11-07 04:24:12 +00:00
Enrico Granata f35bc63220 This is a large, but clearical, commit that enables the C++ formatters to take on the additional TypeSummaryOptions argument. It is still not used for anything, but it is now there. Adding support for this extra argument to Python formatters will follow suit
llvm-svn: 221486
2014-11-06 21:55:30 +00:00
Enrico Granata c1247f5596 Introduce the notion of "type summary options" as flags that can be passed down to individual summary formatters to alter their behavior in a formatter-dependent way
Two flags are introduced:
- preferred display language (as in, ObjC vs. C++)
- summary capping (as in, should a limit be put to the amount of data retrieved)

The meaning - if any - of these options is for individual formatters to establish
The topic of a subsequent commit will be to actually wire these through to individual data formatters

llvm-svn: 221482
2014-11-06 21:23:20 +00:00
Sean Callanan 4c508df925 Handle types from the runtime that conform to
protocols.

<rdar://problem/18883778>

llvm-svn: 221476
2014-11-06 19:26:10 +00:00
Greg Clayton 81eed943a3 Fixed the C++ method name class to be a bit more picky about what it identifies as a C++ method.
This was done by using regular expressions on any basename we find to ensure it is valid.

This fixed setting breakpoints by name with values like '[J]com.robovm.debug.server.apps.SleepLoop.startingUp()V'. This was previously triggering the C++ method name class to identify the string as C++ with a basename of '[J]com.robovm.debug.server.apps.SleepLoop.startingUp' which was obviously incorrect. 

The changes also fixed errors in templated function names like "void foo<int>(...)" where "void foo<int>" was being identified incorrectly as the basename. We also handle more C++ operators correctly now.

llvm-svn: 221416
2014-11-05 23:56:37 +00:00
Zachary Turner 742346a22f Decouple ProcessWindows from the Windows debug driver thread.
In the llgs world, ProcessWindows will eventually go away and
we'll implement a different protocol.  This patch decouples
ProcessWindows from the core debug loop so that this transition
will not be more difficult than it needs to be.

llvm-svn: 221405
2014-11-05 22:16:28 +00:00
Enrico Granata ebdc1ac014 Add a setting escape-non-printables that drives whether the StringPrinter should or should not escape sequences such as \t, \n, .. and generally any non-printing character
The recent StringPrinter changes made this behavior the default, and the setting defaults to yes
If you want to change this behavior and see non-printables unescaped (e.g. "a\tb" as "a    b"), set it to false

Fixes rdar://12969594

llvm-svn: 221399
2014-11-05 21:20:48 +00:00
Zachary Turner 0d594e136e Fix LLDB build as a result of upstream LLVM changes.
llvm-svn: 221378
2014-11-05 18:37:53 +00:00
Shawn Best 629680e499 for Oleksiy Vyalov - Redirect stdin, stdout and stderr to /dev/null when launching LLGS process. Differential Revision: http://reviews.llvm.org/D6105
llvm-svn: 221324
2014-11-05 00:58:55 +00:00
Zachary Turner ea66dac7cd Rename some classes in ProcessWindows.
Renamed monitor -> driver, to make clear that the implementation here
is in no way related to that of other process plugins which have also
implemented classes with similar names such as DebugMonitor.

Also created a DebugEventHandler interface, which will be used by
implementors to get notified when debugging events happen in the
inferiors.

llvm-svn: 221322
2014-11-05 00:33:28 +00:00
Shawn Best fd13743f57 for Siva Chandra: Fix compilation of StringPrinter.cpp with GCC. Differential Revision: http://reviews.llvm.org/D6122
llvm-svn: 221310
2014-11-04 22:43:34 +00:00
Enrico Granata 0eb0ec298c Fix a problem where ValueObjectVariable was not correctly setting its 'has value changed' flag for scalar valued variables. This fixes rdar://17851144
llvm-svn: 221298
2014-11-04 21:28:50 +00:00
Enrico Granata 404ab37e8b Fix the build for LLVM changes
llvm-svn: 221286
2014-11-04 19:33:45 +00:00
Jason Molenda 8030ffda91 Add recognition for another x86 epilogue sequence (ret followed by
a nop).  Fixes an instruction stepping problem when trying to step
over the final instructions of an epilogue.
<rdar://problem/18068877> 

llvm-svn: 221241
2014-11-04 05:48:11 +00:00
Jason Molenda 9bb421d38b Add one extra sanity check to RegisterContextLLDB::TryFallbackUnwindPlan
so it doesn't try the arch default if a comiler-generated (eh_frame,
compact unwind info) based unwind plan has failed.

llvm-svn: 221239
2014-11-04 05:35:32 +00:00
Jason Molenda 4b00893243 Back out r221229 -- instead of trying to identify the end of the unwind,
let's let lldb try the arch default unwind every time but not destructively --
it doesn't permanently replace the main unwind method for that function from
now on.

This fix is for <rdar://problem/18683658>.  

I tested it against Ryan Brown's go program test case and also a
collection of core files of tricky unwind scenarios 
<rdar://problem/15664282> <rdar://problem/15835846>
<rdar://problem/15982682> <rdar://problem/16099440>
<rdar://problem/17364005> <rdar://problem/18556719> 
that I've fixed over the last 6-9 months.

llvm-svn: 221238
2014-11-04 05:28:40 +00:00
Eric Christopher 0010b202ba Fix one more [-Werror,-Winconsistent-missing-override] error.
llvm-svn: 221232
2014-11-04 03:14:57 +00:00
Eric Christopher 7ab81b9149 Fix a bunch of [-Werror,-Winconsistent-missing-override] errors.
llvm-svn: 221231
2014-11-04 03:13:17 +00:00
Jason Molenda d98c3abf9f After we've completed a full backtrace, we'll have one frame which
is "invalid" -- it is past the end of the stack trace.  Add a new
method IsCompletedStackWalk() so we can tell if an invalid stack
frame is from a complete backtrace or if it might be worth re-trying
the last unwind with a different method.

This fixes the unwinder problems Ryan Brown was having with go
programs.  The unwinder can (under the right circumstances) still
destructively replace unwind plans permanently - I'll work on
that in a different patch.  

<rdar://problem/18683658> 

llvm-svn: 221229
2014-11-04 02:31:50 +00:00
Greg Clayton 8691dc5b75 Fixed SBTarget::ReadMemory() to work correctly and the TestTargetAPI.py test case that was reading target memory in TargetAPITestCase.test_read_memory_with_dsym and TargetAPITestCase.test_read_memory_with_dwarf.
The problem was that SBTarget::ReadMemory() was making a new section offset lldb_private::Address by doing:


size_t
SBTarget::ReadMemory (const SBAddress addr,
                      void *buf,
                      size_t size,
                      lldb::SBError &error)
{
        ...
        lldb_private::Address addr_priv(addr.GetFileAddress(), NULL);
        bytes_read = target_sp->ReadMemory(addr_priv, false, buf, size, err_priv);


This is wrong. If you get the file addresss from the "addr" argument and try to read memory using that, it will think the file address is a load address and it will try to resolve it accordingly. This will work fine if your executable is loaded at the same address (no slide), but it won't work if there is a slide.

The fix is to just pass along the "addr.ref()" instead of making a new addr_priv as this will pass along the lldb_private::Address that is inside the SBAddress (which is what we want), and not always change it into something that becomes a load address (if we are running), or abmigious file address (think address zero when you have 150 shared libraries that have sections that start at zero, which one would you pick). The main reason for passing a section offset address to SBTarget::ReadMemory() is so you _can_ read from the actual section + offset that is specified in the SBAddress. 

llvm-svn: 221213
2014-11-04 00:56:30 +00:00
Zachary Turner 8f21174700 Implement a framework for live debugging on Windows.
When processes are launched for debugging on Windows now, LLDB
will detect changes such as DLL loads and unloads, breakpoints,
thread creation and deletion, etc.

These notifications are not yet propagated to LLDB in a way that
LLDB understands what is happening with the process.  This only
picks up the notifications from the OS in a way that they can be
sent to LLDB with subsequent patches.

Reviewed by: Scott Graham

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

llvm-svn: 221207
2014-11-04 00:00:12 +00:00
Greg Clayton 118593a3af The change previously committed as 220983 broke large binary memory reads. I kept the "idx - 1" fix from 220983, but reverted the while loop that was incorrectly added.
The details are: large packets (like large memory reads (m packets) or large binary memory reads (x packet)) can get responses that come in across multiple read() calls. The while loop that was added meant that if only a partial packet came in (like only "$abc" coming for a response) GDBRemoteCommunication::CheckForPacket() was called, it would deadlock in the while loop because no more data is going to come in as this function needs to be called again with more data from another read. So the original fix will need to be corrected and resubmitted.

<rdar://problem/18853744>

llvm-svn: 221181
2014-11-03 21:02:54 +00:00
Filipe Cabecinhas dfa8688082 Fix the Makefile build by actually building ABI/SysV-ppc
llvm-svn: 221111
2014-11-02 22:03:15 +00:00
Ed Maste d455a1ecb8 Update for LLVM API change in r221024
llvm-svn: 221073
2014-11-02 00:24:22 +00:00
Justin Hibbits 3411c3ea53 Use kern.proc.auxv to get the aux data
Summary:
Instead of using a homegrown solution to get the auxv from a process, instead
use the OS-provided sysctl to get the needed data.  This allows the same code to
be used for both 32-bit and 64-bit processes on a 64-bit host.

Reviewers: emaste

Reviewed By: emaste

Subscribers: emaste, lldb-commits

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

llvm-svn: 221063
2014-11-01 21:27:08 +00:00
Sean Callanan ada6d1693e Complete the superclass type when completing an
Objective-C class type.

llvm-svn: 221022
2014-10-31 23:55:36 +00:00
Shawn Best 3ab672d7ef TOT broken by R220956 - Differential Revision: http://reviews/llvm.org/D6066
llvm-svn: 221018
2014-10-31 23:20:13 +00:00
Stephane Sezer 15d810fa29 Always transmit SIGPROF back to the inferior.
Summary:
SIGPROF is used for profiling processes (with google-perftools for
instance), which results in the inferior receiving a SIGPROF from the
kernel every few milliseconds. Instead of stopping the debugging session
and notifying the user of this, we should just pass the signal and keep
running.

This follows the behavior we have in UnixSignals.cpp.

Test Plan: Run LLDB on linux with a binary using google-perftools, see that execution gets interrupted all the time because we receive SIGPROF. Apply the patch, everything works fine.

Subscribers: lldb-commits

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

llvm-svn: 221011
2014-10-31 22:37:24 +00:00
Jason Molenda fca26da446 SBAddress currently *may* have an Address object or it may not.
If it has an Address object, it is assumed to be Valid.
Change SBAddress to always have an Address object and check
whether it is valid or not in those case.

This is fixing a subtle problem where we ended up with
a SBAddress with an Address of LLDB_INVALID_ADDRESS could
run through a copy constructor and turn into an SBAddress
with no Address object being backed (because it wasn't
distinguishing between invalid-Address versus no-Address.)

The cost of an Address object is not high and this will be
an easy mistake for someone else to make; I'm fixing
SBAddress so it doesn't come up again.
<rdar://problem/18069407> 

llvm-svn: 221002
2014-10-31 21:30:59 +00:00
Shawn Best 396f80a1ea commit on behalf of Oleksiy Vyalov Fix junk content handling within GDBRemoteCOmmunication::CheckForPacket 1. Avoid removing of an extra symbol from m_bytes. 2. iterate over m_bytes until useful content is found. Differential Revision: http://reviews.llvm.org/D6042
llvm-svn: 220983
2014-10-31 18:18:23 +00:00
Sean Callanan acff5e60b5 In ValueObjectDynamicValue, trust what comes from
the runtime rather than trying to fix it up,
because now those types have ivars regardless of
whether they come from "frame variable" or from
expressions.

Patch by Enrico Granata.

llvm-svn: 220982
2014-10-31 18:07:44 +00:00
Sean Callanan 9dfe45ff1c Updated the Objective-C runtime type vendor to
load ivars into classes that are reported to the
Objective-C runtime.

llvm-svn: 220981
2014-10-31 18:06:26 +00:00
Sean Callanan b678b90749 - Fixed a bug where ::Describe for class descriptors
would fail if the class had no ivars.

- Updated use of the RealizeType API by the class
  descriptors to use "for_expression" rather than
  the misnamed "allow_unknownanytype."

llvm-svn: 220980
2014-10-31 18:05:26 +00:00
Sean Callanan a330933f15 - Use "for_expression" rather than "allow_unknownanytype"
to indicate that we're doing stuff for the expression
  parser.

- When for_expression is true, look through @s and find
  the actual class rather than just returning id. 

- Rename BuildObjCObjectType to BuildObjCObjectPointerType
  since it's actually returning an object *pointer* type.

llvm-svn: 220979
2014-10-31 18:02:30 +00:00
Justin Hibbits db39cdfbb7 Fix some bugs from D5988
Summary:
Ed Maste found some problems with the commit in D5988.  Address most of these.
While here, also add floating point return handling.  This doesn't handle
128-bit long double yet.  Since I don't have any system that uses it, I don't
currently have plans to implement it.

Reviewers: emaste

Reviewed By: emaste

Subscribers: emaste, lldb-commits

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

llvm-svn: 220963
2014-10-31 15:57:52 +00:00
Jason Molenda 0abae879ad Update default disassembly format string so we get
better output when we don't have any symbol name.
It looked like this:

0x1097fd029 <ud2    
0x1097fd02b <addb   %al, (%rax)

now, like this:

0x10cdd3064: ud2    
0x10cdd3066: addb   %al, (%rax)

<rdar://problem/18833391> 

llvm-svn: 220948
2014-10-31 03:40:06 +00:00
Justin Hibbits 6256a0ea8f First cut of PowerPC(64) support in LLDB.
Summary:
This adds preliminary support for PowerPC/PowerPC64, for FreeBSD.  There are
some issues still:

 * Breakpoints don't work well on powerpc64.
 * Shared libraries don't yet get loaded for a 32-bit process on powerpc64 host.
 * Backtraces don't work.  This is due to PowerPC ABI using a backchain pointer
   in memory, instead of a dedicated frame pointer register for the backchain.
 * Breakpoints on functions without debug info may not work correctly for 32-bit
   powerpc.

Reviewers: emaste, tfiala, jingham, clayborg

Reviewed By: clayborg

Subscribers: emaste, lldb-commits

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

llvm-svn: 220944
2014-10-31 02:34:28 +00:00
Greg Clayton c3eefa39cc Get the correct process architecture in ProcessKDP::DidAttach().
<rdar://problem/18806212>

llvm-svn: 220938
2014-10-31 00:06:52 +00:00
Zachary Turner c19cf1d424 Remove #include <codecvt>. It isn't supported on all compilers.
Also it wasn't being used anyway, so it appears to be a dead include.

llvm-svn: 220921
2014-10-30 19:42:08 +00:00
Enrico Granata 2206b48d6d Also port the C string reading code in ValueObject over to using StringPrinter API
llvm-svn: 220917
2014-10-30 18:27:31 +00:00
Ed Maste 236a5bc619 Fix CMake build, adding StringPrinter.cpp from r220894
llvm-svn: 220909
2014-10-30 14:50:42 +00:00
Enrico Granata ca6c8ee23b Start adopting the StringPrinter API. The StringPrinter API is the new blessed way of printing strings that supports escaping non-printables, and has better handling of different UTF encodings
llvm-svn: 220894
2014-10-30 01:45:39 +00:00
Enrico Granata a449e8642f Add the ability for a ClangASTType to be marked as 'packed' when constructed
llvm-svn: 220891
2014-10-30 00:53:28 +00:00
Enrico Granata 76b08d584b Fix the NSPathStore2 data formatter to actually handle the explicit length stored inside the object. The meat of this commit, however, is a nice little API for easily adding new __lldb_autogen_ helper types to an AST context
llvm-svn: 220881
2014-10-29 23:08:02 +00:00
Enrico Granata b6d7cba141 Shuffle a couple of formatters around. This should fix the bug that never dies, aka rdar://15154623
llvm-svn: 220836
2014-10-29 01:03:09 +00:00
Enrico Granata e0afce767a Add a few functions to SBType to handle arrays and typedefs. Fixes rdar://12675166
llvm-svn: 220824
2014-10-28 21:44:06 +00:00
Enrico Granata 88282c69f3 Add a feature where a string data formatter can now be partially composed of Python summary functions
This works similarly to the {thread/frame/process/target.script:...} feature - you write a summary string, part of which is

${var.script:someFuncName}
someFuncName is expected to be declared as
def someFuncName(SBValue,otherArgument) - essentially the same as a summary function

Since . -> [] are the only allowed separators, and % is used for custom formatting, .script: would not be a legitimate symbol anyway, which makes this non-ambiguous

llvm-svn: 220821
2014-10-28 21:07:00 +00:00
Enrico Granata 4f2fe82b6d When trying to get the element type of an array type, do not go to the canonical type, since that will strip typedefs where we want them to be preserved. Fixes rdar://15453076
llvm-svn: 220810
2014-10-28 18:25:50 +00:00
Jason Molenda 2586e94bfb Add breakpoint instruction byte sequences for arm to
PlatformLinux::GetSoftwareBreakpointTrapOpcode.

Patch by Stephane Sezer.
http://reviews.llvm.org/D5923

llvm-svn: 220762
2014-10-28 03:43:54 +00:00
Hafiz Abid Qadeer f289628178 Stub out 'close' call on m_master_fd for Windows.
PseudoTerminal.cpp uses a dummy implementation of posix_openpt for Windows. This
implementation just returns 0. So m_master_fd is 0. But destructor calls 'close'
on m_master_fd. This 'close' calls seems un-necessary as m_master_fd was never
opened in first place and calling 'close' on 0 can have other un-intended 
consequences.

I am committing it as obvious as it is only a one-liner. Long term, we may want
to refactor this class.

llvm-svn: 220705
2014-10-27 19:27:00 +00:00
Hafiz Abid Qadeer 01db53848e Added a missing call to 'Reset'.
HostThreadWindows::Join() did not call the Reset as is done by
the HostThreadPosix::Join(). As a result, future call to 
IsJoinable() can fail.

Committed as obvious.
 

llvm-svn: 220651
2014-10-26 21:38:43 +00:00
Jim Ingham fa39bb4a56 Setting breakpoints with name mask eFunctionNameTypeBase was broken for straight C names by 220432. Get
that working again.

llvm-svn: 220602
2014-10-25 00:33:55 +00:00
Zachary Turner 7c2896a234 Implement explicit thread stack size specification on Windows.
llvm-svn: 220596
2014-10-24 22:06:29 +00:00
Zachary Turner 047a070f7c Make ProcessWindows just use Host::LaunchProcess.
llvm-svn: 220574
2014-10-24 17:51:56 +00:00
Enrico Granata 249d639786 Fix a problem where an SBType was advertising its static type class even though a dynamic type was available. Solves rdar://18744420
llvm-svn: 220511
2014-10-23 21:15:20 +00:00
Hafiz Abid Qadeer ae9446088b Fix code where goto jumped over local variable initialization.
llvm-svn: 220473
2014-10-23 10:36:53 +00:00
Enrico Granata 2809b98c0e Reverting r220435. Jim Ingham and I discussed this for a bit, and we came up with a better command model for this feature
llvm-svn: 220437
2014-10-22 22:33:08 +00:00
Enrico Granata 83f231854a Add a 'type info' command, which can be fed one or more local variables - and it will spew out the list of formatters that apply to each of those variables, if any
llvm-svn: 220435
2014-10-22 22:04:40 +00:00
Enrico Granata 6714a0fd09 More cleanup of the CXXFormatterFunctions header
llvm-svn: 220433
2014-10-22 21:47:27 +00:00
Greg Clayton c3795409c9 Fixed name lookups for names that contain "::" but aren't actually C++ qualified C++ names.
To do this, I fixed the  CPPLanguageRuntime::StripNamespacesFromVariableName() function to use a regular expression that correctly determines if the name passed to it is a qualfied C++ name like "a:🅱️:c" or "b::c". The old version of this function was treating '__54-[NSUserScriptTask executeWithInterpreter:arguments::]_block_invoke' as a match with a basename of ']_block_invoke'.

Also fixed a case in the by name lookup of functions where we wouldn't look for the full name if we actually tried to call CPPLanguageRuntime::StripNamespacesFromVariableName() and got an empty basename back.

<rdar://problem/18527866>

llvm-svn: 220432
2014-10-22 21:47:13 +00:00
Greg Clayton fa226b74d1 Re-use the GetMatchAtIndex() that uses the StringRef to avoid code duplication and properly detect when a capture is invalid and return false.
llvm-svn: 220431
2014-10-22 21:43:15 +00:00
Zachary Turner b5c4971a4c Fix CMake build broken after r220421.
llvm-svn: 220430
2014-10-22 21:18:29 +00:00
Enrico Granata e85fe3a4d1 Reorganize some of the data formatters code to simplify CXXFormattersFunction.h. Also, add a synthetic child provider for libc++'s version of std::initializer_list<T>
llvm-svn: 220421
2014-10-22 20:34:38 +00:00
Enrico Granata 50bed5e86f Fix a problem where summary strings could not use a synthetically generated value as part of themselves
llvm-svn: 220414
2014-10-22 20:14:09 +00:00
Matthew Gardiner c928de3e8e Added functions to the C++ API, for the benefit of non-8-bit byte architectures.
New functions to give client applications to tools to discover target byte sizes
for addresses prior to ReadMemory. Also added GetPlatform and ReadMemory to the
SBTarget class, since they seemed to be useful utilities to have.

Each new API has had a test case added.

http://reviews.llvm.org/D5867

llvm-svn: 220372
2014-10-22 07:22:56 +00:00
Jim Ingham a672ecefef The breakpoint location hit counts were getting incremented in
BreakpointLocation::ShouldStop.  That worked but wasn't really right,
since there's nothing to guarantee that won't get called more than
once.  So this change moves that responsibility to the StopInfoBreakpoint
directly, and then it uses the BreakpointSite to actually do the bumping.

Also fix a test case that was assuming if you had many threads running some 
code with a breakpoint in it, the hit count when you stopped would always be
1.  Many of the threads could have hit it at the same time...

<rdar://problem/18577603>

llvm-svn: 220358
2014-10-22 01:54:17 +00:00
Enrico Granata 622be238eb Expose the type-info flags at the public API layer. These flags provide much more informational content to consumers of the LLDB API than the existing TypeClass. Part of the fix for rdar://18517593
llvm-svn: 220322
2014-10-21 20:52:14 +00:00
Eric Christopher 098f898fd2 Move anonymous types declared in an anonymous union to
outside the anonymous union as it's a language extension
we don't normally support.

llvm-svn: 220320
2014-10-21 20:39:34 +00:00
Eric Christopher f75b0ee2ab Remove unused variable.
llvm-svn: 220319
2014-10-21 20:36:17 +00:00
Eric Christopher a2b05d0441 Fix implicit conversion of NULL constant to 'bool'.
llvm-svn: 220318
2014-10-21 20:35:35 +00:00