Commit Graph

916 Commits

Author SHA1 Message Date
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