Commit Graph

1069 Commits

Author SHA1 Message Date
Siva Chandra d8335e9ab4 Read macro info from .debug_macro section and use it for expression evaluation.
Summary:
DWARF 5 proposes a reinvented .debug_macro section. This change follows
that spec.

Currently, only GCC produces the .debug_macro section and hence
the added test is annottated with expectedFailureClang.

Reviewers: spyffe, clayborg, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 255729
2015-12-16 00:22:08 +00:00
Sean Callanan edd508b362 Fixed a bug where the size of a type was used instead of the size of a pointer.
llvm-svn: 252655
2015-11-10 21:48:05 +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
Duncan P. N. Exon Smith 33e43ca608 lldb/ADT: Remove implicit ilist iterator conversions, NFC
Remove implicit ilist iterator conversions before reapplying r252372
(which will disallow them).

llvm-svn: 252378
2015-11-07 00:54:13 +00:00
Jim Ingham 51148e9f94 AddInitialArguments -> AddArguments, and we pass in the struct_address and push it too. All the
callers had to do this by hand and we ended up never actually adding initial arguments and then
reusing them by passing in the struct address separately, so the distinction wasn't needed.

llvm-svn: 252108
2015-11-05 00:24:18 +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
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
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 adb5b1dfc2 Fix Clang-tidy modernize-use-override warnings in include/lldb/Expression, source/Expression and tools/lldb-mi; other minor fixes.
llvm-svn: 251730
2015-10-31 00:43:59 +00:00
Eugene Zelenko 315b688457 Fix Clang-tidy modernize-use-override warnings in some files in source; other minor fixes.
llvm-svn: 251309
2015-10-26 17:00:13 +00:00
Sean Callanan 44dbf115fe Log information about sections that didn't make it into the target's memory.
llvm-svn: 251084
2015-10-23 00:39:09 +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
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
Sean Callanan ffd77e01a5 Added REPL.cpp to the relevant CMakeLists.txt
llvm-svn: 250755
2015-10-19 23:18:49 +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
Dawn Perchik 1bbaede5b9 Decide on the expression language inside UserExpression
When the target settings are consulted to decide the expression language
is decided in CommandObjectExpression, this doesn't help if you're running
SBFrame::EvaluateExpression().  Moving the logic into UserExpression fixes
this.

Based on patch from scallanan@apple.com
Reviewed by: dawn
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D13267

llvm-svn: 249624
2015-10-07 22:01:12 +00:00
Bruce Mitchener 804f981fd0 Reduce header inclusion in Expression.
Reviewers: spyffe

Subscribers: lldb-commits

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

llvm-svn: 249570
2015-10-07 17:22:54 +00:00
Sean Callanan 9fda9d2177 Add PersistentVariableDelegate to handle language-specific dematerialization.
The concept here is that languages may have different ways of communicating
results.  In particular, languages may have different names for their result
variables and in fact may have multiple types of result variables (e.g.,
error results).  Materializer was tied to one specific model of result handling.

Instead, now UserExpressions can register their own handlers for the result
variables they inject.  This allows language-specific code in Materializer to
be moved into the expression parser plug-in, and it simplifies Materializer.
These delegates are subclasses of PersistentVariableDelegate.

PersistentVariableDelegate can provide the name of the result variable, and is
notified when the result variable is populated.  It can also be used to touch
persistent variables if need be, updating language-specific state.  The
UserExpression owns the delegate and can decide on its result based on
consulting all of its (potentially multiple) delegates.

The user expression itself now makes the determination of what the final result
of the expression is, rather than relying on the Materializer, and I've added a
virtual function to UserExpression to allow this.

llvm-svn: 249233
2015-10-03 09:09:01 +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
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
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
Sean Callanan e6f4a8261a Removed a bunch of dependencies of Materializer on ClangUserExpression.
Instead we now just generically use UserExpression.

llvm-svn: 248842
2015-09-29 22:52:50 +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
Tamas Berghammer 92d2c8eaef Eliminate a potential crash in the struct layout code with a gracefull fallback
Differential revision: http://reviews.llvm.org/D12963

llvm-svn: 248571
2015-09-25 12:50:51 +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
Enrico Granata 15a67f49aa Make the ObjCLanguageRuntimes comply with llvm-style RTTI
llvm-svn: 248427
2015-09-23 20:12:19 +00:00
Bruce Mitchener 23a3b0e8a4 Rename clang_type_t to opaque_compiler_type_t.
Summary:
This is no longer related to Clang and is just an opaque pointer
to data for a compiler type.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 248288
2015-09-22 17:04:24 +00:00
Tamas Berghammer 1bacb9220a Fix MSVC warings in DWARFExpression.cpp
llvm-svn: 248148
2015-09-21 10:24:59 +00:00
Bruce Mitchener 1c95046aa5 Reduce inclusion of clang headers.
Summary:
With the recent changes to separate clang from the core structures
of LLDB, many inclusions of clang headers can be removed.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 248004
2015-09-18 17:02:48 +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
Sean Callanan c608d206c7 Removed a needless cast to ClangExpressionVariable.
llvm-svn: 247910
2015-09-17 18:19:12 +00:00
Paul Herman ea188fc318 Add using directives to the clang::DeclContext and fix decls for variables inside namespaces
Summary: Supports the parsing of the "using namespace XXX" and "using XXX::XXX" directives. Added ambiguity errors when it two decls with the same name are encountered (see comments in TestCppNsImport). Fixes using directives being duplicated for anonymous namespaces. Fixes GetDeclForUID for specification DIEs.

Reviewers: sivachandra, chaoren, clayborg

Subscribers: lldb-commits

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

llvm-svn: 247836
2015-09-16 18:48:30 +00:00
Tamas Berghammer 1f5e4483a4 Add support for the DWARFLocationList used by split-dwarf
Split-dwarf uses a different header format to specify the address range
for the elements of the location lists.

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

llvm-svn: 247789
2015-09-16 12:37:06 +00:00
Chaoren Lin 3ca7a3eb41 Fix off-by-one size check.
llvm-svn: 247766
2015-09-16 01:20:34 +00:00
Paul Herman d628cbb999 Search variables based on clang::DeclContext and clang::Decl tree
Summary: SymbolFileDWARF now creates VarDecl and BlockDecl and adds them to the Decl tree. Then, in ClangExpressionDeclMap it uses the Decl tree to search for a variable. This fixes lots of variable scoping problems.

Reviewers: sivachandra, chaoren, spyffe, clayborg

Subscribers: tberghammer, jingham, lldb-commits

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

llvm-svn: 247746
2015-09-15 23:44:17 +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
Tamas Berghammer 41b1f73122 Add support for DW_OP_GNU_const_index to dwarf expression
DW_OP_GNU_const_index is a new opcode used when split dwarf is enabled

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

llvm-svn: 247672
2015-09-15 10:33:54 +00:00
Sean Callanan 85aabaf935 ClangExpressionDeclMap should only disable the Clang parser-specific state on
Clang persistent variables.

llvm-svn: 247615
2015-09-14 21:03:44 +00:00
Hafiz Abid Qadeer 87f4f413ba Remove an invalid check in DW_OP_piece processing.
Summary:
When lldb is processing a location containing DW_OP_piece, the result is being
stored in the 'pieces' variable. The location is popped from the 'stack' variable.
So this check to see that 'stack' is not empty was invalid and caused the pieces
after the first to not get processed.

I am working on an architecture which has 16-bit and 8-bit registers. So this
problem was quite easy to see. But I was able to re-produce this issue on x86
too with long long variable and compiling woth -m32. It resulted in following
location list.
00000014 08048496 080484b5 (DW_OP_reg6 (esi); DW_OP_piece: 4; DW_OP_reg7 (edi); DW_OP_piece: 4)

and lldb was only showing the contents of first register when I evaluated the
variable as it does not process the 2nd piece due to this check.

Reviewers: clayborg, aprantl

Subscribers: lldb-commits

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

llvm-svn: 247124
2015-09-09 09:06:05 +00:00
Sean Callanan 3820e9cd17 ExpressionVariable now uses llvm::cast() instead of As...() for RTTI.
As part of our overall switch from hand-rolling RTTI to using LLVM-compatible
methods, I've done the same for ExpressionVariable.  The main documentation for
how to do this is in TypeSystem.h, so I've simply referred to that.

llvm-svn: 247085
2015-09-08 22:23:39 +00:00
Greg Clayton f73034f99a Use LLVM casting for TypeSystem so you can cast it to subclasses.
This will keep our code cleaner and it removes the need for intrusive additions to TypeSystem like:

class TypeSystem
{
    virtual ClangASTContext *
    AsClangASTContext() = 0;
}

As you can now just use the llvm::dyn_cast and other casts.

llvm-svn: 247041
2015-09-08 18:15:05 +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
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
Siva Chandra 0f4873d7d0 Lookup function using full name if one with mangled name is not found.
Summary:
Remove expected failure decorators from tests which now should start
passing.

Reviewers: clayborg, spyffe

Subscribers: lldb-commits

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

llvm-svn: 246820
2015-09-03 23:27:10 +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
Bruce Mitchener 49948af9cd Fix cmake build.
llvm-svn: 246746
2015-09-03 04:17:57 +00:00
Sean Callanan 30e339749f Jim told me about a cleaner way to include headers from plug-ins.
This is still something I need to fix, but at least it's not so ugly, and it's
consistent with the other code that does that so we will catch it when we purge
all such code.

llvm-svn: 246738
2015-09-03 00:48:23 +00:00
Sean Callanan e33724f371 In preparation for factoring persistent variables into a generic part and a
Clang-specific part, create the ExpressionVariable source/header file and
move ClangExpressionVariable into the Clang expression parser plugin.

It is expected that there are some ugly #include paths... these will be resolved
by either (1) making that code use generic expression variables (once they're
separated appropriately) or (2) moving that code into a plug-in, often
the expression parser plug-in.

llvm-svn: 246737
2015-09-03 00:35:46 +00:00
Sean Callanan 761844be66 When looking up types, find the first type we can import rather than just taking
the first type we find and failing if it can't be imported.

llvm-svn: 246563
2015-09-01 18:00:35 +00:00
Tamas Berghammer 35d9d2dc1e Handle DW_OP_GNU_addr_index in DWARF expressions
Differential revision: http://reviews.llvm.org/D12290

llvm-svn: 245932
2015-08-25 11:46:06 +00:00
Tamas Berghammer c178d4c0ce Add support for DW_FORM_GNU_[addr,str]_index
These are 2 new value currently in experimental status used when split
debug info is enabled.

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

llvm-svn: 245931
2015-08-25 11:45:58 +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 641e1987d6 Fix evaluation of global operators in C++
llvm-svn: 245508
2015-08-19 21:44:56 +00:00
Chaoren Lin 57998de165 Update to r245397.
`ast_transformer` could be null, in which case we should initialize
`m_code_generator` with the ASTContext.

llvm-svn: 245398
2015-08-19 01:24:57 +00:00
Richard Smith 453930d7c3 Fix LLDB after Clang r245346.
The right thing to do here would be to give the ASTConsumer to the
CompilerInstance so it can set things up for us, but we can't do that
because we don't own it. So instead just initialize it ourselves.

llvm-svn: 245397
2015-08-19 01:05:34 +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
Richard Smith 4cb29abcdb Update lldb's ExternalASTSources to match Clang r244161.
llvm-svn: 244194
2015-08-06 05:13:41 +00:00
Pavel Labath 3a29f8b9ec Fix warnings detected by -Wpessimizing-move
patch by Eugene Zelenko

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

llvm-svn: 243399
2015-07-28 09:18:32 +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
Sean Callanan 9ff456c8a2 Fixed a problem where variables in modules were not appropriately discovered by
the expression parser.

<rdar://problem/21395220>

llvm-svn: 241917
2015-07-10 17:34:23 +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 007135e612 Fixed the C modules test case on Darwin by streamlining its code.
We don't need to do the fancy dance with checking whether the iterator
represents a #define -- in fact, that's the wrong thing to do.  The thing to do
is check whether the highest-priority module that did something to the module
#defined or #undefd it.  If it #defined it, then the MacroInfo* will be non-NULL
and we're good to go.

llvm-svn: 241651
2015-07-08 00:13:49 +00:00
Greg Clayton d6171a74f0 Make sure we can lookup re-exported symbols after recent changes to lldb_private::Symbol.
Recently lldb_private::Symbol was changed so the old code:

Address &Symbol::GetAddress();

Is now:

Address Symbol::GetAddress();

And the Address object that is returned will be invalid for non-address based symbols. When we have re-exported symbols this code would now fail:

    const Address sym_address = sym_ctx.symbol->GetAddress();

    if (!sym_address.IsValid())
        continue;

    symbol_load_addr = sym_ctx.symbol->ResolveCallableAddress(*target_sp);

    if (symbol_load_addr == LLDB_INVALID_ADDRESS)
    {
        symbol_load_addr = sym_address.GetLoadAddress(target_sp.get());
    }

It used to return an Address reference to the value of the re-exported symbol that contained no section and a zero value for Address.m_offset (since the original symbol in the symbol table had a value of zero). When a reference was returned, this meant the "sym_address.IsValid()" would return true because the Address.m_offset was not LLDB_INVALID_ADDRESS, it was zero. This was working by mistake.

The Symbol::ResolveCallableAddress(...) actually checks for reexported symbols and whole bunch of other cases and resolves the address correctly, so we should let it do its thing and not cut it off before it can resolve the address with the "if (!sym_address.IsValid()) continue;".

llvm-svn: 241282
2015-07-02 16:43:49 +00:00
Dawn Perchik 508f040994 Fix typo in comment.
llvm-svn: 241173
2015-07-01 17:41:02 +00:00
Dawn Perchik 53f34c8736 Rename ClangUserExpression members to avoid confusion with language.
The new names clarify that the members have to do with the execution
context and not the language.  For example, m_cplusplus was renamed to
m_in_cplusplus_method.

llvm-svn: 241132
2015-07-01 00:54:02 +00:00
Tamas Berghammer 0b736f1ed0 Fix LLDB build after r241035
llvm-svn: 241050
2015-06-30 09:26:52 +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
Bruce Mitchener 58ef391f3e Fix a variety of typos.
No functional change.

llvm-svn: 239995
2015-06-18 05:27:05 +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
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
Sean Callanan 8ebc973133 If we see an external function in the symbols, make
it an extern "C" function instead of a C++ function
so that Clang doesn't emit a mangled function reference.

Also removed the hack in ClangExpressionDeclMap that
works around this.

llvm-svn: 238476
2015-05-28 20:07:44 +00:00
Sean Callanan 235de0aed3 Don't crash if we don't have a process and need
to check for alternate manglings.

llvm-svn: 238475
2015-05-28 20:06:40 +00:00
Greg Clayton 4e1042e1bf Allow expresions to have unique expression prefixes:
expr_options = lldb.SBExpressionOptions()
expr_options.SetPrefix('''
struct Foo {
   int a;
   int b;
   int c;
}
'''
expr_result = frame.EvaluateExpression ("Foo foo = { 1, 2, 3}; foo", expr_options)

This fixed a current issue with ptr_refs, cstr_refs and malloc_info so that they can work. If expressions define their own types and then return expression results that use those types, those types get copied into the target's AST context so they persist and the expression results can be still printed and used in future expressions. Code was added to the expression parser to copy the context in which types are defined if they are used as the expression results. So in the case of types defined by expressions, they get defined in a lldb_expr function and that function and _all_ of its statements get copied. Many types of statements are not supported in this copy (array subscript, lambdas, etc) so this causes expressions to fail as they can't copy the result types. To work around this issue I have added code that allows expressions to specify an expression specific prefix. Then when you evaluate the expression you can pass the "expr_options" and have types that can be correctly copied out into the target. I added this as a way to work around an issue, but I also think it is nice to be allowed to specify an expression prefix that can be reused by many expressions, so this feature is very useful.

<rdar://problem/21130675>

llvm-svn: 238365
2015-05-27 22:32:39 +00:00
Greg Clayton 67d49488a7 Don't allow infininte recursion when trying to resolve re-exported symbols.
<rdar://problem/20821289>

llvm-svn: 237477
2015-05-15 21:27:16 +00:00
Vince Harron d7e6a4f2f0 Fixed a ton of gcc compile warnings
Removed some unused variables, added some consts, changed some casts
to const_cast. I don't think any of these changes are very
controversial.

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

llvm-svn: 237218
2015-05-13 00:25:54 +00:00
Ilia K ece0a3f69c Fix ClangUserExpression::Evaluate return code in case of eExpressionParseError
Summary: This patch fixes retvalue of ClangUserExpression::Evaluate in case of eExpressionParseError error

Reviewers: jingham, spyffe, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, spyffe, jingham

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

llvm-svn: 236700
2015-05-07 06:27:43 +00:00
Sean Callanan 80c9759ef7 Added support for locating and importing functions
(including inline functions) from modules in the
expression parser.  We now have to retain a reference
to the code generator in ClangExpressionDeclMap so
that any imported function bodies can be appropriately
sent to that code generator.

<rdar://problem/19883002>

llvm-svn: 236297
2015-05-01 00:47:29 +00:00
Sean Callanan 1376469a61 Updated our use of clang::Preprocessor to reflect
a change in the API used to get macros.

llvm-svn: 236292
2015-05-01 00:19:44 +00:00
Sean Callanan 68f85e7d6a Made macros from modules be injected before our
global convenience expression prefix.  Also ensured
that if macros are defined by the modules we don't
try to redefine them.  Finally cleaned up a bit of
code while I was in there.

<rdar://problem/20756642>

llvm-svn: 236266
2015-04-30 21:49:58 +00:00
Richard Smith 63a41277fe Fix build after Clang API change in r236176.
llvm-svn: 236182
2015-04-29 23:46:48 +00:00
Chaoren Lin 82c6a40ba6 Fix build.
llvm-svn: 235653
2015-04-23 22:19:29 +00:00
Richard Smith 6d48859b18 Fix build of lldb after clang r235614.
llvm-svn: 235631
2015-04-23 19:36:34 +00:00
Sean Callanan f0c5aeb690 This patch implements several improvements to the
module-loading support for the expression parser.

- It adds support for auto-loading modules referred
  to by a compile unit.  These references are
  currently in the form of empty translation units.
  This functionality is gated by the setting

  target.auto-import-clang-modules (boolean) = false

- It improves and corrects support for loading
  macros from modules, currently by textually
  pasting all #defines into the user's expression.
  The improvements center around including only those
  modules that are relevant to the current context -
  hand-loaded modules and the modules that are imported
  from the current compile unit.

- It adds an "opt-in" mechanism for all of this
  functionality.  Modules have to be explicitly
  imported (via @import) or auto-loaded (by enabling
  the above setting) to enable any of this
  functionality.

It also adds support to the compile unit and symbol
file code to deal with empty translation units that
indicate module imports, and plumbs this through to
the CompileUnit interface.

Finally, it makes the following changes to the test
suite:

- It adds a testcase that verifies that modules are
  automatically loaded when the appropriate setting
  is enabled (lang/objc/modules-auto-import); and

- It modifies lanb/objc/modules-incomplete to test
  the case where a module #undefs something that is
  #defined in another module.

<rdar://problem/20299554>

llvm-svn: 235313
2015-04-20 16:31:29 +00:00
Sean Callanan b8bf6efa6e Added support to ClangUserExpression for importing
all the macros from the modules the user has loaded.
These macros are currently imported textually into
the expression's source code, which turns out not to
impose the horrific string processing overhead that
I thought it would, but I still plan to look into
performance improvements.

Also modified TestCModules to test that this works.

llvm-svn: 234922
2015-04-14 18:36:17 +00:00
Sean Callanan 507b588a34 Updated IRForTarget to change the way we generate
relocations.  We used to do GEP on a pointer to
the result type, which is wrong.  We should be doing
GEP on a pointer to char, which allows us to offset
correctly.

This fixes the C modules testcase, so it's no longer
ExpectFail.

llvm-svn: 234918
2015-04-14 18:17:35 +00:00
Siva Chandra 0f404e0575 [IRForTarget] Strenghten handling of alternate mangling.
Summary:
This fixes an issue with GCC generated binaries wherein an expression
with method invocations on std::string variables was failing. Such use
cases are tested in TestSTL (albeit, in a test marked with
@unittest2.expectedFailure because of other reasons).

The reason for this particular failure with GCC is that the generated
DWARF for std::basic_string<...> is incomplete, which makes clang not
to use the alternate mangling scheme. GCC correctly generates the name
of basic_string<...>:

DW_AT_name "basic_string<char, std::char_traits<char>, std::allocator<char> >"

It also lists the template parameters of basic_string correctly:

DW_TAG_template_type_parameter
    DW_AT_name                  "_CharT"
    DW_AT_type                  <0x0000009c>
DW_TAG_template_type_parameter
    DW_AT_name                  "_Traits"
    DW_AT_type                  <0x00000609>
DW_TAG_template_type_parameter
    DW_AT_name                  "_Alloc"
    DW_AT_type                  <0x000007fb>

However, it does not list the template parameters of std::char_traits<>.
This makes Clang feel (while parsing the expression) that the string
variable is not actually a basic_string instance, and consequently does
not use the alternate mangling scheme.

Test Plan:
dotest.py -C gcc -p TestSTL
          -- See it go past the "for" loop expression successfully.

Reviewers: clayborg, spyffe

Reviewed By: clayborg, spyffe

Subscribers: tberghammer, zturner, lldb-commits

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

llvm-svn: 234522
2015-04-09 18:48:34 +00:00
Stephane Sezer 9901e9c6c8 Fix resolution of certain recursive types.
Summary:
If a struct type S has a member T that has a member that is a function that
returns a typedef of S* the respective field would be duplicated, which caused
an assert down the line in RecordLayoutBuilder. This patch adds a check that
removes the possibility of trying to resolve the same type twice within the
same callstack.

This commit also adds unit tests for these failures.

Fixes https://llvm.org/bugs/show_bug.cgi?id=20486.

Patch by Cristian Hancila.

Test Plan: Run unit tests.

Reviewers: clayborg spyffe

Subscribers: lldb-commits

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

llvm-svn: 234441
2015-04-08 21:52:45 +00:00
David Blaikie 129b839d71 Fix -Wformat-pedantic warnings
llvm-svn: 234429
2015-04-08 20:23:52 +00:00
Sean Callanan 157f1af743 Fixed a problem where the second @import statement
in a session would be silently ignored by the compiler
because the compiler looked at its SourceLocation and
decided it had already handled it.

Also updated the relevant test case.

<rdar://problem/20315447>

llvm-svn: 234330
2015-04-07 17:02:02 +00:00
Sean Callanan a85f0e82dc Fixed a crash because we weren't generating
type-safe relocations against @reloc_placeholder.

<rdar://problem/20438754>

llvm-svn: 234260
2015-04-06 23:51:08 +00:00
Greg Clayton b23c24c2a8 We have an issue where if you use a C function right now that has no prototype, it isn't marked as extern "C" and the name to lookup is some C++ mangled form of the name.
This used to be the case for "printf" before a function prototype was added to the builtin expression prefix file. This fix makes sure that if we get a mangled name that we don't find in the current target, that we only fall back to looking up function by basename if the function isn't contained in a namespace or class (no decl context).

llvm-svn: 234178
2015-04-06 17:14:02 +00:00
Sean Callanan 8505434011 Added a testcase that covers loading a module and
verifying that the types from that module don't
override types from DWARF.  Also added a target setting
to LLDB so we can tell Clang where to look for these
local modules.

<rdar://problem/18805055>

llvm-svn: 234016
2015-04-03 15:39:47 +00:00
Zachary Turner d4e1b8685e Fix error resulting from llvm r233938.
llvm-svn: 233942
2015-04-02 20:37:10 +00:00
Tamas Berghammer dccbfaf917 Fix type detection for 'char' variables
A char can have signed and unsigned encoding but previously lldb always
assumed it is signed. This CL adds a logic to detect the encoding of
'char' types based on the default encoding on the target architecture.
It fixes variable printing and expression evaluation on architectures
where 'char' is signed by default.

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

llvm-svn: 233682
2015-03-31 10:21:50 +00:00
Zachary Turner b2a2539cc7 Fix build broken by missing `typename` keyword.
llvm-svn: 233106
2015-03-24 20:22:50 +00:00
Zachary Turner a98fac28aa Fix error introduced by changing function signatures.
Since ClangASTSource::layoutRecordType() was overriding a virtual
function in the base, this was inadvertently causing a new method
to be introduced rather than an override.  To fix this all method
signatures are changed back to taking DenseMaps, and the `override`
keyword is added to make sure this type of error doesn't happen
again.

To keep the original fix intact, which is that fields and bases
must be added in offset order, the ImportOffsetMap() function
now copies the DenseMap into a vector and then sorts the vector
on the value type (e.g. the offset) before iterating over the
sorted vector and inserting the items.

llvm-svn: 233099
2015-03-24 18:56:08 +00:00
Zachary Turner 504f38da4e Fix record layout when synthesizing class types.
Prior to this patch, we would try to synthesize class types by
iterating over a DenseMap of FieldDecls and adding each one to
a CXXRecordDecl.  Since a DenseMap doesn't provide a deterministic
ordering of the elements, this would not add the fields in
FieldOffset order, but rather in some random order determined by
the memory layout of the DenseMap.

This patch fixes the issue by changing DenseMaps to vectors.  The
ability to lookup a value in the DenseMap was hardly being used,
and where it is sufficient to do a vector lookup.

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

llvm-svn: 233090
2015-03-24 16:24:50 +00:00
Zachary Turner 3294de270e Move lldb-log.cpp to core/Logging.cpp
So that we don't have to update every single #include in the entire
codebase to #include this new header (which used to get included by
lldb-private-log.h, we automatically #include "Logging.h" from
within "Log.h".

llvm-svn: 232653
2015-03-18 18:20:42 +00:00
Vince Harron 0fc6c6762f Added nullptr to fix build
llvm-svn: 232345
2015-03-16 03:54:22 +00:00
Greg Clayton 58ea3e35d0 Fixed a bug where the expression parser relied on having symbols for things even if they were in the debug info.
The issue can happen if you strip your main executable and then run an expression and it would fail to find the stripped symbol and it would then not be able to make the function call. The issue was fixed by doing our normal FindFunctions call.

<rdar://problem/20072750>

llvm-svn: 231667
2015-03-09 16:46:57 +00:00
Greg Clayton 12ba733ce8 When we have a symbol, like "NSLog" that we try to call in an expression, make sure we prioritize the external symbols over the internal one.
This is a temporary fix until a more comprehensive fix can be made for finding functions that we call in expressions.

We find "NSLog" in ClangExpressionDeclMap::FindExternalVisibleDecls() in after a call to target->GetImages().FindFunctions(...). Note that there are two symbols: NSLog from CFNetwork which is not external, and NSLog from Foundation which _is_ external. We do something with the external symbol with:

                    if (extern_symbol)
                    {
                        AddOneFunction (context, NULL, extern_symbol, current_id);
                        context.m_found.function = true;
                    }

Then later we try to lookup the _Z5NSLogP8NSStringz name and we don't find it so we call ClangExpressionDeclMap::GetFunctionAddress() with "_Z5NSLogP8NSStringz" as the name and the sc_list_size is zero at the "if" statement at line 568 because we don't find the mangled name and we extract the basename "NSLog" and call:

            FindCodeSymbolInContext(ConstString(basename), m_parser_vars->m_sym_ctx, sc_list);
            sc_list_size = sc_list.GetSize();

and we get a list size of two again, and we proceed to search for the symbol again, this time ignoring the external vs non-external-ness of the symbols that we find. This fix ensures we prioritize the external symbol until we get a real fix from Sean Callanan when he gets back to make sure we don't do multiple lookups for the same symbol we already resolved.

<rdar://problem/19879282>

llvm-svn: 231420
2015-03-05 23:12:02 +00:00
Jason Molenda 9594459b21 Add support for the DWARFv3 (circa 2005) DW_OP_form_tls_address
operator in addition to the vendor-extension DW_OP_GNU_push_tls_address.
clang on PS4 and Darwin will be emitting the standard opcode 
as of r231286 via http://reviews.llvm.org/D8018

Behavior of this standard  opcode is the same as 
DW_OP_GNU_push_tls_address.

<rdar://problem/20043195>

llvm-svn: 231342
2015-03-05 02:42:06 +00:00
Zachary Turner fc8588136c Don't #include clang headers from BreakpointLocation.h
llvm-svn: 231263
2015-03-04 17:43:00 +00:00
Zachary Turner a78bd7ffc1 Don't #include FormatManager.h from Debugger.h
Debugger.h is a huge file that gets included everywhere, and
FormatManager.h brings in a ton of unnecessary stuff and doesn't
even use anything from it in the header.

llvm-svn: 231161
2015-03-03 23:11:11 +00:00
Zachary Turner af0f45f1c9 Don't #include ClangPersistentVariables.h from Process.h
Nothing from this header file was even being referenced in
Process.h anyway, so it was a completely unnecessary include.

llvm-svn: 231131
2015-03-03 21:05:17 +00:00
Zachary Turner 32abc6edac Reduce header footprint of Target.h
This continues the effort to reduce header footprint and improve
build speed by removing clang and other unnecessary headers
from Target.h.  In one case, some headers were included solely
for the purpose of declaring a nested class in Target, which was
not needed by anybody outside the class.  In this case the
definition and implementation of the nested class were isolated
in the .cpp file so the header could be removed.

llvm-svn: 231107
2015-03-03 19:23:09 +00:00
Zachary Turner 88c6b62e9c Don't #include ClangASTContext.h from Module.h
This is part of a larger effort to reduce header file footprints.
Combined, these patches reduce the build time of LLDB locally by
over 30%.  However, they touch many files and make many changes,
so will be submitted in small incremental pieces.

Reviewed By: Greg Clayton
Differential Revision: http://reviews.llvm.org/D8022

llvm-svn: 231097
2015-03-03 18:34:26 +00:00
Greg Clayton f9da928993 Fixed an infinite recursion bug that could happen when using python operating system plug-ins where we would ask the operating system plug-in to update its threads and this would cause the plugin to run an expression which would eventually run IRForTarget::CreateResultVariable() which would try to get the selected thread and cause re-entrant bug.
<rdar://problem/19924734>

llvm-svn: 230711
2015-02-27 00:12:22 +00:00
Chandler Carruth 43edccdfe1 Update for Clang API change in r230123 -- lookup_result was always
const, there was never a need for lookup_const_result. Now that vestigal
type is gone, so switch LLDB to lookup_result and to use the
DeclContextLookupResult rather than the Const variant.

llvm-svn: 230126
2015-02-21 04:31:13 +00:00
Ilia K c9a475d447 Fix build after r229094: replace llvm/PassManager.h -> llvm/IR/LegacyPassManager.h
llvm-svn: 229100
2015-02-13 10:49:18 +00:00
Greg Clayton 526ae040ba Make a more complete fix for always supplying an execution context when getting byte sizes from types.
There was a test in the test suite that was triggering the backtrace logging output that requested that the client pass an execution context. Sometimes we need the process for Objective C types because our static notion of the type might not align with the reality when being run in a live runtime.

Switched from an "ExecutionContext *" to an "ExecutionContextScope *" for greater ease of use.

llvm-svn: 228892
2015-02-12 00:34:25 +00:00
Greg Clayton a03b9389ca Don't crash when evaluating a DWARF expression has a DW_OP_bra with nothing on the value stack.
<rdar://problem/18919125>

llvm-svn: 228729
2015-02-10 19:43:15 +00:00
Greg Clayton 554f68d385 Get rid of Debugger::FormatPrompt() and replace it with the new FormatEntity class.
Why? Debugger::FormatPrompt() would run through the format prompt every time and parse it and emit it piece by piece. It also did formatting differently depending on which key/value pair it was parsing. 

The new code improves on this with the following features:
1 - Allow format strings to be parsed into a FormatEntity::Entry which can contain multiple child FormatEntity::Entry objects. This FormatEntity::Entry is a parsed version of what was previously always done in Debugger::FormatPrompt() so it is more efficient to emit formatted strings using the new parsed FormatEntity::Entry.
2 - Allows errors in format strings to be shown immediately when setting the settings (frame-format, thread-format, disassembly-format
3 - Allows auto completion by implementing a new OptionValueFormatEntity and switching frame-format, thread-format, and disassembly-format settings over to using it.
4 - The FormatEntity::Entry for each of the frame-format, thread-format, disassembly-format settings only replaces the old one if the format parses correctly
5 - Combines all consecutive string values together for efficient output. This means all "${ansi.*}" keys and all desensitized characters like "\n" "\t" "\0721" "\x23" will get combined with their previous strings
6 - ${*.script:} (like "${var.script:mymodule.my_var_function}") have all been switched over to use ${script.*:} "${script.var:mymodule.my_var_function}") to make the format easier to parse as I don't believe anyone was using these format string power user features.
7 - All key values pairs are defined in simple C arrays of entries so it is much easier to add new entries.

These changes pave the way for subsequent modifications where we can modify formats to do more (like control the width of value strings can do more and add more functionality more easily like string formatting to control the width, printf formats and more).

llvm-svn: 228207
2015-02-04 22:00:53 +00:00
Greg Clayton ff48e4bea0 Fixed bugs in the multi-threaded access in HostInfoBase. Prior to this fix, static bool variables were used but this is not sufficient. We now use std::call_once in all places where the previous static bool code was used to try to implement thread safety.
This was causing code that opened multiple targets to try and get a path to debugserver from the GDB remote communication class, and it would get the LLDB path and some instances would return empty strings and it would cause debugserver to not be found.

<rdar://problem/18756927>

llvm-svn: 227935
2015-02-03 02:05:44 +00:00
Enrico Granata 1cd5e921e1 Preparatory infrastructural work to support dynamically determining sizes of ObjC types via the runtime
This is necessary because the byte size of an ObjC class type is not reliably statically knowable (e.g. because superclasses sit deep in frameworks that we have no debug info for)
The lack of reliable size info is a problem when trying to freeze-dry an ObjC instance (not the pointer, the pointee)

This commit lays the foundation for having language runtimes help in figuring out byte sizes, and having ClangASTType ask for runtime help
No feature change as no runtime actually implements the logic, and nowhere is an ExecutionContext passed in yet

llvm-svn: 227274
2015-01-28 00:07:51 +00:00
Jim Ingham 27e5fe8604 The MCJIT doesn't seem to call getPointerForNamedFunction from the MemoryManager anymore, switching to getSymbolAddress, which
it does call, and implementing it so that we once again look up external symbols in the JIT.

Also juked the error reporting from the JIT a little bit.

This resolves:
http://llvm.org/bugs/show_bug.cgi?id=22314

llvm-svn: 227217
2015-01-27 18:03:05 +00:00
Greg Clayton cd6bbba186 Fix the -*-version-min option to not try and use the current OS version for iOS and the simulator since llvm/clang will assert and kill LLDB.
llvm-svn: 226846
2015-01-22 18:25:49 +00:00
Jason Molenda 07fd86a9df Update ExpressionSourceCode::GetText() to match the
name of the iOS simulator platform which was changed
in r181631.
<rdar://problem/19200084> 

llvm-svn: 226789
2015-01-22 06:31:58 +00:00
Kate Stone cc391a0a12 Expression evaluation for functions with unknown signatures on works by
inferring the function signature.  This works well where the ABI doesn't
distinguish between variadic and fixed argument lists, but on arm64 the
calling conventions differ.  The default assumption works for fixed argument
lists, but variadic functions require explicit prototypes to be called.

By far the most common case where this is an issue is when attempting to use
 printf().  This change augments the default expression prefix to include a
working variadic prototype for the function.

<rdar://problem/19024779>

llvm-svn: 226744
2015-01-21 23:39:16 +00:00
Nico Weber f37054fbde Fix build after clang r226128.
llvm-svn: 226180
2015-01-15 17:51:05 +00:00
Sylvestre Ledru a9a57804ea In commit clang r226096, DefinitionRequired has been removed. Do the same in lldb implementation
llvm-svn: 226162
2015-01-15 11:50:50 +00:00
Zachary Turner f16ae603e8 Fix issues with LLDB's interpreter and MS ABI guard variables.
MS ABI guard variables end with @4IA, so this patch teaches the
interpreter about that.  Additionally, there was an issue with
TurnGuardLoadIntoZero which was causing some guard uses of a
variable to be missed.  This fixes that by calling
Instruction::replaceAllUsesWith() instead of trying to replicate
that function.

llvm-svn: 225547
2015-01-09 21:12:22 +00:00
Sean Callanan dc00334dc3 Added support to the expression parser for finding
Objective-C types and enums in modules.  We now have
a three-stage fallback when looking for methods and
properties: first the DWARF, second the modules, third
the runtime.

<rdar://problem/18782288>

llvm-svn: 223939
2014-12-10 19:23:29 +00:00
Duncan P. N. Exon Smith f3079d2762 ClangFunction: Fix destruction order of parser and execution unit
Fix PR21802 by correcting the destruction order of
`ClangExpressionParser` and `IRExecutionUnit` in `ClangFunction`.  The
former has hooks into the latter -- i.e., `clang::CGDebugInfo` points at
the `LLVMContext` -- so it needs to be torn down first.

This was exposed by r223802 in LLVM, which started doing work in the
`CGDebugInfo` teardown.

llvm-svn: 223916
2014-12-10 04:59:18 +00:00
Zachary Turner 543afa18b3 Fix compilation failures resulting from the llvm Metadata refactor.
Patch by Duncan P. N. Exon Smith

llvm-svn: 223844
2014-12-09 22:29:47 +00:00
Enrico Granata 0c10a85000 Add the ability for an SBValue to create a persisted version of itself.
Such a persisted version is equivalent to evaluating the value via the expression evaluator, and holding on to the $n result of the expression, except this API can be used on SBValues that do not obviously come from an expression (e.g. are the result of a memory lookup)

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

Includes testcase

Fixes rdar://19136664

llvm-svn: 223711
2014-12-08 23:13:56 +00:00
Sean Callanan 498ff1c1b8 Add new-lines after module compiler errors so
they are readable.

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

llvm-svn: 223541
2014-12-05 22:54:56 +00:00
Zachary Turner b88ec656b5 Fix compilation errors after clang modules checkin.
llvm-svn: 223484
2014-12-05 17:38:20 +00:00
Sean Callanan 221262996a Added CMake support so all the Clang modules code
will at least be built by non-OS X builders. This
should head off some build breakage at the pass.

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

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

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

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

llvm-svn: 223388
2014-12-04 21:26:25 +00:00
Enrico Granata c5d32d751e Fix a build breakage. Looks like the LLVM side of this change has been reverted
llvm-svn: 223375
2014-12-04 18:39:40 +00:00
Jason Molenda 286fd1aaac Update setMCJITMemoryManager call to keep in line with llvm r223183.
Patch from Ryan Goodfellow.

llvm-svn: 223196
2014-12-03 04:02:03 +00:00
Duncan P. N. Exon Smith 68caa7d34d Revert "Update for LLVM API change in r221024"
This reverts commit r221073 to match upstream revert in r221711.

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

llvm-svn: 221660
2014-11-11 02:49:44 +00:00
Greg Clayton 45f4f8bd7e Fix comments to match the current reality.
llvm-svn: 221633
2014-11-10 21:48:12 +00:00
Greg Clayton bd549169d7 Fix selectors not being objc-uniquified in the expression parser after a recent renaming in clang (clang change for revision 221451). This broke all objective C expressions in LLDB.
llvm-svn: 221632
2014-11-10 21:45:59 +00:00
Zachary Turner 0d594e136e Fix LLDB build as a result of upstream LLVM changes.
llvm-svn: 221378
2014-11-05 18:37:53 +00:00
Ed Maste d455a1ecb8 Update for LLVM API change in r221024
llvm-svn: 221073
2014-11-02 00:24:22 +00:00
Sean Callanan 35e678c7e0 Don't allow the expression parser to magically
look through 'self' at its ivars.  It produces
surprising results.

<rdar://problem/18698760>

llvm-svn: 220220
2014-10-20 18:36:58 +00:00
Zachary Turner cb5742b828 Don't use mkstemp, as it doesn't exist on Windows.
Differential Revision: http://reviews.llvm.org/D5849
Reviewed by: Jason Molenda

llvm-svn: 220218
2014-10-20 17:46:56 +00:00
Sean Callanan 5e3bdbff3f Fixed the expression parser to handle cases where
GetValueForVariableExpressionPath returns NULL and
doesn't set an error.

<rdar://problem/18682916>

llvm-svn: 220070
2014-10-17 18:16:04 +00:00
Jason Molenda bc464ee614 Change a use of mktemp() to mkstemp() for better security.
We have two more uses of mktemp still in the source base
but they'll take a little more consideration.
clang static analyzer fixit.

llvm-svn: 219983
2014-10-16 23:10:03 +00:00
Jason Molenda e5d8eaf042 Only call RemovePersistentVariable on expr_result if that shared
pointer contains something.

llvm-svn: 219966
2014-10-16 21:25:43 +00:00