Commit Graph

1563 Commits

Author SHA1 Message Date
Jason Molenda 62e0681afb Add -Wimplicit-fallthrough command line option to clang in
the xcode project file to catch switch statements that have a
case that falls through unintentionally.

Define LLVM_FALLTHROUGH to indicate instances where a case has code
and intends to fall through.  This should be in llvm/Support/Compiler.h;
Peter Collingbourne originally checked in there (r237766), then
reverted (r237941) because he didn't have time to mark up all the
'case' statements that were intended to fall through.  I put together
a patch to get this back in llvm http://reviews.llvm.org/D17063 but
it hasn't been approved in the past week.  I added a new
lldb-private-defines.h to hold the definition for now.

Every place in lldb where there is a comment that the fall-through
is intentional, I added LLVM_FALLTHROUGH to silence the warning.
I haven't tried to identify whether the fallthrough is a bug or
not in the other places.

I haven't tried to add this to the cmake option build flags.
This warning will only work for clang.

This build cleanly (with some new warnings) on macosx with clang
under xcodebuild, but if this causes problems for people on other
configurations, I'll back it out.

llvm-svn: 260930
2016-02-16 04:14:33 +00:00
Sean Callanan 7b3ef05a37 Objective-C++ is a kind of C++.
llvm-svn: 260715
2016-02-12 19:47:57 +00:00
Sean Callanan 92734d1b2b Make Target::CalculateProcess() return a sensible result.
The Calculate* functions in general should not derive any information that isn't
implicit, but for Target the process pointer is a member so it's fine to return
it for CalculateProcess().

llvm-svn: 260713
2016-02-12 19:45:31 +00:00
Greg Clayton ae088e52f3 Now that SymbolFileDWARF supports having types in completely separate .pcm file with "-fmodules -gmodules", each SymbolFileDWARF can reference module DWARF info by looking in other DWARF files. Then if you have 1000 .o files that each reference one or more .pcm files in their debug info, a simple Module::FindTypes(...) call can end up searching the same .pcm file over and over and over. Now all internal FindTypes methods in classes (ModuleList, Module, SymbolFile) now take an extra argument:
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files
    
Each time a SymbolFile::FindTypes() is called, it needs to check the searched_symbol_files list to make sure it hasn't already been asked to find the type and return immediately if it has been checked. This will stop circular dependencies from also crashing LLDB during type queries. 

This has proven to be an issue when debugging large applications on MacOSX that use DWARF in .o files. 

<rdar://problem/24581488>

llvm-svn: 260434
2016-02-10 21:28:13 +00:00
Enrico Granata 41571781c0 Per Jim's suggestion, move checks that we're not mixing and matching Debuggers and Commands deeper in the bowels of LLDB
NFC

llvm-svn: 259972
2016-02-06 01:36:07 +00:00
Enrico Granata 0a66e2f135 Fix an issue where certain CommandObjects (or Options thereof) were being created once, bound to a specific CommandInterpreter (and hence a specific Debugger), and then cached for reuse across different Debugger instances
Obviously, if the original Debugger goes away, those commands are holding on to now stale memory, which has the potential to cause crashes

Fixes rdar://24460882

llvm-svn: 259964
2016-02-06 00:43:07 +00:00
Jim Ingham a1ca8148a1 Fix a little threading thinko in StartPrivateStateThread - don't pass stack variables
as args to a pthread_create function...

<rdar://problem/24485206>

llvm-svn: 259738
2016-02-04 01:34:33 +00:00
Jim Ingham ac96dd3335 Remove a stray ;.
llvm-svn: 259685
2016-02-03 19:49:03 +00:00
Jim Ingham 22eeb7227c The SetStopInfo from a Mach Exception was setting the stop
reason to None when we stop due to a trace, then noticed that
we were on a breakpoint that was not valid for the current thread.
That should actually have set it back to trace.

This was pr26441 (<rdar://problem/24470203>)

llvm-svn: 259684
2016-02-03 19:45:31 +00:00
Siva Chandra b90168ff41 Fix a thinko in StackFrame::GetInScopeVariableList.
Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 259607
2016-02-02 23:49:41 +00:00
Jim Ingham cbff63adb4 Fixed a couple of places where we were getting the module from a
section and using it w/o checking that it was valid.  This can
cause crashes - usually when tearing down a target.

llvm-svn: 259237
2016-01-29 20:21:33 +00:00
Eugene Zelenko c33088f41e Remove autoconf support from source directories.
Differential revision: http://reviews.llvm.org/D16662

llvm-svn: 259098
2016-01-28 22:05:24 +00:00
Bhushan D. Attarde df5f0b448c [LLDB][MIPS] A small fix in GetBreakableLoadAddress() for MIPS
SUMMARY:
    Get the load address for the address given by symbol and function.
    Earlier, this was done for function only, this patch does it for symbol too.
    This patch also adds TestAvoidBreakpointInDelaySlot.py to test this change.
    
    Reviewers: clayborg
    Subscribers: labath, zturner, mohit.bhakkad, sagar, jaydeep, lldb-commits
    Differential Revision: http://reviews.llvm.org/D16049

llvm-svn: 258919
2016-01-27 10:16:30 +00:00
Saleem Abdulrasool 329860e495 Revert r258546.
Seems that the patch was rebased on top of another change which obsoleted the
change but wasnt caught.

Thanks to nbjoerg for pointing this out!

llvm-svn: 258821
2016-01-26 17:43:48 +00:00
Saleem Abdulrasool 79e6749da3 Target: fix -Wcast-qual warning
We were unnecessarily stripping the const qualifier on the temporary variable.
Restore the constness to avoid the warning.  NFC.

llvm-svn: 258547
2016-01-22 20:26:32 +00:00
Saleem Abdulrasool 27ea26b7c0 Silence -Wreturn-type warnings
Address a couple of instances of -Wreturn-type warning from GCC.  The switches
are covered, add an llvm_unreachable to the end of the functions to silence the
warning.  NFC.

llvm-svn: 258546
2016-01-22 20:26:30 +00:00
Davide Italiano 13fe2a9517 Placate MVSC after my last commit.
Zachary introduced the 'default' case explicitly to placate a warning in
the Microsoft compiler but that broke clang with -Werror. 
The new code should keep both compilers happy.

llvm-svn: 258212
2016-01-19 22:47:51 +00:00
Davide Italiano 576dc8d27d [Process] Remove dead code. All the switch cases are already covered.
llvm-svn: 258199
2016-01-19 21:59:12 +00:00
Oleksiy Vyalov 8b85b03b06 Implementing the method Target::TargetEventData::Dump (Stream *s) so that its clients can easily dump it out for informational messages.
http://reviews.llvm.org/D16244

Submitting on behalf of vishwesh@google.com.

llvm-svn: 258150
2016-01-19 17:54:47 +00:00
Sean Callanan b0300a4c30 Enable the use of modules in the expression parser by default.
If your program refers to modules (as indicated in DWARF) we will now try to
load these modules and give you access to their types in expressions.  This used
to be gated by a setting ("settings set target.auto-import-clang-modules true")
but that setting defaulted to false.  Now it defaults to true -- but you can
disable it by toggling the setting to false.

llvm-svn: 257812
2016-01-14 21:46:09 +00:00
Zachary Turner a505be4e5d Fix some compiler warnings with MSVC 2015.
llvm-svn: 257671
2016-01-13 21:22:00 +00:00
Jason Molenda fd4cea53d5 Re-apply r257117 (reverted in r257138 temporarily),
with the one change that ThreadPlanStepOut::ThreadPlanStepOut
will now only advance the return address breakpoint to
the end of a source line, if we have source line debug information.
It will not advance to the end of a Symbol if we lack source line
information.  This, or the recognition of the LEAVE instruction
in r257209, would have fixed the regression that Siva was seeing.
Both were good changes, so I've made both.

Original commit message:

Performance improvement: Change lldb so that it puts a breakpoint
on the first branch instruction after a function return (or the end
of a source line), instead of a breakpoint on the return address,
to skip an extra stop & start of the inferior process.

I changed Process::AdvanceAddressToNextBranchInstruction to not
take an optional InstructionList argument - no callers are providing
a cached InstructionList today, and if this function was going to
do that, the right thing to do would be to fill out / use a
DisassemblerSP which is a disassembler with the InstructionList for
this address range.


http://reviews.llvm.org/D15708
<rdar://problem/23309838> 

llvm-svn: 257210
2016-01-08 21:40:11 +00:00
Jason Molenda 7cb9d98cf9 Revert r257117 "Performance improvement: Change lldb so that it
puts a breakpoint" it is causing a regression in the TestStepNoDebug
test case on ubuntu 14.04 with gcc 4.9.2.  Thanks for the email
Siva.  I'll recommit when I've figured out the regression.

llvm-svn: 257138
2016-01-08 02:26:03 +00:00
Jason Molenda b4a8b4c401 Performance improvement: Change lldb so that it puts a breakpoint
on the first branch instruction after a function return (or the end
of a source line), instead of a breakpoint on the return address,
to skip an extra stop & start of the inferior process.

I changed Process::AdvanceAddressToNextBranchInstruction to not
take an optional InstructionList argument - no callers are providing
a cached InstructionList today, and if this function was going to
do that, the right thing to do would be to fill out / use a
DisassemblerSP which is a disassembler with the InstructionList for
this address range.


http://reviews.llvm.org/D15708
<rdar://problem/23309838> 

llvm-svn: 257117
2016-01-08 00:06:03 +00:00
Pavel Labath 2acc48827e Fix a typo in Process.cpp
llvm-svn: 256852
2016-01-05 17:55:32 +00:00
Jim Ingham 277dc3f4d5 Fix formatting for last commit.
llvm-svn: 255973
2015-12-18 02:15:25 +00:00
Jim Ingham a202357197 Make the Language print the description of the Exception Breakpoint resolver. Also
have the breakpoint description print the precondition description if one exists.
No behavior change.

<rdar://problem/22885189>

llvm-svn: 255972
2015-12-18 02:14:04 +00:00
Kate Stone ef8b4e22f7 Set the minimum stack size for private state thread to 8MB
Demangling complex Boost symbols can exhaust the default stack size.  In practice, any thread that calls into LLDB functionality that touches symbols runs this risk.  Guaranteeing a reasonable minimum for our own private state thread addressees some known scenarios debugging processes that make use of cpp-netlib.

llvm-svn: 255868
2015-12-17 01:37:00 +00:00
Dawn Perchik bfd96183ef Rework breakpoint language filtering to use the symbol context's language.
This patch reworks the breakpoint filter-by-language patch to use the
symbol context instead of trying to guess the language solely from the
symbol's name. This has the advantage that symbols compiled with debug
info will have their actual language known. Symbols without debug info
will still do the same "guess"ing because Symbol::GetLanguage() is
implemented using Mangled::GuessLanguage(). The recognition of ObjC
names was merged into Mangled::GuessLanguage.

Reviewed by: jingham, clayborg
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D15326

llvm-svn: 255808
2015-12-16 19:40:00 +00:00
Eugene Zelenko e65b2cf297 Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/.
Simplify smart pointers checks in conditions. Other minor fixes.

llvm-svn: 255598
2015-12-15 01:33:19 +00:00
Kamil Rytarowski cec6b45aec Welcome to NetBSD signals
Summary:
Signals 1-32 are matching the default UNIX platform.

There are platform specific ones above 32.

From the `/usr/include/sys/signal.h` header:

```
#define SIGPWR          32      /* power fail/restart (not reset when caught) */
#ifdef _KERNEL
#define SIGRTMIN        33      /* Kernel only; not exposed to userland yet */
#define SIGRTMAX        63      /* Kernel only; not exposed to userland yet */
#endif
```

Reviewers: emaste, joerg

Subscribers: lldb-commits

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

llvm-svn: 255592
2015-12-15 00:50:19 +00:00
Jason Molenda 25d5b10b22 When constructing an address range to "step" or "next" through,
find the largest address range (possibly combining multiple 
LineEntry's for this line number) that is contiguous.

This allows lldb's fast-step stepping algorithm to potentially
run for a longer address range than if we have to stop at every
LineEntry indicating a subexpression in the source line.

http://reviews.llvm.org/D15407
<rdar://problem/23270882> 

llvm-svn: 255590
2015-12-15 00:40:30 +00:00
Jason Molenda a38312a9a4 Fix the L1 cache search in MemoryCache::Read to use the
stl upper_bound method instead of lower_bound - we were
failing to find some cached data in the L1 cache resulting
in extra memory read packets while stepping.

The bug with the existing code looked like this:
If the L1 cache has 8 bytes at address 0x1000 and 8 bytes
at address 0x2000 and we are searching for 4 bytes at 0x2004,
the use of lower_bound would return the end() of the container
and so we would incorrectly treat the memory as uncached.

(the L1 cache is memory seeded from debugserver in the T aka
questionmark packet, where debugserver will send up the stack
memory that likely contains the caller's stack pointer and 
frame pointer values.)

<rdar://problem/23869227> 

llvm-svn: 255421
2015-12-12 03:06:10 +00:00
Eugene Zelenko e2ccd33359 Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in source/Target/Target.cpp.
Simplify smart pointers checks in conditions.

llvm-svn: 255364
2015-12-11 19:52:15 +00:00
Sean Callanan 77decf5f20 When printing warnings, the repeat_key should be
const void * because the data is never accessed,
the pointer is the only useful piece of data.

llvm-svn: 255090
2015-12-09 01:25:01 +00:00
Tamas Berghammer ccd6cffba3 Modify "platform connect" to connect to processes as well
The standard remote debugging workflow with gdb is to start the
application on the remote host under gdbserver (e.g.: gdbserver :5039
a.out) and then connect to it with gdb.

The same workflow is supported by debugserver/lldb-gdbserver with a very
similar syntax but to access all features of lldb we need to be
connected also to an lldb-platform instance running on the target.

Before this change this had to be done manually with starting a separate
lldb-platform on the target machine and then connecting to it with lldb
before connecting to the process.

This change modifies the behavior of "platform connect" with
automatically connecting to the process instance if it was started by
the remote platform. With this command replacing gdbserver in a gdb
based worflow is usually as simple as replacing the command to execute
gdbserver with executing lldb-platform.

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

llvm-svn: 255016
2015-12-08 14:08:19 +00:00
Tamas Berghammer 4fbd67ac11 Add a new option to Platform::LoadImage to install the image
This change introduce 3 different working mode for Platform::LoadImage
depending on the file specs specified.
* If only a remote file is specified then the remote file is loaded on
  the target (same behavior as before)
* If only a local file is specified then the local file is installed to
  the current working directory and then loaded from there.
* If both local and remote file is specified then the local file is
  installed to the specified location and then loaded from there.

The same options are exposed on the SB API with a new method LoadImage
method while the old signature presers its meaning.

On the command line the installation of the shared library can be specified
with the "--install" option of "process load".

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

llvm-svn: 255014
2015-12-08 13:43:59 +00:00
Pavel Labath 19da1f16c2 Recommit "Fix race during process interruption"
This is a resubmit of r254403, see that commit's message for context. This fixes an issue in the
original commit, where we would incorrectly interrupt the process if the interrupt request came
just as we were about to send the stopped event to the public.

llvm-svn: 254902
2015-12-07 12:36:52 +00:00
Dawn Perchik f268357514 Fix breakpoint language filtering for other C variants (like C99) and Pascal.
This patch fixes setting breakpoints on symbol for variants of C and
Pascal where the language is "unknown" within the filter-by-language
process added in r252356. It also renames GetLanguageForSymbolByName to
GuessLanguageForSymbolByName and adds comments explaining the pitfalls
of the flawed assumption that the language can be determined solely from
the name and target.

Reviewed by: jingham
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D15175

llvm-svn: 254753
2015-12-04 19:34:00 +00:00
Jason Molenda afdf6cbf3c Add a space char so step logging doesn't print things like
"Stepping out from a.out`bar at a.c:3returning to frame"

llvm-svn: 254698
2015-12-04 02:52:49 +00:00
Enrico Granata f3129cbd84 Add a newline at the end of this file
llvm-svn: 254666
2015-12-03 23:53:45 +00:00
Mohit K. Bhakkad 8be7499507 [LLDB] Switch to assembly view if source is moved
Reviewers: clayborg, jingham, jasonmolenda.
Subscribers: jaydeep, bhushan, sagar, nitesh.jain,lldb-commits.
Differential Revision: http://reviews.llvm.org/D12877

llvm-svn: 254588
2015-12-03 04:56:16 +00:00
Tamas Berghammer 3cb132a0f4 Fix "process load/unload" on android
On android the symbols exposed by libdl (dlopen, dlclose, dlerror)
prefixed by "__dl_". This change moves the handling of process
load/unload to the platform object and override it for android to
handle the special prefix.

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

llvm-svn: 254504
2015-12-02 11:58:51 +00:00
Pavel Labath 00fea63627 Revert "Fix race during process interruption"
The android buildbot gets quite flaky after this change. I'm reverting it while I investigate.

llvm-svn: 254430
2015-12-01 17:59:56 +00:00
Pavel Labath df55f522bd Fix race during process interruption
Summary:
The following situation was occuring in TestAttachResume:
- we did a "continue" from a breakpoint (which involves a private start-stop to step over the
  breakpoint)
- after receiving the stop-reply from the step-over, we issue a "detach" (which requires a
  process interrupt)
- at this moment, the public state is "running", private state is "about-to-be-stopped" (the
  stopped event was broadcast, but it was not received yet)
- StopForDestroyOrDetach (public thread) notes the public state is running, sends an interrupt
  request to the private thread
- private thread gets the eBroadcastBitInterrupt (before the eStateStopped message), and asks the
  process plugin to stop (via Halt())
- process plugin says it has nothing to do as the process is already stopped
- private thread shrugs and carries on. receives the stop event, restores the breakpoint and
  resumes the process.
- after a while, the public thread times out and says it failed to stop the process

This patch does the following:
- splits Halt() into two functions, private and public, their usage depends on the context
  - public Halt(): sends eBroadcastBitInterrupt to the private thread and waits for the Stop
    event
  - HaltPrivate(): asks the plugin to stop and makes a note that the halt was requested. When the
    next stop event comes it sets the interrupt flag on it.
- removes HijackPrivateProcessEvents(), as the only user (old Halt()) has gone away
- removes the m_currently_handling_event hack, as the new Halt() does not need it
- adds a use_run_lock parameter to public Halt() and WaitForProcessToStop(). This was needed
  because RunThreadPlan uses Halt() while holding the run lock and we don't want Halt() to take
  it away from him.

Reviewers: clayborg, jingham

Subscribers: lldb-commits

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

llvm-svn: 254403
2015-12-01 11:28:47 +00:00
Jason Molenda e92a74ce64 Add code to PlatformDarwin and HostInfoMacOSX so they return the
correct OS type when running on an apple tv or apple watch.
Also, in TargetList::CreateTargetInternal, check that a platform
is returned by GetPlatformForArchitecture fallback instead of 
adding it to the vector of platforms unconditionally; we can end up
crashing when we call a member function on it later.

<rdar://problem/23601982>, <rdar://problem/21292886>

llvm-svn: 253763
2015-11-21 04:00:43 +00:00
Enrico Granata 46252398f0 Fix up LLDB for a change in the way clang represents anonymous unions such that the 'frame variable' command can still find the members of such union as if they were top-level variables in the current scope
llvm-svn: 253613
2015-11-19 22:28:58 +00:00
Enrico Granata 293207dd57 Pass the ExecutionContext as well, since it is actually useful
llvm-svn: 253537
2015-11-19 02:50:27 +00:00
Enrico Granata d4129b47d0 Allow the language plugins a say in how the function name is rendered as part of frame formatting
llvm-svn: 253531
2015-11-19 01:11:53 +00:00
Jim Ingham 055a08a488 Add the ability (through the SB API & command line) to specify an address
breakpoint as "file address" so that the address breakpoint will track that
module even if it gets loaded in a different place.  Also fixed the Address
breakpoint resolver so that it handles this tracking correctly.

llvm-svn: 253308
2015-11-17 03:39:13 +00:00
Zachary Turner 8f186f8574 Change the null check to an assert.
llvm-svn: 253092
2015-11-13 21:53:03 +00:00
Zachary Turner 0ee8282f4a Add a null check against the ThreadPlan
I'm seeing some cases where the ThreadPlan is null.  It could
be a sign of a valid race condition, but at least we shouldn't
crash.

llvm-svn: 253086
2015-11-13 21:28:53 +00:00
Jim Ingham a3f466b9e7 Fix commit 252963 to work around a bug on some platforms where they don't
correctly handle stepping over one breakpoint directly onto another breakpoint.  
This isn't fixing that bug, but rather just changing 252963 to not use breakpoints
if it is only stepping one instruction.

llvm-svn: 253008
2015-11-13 03:37:48 +00:00
Ying Chen 1f6689eae3 Revert "Another little stepping optimization: if any of the source step commands are running through a range "
- Revert because this commit introduce several failures in lldb test suite
- http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/8391
- This reverts commit 78943bb678c2893703ee4e8b41969372740c8a6f.

llvm-svn: 252980
2015-11-13 00:31:21 +00:00
Jim Ingham 127be38fb8 Another little stepping optimization: if any of the source step commands are running through a range
of addresses, and the range has no branches, instead of running to the last instruction and
single-stepping over that, run to the first instruction after the end of the range.  If there
are no branches in the current range, then the bytes right after it have to be in the current
function, and have to be instructions not data in code, so this is safe.  And it cuts down one
extra stepi per source range step.

Incidentally, this also works around a bug in the llvm Intel assembler where it treats the "rep" 
prefix as a separate instruction from the repeated instruction.  If that were at the end of a
line range, then we would put a trap in place of the repeated instruction, which is undefined
behavior.  Current processors just ignore the repetition in this case, which changes program behavior.
Since there would never be a line range break after the rep prefix, always doing the range stepping 
to the beginning of the new range avoids this problem.

<rdar://problem/23461686>

llvm-svn: 252963
2015-11-12 22:32:09 +00:00
Sean Callanan a3444ffcdd Made the ClangASTImporter into a shared pointer, eliminating a race condition.
It used to be a unique pointer, and there could be a case where ClangASTSource
held onto a copy of the pointer but Target::Destroy destroyed the unique pointer
in the mean time.

I also ensured that there is a validity check on the target (which confirms that
a ClangASTImporter can be generated) before the target's shared pointer is
copied into ClangASTSource.

This race condition caused a crash if Target::Destroy was called and then later
the target objecct was deleted.

llvm-svn: 252665
2015-11-10 22:54:42 +00:00
Enrico Granata 608d67c152 Introduce a way for Languages to specify whether values of "reference types" are "nil" (not pointing to anything) or uninitialized (never made to point at anything)
This latter determination may or may not be possible on a per-language basis; and neither is mandatory to implement for any language

Use this knowledge in the ValueObjectPrinter to generalize the notion of IsObjCNil() and the respective printout

llvm-svn: 252663
2015-11-10 22:39:15 +00:00
Jason Molenda d91c3fdfb8 Upstream a small change from Greg Clayton for the REPL support:
"Modify internal breakpoints so they resolve just like external
breakpoints do. This allow you to set symbol and file + line internal
breakpoints and have them get updated correctly."

<rdar://problem/16931767>

llvm-svn: 252584
2015-11-10 04:18:12 +00:00
Jason Molenda dad8af4cf6 The other half of a change made by Enrico for trying to get a correct
triple for a process.  He writes, "Changes to the way setting the
triple works on a target so that if the target has passed a fully
specified triple, and the newly passed triple is not a revamp of
the current one, and the current one is fully specified, then do
not replace the existing triple."

Triple handling got a bit more complicated on mac with the addition
of ios/watchos/tvos and their simulators, and tracking the correct
os versions for them so expressions are compiled with the expected
APIs available to the user.

<rdar://problem/19820698> 

llvm-svn: 252583
2015-11-10 04:11:37 +00:00
Bruce Mitchener 9ccb970f23 Make lldb::endian::InlHostByteOrder() private.
Summary:
Since this is within the lldb namespace, the compiler tries to
export a symbol for it. Unfortunately, since it is inlined, the
symbol is hidden and this results in a mess of warnings when
building on OS X with cmake.

Moving it to the lldb_private namespace eliminates that problem.

Reviewers: clayborg

Subscribers: emaste, lldb-commits

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

llvm-svn: 252396
2015-11-07 04:40:13 +00:00
Chaoren Lin 6e8fbc6f39 Fix TestThreadSpecificBreakpoint.py on Linux after rL252355.
Summary:
On Linux, if a thread-specific conditional breakpoint was hit, it
won't necessarily be the thread that hit the breakpoint itself that
evaluates the conditional expression, so the thread that hit the
breakpoint could still be asked to stop, even though it hasn't been
allowed to run since the previous stop.

Reviewers: sivachandra, jingham

Subscribers: lldb-commits

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

llvm-svn: 252391
2015-11-07 02:16:31 +00:00
Jim Ingham 0fcdac363c Make the language specifier to "break set" actually filter the names by their language. So for
instance:

break set -l c++ -r Name

will only break on C++ symbols that match Name, not ObjC or plain C symbols.  This also works
for "break set -n" and there are SB API's to pass this as well.

llvm-svn: 252356
2015-11-06 22:48:59 +00:00
Jim Ingham 569aaf9e1a Another optimization to keep down gdb-remote traffic. If we have suspended a thread while
running, don't request the thread status when deciding why we stopped.

llvm-svn: 252355
2015-11-06 22:45:57 +00:00
Jason Molenda 9d58c72848 Add a warning to TargetList::CreateTargetInternal
so when it is run on a kext (which won't activate
any platform plugins), you'll get a warning message
which may be helpful to the user.

llvm-svn: 252245
2015-11-05 23:59:30 +00:00
Jason Molenda a814f704d3 Add support for the new (added last week) llvm::Triple::WatchOS and ::TvOS
in places where we check for Triple::IOS.  They're mostly the same as far
as lldb is conerned.
.
Also add a base cass implementation for Process::IsAlive - Greg added this 
last year but it didn't get upstreamed.

llvm-svn: 252227
2015-11-05 23:03:44 +00:00
Jim Ingham 13c30d2f7d Let the process help figure out the Host OS if nobody else
can figure it out.

llvm-svn: 252224
2015-11-05 22:33:17 +00:00
Jim Ingham 2c38141423 Add "zero_memory" option to IRMemoryMap::FindSpace & IRMemoryMap::Malloc. Zero out
the Expression ResultVariable so it's in a known initial state.

llvm-svn: 252072
2015-11-04 20:32:27 +00:00
Enrico Granata b766292951 Fix an issue where LLDB would truncate summaries for string types without producing any evidence thereof
llvm-svn: 252018
2015-11-04 00:02:08 +00:00
Pavel Labath 862432c90e Fix race during process detach
Summary:
The code which was preventing the usage of the OS plugin while detach is in
progress also prevented us to update the thread list correctly. This resulted
in an empty thread list, which confused the detaching logic. Change the
condition do only do what it says (disable the usage of the OS plugin).

Reviewers: clayborg, jingham

Subscribers: lldb-commits

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

llvm-svn: 251932
2015-11-03 16:05:18 +00:00
Mohit K. Bhakkad 13763c3046 [LLDB][Watchpoint] Change ignore_count condition location to fix watchpoint ignore feature for architectures with watchpoint_exceptions_received=before
Reviewers: jingham.
Subscribers: clayborg, jaydeep, bhushan, sagar, nitesh.jain, lldb-commits.
Differential Revision: http://reviews.llvm.org/D13296

llvm-svn: 251905
2015-11-03 09:04:33 +00:00
Jim Ingham 19a63fc6fa Add the ability to pass an EvaluateExpressionOptions when you make a UserExpression. This
isn't used in this commit but will be in a future commit.

llvm-svn: 251887
2015-11-03 02:11:24 +00:00
Enrico Granata 407b5c62ba Change ValueObject::IsLogicalTrue so that it starts by asking the applicable Language plugin before using the C-style rule
llvm-svn: 251838
2015-11-02 21:52:05 +00:00
Jim Ingham a309efef39 Change Target::EvaluateExpression to take an ExecutionContextScope * rather than a
StackFrame * (StackFrame is an ExecutionContextScope.)  That allows you to call an
expression on a particular Thread, but not using the context of any particular frame.
That in turn is useful for injecting utility functions that don't actually depend on
locals/self/etc of the current frame.

I also had to include StackFrame.h in a couple of places so the compiler knew
how to downcast StackFrame to ExecutionContextScope.

<rdar://problem/22852953>

llvm-svn: 251564
2015-10-28 22:23:17 +00:00
Adrian McCarthy 3f989d4e6e Revert "Clang module compilation options need to be per-platform."
This reverts commit r251340.

Breaks the Windows build because Windows doesn't have getuid.  The fix is not obvious.

llvm-svn: 251354
2015-10-26 21:38:41 +00:00
Sean Callanan df0ac7038f Clang module compilation options need to be per-platform.
On UNIX (but not Darwin) the username needs to be respected when creating a 
temporary module directory, so that different users don't pollute each others'
module caches.

llvm-svn: 251340
2015-10-26 20:33:24 +00:00
Eugene Zelenko 8f30a65ca3 Fix Clang-tidy modernize-use-override warnings in source/Target; other minor fixes.
llvm-svn: 251134
2015-10-23 18:39:37 +00:00
Sean Callanan 97f84e870f Fix error handling when there are no REPLs installed.
Before, in the absence of any configured REPLs, LLDB would act as if there were
multiple possible REPL options, whereas actually no REPL language is supported.
Now we make a better error.

llvm-svn: 250931
2015-10-21 19:31:17 +00:00
Sean Callanan 93c0b00380 Fixed version of r250913, which actually implements all the static functions.
Thanks to Siva Chandra and Oleksiy Vyalov for pouncing on this.

llvm-svn: 250928
2015-10-21 19:14:33 +00:00
Siva Chandra 654aaf12dc Revert "Made the REPL choose a default language if only one REPL can be chosen."
Summary: This reverts commit babd6dd74e316b1fcd9d171d7d8c83845d51a487.

Reviewers: spyffe

Subscribers: lldb-commits

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

llvm-svn: 250927
2015-10-21 18:58:01 +00:00
Sean Callanan bea731292f Made the REPL choose a default language if only one REPL can be chosen.
This requires REPLs to enumerate the languages they support.

llvm-svn: 250913
2015-10-21 17:43:18 +00:00
Sean Callanan 9a6940cef4 When a REPL creates a new target for itself, it is that target's REPL.
To allow that, I've added a SetREPL call to the Target, which allows a REPL
that just created a target to install itself as the go-to REPL for the
corresponding language.

llvm-svn: 250870
2015-10-21 00:36:34 +00:00
Sean Callanan 3b682de6b1 When target is NULL, provide a debugger so that REPLs can use that to create
their own target.

llvm-svn: 250869
2015-10-21 00:28:44 +00:00
Pavel Labath f29914883d Increase default memory cache line size for android
Summary:
ADB packets have a maximum size of 4k. This means the size of memory reads does not affect speed
too much (as long as it fits in one packet). Therefore, I am increasing the default memory read
size for android to 2k. This value is used only if the user has not modified the default
memory-cache-line-size setting.

Reviewers: clayborg, tberghammer

Subscribers: tberghammer, danalbert, srhines, lldb-commits

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

llvm-svn: 250814
2015-10-20 10:33:17 +00:00
Tamas Berghammer 8f81e88184 Fix build and some warnings after r250798
llvm-svn: 250810
2015-10-20 09:21:04 +00:00
Mohit K. Bhakkad 79be9e8cb5 [LLDB] Insert names with same signo as alias instead of a new entry
Reviewers: clayborg, labath.
Subscribers: jaydeep, dsanders, bhushan, sagar, nitesh.jain, emaste,lldb-commits.
Differential Revision: http://reviews.llvm.org/D13646

llvm-svn: 250801
2015-10-20 07:05:46 +00:00
Sean Callanan 3e7e915dca Added support for the "--repl" argument to LLDB.
This makes LLDB launch and create a REPL, specifying no target so that the REPL
can create one for itself.  Also added the "--repl-language" option, which
specifies the language to use.  Plumbed the relevant arguments and errors
through the REPL creation mechanism.

llvm-svn: 250773
2015-10-20 00:23:46 +00:00
Greg Clayton e75e5d8afa Make sure we restore the process events so they aren't hijacked when using the async attach when attaching to a process by name and with waitfor.
<rdar://problem/22821480>

llvm-svn: 250768
2015-10-20 00:14:20 +00:00
Sean Callanan 6681041d70 Added the concept of a Read-Eval-Print-Loop to LLDB.
A REPL takes over the command line and typically treats input as source code.
REPLs can also do code completion.  The REPL class allows its subclasses to
implement the language-specific functionality without having to know about the
IOHandler-specific internals.

Also added a PluginManager-based way of getting to a REPL given a language and
a target.

Also brought in some utility code and expression options that are useful for
REPLs, such as line offsets for expressions, ANSI terminal coloring of errors,
and a few IOHandler convenience functions.

llvm-svn: 250753
2015-10-19 23:11:07 +00:00
Enrico Granata c8e7649a19 Let Language plugins vend a default DeclPrintingHelper in case a custom one is not specified for the specific invocation
llvm-svn: 250744
2015-10-19 22:04:25 +00:00
Keno Fischer 47db4a2c50 Add a missing Mutex Locker in ResetCurrentInlinedDepth
Summary: This function reads m_frames, so it needs to lock the
mutex like all other function that access m_frames.
Found using AddressSanitizer.

Reviewers: jingham, clayborg

Subscribers: lldb-commits

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

llvm-svn: 250493
2015-10-16 05:17:25 +00:00
Adrian McCarthy 6ecdbc87e6 Factor the execution of the test method into a separate function to ensure that any exceptions that are thrown go out of scope and no longer hold references to SB objects that need to be freed before teardown.
Differential Revision: http://reviews.llvm.org/D13788

llvm-svn: 250467
2015-10-15 22:39:55 +00:00
Stephane Sezer cdb2a11e04 Minor indentation fix in StackFrameList.cpp.
llvm-svn: 250465
2015-10-15 22:24:17 +00:00
Zachary Turner 4eff2d3177 Make uses of /dev/null portable across OSes.
Most platforms have "/dev/null".  Windows has "nul".  Instead of
hardcoding the string /dev/null at various places, make a constant
that contains the correct value depending on the platform, and use
that everywhere instead.

llvm-svn: 250331
2015-10-14 21:37:36 +00:00
Todd Fiala 7df337f85c ArchSpec: fix unintentional promotion of unspecified unknowns to specified unknowns
* ArchSpec::MergeFrom() would erroneously promote an unspecified
  unknown to a specified unknown when both the ArchSpec and the merged
  in ArchSpec were both unspecified unknowns. This no longer happens,
  which fixes issues with global module cache lookup in some
  situations.

* Added ArchSpec::DumpTriple(Stream&) that now properly prints
  unspecified unknowns as '*' and specified unknows as 'unknown'.
  This makes it trivial to tell the difference between the two.
  Converted printing code over ot using DumpTriple() rather than
  building from scratch.

* Fixed up a couple places that were not guaranteeing that an
  unspecified unknown was recorded as such.

llvm-svn: 250253
2015-10-13 23:41:19 +00:00
Jim Ingham c60963c6c7 Fix a misunderstanding of the ThreadPlan::OkayToDiscard flag in InferiorCallPOSIX. It was
set to true, but all plans run by RunThreadPlan need to have this set to false so they will
return control to RunThreadPlan without consulting plans higher on the stack.

Since this seems like a common error, I also modified RunThreadPlan to enforce this behavior.

<rdar://problem/22543166>

llvm-svn: 250084
2015-10-12 19:11:03 +00:00
Jim Ingham 1fd2f08ea9 Return the right answer for ShouldStop for the RunToAddress plan. This isn't
strictly necessary because RunToAddress is always used as a subsidiary plan, so
it's ShouldStop seldom matters.  But get it right anyway.

llvm-svn: 250083
2015-10-12 19:03:32 +00:00
Sean Callanan c7b054a60c Don't blindly use C for eLanguageTypeUnknown when getting a scratch TypeSystem.
Instead check what languages are supported for expressions; use C if available,
but otherwise pick one of the supported languages.
This can be overridden using the target settings.

<rdar://problem/22290878>

llvm-svn: 249864
2015-10-09 18:01:10 +00:00
Sean Callanan fe38c8506f Added support for enumerating the languages that actually support TypeSystems
and expressions.  Also wired that into the OptionValue infrastructure, although
it isn't used for tab-completion yet.

llvm-svn: 249769
2015-10-08 23:07:53 +00:00
Greg Clayton 5beec213e2 Moved the target specific ClangASTContext initialization over into ClangASTContext::CreateInstance.
This involved changing the TypeSystem::CreateInstance to take a module or a target. This allows type systems to create an AST for modules (no expression support needed) or targets (expression support is needed) and return the correct class instance for both cases.

llvm-svn: 249747
2015-10-08 21:04:34 +00:00
Enrico Granata 675f49bbd5 This is the work I was building up to with my patches yesterday
Introduce the notion of Language-based formatter prefix/suffix
This is meant for languages that share certain data types but present them in syntatically different ways, such that LLDB can now have language-based awareness of which of the syntax variations it has to present to the user when formatting those values

This is goodness for new languages and interoperability, but is NFC for existing languages. As such, existing tests cover this

llvm-svn: 249587
2015-10-07 18:36:53 +00:00
Pavel Labath fcc7f6622f Resumbit "Fix race condition during process detach"
This is a resubmission of r248371. It also incorporates the process event hijack patch by Kyrill
Lapshin in D12968.

llvm-svn: 249554
2015-10-07 15:11:11 +00:00
Mohit K. Bhakkad acdff168e2 [LLDB][MIPS] Fix hit_count for mips watchpoints
Reviewers: clayborg, jingham.
Subscribers: jaydeep, bhushan, dsanders, sagar, nitesh.jain, zturner, jasonmolenda, lldb-commits.
Differential Revision: http://reviews.llvm.org/D13241

llvm-svn: 249377
2015-10-06 05:25:17 +00:00
Greg Clayton b3788eaf99 SBTarget::Attach(SBAttachInfo &) was changed to not be asynchronous back in February and this affected Xcode's abililty to cancel an attach to process by name.
Added the ability to specify if an attach by name should be synchronous or not in SBAttachInfo and ProcessAttachInfo.

<rdar://problem/22821480>

llvm-svn: 249361
2015-10-05 22:58:37 +00:00
Sean Callanan a994b0b273 Made GetScratchTypeSystemForLanguage return an error if desired.
Also made it not store nullptrs in its TypeSystemMap, so it will retry to make
the AST context if it errored out last time.

llvm-svn: 249167
2015-10-02 18:40:30 +00:00
Sean Callanan 9301ec1191 Eliminated redundant "constructors" for ClangExpressionVariable.
The ClangExpressionVariable::CreateVariableInList functions looked cute, but                                                                                                                                           
caused more confusion than they solved.  I removed them, and instead made sure                                                                                                                                         
that there are adequate facilities for easily adding newly-constructed                                                                                                                                                 
ExpressionVariables to lists.      

I also made some of the constructors that are common be generic, so that it's
possible to construct expression variables from generic places (like the ABI and
ValueObject) without having to know the specifics about the class.

llvm-svn: 249095
2015-10-01 23:07:06 +00:00
Enrico Granata 9b0af1b86f Add a 'type lookup' command. This command is meant to look up type information by name in a language-specific way.
Currently, it only supports Objective-C - C++ types can be looked up through debug info via 'image lookup -t', whereas ObjC types via this command are looked up by runtime introspection

This behavior is in line with type lookup's behavior in Xcode 7, but I am definitely open to feedback as to what makes the most sense here

llvm-svn: 249047
2015-10-01 18:16:18 +00:00
Oleksiy Vyalov d21ca280cb Use %HOME%/.lldb/module_cache as a default module cache directory.
http://reviews.llvm.org/D13323

llvm-svn: 249040
2015-10-01 17:48:57 +00:00
Sean Callanan 1ab1ee7620 Removed a mutex guard that I accidentally pasted in from other code.
It was causing deadlocks when stepping out.

llvm-svn: 249039
2015-10-01 17:48:25 +00:00
Sean Callanan b92bd7538e Made Target hold a map of languages to TypeSystems, and added some accessors.
Also added some target-level search functions so that persistent variables and
symbols can be searched for without hand-iterating across the map of
TypeSystems.

llvm-svn: 249027
2015-10-01 16:28:02 +00:00
Enrico Granata 6754e04f6d Introudce a IsTopLevelFunction() API on Language and Function
This is meant to support languages that have a scripting mode with top-level code that acts as global

For now, this flag only controls whether 'frame variable' will attempt to treat globals as locals when within such a function

llvm-svn: 248960
2015-09-30 23:12:22 +00:00
Sean Callanan 8f1f9a1be3 Now persistent expression data no longer lives with the Target, but rather with
the corresponding TypeSystem.  This makes sense because what kind of data there
is -- and how it can be looked up -- depends on the language.

Functionality that is common to all type systems is factored out into
PersistentExpressionState.

llvm-svn: 248934
2015-09-30 19:57:57 +00:00
Pavel Labath c8c77d46ef Revert "Fix race condition during process detach"
This fix is not correct on its own until D12968 is resolved. Will resumbit once that is done.

llvm-svn: 248702
2015-09-28 09:37:51 +00:00
Sean Callanan 4dbb271fcc Moved more Clang-specific parts of the expression parser into the Clang plugin.
There are still a bunch of dependencies on the plug-in, but this helps to
identify them.
There are also a few more bits we need to move (and abstract, for example the
ClangPersistentVariables).

llvm-svn: 248612
2015-09-25 20:35:58 +00:00
Bruce Mitchener 3ad353f3f4 Rename clang_type -> compiler_type for variables.
Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 248461
2015-09-24 03:54:50 +00:00
Pavel Labath 84f6f277ac Fix race condition during process detach
Summary:
The following situation occured in TestAttachResume:

The inferior was stoped at a breakpoint and we did a continue, immediately followed by a detach.
Since there was a trap instruction under the IP, the continue did a step-over-breakpoint before
resuming the inferior for real. In some cases, the detach command was executed between these two
events (after the step-over stop, but before continue). Here, public state was running, but
private state was stopped. This caused a problem because HaltForDestroyOrDetach was checking the
public state to see whether it needs to stop the process (call Halt()), but Halt() was checking
the private state and concluded that there is nothing for it to do.

Solution: Instead of Halt() call SendAsyncInterrupt(), which will then cause Halt() to be
executed in the context of the private state thread. I also rename HaltForDestroyOrDetach to
reflect it does not call halt directly.

Reviewers: jingham, clayborg

Subscribers: lldb-commits

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

llvm-svn: 248371
2015-09-23 10:16:57 +00:00
Jaydeep Patil 44d07fcc7c [LLDB][MIPS] microMIPS breakpoints, disassembly and compressed addresses
SUMMARY:
    This patch detects microMIPS symbols, sets breakpoints using un-compressed address and 
    display disassembly in mixed mode for microMIPS applications (running on bare-iron targets).

    Reviewers: clayborg
    Subscribers: nitesh.jain, mohit.bhakkad, sagar, bhushan and lldb-commits
    Differential Revision: http://reviews.llvm.org/D12079

llvm-svn: 248248
2015-09-22 06:36:56 +00:00
Bruce Mitchener 937e3964e2 Further reduction of Clang-related header inclusion.
Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 248176
2015-09-21 16:56:08 +00:00
Tamas Berghammer 6b144354ff Use ClangASTContext for compile units with language eLanguageTypeMipsAssembler
Both GNU AS and LLVM emits language type DW_LANG_Mips_Assembler for
all assembly code.

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

llvm-svn: 248146
2015-09-21 10:08:49 +00:00
Greg Clayton 56939cb310 TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
    lldb::ClangASTContextUP     m_ast;          ///< The Clang AST context for this module.
    lldb::GoASTContextUP        m_go_ast;       ///< The Go AST context for this module.
    
    Now we have a type system map:
    
    typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
    TypeSystemMap               m_type_system_map;    ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:

    class CompilerType
    {
    ...
    
    //----------------------------------------------------------------------
    // Return a new CompilerType that is a L value reference to this type if
    // this type is valid and the type system supports L value references,
    // else return an invalid type.
    //----------------------------------------------------------------------
    CompilerType
    GetLValueReferenceType () const;

    //----------------------------------------------------------------------
    // Return a new CompilerType that is a R value reference to this type if
    // this type is valid and the type system supports R value references,
    // else return an invalid type.
    //----------------------------------------------------------------------
    CompilerType
    GetRValueReferenceType () const;

    //----------------------------------------------------------------------
    // Return a new CompilerType adds a const modifier to this type if
    // this type is valid and the type system supports const modifiers,
    // else return an invalid type.
    //----------------------------------------------------------------------
    CompilerType
    AddConstModifier () const;

    //----------------------------------------------------------------------
    // Return a new CompilerType adds a volatile modifier to this type if
    // this type is valid and the type system supports volatile modifiers,
    // else return an invalid type.
    //----------------------------------------------------------------------
    CompilerType
    AddVolatileModifier () const;

    //----------------------------------------------------------------------
    // Return a new CompilerType adds a restrict modifier to this type if
    // this type is valid and the type system supports restrict modifiers,
    // else return an invalid type.
    //----------------------------------------------------------------------
    CompilerType
    AddRestrictModifier () const;

    //----------------------------------------------------------------------
    // Create a typedef to this type using "name" as the name of the typedef
    // this type is valid and the type system supports typedefs, else return
    // an invalid type.
    //----------------------------------------------------------------------
    CompilerType
    CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
    
    };
    
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed

llvm-svn: 247953
2015-09-17 22:23:34 +00:00
Ryan Brown 65d4d5c3c6 Add an OperatingSystem plugin to support goroutines
The Go runtime schedules user level threads (goroutines) across real threads.
This adds an OS plugin to create memory threads for goroutines.
It supports the 1.4 and 1.5 go runtime.

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

llvm-svn: 247852
2015-09-16 21:20:44 +00:00
Enrico Granata 7cb59e1a0f Move hardcoded formatters from the FormatManager to the Language plugins
llvm-svn: 247831
2015-09-16 18:28:11 +00:00
Jim Ingham 151c032c86 This patch makes Clang-independent base classes for all the expression types that lldb currently vends.
Before we had:

ClangFunction
ClangUtilityFunction
ClangUserExpression

and code all over in lldb that explicitly made Clang-based expressions. This patch adds an Expression 
base class, and three pure virtual implementations for the Expression kinds:

FunctionCaller
UtilityFunction
UserExpression

You can request one of these expression types from the Target using the Get<ExpressionType>ForLanguage. 
The Target will then consult all the registered TypeSystem plugins, and if the type system that matches 
the language can make an expression of that kind, it will do so and return it.

Because all of the real expression types need to communicate with their ExpressionParser in a uniform way, 
I also added a ExpressionTypeSystemHelper class that expressions generically can vend, and a ClangExpressionHelper 
that encapsulates the operations that the ClangExpressionParser needs to perform on the ClangExpression types. 
Then each of the Clang* expression kinds constructs the appropriate helper to do what it needs.

The patch also fixes a wart in the UtilityFunction that to use it you had to create a parallel FunctionCaller 
to actually call the function made by the UtilityFunction. Now the UtilityFunction can be asked to vend a 
FunctionCaller that will run its function. This cleaned up a lot of boiler plate code using UtilityFunctions.

Note, in this patch all the expression types explicitly depend on the LLVM JIT and IR, and all the common 
JIT running code is in the FunctionCaller etc base classes. At some point we could also abstract that dependency 
but I don't see us adding another back end in the near term, so I'll leave that exercise till it is actually necessary.

llvm-svn: 247720
2015-09-15 21:13:50 +00:00
Jim Ingham 0ca778eb2e Make the source-map help grammatical.
llvm-svn: 247709
2015-09-15 18:03:00 +00:00
Enrico Granata ac49453b58 Introduce the notion of an escape helper. Different languages have different notion of what to print in a string and how to escape non-printable things. The escape helper is where this notion is provided to LLDB
This is NFC, other than a code re-org

llvm-svn: 247200
2015-09-09 22:30:24 +00:00
Enrico Granata d3233c1ed7 Data formatter candidate matches can be generated in a number of ways; language-based dynamic type discovery being one of them (for instance, this is what takes an 'id' and discovers that it truly is an __NSArrayI, so it should probably use the NSArray formatter)
This used to be hardcoded in the FormatManager, but in a pluginized world that is not the right way to go

So, move this step to the Language plugin such that appropriate language plugins for a type get a say about adding candidates to the formatters lookup tables

llvm-svn: 247112
2015-09-09 01:10:46 +00:00
Enrico Granata b5be2ffae5 Implement a Target::GetTypeSystemForLanguage API, as well as provide helpers on the TypeSystem to get numeric types of specific sizes and signedness
llvm-svn: 247082
2015-09-08 22:09:19 +00:00
Tamas Berghammer 25b9f7ebd3 Use eAddressClassCode for address lookup for opcodes for stack frames
It is required because of the following edge case on arm:

bx <addr>   Non-tail call in a no return function
[data-pool] Marked with $d mapping symbol

The return address of the function call will point to the data pool but
we have to treat it as code so the StackFrame can calculate the symbols
correctly.

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

llvm-svn: 246958
2015-09-07 09:58:09 +00:00
Sean Callanan bc8ac34e61 This patch separates the generic portion of ClangExpressionVariable, which
stores information about a variable that different parts of LLDB use, from the
compiler-specific portion that only the expression parser cares about.

http://reviews.llvm.org/D12602

llvm-svn: 246871
2015-09-04 20:49:51 +00:00
Tamas Berghammer 980662ee9d Fix TestLoadUnload.test_load_unload for android API > 21
* Change Module::MatchesModuleSpec to return true in case the file spec
  in the specified module spec matches with the platform file spec, but
  not with the local file spec
* Change the module_resolver used when resolving a remote shared module
  to always set the platform file spec to the file spec requested

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

llvm-svn: 246852
2015-09-04 12:42:41 +00:00
Dawn Perchik 009d110de4 Set the default language to use when evaluating to that of the frame's CU.
* Use the frame's context (instead of just the target's) when evaluating,
  so that the language of the frame's CU can be used to select the
  compiler and/or compiler options to use when parsing the expression.
  This allows for modules built with mixed languages to be parsed in
  the context of their frame. 
* Add all C and C++ language variants when determining the language options
  to set.
* Enable C++ language options when language is C or ObjC as a workaround since
  the expression parser uses features of C++ to capture values.
* Enable ObjC language options when language is C++ as a workaround for ObjC
  requirements.
* Disable C++11 language options when language is C++03.
* Add test TestMixedLanguages.py to check that the language being used
  for evaluation is that of the frame.
* Fix test TestExprOptions.py to check for C++11 instead of C++ since C++ has
  to be enabled for C, and remove redundant expr --language test for ObjC.
* Fix TestPersistentPtrUpdate.py to not require C++11 in C.

Reviewed by: clayborg, spyffe, jingham
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D11102

llvm-svn: 246829
2015-09-04 01:02:30 +00:00
Pavel Labath ea3fb8e378 Fix logging message
llvm-svn: 246776
2015-09-03 15:44:14 +00:00
Pavel Labath a9a43373e1 Fix rare failure in TestProcessIO
Summary:
There was a race condition in Process class, where we would not wait for process stdout to
propagate fully before we would shut down the connection (repro case: slow down the stdio thread
by placing a sleep right at the end of the while loop in Communication::ReadThread). The Process
class already tried to solve this problem by synchronizing with the read thread in
Process::ShouldBroadcastEvent, but unfortunately the connection got closed before that in
Process::SetExitStatus. I solve this issue by delaying the connection shutdown until we get a
chance to process the event and synchronize. Alternatively, I could have moved the
synchronization point to an earlier point in SetExitStatus, but it seems safer to delay the
shutdown until other things get a chance to notice the process has exited.

Reviewers: clayborg, ovyalov

Subscribers: lldb-commits

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

llvm-svn: 246753
2015-09-03 09:30:17 +00:00
Bruce Mitchener db25a7a245 [cmake] Remove LLVM_NO_RTTI.
Summary:
This doesn't exist in other LLVM projects any longer and doesn't
do anything.

Reviewers: chaoren, labath

Subscribers: emaste, tberghammer, lldb-commits, danalbert

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

llvm-svn: 246749
2015-09-03 08:46:55 +00:00
Jim Ingham 0d5a2bd6f7 Purge a few places where *LanguageRuntime.h was being used when it
wasn't needed.

llvm-svn: 246744
2015-09-03 01:40:51 +00:00
Jim Ingham aa816b8f3b Move more functionality from the LanguageRuntimes to the Languages.
llvm-svn: 246616
2015-09-02 01:59:14 +00:00
Enrico Granata 28b3831e39 Add a Language::ForAllLanguages helper function
llvm-svn: 246614
2015-09-02 01:31:10 +00:00
Jim Ingham 0e0984eebb Move things from the LanguageRuntime that obviously belong in the new Language plugin instead.
llvm-svn: 246611
2015-09-02 01:06:46 +00:00
Zachary Turner 7529df9abd Have the Process hold a weak_ptr to the Target.
llvm-svn: 246578
2015-09-01 20:02:29 +00:00
Enrico Granata 980c0484c5 Add support for language plugins to provide data formatters (second attempt)
Historically, data formatters all exist in a global repository (the category map)
On top of that, some formatters can be "hardcoded" when the conditions under which they apply are not expressible as a typename (or typename regex)

This change paves the way to move formatters into per-language buckets such that the C++ plugin is responsible for ownership of the C++ formatters, and so on
The advantages of this are:
a) language formatters only get created when they might apply
b) formatters for a language are clearly owned by the matching language plugin

The current model is one of static instantiation, that is a language knows the full set of formatters it vends and that is only asked-for once, and then handed off to the FormatManager
In a future revision it might be interesting to add similar ability to the language runtimes, and monitor for certain shared library events to add even more library-specific formatters

No formatters are moved as part of this change, so practically speaking this is NFC

llvm-svn: 246568
2015-09-01 18:22:39 +00:00
Chaoren Lin c963a222f1 Make ProcessGDBRemote get a //copy// of platform Unix signals.
Summary: Update to http://reviews.llvm.org/rL243618.

Reviewers: jaydeep, clayborg

Subscribers: labath, tberghammer, lldb-commits

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

llvm-svn: 246557
2015-09-01 16:58:45 +00:00
Pavel Labath f15a16704b Revert "Add support for language plugins to provide data formatters"
This reverts r246515 (and related cmake fixes) as it breaks all libcxx tests.

llvm-svn: 246536
2015-09-01 09:02:54 +00:00
Enrico Granata 2233895a3b Add support for language plugins to provide data formatters
Historically, data formatters all exist in a global repository (the category map)
On top of that, some formatters can be "hardcoded" when the conditions under which they apply are not expressible as a typename (or typename regex)

This change paves the way to move formatters into per-language buckets such that the C++ plugin is responsible for ownership of the C++ formatters, and so on
The advantages of this are:
a) language formatters only get created when they might apply
b) formatters for a language are clearly owned by the matching language plugin

The current model is one of static instantiation, that is a language knows the full set of formatters it vends and that is only asked-for once, and then handed off to the FormatManager
In a future revision it might be interesting to add similar ability to the language runtimes, and monitor for certain shared library events to add even more library-specific formatters

No formatters are moved as part of this change, so practically speaking this is NFC

llvm-svn: 246515
2015-09-01 01:01:48 +00:00
Enrico Granata 2996d8236c Include <mutex>
llvm-svn: 246222
2015-08-27 22:14:06 +00:00
Enrico Granata 8f5e331dc2 Added a missing file to the CMakeLists
llvm-svn: 246216
2015-08-27 21:45:59 +00:00
Enrico Granata 5f9d310640 Add a new type of plugin: Language plugin
The Language plugin is menat to answer language-specific questions that are not bound to the existence of a process. Those are still the domain of the LanguageRuntime plugin

The Language plugin will, instead, answer questions such as providing language-specific data formatters or expression evaluation

At the moment, the interface is hollowed out, and empty do-nothing plugins have been setup for ObjC, C++ and ObjC++

llvm-svn: 246212
2015-08-27 21:33:50 +00:00
Enrico Granata 6e25aeea96 Add functionality to the platforms to figure out the proper name for a dynamic library on the system given a basename
This will do things like,
given mylibrary,
return

libmylibrary.dylib on OSX
mylibrary.dll on Windows

and so on for other platforms
It is currently implemented for Windows, Darwin, and Linux. Other platforms should fill in accordingly

llvm-svn: 246131
2015-08-27 00:53:57 +00:00
Greg Clayton 6071e6fc94 Major DWARF cleanup.
Added a new class called DWARFDIE that contains a DWARFCompileUnit and DWARFDebugInfoEntry so that these items always stay together.

There were many places where we just handed out DWARFDebugInfoEntry pointers and then use them with a compile unit that may or may not be the correct one. Clients outside of DWARFCompileUnit and DWARFDebugInfoEntry should all be dealing with DWARFDIE instances instead of playing with DWARFCompileUnit/DWARFDebugInfoEntry pairs manually.

This paves to the way for some modifications that are coming for DWO.

llvm-svn: 246100
2015-08-26 22:57:51 +00:00
Bhushan D. Attarde 7f3daeda9a [MIPS] Avoid breakpoint in delay slot
SUMMARY:
    This patch implements Target::GetBreakableLoadAddress() method that takes an address
    and checks for any reason there is a better address than this to put a breakpoint on.
    If there is then return that address.
    MIPS uses this method to avoid breakpoint in delay slot.
    
    Reviewers: clayborg, jingham
    Subscribers: jingham, mohit.bhakkad, sagar, jaydeep, nitesh.jain, lldb-commits
    Differential Revision: http://http://reviews.llvm.org/D12184

llvm-svn: 246015
2015-08-26 06:04:54 +00:00
Greg Clayton 99558cc424 Final bit of type system cleanup that abstracts declaration contexts into lldb_private::CompilerDeclContext and renames ClangType to CompilerType in many accessors and functions.
Create a new "lldb_private::CompilerDeclContext" class that will replace all direct uses of "clang::DeclContext" when used in compiler agnostic code, yet still allow for conversion to clang::DeclContext subclasses by clang specific code. This completes the abstraction of type parsing by removing all "clang::" references from the SymbolFileDWARF. The new "lldb_private::CompilerDeclContext" class abstracts decl contexts found in compiler type systems so they can be used in internal API calls. The TypeSystem is required to support CompilerDeclContexts with new pure virtual functions that start with "DeclContext" in the member function names. Converted all code that used lldb_private::ClangNamespaceDecl over to use the new CompilerDeclContext class and removed the ClangNamespaceDecl.cpp and ClangNamespaceDecl.h files.

Removed direct use of clang APIs from SBType and now use the abstract type systems to correctly explore types.

Bulk renames for things that used to return a ClangASTType which is now CompilerType:

    "Type::GetClangFullType()" to "Type::GetFullCompilerType()"
    "Type::GetClangLayoutType()" to "Type::GetLayoutCompilerType()"
    "Type::GetClangForwardType()" to "Type::GetForwardCompilerType()"
    "Value::GetClangType()" to "Value::GetCompilerType()"
    "Value::SetClangType (const CompilerType &)" to "Value::SetCompilerType (const CompilerType &)"
    "ValueObject::GetClangType ()" to "ValueObject::GetCompilerType()"
    many more renames that are similar.

llvm-svn: 245905
2015-08-24 23:46:31 +00:00
Paul Herman 10bc1a4e83 Fix resolution conflict between global and class static variables in C++
llvm-svn: 245381
2015-08-18 22:46:57 +00:00
Jason Molenda a18f7071c2 A messy bit of cleanup: Move towards more descriptive names
for eh_frame and stabs register numberings.  This is not
complete but it's a step in the right direction.  It's almost
entirely mechanical.

lldb informally uses "gcc register numbering" to mean eh_frame.
Why?  Probably because there's a notorious bug with gcc on i386
darwin where the register numbers in eh_frame were incorrect.
In all other cases, eh_frame register numbering is identical to
dwarf.

lldb informally uses "gdb register numbering" to mean stabs.
There are no official definitions of stabs register numbers
for different architectures, so the implementations of gdb
and gcc are the de facto reference source.

There were some incorrect uses of these register number types
in lldb already.  I fixed the ones that I saw as I made
this change.

This commit changes all references to "gcc" and "gdb" register
numbers in lldb to "eh_frame" and "stabs" to make it clear 
what is actually being represented.

lldb cannot parse the stabs debug format, and given that no
one is using stabs any more, it is unlikely that it ever will.
A more comprehensive cleanup would remove the stabs register
numbers altogether - it's unnecessary cruft / complication to
all of our register structures.

In ProcessGDBRemote, when we get register definitions from
the gdb-remote stub, we expect to see "gcc:" (qRegisterInfo)
or "gcc_regnum" (qXfer:features:read: packet to get xml payload).
This patch changes ProcessGDBRemote to also accept "ehframe:"
and "ehframe_regnum" from these remotes.

I did not change GDBRemoteCommunicationServerLLGS or debugserver
to send these new packets.  I don't know what kind of interoperability
constraints we might be working under.  At some point in the future
we should transition to using the more descriptive names.

Throughout lldb we're still using enum names like "gcc_r0" and "gdb_r0",
for eh_frame and stabs register numberings.  These should be cleaned
up eventually too.

The sources link cleanly on macosx native with xcode build.  I
don't think we'll see problems on other platforms but please let
me know if I broke anyone.

llvm-svn: 245141
2015-08-15 01:21:01 +00:00
Jim Ingham 55828080a0 I was assuming that when a bit of inlined code was followed by code from the inlining site, it was going to execute to the inlining site code, but apparently that's not always true. So we need to be a bit more careful getting past the inlining, and use a StepOverRange plan not a RunToAddress plan.
<rdar://problem/22191804>

llvm-svn: 244999
2015-08-14 01:38:21 +00:00
Jaydeep Patil 831435042e [LLDB][MIPS] Handle false positives for MIPS hardware watchpoints
SUMMARY:
    Last 3bits of the watchpoint address are masked by the kernel. For example, n is 
    at 0x120010d00 and m is 0x120010d04. When a watchpoint is set at m, then watch 
    exception is generated even when n is read/written. To handle this case, instruction 
    at PC is emulated to find the base address of the load/store instruction. This address 
    is then appended to the description of the stop-info packet. Client then reads this 
    information to check whether the user has set a watchpoint on this address.
    
    Reviewers: jingham, clayborg
    Subscribers: nitesh.jain, mohit.bhakkad, sagar, bhushan and lldb-commits
    Differential Revision: http://reviews.llvm.org/D11672

llvm-svn: 244864
2015-08-13 03:44:09 +00:00
Tamas Berghammer ec3f92a5e2 Download symbol file for .oat files on android
On android .oat files (compiled java code) don't have symbol
information but on SDK 23+ it can be generated by the oatdump tool
(based on the dex information).

This CL adds logic to download this information and store it in the
module cache.

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

llvm-svn: 244738
2015-08-12 11:10:25 +00:00
Greg Clayton a1e5dc86a6 ClangASTType is now CompilerType.
This is more preparation for multiple different kinds of types from different compilers (clang, Pascal, Go, RenderScript, Swift, etc).

llvm-svn: 244689
2015-08-11 22:53:00 +00:00
Greg Clayton d8d4a57b37 First step in getting LLDB ready to support multiple different type systems.
This is the work done by Ryan Brown from http://reviews.llvm.org/D8712 that makes a TypeSystem class and abstracts types to be able to use a type system.

All tests pass on MacOSX and passed on linux the last time this was submitted. 

llvm-svn: 244679
2015-08-11 21:38:15 +00:00
Jason Molenda 484900bd3b Feedback from Jim: Change the "optimized code" warning to be entirely
contained within Process so that we won't be duplicating the warning
message if other parts of the code want to issue the message.  Change
Process::PrintWarning to be a protected method - the public method
will be the PrintWarningOptimization et al.  Also, Have
Thread::FunctionOptimizationWarning shortcut out if the warnings
have been disabled so that we don't (potentially) compute parts of
the SymbolContext unnecessarily.

llvm-svn: 244436
2015-08-10 07:55:25 +00:00
Jason Molenda 03c9cd0852 Change the warning message about optimization to be printed once
per Module instead of once per CompileUnit, and print the 
module name.  A module may have a mix of compile units built with
optimization and compile units built without optimization -- the
warning won't be printed until the user selects a stack frame of
a function that was built with optimization.  And as before, it
will only be printed once per module per debug session.

<rdar://problem/19281172> 

llvm-svn: 244281
2015-08-06 21:54:29 +00:00
Jason Molenda ef7d641617 Second part of indicating when the user is stopped in optimized code.
The first part was in r243508 -- the extent of the UI changes in that
patchset was to add "[opt]" to the frame-format when a stack frame was
built with optimized code.

In this change, when a stack frame built with optimization is selected,
a message will be printed to the async output channel --

opt1.c was compiled with optimization - stepping may behave oddly; variables may not be available.

The warning will be only be printed once per source file in a debug session.
These warnings may be disabled by

settings set target.process.optimization-warnings false

Internally, a new Process::PrintWarning() method has been added for
warnings that we want to print only once to the user.  It takes a type
of warning (currently only eWarningsOptimization) and an object
pointer (CompileUnit*) - the warning will only be printed once for a
given object pointer value.

This is a bit of a prototype of this change -  I think we will be
tweaking it more in the future.  But I wanted to land this and see
how it goes.  Advanced users will find these warnings unnecessary
noise and will quickly disable them - but anyone who maintains a 
debugger knows that debugging optimized code, without realizing it,
is a constant source of confusion and frustation for more typical
debugger users.  

I imagine there will be more of these "warn once per whatever" style
warnings that we will want to add in the future and we'll need to 
come up with a better way for enabling/disabling them.  But I'm not
srue what form that warning settings should take and I didn't want
to code up something that we regret later, so for now I just added
another process setting for this one warning.

<rdar://problem/19281172> 

llvm-svn: 244190
2015-08-06 03:27:10 +00:00
Dawn Perchik e0c96acebc Fix help message for target.language setting.
llvm-svn: 243697
2015-07-30 22:10:08 +00:00
Jim Ingham 9d1ccdaf7e Add a function to make a mutex-protected copy of a breakpoint site's
owners list, so the StopInfo machinery can get the list of owners without
some other thread being able to mess up the list by deleting/disabline one of its
locations in the process of doing so.

<rdar://problem/18685197>

llvm-svn: 243541
2015-07-29 17:51:36 +00:00
Jason Molenda 08a3258bd8 Add some initial logging for when lldb is searching for binaries,
dSYMs, or reading binaries out of memory to the 'Host' log channel.
There's more to be done here, both for Mac and for other platforms,
but the initial set of new loggings are useful enough to check in
at this point.

llvm-svn: 243200
2015-07-25 02:39:42 +00:00
Tamas Berghammer 5aa27e1acc Improve C++ function name handling and step-in avoid regerxp handling
If the function is a template then the return type is part of the
function name. This CL fixes the parsing of these function names in
the case when the return type contains ':'.

The name of free functions in C++ don't have context part. Fix the
logic geting the function name without arguments out from a full
function name to handle this case.

Change the handling of step-in-avoid-regexp to match the value against
the function name without it's arguments and return value. This is
required because the default regex ("^std::") would match any template
function returning an std object.

Fifferential revision: http://reviews.llvm.org/D11461

llvm-svn: 243099
2015-07-24 08:54:22 +00:00
Bruce Mitchener 8a67bf7298 Add UNUSED_IF_ASSERT_DISABLED and apply it.
Summary:
This replaces (void)x; usages where they x was subsequently
involved in an assertion with this macro to make the
intent more clear.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 243074
2015-07-24 00:23:29 +00:00
Jim Ingham 9b03fa0c69 Most thread plans don't handle eStopReasonInstrumentation stop reasons,
but that wasn't added to the list of reasons they don't explain.  That
would mean we keep stepping after hitting the AsanDie breakpoint rather
than stopping when the Asan event occurred.

<rdar://problem/21925479>

llvm-svn: 243035
2015-07-23 19:55:02 +00:00
Bruce Mitchener a026de0585 Fix warnings.
Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 242913
2015-07-22 17:31:44 +00:00
Pavel Labath cb213b3831 Fix warnings found by -Wextra-semi
patch by Eugene Zelenko.

llvm-svn: 242875
2015-07-22 08:12:01 +00:00
Bruce Mitchener e171da5cb7 Fix typos.
Summary: Fix a bunch of typos.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 242856
2015-07-22 00:16:02 +00:00
Dawn Perchik 23b1decbe7 Add support for specifying a language to use when parsing breakpoints.
Target and breakpoints options were added:
    breakpoint set --language lang --name func
    settings set target.language pascal
These specify the Language to use when interpreting the breakpoint's
expression (note: currently only implemented for breakpoints on
identifiers).  If the breakpoint language is not set, the target.language
setting is used.
This support is required by Pascal, for example, to set breakpoint at 'ns.foo'
for function 'foo' in namespace 'ns'.
Tests on the language were also added to Module::PrepareForFunctionNameLookup
for efficiency.

Reviewed by: clayborg
Subscribers: jingham, lldb-commits
Differential Revision: http://reviews.llvm.org/D11119

llvm-svn: 242844
2015-07-21 22:05:07 +00:00
Greg Clayton 2e309076f2 More packet performance improvements.
Changed the "jthreads" key/value in the stop reply packets to be "jstopinfo". This JSON only contains threads with valid stop reasons and allows us not to have to ask about other threads via qThreadStopInfo when we are stepping. The "jstopinfo" only gets sent if there are more than one thread since the stop reply packet contains all the info needed for a single thread.

Added a Process::WillPublicStop() in case process subclasses want to do any extra gathering for public stops. For ProcessGDBRemote, we end up sending a jThreadsInfo packet to gather all expedited registers, expedited memory and MacOSX queue information. We only do this for public stops to minimize the packets we send when we have multiple private stops. Multiple private stops happen when a source level single step, step into or step out run the process multiple times while implementing the stepping, and none of these private stops make it out to the UI via notifications because they are private stops. 

llvm-svn: 242593
2015-07-17 23:42:28 +00:00
Pavel Labath 8c0970febd Fix compiler warning in ThreadPlanStepRange
llvm-svn: 242403
2015-07-16 14:21:49 +00:00
Jason Molenda 25c34d9464 Small fix to ThreadPlanStepRange::DumpRanges to logging
output when stepping through multiple ranges.

llvm-svn: 242243
2015-07-14 23:17:29 +00:00
Ewan Crawford 90ff791141 Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support. 
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.

In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation. 
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter. 

The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.

Reviewers: jingham, spyffe

Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427

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

llvm-svn: 242137
2015-07-14 10:56:58 +00:00
Chaoren Lin 98d0a4b39a Refactor Unix signals.
Summary:
- Consolidate Unix signals selection in UnixSignals.
- Make Unix signals available from platform.
- Add jSignalsInfo packet to retrieve Unix signals from remote platform.
- Get a copy of the platform signal for each remote process.
- Update SB API for signals.
- Update signal utility in test suite.

Reviewers: ovyalov, clayborg

Subscribers: chaoren, jingham, labath, emaste, tberghammer, lldb-commits

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

llvm-svn: 242101
2015-07-14 01:09:28 +00:00
Greg Clayton bf91f712b3 Don't try to make a pseudo terminal if we are launching in a separate terminal, it causes a deadlock when debugging because we create a PTY and yet it isn't hooked up to anything on the slave side.
llvm-svn: 241919
2015-07-10 18:04:46 +00:00
Pavel Labath d5b310f2a3 Avoid going through Platform when creating a NativeProcessProtocol instance
Summary:
This commit avoids the Platform instance when spawning or attaching to a process in lldb-server.
Instead, I have the server call a (static) method of NativeProcessProtocol directly. The reason
for this is that I believe that NativeProcessProtocol should be decoupled from the Platform
(after all, it always knows which platform it is running on, unlike the rest of lldb).
Additionally, the kind of platform actions a NativeProcessProtocol instance is likely to differ
greatly from the platform actions of the lldb client, so I think the separation makes sense.

After this, the only dependency NativeProcessLinux has on PlatformLinux is the ResolveExecutable
method, which needs additional refactoring.

This is a resubmit of r241672, after it was reverted due to build failueres on non-linux
platforms.

Reviewers: ovyalov, clayborg

Subscribers: lldb-commits

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

llvm-svn: 241796
2015-07-09 11:51:11 +00:00
Greg Clayton ddaf6a7259 Make many mangled functions that might demangle a name be allowed to specify a language to use in order to soon support Pascal and Java demangling. Dawn Perchik will take care of making this so.
llvm-svn: 241751
2015-07-08 22:32:23 +00:00
Sean Callanan c307c27035 Revert r241672, which breaks the OS X build by introducing a dependency on
platform-specific symbols that are not implemented on OS X.

The build error that caused this is

Undefined symbols for architecture x86_64:
  "lldb_private::NativeProcessProtocol::Attach(unsigned long long, lldb_private::NativeProcessProtocol::NativeDelegate&, std::__1::shared_ptr<lldb_private::NativeProcessProtocol>&)", referenced from:
      lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::AttachToProcess(unsigned long long) in liblldb-core.a(GDBRemoteCommunicationServerLLGS.o)
  "lldb_private::NativeProcessProtocol::Launch(lldb_private::ProcessLaunchInfo&, lldb_private::NativeProcessProtocol::NativeDelegate&, std::__1::shared_ptr<lldb_private::NativeProcessProtocol>&)", referenced from:
      lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::LaunchProcess() in liblldb-core.a(GDBRemoteCommunicationServerLLGS.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

llvm-svn: 241688
2015-07-08 16:33:46 +00:00
Pavel Labath 235c8405eb Avoid going through Platform when creating a NativeProcessProtocol instance
Summary:
This commit avoids the Platform instance when spawning or attaching to a process in lldb-server.
Instead, I have the server call a (static) method of NativeProcessProtocol directly. The reason
for this is that I believe that NativeProcessProtocol should be decoupled from the Platform
(after all, it always knows which platform it is running on, unlike the rest of lldb).
Additionally, the kind of platform actions a NativeProcessProtocol instance is likely to differ
greatly from the platform actions of the lldb client, so I think the separation makes sense.

After this, the only dependency NativeProcessLinux has on PlatformLinux is the ResolveExecutable
method, which needs additional refactoring.

Reviewers: ovyalov, clayborg

Subscribers: lldb-commits

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

llvm-svn: 241672
2015-07-08 09:08:53 +00:00
Jim Ingham ce400d9ab4 Don't select a thread that stopped for a signal that was
not set to stop - there must be some other thread that
stopped for a more interesting reason.

<rdar://problem/19943567>

llvm-svn: 241650
2015-07-08 00:06:30 +00:00
Greg Clayton e521457db3 Fix indentation.
llvm-svn: 241209
2015-07-01 23:28:31 +00:00
Mohit K. Bhakkad e0d8c422a0 [LLDB][MIPS] Getting correct flags for MIPS
Patch by Nitesh Jain

Reviewers: clayborg, ovyalov, emaste.
Subscribers: jaydeep, bhushan, dsanders, mohit.bhakkad, sagar, labath, tberghammer, lldb-commits.
Differential Revision: http://reviews.llvm.org/D10685

llvm-svn: 241045
2015-06-30 06:29:12 +00:00
Greg Clayton 358cf1ea30 Resubmitting 240466 after fixing the linux test suite failures.
A few extras were fixed

- Symbol::GetAddress() now returns an Address object, not a reference. There were places where people were accessing the address of a symbol when the symbol's value wasn't an address symbol. On MacOSX, undefined symbols have a value zero and some places where using the symbol's address and getting an absolute address of zero (since an Address object with no section and an m_offset whose value isn't LLDB_INVALID_ADDRESS is considered an absolute address). So fixing this required some changes to make sure people were getting what they expected. 
- Since some places want to access the address as a reference, I added a few new functions to symbol:
    Address &Symbol::GetAddressRef();
    const Address &Symbol::GetAddressRef() const;

Linux test suite passes just fine now.

<rdar://problem/21494354>

llvm-svn: 240702
2015-06-25 21:46:34 +00:00
Ewan Crawford aa7eda7a9e Proper handling of QNonStop packet response.
Turn non-stop mode off if reply to QNonStop packet isn't an OK.

llvm-svn: 240546
2015-06-24 15:14:26 +00:00
Jim Ingham 60c915e96a Fix the handling of the run lock in cases where you needed to run
a hand-called function from the private state thread.  The problem 
was that on the way out of the private state thread, we try to drop
the run lock.  That is appropriate for the main private state thread,
but not the secondary private state thread.  Only the thread that 
spawned them can know whether this is an appropriate thing to do or
not.

<rdar://problem/21375352>

llvm-svn: 240461
2015-06-23 21:02:45 +00:00
Chaoren Lin 7a30608026 Revert "Reduced packet counts to the remote GDB server where possible."
This reverts commit 0cc0745ea9c68d7fdcadc9904cee3f13c96dae60.

Due to breakage on Linux build bot:

http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/3436

llvm-svn: 240371
2015-06-23 03:17:01 +00:00
Greg Clayton ffb2d44ab9 Reduced packet counts to the remote GDB server where possible.
We have been working on reducing the packet count that is sent between LLDB and the debugserver on MacOSX and iOS. Our approach to this was to reduce the packets required when debugging multiple threads. We currently make one qThreadStopInfoXXXX call (where XXXX is the thread ID in hex) per thread except the thread that stopped with a stop reply packet. In order to implement multiple thread infos in a single reply, we need to use structured data, which means JSON. The new jThreadsInfo packet will attempt to retrieve all thread infos in a single packet. The data is very similar to the stop reply packets, but packaged in JSON and uses JSON arrays where applicable. The JSON output looks like:


[
  { "tid":1580681,
    "metype":6,
    "medata":[2,0],
    "reason":"exception",
    "qaddr":140735118423168,
    "registers": {
      "0":"8000000000000000",
      "1":"0000000000000000",
      "2":"20fabf5fff7f0000",
      "3":"e8f8bf5fff7f0000",
      "4":"0100000000000000",
      "5":"d8f8bf5fff7f0000",
      "6":"b0f8bf5fff7f0000",
      "7":"20f4bf5fff7f0000",
      "8":"8000000000000000",
      "9":"61a8db78a61500db",
      "10":"3200000000000000",
      "11":"4602000000000000",
      "12":"0000000000000000",
      "13":"0000000000000000",
      "14":"0000000000000000",
      "15":"0000000000000000",
      "16":"960b000001000000",
      "17":"0202000000000000",
      "18":"2b00000000000000",
      "19":"0000000000000000",
      "20":"0000000000000000"},
    "memory":[
      {"address":140734799804592,"bytes":"c8f8bf5fff7f0000c9a59e8cff7f0000"},
      {"address":140734799804616,"bytes":"00000000000000000100000000000000"}
    ]
  }
]

It contains an array of dicitionaries with all of the key value pairs that are normally in the stop reply packet. Including the expedited registers. Notice that is also contains expedited memory in the "memory" key. Any values in this memory will get included in a new L1 cache in lldb_private::Process where if a memory read request is made and that memory request fits into one of the L1 memory cache blocks, it will use that memory data. If a memory request fails in the L1 cache, it will fall back to the L2 cache which is the same block sized caching we were using before these changes. This allows a process to expedite memory that you are likely to use and it reduces packet count. On MacOSX with debugserver, we expedite the frame pointer backchain for a thread (up to 256 entries) by reading 2 pointers worth of bytes at the frame pointer (for the previous FP and PC), and follow the backchain. Most backtraces on MacOSX and iOS now don't require us to read any memory!

We will try these packets out and if successful, we should port these to lldb-server in the near future. 

<rdar://problem/21494354>

llvm-svn: 240354
2015-06-22 23:12:45 +00:00
Bruce Mitchener 58ef391f3e Fix a variety of typos.
No functional change.

llvm-svn: 239995
2015-06-18 05:27:05 +00:00
Dawn Perchik d0e87eb07e Fix enum LanguageType values and language string table lookups.
Summary:
* Fix enum LanguageType values so that they can be used as indexes
into array language_names and g_languages as assumed by
LanguageRuntime::GetNameForLanguageType,
Language::SetLanguageFromCString and Language::AsCString.
* Add DWARFCompileUnit::LanguageTypeFromDWARF to convert from DWARF
DW_LANG_* values to enum LanguageType values.

Reviewed By: clayborg, abidh
Differential Revision: http://reviews.llvm.org/D10484

llvm-svn: 239963
2015-06-17 22:30:24 +00:00
Jim Ingham 637338543f Fix a typo in the help.
llvm-svn: 239854
2015-06-16 21:39:56 +00:00
Chaoren Lin 372e9067a7 Rename `FileSpec::IsRelativeToCurrentWorkingDirectory` to `IsRelative`.
Summary:
`IsRelativeToCurrentWorkingDirectory` was misleading, because relative paths
are sometimes appended to other directories, not just the cwd. Plus, the new
name is shorter. Also added `IsAbsolute` for completeness.

Reviewers: clayborg, ovyalov

Reviewed By: ovyalov

Subscribers: tberghammer, lldb-commits

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

llvm-svn: 239419
2015-06-09 17:54:27 +00:00
Pavel Labath c7c30eb528 Revert "Introduce a TypeSystem interface to support adding non-clang languages."
This seems to break expression evaluation on the linux build.

llvm-svn: 239366
2015-06-08 23:38:06 +00:00
Pavel Labath c33ae024a6 Introduce a TypeSystem interface to support adding non-clang languages.
Reviewers: clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D8712
Original Author: Ryan Brown <ribrdb@google.com>

llvm-svn: 239360
2015-06-08 22:27:10 +00:00
Greg Clayton 23d54f4eac Fixed a deadlock that was slowing down processes when they shut down. A 3 second delay could occur sometimes when a process exits, now that delay is gone.
llvm-svn: 238893
2015-06-03 00:34:01 +00:00
Jim Ingham acbea8fb37 Fix up some comments to be more explicit. Remove some long-commented out code.
llvm-svn: 238862
2015-06-02 20:26:13 +00:00
Greg Clayton 81e2b6bbe7 Fix a race condition where 2 threads might try to call Process::SetExitStatus() at the same time.
The problem was the mutex was only protecting the setting of m_exit_string and m_exit_string, but this function relies on the m_private_state being set to eStateExited in order to prevent more than 1 client setting the exit status. We want to only allow the first caller to succeed.

On MacOSX we have a thread that reaps the process we are debugging, and we also have a thread that monitors the debugserver process. When a process exists, the ProcessGDBRemote::AsyncThread() would set the exit status to the correct value and then another thread would reap the debugserver process and they would often both end up in Process::SetExitStatus() at the same time. With the mutex at the top we allow all variables to be set and the m_private_state to be set to eStateExited _before_ the other thread (debugserver reaped) can try to set th exist status to -1 and "lost connection to debugserver" being set as the exit status.

This was probably an issue for lldb-server as well and could very well cleanup some tests that might have been expecting a specific exit status from the process being debugged.

llvm-svn: 238794
2015-06-01 23:14:09 +00:00
Tamas Berghammer 0f8452ba2e Fix address adjusment in stack frame inline block lookup
When the current address is pointing 1 (unit) over the end of a
section the we have to do a section lookup after making the adjusment
of the current address.

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

llvm-svn: 238737
2015-06-01 10:38:23 +00:00
Chaoren Lin d3173f34e8 Refactor many file functions to use FileSpec over strings.
Summary:
This should solve the issue of sending denormalized paths over gdb-remote
if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the
server handle any denormalization.

Reviewers: ovyalov, zturner, vharron, clayborg

Reviewed By: clayborg

Subscribers: tberghammer, emaste, lldb-commits

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

llvm-svn: 238604
2015-05-29 19:52:29 +00:00
Zachary Turner 1124045ac7 Don't #include "lldb-python.h" from anywhere.
Since interaction with the python interpreter is moving towards
being more isolated, we won't be able to include this header from
normal files anymore, all includes of it should be localized to
the python library which will live under source/bindings/API/Python
after a future patch.

None of the files that were including this header actually depended
on it anyway, so it was just a dead include in every single instance.

llvm-svn: 238581
2015-05-29 17:41:47 +00:00
Pavel Labath c4e25c9648 Report inferior SIGSEGV as a signal instead of an exception on linux
Summary:
Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.

This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.

I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).

Test Plan: All tests pass on linux and osx.

Reviewers: ovyalov, clayborg, emaste

Subscribers: emaste, lldb-commits

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

llvm-svn: 238549
2015-05-29 10:13:03 +00:00