Skip to content
  1. Nov 29, 2011
  2. Nov 18, 2011
    • Sean Callanan's avatar
      This commit completes the rearchitecting of ClangASTSource · 00f43622
      Sean Callanan authored
      to allow variables in the persistent variable store to know
      how to complete themselves from debug information.  That
      fixes a variety of bugs during dematerialization of 
      expression results and also makes persistent variable and
      result variables ($foo, $4, ...) more useful.
      
      I have also added logging improvements that make it much
      easier to figure out how types are moving from place to 
      place, and made some checking a little more aggressive.
      
      The commit includes patches to Clang which are currently being
      integrated into Clang proper; once these fixes are in Clang
      top-of-tree, these patches will be removed.  The patches don't
      fix API; rather, they fix some internal bugs in Clang's 
      ASTImporter that were exposed when LLDB was moving types from
      place to place multiple times.
      
      llvm-svn: 144969
      00f43622
  3. Nov 16, 2011
    • Sean Callanan's avatar
      I made the ClangASTImporter owned by the target · 686b2319
      Sean Callanan authored
      rather than individually on behalf of each
      ASTContext.  This allows the ASTImporter to know
      about all containers of types, which will let it
      be smarter about forwarding information about
      type origins.  That means that the following
      sequence of steps will be possible (after a few
      more changes):
      
      - Import a type from a Module's ASTContext into
        an expression parser ASTContext, tracking its
        origin information -- this works now.
      
      - Because the result of the expression uses that
        type, import it from the expression parser
        ASTContext into the Target's scratch AST
        context, forwarding the origin information --
        this needs to be added.
      
      - For a later expression that uses the result,
        import the type from the Target's scratch AST
        context, still forwarding origin information
        -- this also needs to be added.
      
      - Use the intact origin information to complete
        the type as needed -- this works now if the
        origin information is present.
      
      To this end, I made the following changes:
      
      - ASTImporter top-level copy functions now
        require both a source and a destination AST
        context parameter.
      
      - The ASTImporter now knows how to purge
        records related to an ASTContext that is
        going away.
      
      - The Target now owns and creates the ASTImporter
        whenever the main executable changes or (in the
        absence of a main executable) on demand.
      
      llvm-svn: 144802
      686b2319
  4. Nov 15, 2011
    • Sean Callanan's avatar
      Eliminated a compile warning by removing dyn_cast · 100d74e2
      Sean Callanan authored
      where isa is good enough.
      
      llvm-svn: 144704
      100d74e2
    • Sean Callanan's avatar
      Pulled in a new version of LLVM/Clang to solve a variety · d5c17edb
      Sean Callanan authored
      of problems with Objective-C object completion.  To go
      along with the LLVM/Clang-side fixes, we have a variety
      of Objective-C improvements.
      
      Fixes include:
      
      - It is now possible to run expressions when stopped in
        an Objective-C class method and have "self" act just
        like "self" would act in the class method itself (i.e.,
        [self classMethod] works without casting the return
        type if debug info is present).  To accomplish this,
        the expression masquerades as a class method added by
        a category.
      
      - Objective-C objects can now provide methods and
        properties and methods to Clang on demand (i.e., the
        ASTImporter sets hasExternalVisibleDecls on Objective-C
        interface objects).
      
      - Objective-C built-in types, which had long been a bone
        of contention (should we be using "id"?  "id*"?), are
        now fetched correctly using accessor functions on
        ClangASTContext.  We inhibit searches for them in the
        debug information.
      
      There are also a variety of logging fixes, and I made two
      changes to the test suite:
      
      - Enabled a test case for Objective-C properties in the
        current translation unit.
      
      - Added a test case for calling Objective-C class methods
        when stopped in a class method.
      
      llvm-svn: 144607
      d5c17edb
  5. Nov 14, 2011
  6. Nov 11, 2011
  7. Nov 09, 2011
    • Sean Callanan's avatar
      Added a function to ClangASTSource to service · 0730e9c9
      Sean Callanan authored
      lookups for Objective-C methods by selector.
      Right now all it does is print log information.
      
      Also improved the logging for imported TagDecls
      to indicate whether or not the definition for
      the imported TagDecl is complete.
      
      llvm-svn: 144203
      0730e9c9
  8. Oct 29, 2011
    • Sean Callanan's avatar
      Cloned FindExternalVisibleDecls from · fb3e4306
      Sean Callanan authored
      ClangExpressionDeclMap to ClangASTSource, and
      moved all general type and namespace lookups
      into ClangASTSource.  Now ClangASTSource is ready
      to complete types given nothing more than a target
      and an AST context.
      
      llvm-svn: 143292
      fb3e4306
    • Sean Callanan's avatar
      Moved FindExternalLexicalDecls and a few smaller · ba0aca72
      Sean Callanan authored
      functions from ClangExpressionDeclMap to ClangASTSource.
      
      llvm-svn: 143276
      ba0aca72
    • Sean Callanan's avatar
      I moved the responsibility for interacting with the · 1ee44b74
      Sean Callanan authored
      AST importer on completing namespace mappings from
      ClangExpressionDeclMap to ClangASTSource.
      
      ClangASTSource now contains a TargetSP which it
      uses to lookup namespaces in all of a target's
      modules.  I will use the TargetSP in the future to
      look up globals.
      
      llvm-svn: 143275
      1ee44b74
    • Sean Callanan's avatar
      As part of a general refactoring of ClangASTSource to · eddeb3b9
      Sean Callanan authored
      allow it to complete types on behalf of any AST context
      (including the "scratch" AST context associated with
      the target), I scrapped its role as intermediary between
      the Clang parser and ClangExpressionDeclMap, and instead
      made ClangExpressionDeclMap inherit from ClangASTSource.
      
      After this, I will migrate the functions that complete
      types and perform namespace lookups from
      ClangExpressionDeclMap to ClangASTSource.  Ultimately
      ClangExpressionDeclMap's only responsiblity will be to
      look up variables and ensure that they are materialized
      and dematerialized correctly.
      
      llvm-svn: 143253
      eddeb3b9
  9. Oct 12, 2011
    • Sean Callanan's avatar
      Implemented a namespace map that allows searching · 503aa525
      Sean Callanan authored
      of namespaces (only in the modules where they've
      been found) for entities inside those namespaces.
      
      For each NamespaceDecl that has been imported into
      the parser, we maintain a map containing
      [ModuleSP, ClangNamespaceDecl] pairs in the ASTImporter.
      This map has one entry for each module in which the
      namespace has been found.  When we later scan for an
      entity inside a namespace, we search only the modules
      in which that namespace was found.
      
      Also made a small whitespace fix in 
      ClangExpressionParser.cpp.
      
      llvm-svn: 141748
      503aa525
  10. Oct 08, 2011
  11. Sep 17, 2011
    • Greg Clayton's avatar
      Convert lldb::ModuleSP to use an instrusive ref counted pointer. · 747bcb03
      Greg Clayton authored
      We had some cases where getting the shared pointer for a module from
      the global module list was causing a performance issue when debugging
      with DWARF in .o files. Now that the module uses intrusive ref counts,
      we can easily convert any pointer to a shared pointer.
      
      llvm-svn: 139983
      747bcb03
  12. Jul 30, 2011
    • Sean Callanan's avatar
      This change brings in the latest LLVM/Clang, and · cc427fad
      Sean Callanan authored
      completes the support in the LLDB expression parser
      for incomplete types.  Clang now imports types
      lazily, and we complete those types as necessary.
      
      Changes include:
      
      - ClangASTSource now supports three APIs which it
        passes to ClangExpressionDeclMap.  CompleteType
        completes a TagDecl or an ObjCInterfaceDecl when
        needed; FindExternalVisibleDecls finds named
        entities that are visible in the expression's
        scope; and FindExternalLexicalDecls performs a
        (potentially restricted) search for entities
        inside a lexical scope like a namespace.  These
        changes mean that entities in namespaces should
        work normally.
      
      - The SymbolFileDWARF code for searching a context
        for a specific name is now more general, and can
        search arbitrary contexts.
      
      - We are continuing to adapt our calls into LLVM
        from interfaces that take start and end iterators
        when accepting multiple items to interfaces that
        use ArrayRef.
      
      - I have cleaned up some code, especially our use
        of namespaces.
      
      This change is neutral for our testsuite and greatly
      improves correctness for large programs (like Clang)
      with complicated type systems.  It should also lay
      the groundwork for improving the expression parser's
      performance as we are lazier and lazier about
      providing type information.
      
      llvm-svn: 136555
      cc427fad
  13. Jun 25, 2011
    • Greg Clayton's avatar
      This commit adds broad architectural support for hierarchical · a2721476
      Greg Clayton authored
      inspection of namespaces in the expression parser.
      
      ClangExpressionDeclMap hitherto reported that namespaces had
      been completely imported, even though the namespaces are
      returned empty.  To deal with this situation, ClangASTSource
      was recently extended with an API to complete incomplete type
      definitions, and, for greater efficiency, to complete these
      definitions partially, returning only those objects that have
      a given name.
      
      This commit supports these APIs on LLDB's side, and uses it
      to provide information on types resident in namespaces.
      Namespaces are now imported as they were -- that is to say,
      empty -- but with minimal import mode on.  This means that
      Clang will come back and request their contents by name as
      needed.  We now respond with information on the contained
      types; this will be followed soon by information on functions
      and variables.
      
      llvm-svn: 133852
      a2721476
  14. May 13, 2011
    • Sean Callanan's avatar
      Introduced support for UnknownAnyTy, the Clang type · 77502265
      Sean Callanan authored
      representing variables whose type must be inferred
      from the way they are used.  Functions without debug
      information now return UnknownAnyTy and must be cast.
      
      Variables with no debug information are not yet using
      UnknownAnyTy; instead they are assumed to be void*.
      Support for variables of unknown type is coming (and,
      in fact, some relevant support functions are included
      in this commit) but will take a bit of extra effort.
      
      The testsuite has also been updated to reflect the new
      requirement that the result of printf be cast, i.e.
      
      expr (int) printf("Hello world!")
      
      llvm-svn: 131263
      77502265
  15. Mar 15, 2011
  16. Jan 27, 2011
  17. Jan 23, 2011
  18. Jan 19, 2011
  19. Jan 17, 2011
    • Greg Clayton's avatar
      A few of the issue I have been trying to track down and fix have been due to · 6beaaa68
      Greg Clayton authored
      the way LLDB lazily gets complete definitions for types within the debug info.
      When we run across a class/struct/union definition in the DWARF, we will only
      parse the full definition if we need to. This works fine for top level types
      that are assigned directly to variables and arguments, but when we have a 
      variable with a class, lets say "A" for this example, that has a member:
      "B *m_b". Initially we don't need to hunt down a definition for this class
      unless we are ever asked to do something with it ("expr m_b->getDecl()" for
      example). With my previous approach to lazy type completion, we would be able
      to take a "A *a" and get a complete type for it, but we wouldn't be able to
      then do an "a->m_b->getDecl()" unless we always expanded all types within a
      class prior to handing out the type. Expanding everything is very costly and
      it would be great if there were a better way.
      
      A few months ago I worked with the llvm/clang folks to have the 
      ExternalASTSource class be able to complete classes if there weren't completed
      yet:
      
      class ExternalASTSource {
      ....
      
          virtual void
          CompleteType (clang::TagDecl *Tag);
          
          virtual void 
          CompleteType (clang::ObjCInterfaceDecl *Class);
      };
      
      This was great, because we can now have the class that is producing the AST
      (SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
      and the object that creates the forward declaration types can now also
      complete them anywhere within the clang type system.
      
      This patch makes a few major changes:
      - lldb_private::Module classes now own the AST context. Previously the TypeList
        objects did.
      - The DWARF parsers now sign up as an external AST sources so they can complete
        types.
      - All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
        ClangASTType, and more) can now be iterating through children of any type,
        and if a class/union/struct type (clang::RecordType or ObjC interface) 
        is found that is incomplete, we can ask the AST to get the definition. 
      - The SymbolFileDWARFDebugMap class now will create and use a single AST that
        all child SymbolFileDWARF classes will share (much like what happens when
        we have a complete linked DWARF for an executable).
        
      We will need to modify some of the ClangUserExpression code to take more 
      advantage of this completion ability in the near future. Meanwhile we should
      be better off now that we can be accessing any children of variables through
      pointers and always be able to resolve the clang type if needed.
      
      llvm-svn: 123613
      6beaaa68
  20. Dec 13, 2010
    • Sean Callanan's avatar
      Added support for generating expressions that have · 17827830
      Sean Callanan authored
      access to the members of the Objective-C self object.
      
      The approach we take is to generate the method as a
      @category on top of the self object, and to pass the
      "self" pointer to it.  (_cmd is currently NULL.)
      
      Most changes are in ClangExpressionDeclMap, but the
      change that adds support to the ABIs to pass _cmd
      touches a fair amount of code.
      
      llvm-svn: 121722
      17827830
  21. Dec 03, 2010
    • Sean Callanan's avatar
      Fixed object lifetimes in ClangExpressionDeclMap · 979f74d1
      Sean Callanan authored
      so that it is not referring to potentially stale
      state during IR execution.
      
      This was done by introducing modular state (like
      ClangExpressionVariable) where groups of state
      variables have well-defined lifetimes:
      
      - m_parser_vars are specific to parsing, and only
        exist between calls to WillParse() and DidParse().
      
      - m_struct_vars survive for the entire execution
        of the ClangExpressionDeclMap because they
        provide the template for a materialized set of
        expression variables.
      
      - m_material_vars are specific to a single
        instance of materialization, and only exist
        between calls to Materialize() and
        Dematerialize().
      
      I also removed unnecessary references to long-
      lived state that really didn't need to be referred
      to at all, and also introduced several assert()s
      that helped me diagnose a few bugs (fixed too).
      
      llvm-svn: 120778
      979f74d1
  22. Nov 30, 2010
  23. Nov 18, 2010
  24. Nov 15, 2010
  25. Nov 13, 2010
    • Greg Clayton's avatar
      Got namespace lookup working and was able to print a complex "this" as an · 580c5dac
      Greg Clayton authored
      expression. This currently takes waaaayyyyy too much time to evaluate. We will
      need to look at the expression parser and find ways to optimize the info we
      provide and get this to evaluate quicker. I believe the performance issue is
      currently related to us always providing a complete C++ class type when asked
      about a C++ class which can cause a lot of information to be pulled since all
      classes will be fully created (methods, base classes, members, all their 
      types). We will need to give the classes back the parser and mark them as 
      having external sources and get parser (Sema) to query us when it needs more
      info. This should bring things up to an acceptable level.
      
      llvm-svn: 118979
      580c5dac
  26. Oct 29, 2010
  27. Oct 16, 2010
    • Greg Clayton's avatar
      Made many ConstString functions inlined in the header file. · 7b462cc1
      Greg Clayton authored
      Changed all of our synthesized "___clang" functions, types and variables
      that get used in expressions over to have a prefix of "$_lldb". Now when we
      do name lookups we can easily switch off of the first '$' character to know
      if we should look through only our internal (when first char is '$') stuff,
      or when we should look through program variables, functions and types.
      
      Converted all of the clang expression code over to using "const ConstString&" 
      values for names instead of "const char *" since there were many places that
      were converting the "const char *" names into ConstString names and them
      throwing them away. We now avoid making a lot of ConstString conversions and
      benefit from the quick comparisons in a few extra spots.
      
      Converted a lot of code from LLVM coding conventions into LLDB coding 
      conventions.
      
      llvm-svn: 116634
      7b462cc1
  28. Oct 15, 2010
  29. Oct 13, 2010
    • Greg Clayton's avatar
      Fixed C++ class clang type creation and display by making sure we omit · 24739923
      Greg Clayton authored
      artifical members (like the vtable pointer member that shows up in the DWARF).
      We were adding this to each class which was making all member variables be off
      by a pointer size.
      
      Added a test case so we can track this with "test/forward".
      
      Fixed the type name index in DWARF to include all the types after finding
      some types were being omitted due to the DW_AT_specification having the
      DW_AT_declaration attribute which was being read into the real type instances
      when there were forward declarations in the DWARF, causing the type to be
      omitted. We now check to make sure any DW_AT_declaration values are only
      respected when parsing types if the attribute is from the current DIE.
      
      After fixing the missing types, we ran into some issues with the expression
      parser finding duplicate entries for __va_list_tag since they are built in
      types and would result in a "duplicate __va_list_tag definition" error. We
      are now just ignoring this name during lookup, but we will need to see if
      we can get the name lookup function to not get called in these cases.
      
      Fixed an issue that would cause an assertion where DW_TAG_subroutine_types
      that had no children, would not properly make a clang function type of:
      "void (*) (void)".
      
      llvm-svn: 116392
      24739923
  30. Sep 23, 2010
  31. Sep 21, 2010
    • Sean Callanan's avatar
      Removed the hacky "#define this ___clang_this" handler · fc55f5d1
      Sean Callanan authored
      for C++ classes.  Replaced it with a less hacky approach:
      
       - If an expression is defined in the context of a
         method of class A, then that expression is wrapped as
         ___clang_class::___clang_expr(void*) { ... }
         instead of ___clang_expr(void*) { ... }.
      
       - ___clang_class is resolved as the type of the target
         of the "this" pointer in the method the expression
         is defined in.
      
       - When reporting the type of ___clang_class, a method
         with the signature ___clang_expr(void*) is added to
         that class, so that Clang doesn't complain about a
         method being defined without a corresponding
         declaration.
      
       - Whenever the expression gets called, "this" gets
         looked up, type-checked, and then passed in as the
         first argument.
      
      This required the following changes:
      
       - The ABIs were changed to support passing of the "this"
         pointer as part of trivial calls.
      
       - ThreadPlanCallFunction and ClangFunction were changed
         to support passing of an optional "this" pointer.
      
       - ClangUserExpression was extended to perform the
         wrapping described above.
      
       - ClangASTSource was changed to revert the changes
         required by the hack.
      
       - ClangExpressionParser, IRForTarget, and
         ClangExpressionDeclMap were changed to handle
         different manglings of ___clang_expr flexibly.  This
         meant no longer searching for a function called
         ___clang_expr, but rather looking for a function whose
         name *contains* ___clang_expr.
      
       - ClangExpressionParser and ClangExpressionDeclMap now
         remember whether "this" is required, and know how to
         look it up as necessary.
      
      A few inheritance bugs remain, and I'm trying to resolve
      these.  But it is now possible to use "this" as well as
      refer implicitly to member variables, when in the proper
      context.
      
      llvm-svn: 114384
      fc55f5d1
  32. Sep 14, 2010
    • Sean Callanan's avatar
      Added code to support use of "this" and "self" in · 44096b1a
      Sean Callanan authored
      expressions.  This involved three main changes:
      
       - In ClangUserExpression::ClangUserExpression(),
         we now insert the following lines into the
         expression:
           #define this ___clang_this
           #define self ___clang_self
      
       - In ClangExpressionDeclMap::GetDecls(), we
         special-case ___clang_(this|self) and instead
         look up "this" or "self"
      
       - In ClangASTSource, we introduce the capability
         to generate Decls with a different, overridden,
         name from the one that was requested, e.g.
         this for ___clang_this.
      
      llvm-svn: 113866
      44096b1a
  33. Aug 13, 2010
  34. Aug 04, 2010
    • Sean Callanan's avatar
      Added support for accessing members of C++ objects, · 5666b674
      Sean Callanan authored
      including superclass members.  This involved ensuring
      that access control was ignored, and ensuring that
      the operands of BitCasts were properly scanned for
      variables that needed importing.
      
      Also laid the groundwork for declaring objects of
      custom types; however, this functionality is disabled
      for now because of a potential loop in ASTImporter.
      
      llvm-svn: 110174
      5666b674
  35. Jul 27, 2010
    • Sean Callanan's avatar
      Changed SymbolContext so when you search for functions · 8ade104a
      Sean Callanan authored
      it returns a list of functions as a SymbolContextList.
      
      Rewrote the clients of SymbolContext to use this
      SymbolContextList.
      
      Rewrote some of the providers of the data to SymbolContext
      to make them respect preferences as to whether the list
      should be cleared first; propagated that change out.
      
      ClangExpressionDeclMap and ClangASTSource use this new
      function list to properly generate function definitions -
      even for functions that don't have a prototype in the
      debug information.
      
      llvm-svn: 109476
      8ade104a
  36. Jul 16, 2010
Loading