Commit Graph

859 Commits

Author SHA1 Message Date
Kuba Brecka 058c302e0a Fix the ThreadSanitizer support to avoid creating empty SBThreads and to not crash when thread_id is unavailable. Plus a whitespace fix.
llvm-svn: 264854
2016-03-30 10:50:24 +00:00
Pavel Labath 773c3b0d7c Move DynamicLoader plugins to SystemInitializerFull
Summary: These are not needed by lldb-server. Removing them shrinks the server by about 0.5%.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 264735
2016-03-29 15:00:26 +00:00
Sean Callanan 863fab69a2 Expose top-level Clang expressions via the command line and the API.
Top-level Clang expressions are expressions that act as new translation units,
and define their own symbols.  They do not have function wrappers like regular
expressions do, and declarations are persistent regardless of use of the dollar
sign in identifiers.  Names defined by these are given priority over all other
symbol lookups.

This patch adds a new expression option, '-p' or '--top-level,' which controls
whether the expression is treated this way.  It also adds a flag controlling 
this to SBExpressionOptions so that this API is usable externally.  It also adds
a test that validates that this works.  (The test requires a fix to the Clang
AST importer which I will be committing shortly.)

<rdar://problem/22864976>

llvm-svn: 264662
2016-03-28 21:20:05 +00:00
Stephane Sezer 65fd8f4345 Fix FILE * leak in Python API
Summary:
This fixes a leak introduced by some of these changes:
r257644
r250530
r250525

The changes made in these patches result in leaking the FILE* passed
to SetImmediateOutputFile. GetStream() will dup() the fd held by the
python caller and create a new FILE*. It will then pass this FILE*
to SetImmediateOutputFile, which always uses the flag
transfer_ownership=false when it creates a File from the FILE*.

Since transfer_ownership is false, the lldb File destructor will not
close the underlying FILE*. Because this FILE* came from a dup-ed fd,
it will also not be closed when the python caller closes its file.

Leaking the FILE* causes issues if the same file is used multiple times
by different python callers during the same lldb run, even if these
callers open and close the python file properly, as you can end up
with issues due to multiple buffered writes to the same file.

Reviewers: granata.enrico, zturner, clayborg

Subscribers: zturner, lldb-commits, sas

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

Change by Francis Ricci <fjricci@fb.com>

llvm-svn: 264476
2016-03-25 23:40:32 +00:00
Jim Ingham a1e541bf9f Use Clang's FixItHints to correct expressions with "trivial" mistakes (e.g. "." for "->".)
This feature is controlled by an expression command option, a target property and the
SBExpressionOptions setting.  FixIt's are only applied to UserExpressions, not UtilityFunctions,
those you have to get right when you make them.

This is just a first stage.  At present the fixits are applied silently.  The next step
is to tell the user about the applied fixit.

<rdar://problem/25351938>

llvm-svn: 264379
2016-03-25 01:57:14 +00:00
Kuba Brecka 6a83143650 Add ThreadSanitizer debugging support.
This patch adds ThreadSanitizer support into LLDB:
- Adding a new InstrumentationRuntime plugin, ThreadSanitizerRuntime, in the same way ASan is implemented.
- A breakpoint stops in `__tsan_on_report`, then we extract all sorts of information by evaluating an expression. We then populate this into StopReasonExtendedInfo.
- SBThread gets a new API, SBThread::GetStopReasonExtendedBacktraces(), which returns TSan’s backtraces in the form of regular SBThreads. Non-TSan stop reasons return an empty collection.
- Added some test cases.

Reviewed by Greg Clayton.

llvm-svn: 264162
2016-03-23 15:36:22 +00:00
Pavel Labath a7760cb550 Move OperatingSystem plugins to SystemInitializerFull
Summary: These are not needed in lldb-server. Removing them shrinks the server size by about 1.5%.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 263625
2016-03-16 08:48:56 +00:00
Jim Ingham 2411167fb5 Add an "offset" option to "break set -n" and "break set -f -l".
That way you can set offset breakpoints that will move as the function they are 
contained in moves (which address breakpoints can't do...)

I don't align the new address to instruction boundaries yet, so you have to get
this right yourself for now.

<rdar://problem/13365575>

llvm-svn: 263049
2016-03-09 18:59:13 +00:00
Jim Ingham 583bbb1dd4 Change over the broadcaster/listener process to hold shared or weak pointers
to each other.  This should remove some infrequent teardown crashes when the
listener is not the debugger's listener.

Processes now need to take a ListenerSP, not a Listener&.

This required changing over the Process plugin class constructors to take a ListenerSP, instead
of a Listener&.   Other than that there should be no functional change.
 
<rdar://problem/24580184> CrashTracer: [USER] Xcode at …ework: lldb_private::Listener::BroadcasterWillDestruct + 39

llvm-svn: 262863
2016-03-07 21:50:25 +00:00
Zachary Turner 74e08ca05c Add support for reading line tables from PDB files.
PDB is Microsoft's debug information format, and although we
cannot yet generate it, we still must be able to consume it.
Reason for this is that debug information for system libraries
(e.g. kernel32, C Runtime Library, etc) only have debug info
in PDB format, so in order to be able to support debugging
of system code, we must support it.

Currently this code should compile on every platform, but on
non-Windows platforms the PDB plugin will return 0 capabilities,
meaning that for now PDB is only supported on Windows.  This
may change in the future, but the API is designed in such a way
that this will require few (if any) changes on the LLDB side.
In the future we can just flip a switch and everything will
work.

This patch only adds support for line tables.  It does not return
information about functions, types, global variables, or anything
else.  This functionality will be added in a followup patch.

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

llvm-svn: 262528
2016-03-02 22:05:52 +00:00
Tamas Berghammer 87a9769e9b Add a set of new plugins to handle Java debugging
The purpose of these plugins is to make LLDB capable of debugging java
code JIT-ed by the android runtime.

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

llvm-svn: 262015
2016-02-26 14:21:23 +00:00
Tamas Berghammer 72ac8a840f Handle the case when a variable is only valid in part of the enclosing scope
DWARF stores this information in the DW_AT_start_scope attribute. This
CL add support for this attribute and also changes the functions
displaying frame variables to only display the variables currently in
scope.

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

llvm-svn: 261858
2016-02-25 12:23:37 +00:00
Jason Molenda 878ae01889 This patch stops lldb from loading a .lldbinit file from the current
working directory by default -- a typical security problem that we
need to be more conservative about.

It adds a new target setting, target.load-cwd-lldbinit which may
be true (always read $cwd/.lldbinit), false (never read $cwd/.lldbinit)
or warn (warn if there is a $cwd/.lldbinit and don't read it).  The
default is set to warn.  If this is met with unhappiness, we can look
at changing the default to true (to match current behavior) on a 
different platform.

This does not affect reading of ~/.lldbinit - that will still be read,
as before.  If you run lldb in your home directory, it will not warn
about the presence of a .lldbinit file there.

I had to add two SB API - SBHostOS::GetUserHomeDirectory and 
SBFileSpec::AppendPathComponent - for the lldb driver code to be
able to get the home directory path in an OS neutral manner.

The warning text is

There is a .lldbinit file in the current directory which is not being read.
To silence this warning without sourcing in the local .lldbinit,
add the following to the lldbinit file in your home directory:
    settings set target.load-cwd-lldbinit false
To allow lldb to source .lldbinit files in the current working directory,
set the value of this variable to true.  Only do so if you understand and
accept the security risk.

<rdar://problem/24199163> 

llvm-svn: 261280
2016-02-19 00:05:17 +00:00
Ewan Crawford c6bef146ca Fix OSX cmake build
Commit r260721(http://reviews.llvm.org/D17182) introduced the following error when building for OSX using cmake:

Undefined symbols for architecture x86_64:

"_PyInit__lldb", referenced from:
   -exported_symbol[s_list] command line option

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Adding '*' to the regex solves this problem, since it makes the symbol optional.

Reviewers: sivachandra, zturner, labath
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D17384

llvm-svn: 261227
2016-02-18 17:01:40 +00:00
Jim Ingham cbf6f9b243 Adding an SBThread::StepInto that takes an end-line, also moved the code that figures
out the address range for the step to SymbolContext.

llvm-svn: 260772
2016-02-13 00:31:47 +00:00
Siva Chandra 29d9bea93f Adjust for Python-3.
Summary:
This does not yet give us a clean testsuite run but it does help with:
1. Actually building on linux
2. Run the testsuite with over 70% tests passing on linux.

Reviewers: tfiala, labath, zturner

Subscribers: lldb-commits

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

llvm-svn: 260721
2016-02-12 20:30:47 +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
Pavel Labath d2474ff513 Log error message in SBTarget::Launch
llvm-svn: 259514
2016-02-02 15:16:20 +00:00
Eugene Leviant 24785bd0b8 Ignore breakpoints by default in SBFrame::EvaluateExpression
llvm-svn: 259185
2016-01-29 10:48:11 +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
Hans Wennborg 400e1809ad Fix -Wformat-pedantic warning
/work/llvm-3.8/llvm.src/tools/lldb/source/API/SBProcess.cpp:1003:73:
error: format specifies type 'void *' but the argument has type 'lldb_private::Event *' [-Werror,-Wformat-pedantic]
        log->Printf ("SBProcess::%s (event.sp=%p) => %d", __FUNCTION__, event.get(), ret_val);
                                              ~~                        ^~~~~~~~~~~
1 error generated.

llvm-svn: 257692
2016-01-13 22:40:26 +00:00
Pavel Labath ea2cc5e028 Add logging to SBProcess::GetRestartedFromEvent
llvm-svn: 256853
2016-01-05 17:55:35 +00:00
Ed Maste 81b4c5f236 Strip trailing whitespace
(There are changes in the copies of these four files in the FreeBSD base
system, and I've changed these ones to reduce gratuitous diffs in future
imports.)

llvm-svn: 256723
2016-01-04 01:43:47 +00:00
Enrico Granata e242624ca9 Add API to support retrieving the formatters category for a specific language
llvm-svn: 256033
2015-12-18 21:25:24 +00:00
Greg Clayton 0817da881e First pass at LLDBRPC.framework
llvm-svn: 255697
2015-12-15 23:03:22 +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
Ted Woodward bff0a21b57 Add Hexagon ABI to System Initialization
Summary: When the Hexagon ABI was added, it was inadvertently left out of initialization/termination. This patch adds it.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 255268
2015-12-10 17:53:07 +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
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
Adrian McCarthy f7d1893f5b Enable saving of mini dumps with lldb process save-core.
Also adds SB API to save a core and tests that use it.

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

llvm-svn: 253734
2015-11-20 23:09:11 +00:00
Adrian McCarthy f9a2697e13 Revert "FOO"
Accidentally commited before I was done.

This reverts commit 2ec2da4ee52780582d5e9c88b2e982a688fbdbe1.

llvm-svn: 253685
2015-11-20 18:18:21 +00:00
Adrian McCarthy af75dab383 FOO
llvm-svn: 253684
2015-11-20 18:15:14 +00:00
Enrico Granata 3de08c5f0c Reapply r253423 and r253424 (which cleanup the data formatters iteration model, as well as the type X list commands), along with a change by Zachary Turner to bypass a MSVC bug with SFINAE
llvm-svn: 253493
2015-11-18 19:42:44 +00:00
Tamas Berghammer 68aa90a11e Revert 2 commits breaking the MSVC build
Revert "Remove a few vestigial typedefs from the old world"
This reverts commit 05872cda2a00fbd988c4fc761b1f87fe9edce224.

Revert "Cleanup the type X list commands to use the new ForEach goodness"
This reverts commit 85b1d83819a22cdc9ef12f58fd4fa92b473a4f81.

llvm-svn: 253455
2015-11-18 12:11:34 +00:00
Enrico Granata a76e894bd5 Cleanup the type X list commands to use the new ForEach goodness
llvm-svn: 253423
2015-11-18 01:37:49 +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
Greg Clayton fe68904fa6 Fixed TypeMemberFunctionImpl to not use clang types directly but use the new CompilerDecl class to do the job in an abstract way.
Fixed a crash that would happen if you tried to get the name of a constructor or destructor by calling "getDeclName()" instead of calling getName() (which would assert and crash).

Added the ability to get function arguments names from SBFunction.

llvm-svn: 252622
2015-11-10 17:47:04 +00:00
Enrico Granata 7123e2b5d7 Add SBType::IsAnonymousType() and relative plumbing in the debugger internals
For language that support such a thing, this API allows to ask whether a type is anonymous (i.e. has been given no name)

Comes with test case

llvm-svn: 252390
2015-11-07 02:06:57 +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
Jason Molenda 5e88be9f8c Add PlatformRemoteAppleWatch (apple watch), PlatformRemoteAppleTV (apple tv),
PlatformAppleWatchSimulator (apple watch simulator), PlatformAppleTVSimulator
(apple tv simulator).

llvm-svn: 252251
2015-11-06 00:22:53 +00:00
Ryan Brown 2dd84882fc Add go data formatters.
Differential Revision: http://reviews.llvm.org/D13878

llvm-svn: 252109
2015-11-05 00:24:36 +00:00
Ryan Brown 998c8a1c1c Create an expression parser for Go.
The Go interpreter doesn't JIT or use LLVM, so this also
moves all the JIT related code from UserExpression to a new class LLVMUserExpression.

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

Fix merge

llvm-svn: 251820
2015-11-02 19:30:40 +00:00
Eugene Zelenko dbb0abbf47 Fix Clang-tidy modernize-use-nullptr warnings in include/lldb/API and source/API; other minor fixes.
Other fixes should reduce number of readability-redundant-smartptr-get and readability-implicit-bool-cast.

llvm-svn: 251733
2015-10-31 01:22:59 +00:00
Jim Ingham d612918367 Make the error return more explicit when an SBValue has no value.
llvm-svn: 251722
2015-10-30 21:43:15 +00:00
Jim Ingham 9f521f22d4 Fix an error message (the debugger was invalid, not the target.)
llvm-svn: 251720
2015-10-30 21:32:03 +00:00
Enrico Granata 204aa1d980 Add an 'internal' kind of summary to support one-off subclasses of TypeSummaryImpl
llvm-svn: 251642
2015-10-29 18:58:13 +00:00
Adrian McCarthy 18a9135d56 Refactor Windows process plugin to allow code sharing between live and mini dump debugging.
llvm-svn: 251540
2015-10-28 18:21:45 +00:00
Enrico Granata e7cbaf3e0e Minor cleanup of SBTypeSummary::CreateWithCallback to take an optional description argument
llvm-svn: 251377
2015-10-27 01:17:28 +00:00
Enrico Granata 9e9cf54eb2 Add calls to the SB API to access the multi-language formatter category feature
llvm-svn: 251376
2015-10-27 01:10:35 +00:00