teak-llvm/lldb/packages/Python/lldbsuite/test
Sean Callanan b494578afb [DWARF] Fix lookup in the abstract origins of inlined blocks/functions
LLDB uses clang::DeclContexts for lookups, and variables get put into
the DeclContext for their abstract origin. (The abstract origin is a 
DWARF pointer that indicates the unique definition of inlined code.) 
When the expression parser is looking for variables, it locates the 
DeclContext for the current context. This needs to be done carefully, 
though, e.g.:

__attribute__ ((always_inline)) void f(int a) {
  {
    int b = a * 2;
  }
}

void g() {
  f(3);
}
Here, if we're stopped in the inlined copy of f, we have to find the 
DeclContext corresponding to the definition of f – its abstract 
origin. Clang doesn't allow multiple functions with the same name and 
arguments to exist. It also means that any variables we see must be 
placed in the appropriate DeclContext.

[Bug 1]: When stopped in an inline block, the function 
GetDeclContextDIEContainingDIE for that block doesn't properly
construct a DeclContext for the abstract origin for inlined
subroutines. That means we get duplicated function DeclContexts, but
function arguments only get put in the abstract origin's DeclContext, 
and as a result when we try to look for them in nested contexts they 
aren't found.

[Bug 2]: When stopped in an inline block, the DWARF (for space 
reasons) doesn't explicitly point to the abstract origin for that 
block. This means that the function GetClangDeclContextForDIE returns
a different DeclContext for each place the block is inlined. However, 
any variables defined in the block have abstract origins, so they 
will only get placed in the DeclContext for their abstract origin.

In this fix, I've introduced a test covering both of these issues,
and fixed them.

Bug 1 could be resolved simply by making sure we look up the abstract
origin for inlined functions when looking up their DeclContexts on 
behalf of nested blocks.

For Bug 2, I've implemented an algorithm that makes the DeclContext 
for a block be the containing DeclContext for the closest entity we
would find during lookup that has an abstract origin pointer. That
means that in the following situation:

{ // block 1
  int a;
  { // block 2
    int b;
  }
}
if we looked up the DeclContext for block 2, we'd find the block 
containing the abstract origin of b, and lookup would proceed 
correctly because we'd see b and a. However, in the situation

{ // block 1
  int a;
  { // block 2
  }
}
since there isn't anything to look up in block 2, we can't determine 
its abstract origin (and there is no such pointer in the DWARF for 
blocks). However, we can walk up the parent chain and find a, and its 
abstract origin lives in the abstract origin of block 1. So we simply 
say that the DeclContext for block 2 is the same as the DeclContext 
for block 1, which contains a. Lookups will return the same results.

Thanks to Jim Ingham for review and suggestions.

Differential revision: https://reviews.llvm.org/D32375

llvm-svn: 301263
2017-04-24 22:11:10 +00:00
..
android/platform *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
api Mark this as skipped for now. There is a race condition with 2017-03-10 05:33:27 +00:00
arm_emulation *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
attic *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
benchmarks *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
driver/batch_mode *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
example *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
expression_command Don't access the process in expressions w/o checking that 2016-11-03 23:42:09 +00:00
functionalities Update two android XFAILS 2017-04-24 15:23:21 +00:00
help One more cleanup to lldb version printing 2016-11-14 22:43:08 +00:00
issue_verification test infra: clear file-charged issues on rerun of file 2016-10-01 00:17:08 +00:00
lang [DWARF] Fix lookup in the abstract origins of inlined blocks/functions 2017-04-24 22:11:10 +00:00
linux NPL: Fix one more bug in the single step workaround 2017-02-17 11:48:34 +00:00
logging *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
macosx Back to xfailing this. For some reason on our buildbots 2017-03-08 06:45:34 +00:00
make Android.rules: setup correct objcopy path 2017-04-12 10:13:47 +00:00
plugins *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
python_api Switch SBBreakpointLocation to use a weak_ptr 2017-03-01 10:08:48 +00:00
sample_test Make it clear what you should modify when you copy any of these sample 2017-03-01 22:23:30 +00:00
settings add stop column highlighting support 2016-09-21 20:13:14 +00:00
source-manager add stop column highlighting support 2016-09-21 20:13:14 +00:00
terminal *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
test_runner added Linux support for test timeout sampling 2016-09-26 20:25:47 +00:00
tools Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope 2017-04-04 08:00:28 +00:00
types *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
warnings/uuid *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
__init__.py
.categories
bench-history
bench.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
concurrent_base.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
configuration.py The darwin_log tests are very fragile and currently do not properly assess the state of that functionality. 2017-04-05 20:33:39 +00:00
crashinfo.c
darwin_log.py add availability check to DarwinLog event tests 2016-09-16 03:07:14 +00:00
decorators.py skip android in @skipIfHostIncompatibleWithRemote 2016-11-28 12:15:19 +00:00
dosep.py dotest.py: remove the ability to specify different architectures/compilers in a single invocation 2017-03-15 08:51:59 +00:00
dotest_args.py dotest.py: remove the ability to specify different architectures/compilers in a single invocation 2017-03-15 08:51:59 +00:00
dotest.py Centralize libc++ test skipping logic 2017-03-29 21:01:14 +00:00
lldb_pylint_helper.py
lldbbench.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lldbcurses.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lldbdwarf.py [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS 2017-01-10 09:33:43 +00:00
lldbinline.py dotest.py: remove the ability to specify different architectures/compilers in a single invocation 2017-03-15 08:51:59 +00:00
lldbpexpect.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lldbplatform.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lldbplatformutil.py Centralize libc++ test skipping logic 2017-03-29 21:01:14 +00:00
lldbtest_config.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lldbtest.py Fix remote test suite directory creation 2017-03-20 16:07:17 +00:00
lldbutil.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
lock.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
Makefile
README-TestSuite Add a sample_test directory with simple starter 2017-03-01 20:25:48 +00:00
redo.py *** This commit represents a complete reformatting of the LLDB source code 2016-09-06 20:57:50 +00:00
test_categories.py The darwin_log tests are very fragile and currently do not properly assess the state of that functionality. 2017-04-05 20:33:39 +00:00
test_result.py Improvements to testing blacklist 2016-10-04 18:48:00 +00:00