Skip to content
  1. Apr 11, 2013
    • Sean Callanan's avatar
      Added a Materializer class that contains · 96d2730a
      Sean Callanan authored
      information about each variable that needs to
      be materialized for an expression to work.  The
      next step is to migrate all materialization code
      from ClangExpressionDeclMap to Materializer, and
      to use it for variable materialization.
      
      llvm-svn: 179245
      96d2730a
  2. Apr 05, 2013
    • Sean Callanan's avatar
      Factored out memory access into the target process · 5a1af4e6
      Sean Callanan authored
      from IRExecutionUnit into a superclass called
      IRMemoryMap.  IRMemoryMap handles all reading and
      writing, ensuring that areas are kept track of and
      memory is properly cached (and deleted).
      
      Also fixed several cases where we would simply leak
      binary data in the target process over time.  Now
      the expression objects explicitly own their
      IRExecutionUnit and delete it when they go away.  This
      is why I had to modify ClangUserExpression,
      ClangUtilityFunction, and ClangFunction.
      
      As a side effect of this, I am removing the JIT
      mutex for an IRMemoryMap.  If it turns out that we
      need this mutex, I'll add it in then, but right now
      it's just adding complexity.
      
      This is part of a more general project to make
      expressions fully reusable.  The next step is to
      make materialization and dematerialization use
      the IRMemoryMap API rather than writing and
      reading directly from the process's memory. 
      This will allow the IR interpreter to use the
      same data, but in the host's memory, without having
      to use a different set of pointers.
      
      llvm-svn: 178832
      5a1af4e6
  3. Mar 28, 2013
    • Greg Clayton's avatar
      <rdar://problem/13521159> · 5160ce5c
      Greg Clayton authored
      LLDB is crashing when logging is enabled from lldb-perf-clang. This has to do with the global destructor chain as the process and its threads are being torn down.
      
      All logging channels now make one and only one instance that is kept in a global pointer which is never freed. This guarantees that logging can correctly continue as the process tears itself down.
      
      llvm-svn: 178191
      5160ce5c
  4. Mar 19, 2013
    • Sean Callanan's avatar
      Refactored the expression parser so that the IR · 8dfb68e0
      Sean Callanan authored
      and the JITted code are managed by a standalone
      class that handles memory management itself.
      
      I have removed RecordingMemoryManager and
      ProcessDataAllocator, which filled similar roles
      and had confusing ownership, with a common class
      called IRExecutionUnit.  The IRExecutionUnit
      manages all allocations ever made for an expression
      and frees them when it goes away.  It also contains
      the code generator and can vend the Module for an
      expression to other clases.
      
      The end goal here is to make the output of the
      expression parser re-usable; that is, to avoid
      re-parsing when re-parsing isn't necessary.
      
      I've also cleaned up some code and used weak pointers
      in more places.  Please let me know if you see any
      leaks; I checked myself as well but I might have
      missed a case.
      
      llvm-svn: 177364
      8dfb68e0
  5. Feb 14, 2013
  6. Feb 13, 2013
    • Greg Clayton's avatar
      <rdar://problem/13210494> · a66c4d96
      Greg Clayton authored
      Parse objective C information as efficiently as possible and without taking dangerous runtime locks.
      
      Reworked the way objective C information is parsed by:
      1 - don't read all class names up front, this is about 500K of data with names
      2 - add a 32 bit hash map that maps a hash of a name to the Class pointer (isa)
      3 - Improved name lookups by using the new hash map
      4 - split up reading the objc runtime info into dynamic and shared cache since the shared cache only needs to be read once.
      5 - When reading all isa values, also get the 32 bit hash instead of the name
      6 - Read names lazily now that we don't need all names up front
      7 - Allow the hash maps to not be there and still have this function correctly
      
      There is dead code in here with all of the various methods I tried. I want to check this in first to not lose any of it in case we need to revert to any of the extra code. I will promptly cleanup and commit again.
      
      llvm-svn: 175101
      a66c4d96
  7. Nov 29, 2012
  8. Sep 18, 2012
  9. Jan 29, 2012
    • Greg Clayton's avatar
      Switching back to using std::tr1::shared_ptr. We originally switched away · e1cd1be6
      Greg Clayton authored
      due to RTTI worries since llvm and clang don't use RTTI, but I was able to 
      switch back with no issues as far as I can tell. Once the RTTI issue wasn't
      an issue, we were looking for a way to properly track weak pointers to objects
      to solve some of the threading issues we have been running into which naturally
      led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared 
      pointer from just a pointer, which is also easily solved using the 
      std::tr1::enable_shared_from_this class. 
      
      The main reason for this move back is so we can start properly having weak
      references to objects. Currently a lldb_private::Thread class has a refrence
      to its parent lldb_private::Process. This doesn't work well when we now hand
      out a SBThread object that contains a shared pointer to a lldb_private::Thread
      as this SBThread can be held onto by external clients and if they end up
      using one of these objects we can easily crash.
      
      So the next task is to start adopting std::tr1::weak_ptr where ever it makes
      sense which we can do with lldb_private::Debugger, lldb_private::Target,
      lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and
      many more objects now that they are no longer using intrusive ref counted
      pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive
      pointers).
      
      llvm-svn: 149207
      e1cd1be6
  10. Oct 29, 2011
    • 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
  11. Sep 22, 2011
    • Greg Clayton's avatar
      Converted the lldb_private::Process over to use the intrusive · c14ee32d
      Greg Clayton authored
      shared pointers.
      
      Changed the ExecutionContext over to use shared pointers for
      the target, process, thread and frame since these objects can
      easily go away at any time and any object that was holding onto
      an ExecutionContext was running the risk of using a bad object.
      
      Now that the shared pointers for target, process, thread and
      frame are just a single pointer (they all use the instrusive
      shared pointers) the execution context is much safer and still
      the same size. 
      
      Made the shared pointers in the the ExecutionContext class protected
      and made accessors for all of the various ways to get at the pointers,
      references, and shared pointers.
      
      llvm-svn: 140298
      c14ee32d
  12. Sep 20, 2011
  13. Sep 15, 2011
    • Sean Callanan's avatar
      This patch modifies the expression parser to allow it · 3bfdaa2a
      Sean Callanan authored
      to execute expressions even in the absence of a process.
      This allows expressions to run in situations where the
      target cannot run -- e.g., to perform calculations based
      on type information, or to inspect a binary's static
      data.
      
      This modification touches the following files:
      
      lldb-private-enumerations.h
        Introduce a new enum specifying the policy for
        processing an expression.  Some expressions should
        always be JITted, for example if they are functions
        that will be used over and over again.  Some
        expressions should always be interpreted, for
        example if the target is unsafe to run.  For most,
        it is acceptable to JIT them, but interpretation
        is preferable when possible.
      
      Target.[h,cpp]
        Have EvaluateExpression now accept the new enum.
      
      ClangExpressionDeclMap.[cpp,h]
        Add support for the IR interpreter and also make
        the ClangExpressionDeclMap more robust in the 
        absence of a process.
      
      ClangFunction.[cpp,h]
        Add support for the new enum.
      
      IRInterpreter.[cpp,h]
        New implementation.
      
      ClangUserExpression.[cpp,h]
        Add support for the new enum, and for running 
        expressions in the absence of a process.
      
      ClangExpression.h
        Remove references to the old DWARF-based method
        of evaluating expressions, because it has been
        superseded for now.
      
      ClangUtilityFunction.[cpp,h]
        Add support for the new enum.
      
      ClangExpressionParser.[cpp,h]
        Add support for the new enum, remove references
        to DWARF, and add support for checking whether
        the expression could be evaluated statically.
      
      IRForTarget.[h,cpp]
        Add support for the new enum, and add utility
        functions to support the interpreter.
      
      IRToDWARF.cpp
        Removed
      
      CommandObjectExpression.cpp
        Remove references to the obsolete -i option.
      
      Process.cpp 
        Modify calls to ClangUserExpression::Evaluate
        to pass the correct enum (for dlopen/dlclose)
      
      SBValue.cpp
        Add support for the new enum.
      
      SBFrame.cpp
        Add support for he new enum.
      
      BreakpointOptions.cpp
        Add support for the new enum.
      
      llvm-svn: 139772
      3bfdaa2a
  14. Aug 01, 2011
  15. May 23, 2011
    • Sean Callanan's avatar
      This commit integrates support for the LLVM MCJIT · 79763a42
      Sean Callanan authored
      into the mainline LLDB codebase.  MCJIT introduces
      API improvements and better architectural support.
      
      This commit adds a new subsystem, the
      ProcessDataAllocator, which is responsible for
      performing static data allocations on behalf of the
      IR transformer.  MCJIT currently does not support
      the relocations required to store the constant pool
      in the same allocation as the function body, so we
      allocate a heap region separately and redirect
      static data references from the expression to that
      heap region in a new IR modification pass.
      
      This patch also fixes bugs in the IR
      transformations that were exposed by the transition
      to the MCJIT.  Finally, the patch also pulls in a
      more recent revision of LLVM so that the MCJIT is
      available for use.
      
      llvm-svn: 131923
      79763a42
  16. May 17, 2011
  17. May 07, 2011
  18. Feb 15, 2011
  19. Jan 20, 2011
  20. Jan 18, 2011
    • Greg Clayton's avatar
      Thread safety changes in debugserver and also in the process GDB remote plugin. · c4e411ff
      Greg Clayton authored
      I added support for asking if the GDB remote server supports thread suffixes
      for packets that should be thread specific (register read/write packets) because
      the way the GDB remote protocol does it right now is to have a notion of a
      current thread for register and memory reads/writes (set via the "$Hg%x" packet)
      and a current thread for running ("$Hc%x"). Now we ask the remote GDB server
      if it supports adding the thread ID to the register packets and we enable
      that feature in LLDB if supported. This stops us from having to send a bunch
      of packets that update the current thread ID to some value which is prone to
      error, or extra packets.
      
      llvm-svn: 123762
      c4e411ff
    • Sean Callanan's avatar
      Added support for the fragile ivars provided by · c3a16006
      Sean Callanan authored
      Apple's Objective-C 2.0 runtime.  They are enabled
      if the Objective-C runtime has the proper version.
      
      llvm-svn: 123694
      c3a16006
  21. Jan 13, 2011
    • Sean Callanan's avatar
      Implemented a major overhaul of the way variables are handled · 92adcac9
      Sean Callanan authored
      by LLDB.  Instead of being materialized into the input structure
      passed to the expression, variables are left in place and pointers
      to them are materialzied into the structure.  Variables not resident
      in memory (notably, registers) get temporary memory regions allocated
      for them.
      
      Persistent variables are the most complex part of this, because they
      are made in various ways and there are different expectations about
      their lifetime.  Persistent variables now have flags indicating their
      status and what the expectations for longevity are.  They can be
      marked as residing in target memory permanently -- this is the
      default for result variables from expressions entered on the command
      line and for explicitly declared persistent variables (but more on
      that below).  Other result variables have their memory freed.
      
      Some major improvements resulting from this include being able to
      properly take the address of variables, better and cleaner support
      for functions that return references, and cleaner C++ support in
      general.  One problem that remains is the problem of explicitly
      declared persistent variables; I have not yet implemented the code
      that makes references to them into indirect references, so currently
      materialization and dematerialization of these variables is broken.
      
      llvm-svn: 123371
      92adcac9
  22. 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
  23. Sep 25, 2010
    • Greg Clayton's avatar
      Cleaned a few build related things up: · 5573fde3
      Greg Clayton authored
      Added a virtual destructor to ClangUtilityFunction with a body to it cleans
      itself up.
      
      Moved our SharingPtr into the lldb_private namespace to keep it easy to make
      an exports file that exports only what is needed ("lldb::*").
      
      llvm-svn: 114771
      5573fde3
  24. Sep 13, 2010
    • Sean Callanan's avatar
      Bugfixes to the expression parser. Fixes include: · 9e6ed53e
      Sean Callanan authored
       - If you put a semicolon at the end of an expression,
         this no longer causes the expression parser to
         error out.  This was a two-part fix: first,
         ClangExpressionDeclMap::Materialize now handles
         an empty struct (such as when there is no return
         value); second, ASTResultSynthesizer walks backward
         from the end of the ASTs until it reaches something
         that's not a NullStmt.
      
       - ClangExpressionVariable now properly byte-swaps when
         printing itself.
      
       - ClangUtilityFunction now cleans up after itself when
         it's done compiling itself.
      
       - Utility functions can now use external functions just
         like user expressions.
      
       - If you end your expression with a statement that does
         not return a value, the expression now runs correctly
         anyway.
      
      Also, added the beginnings of an Objective-C object
      validator function, which is neither installed nor used
      as yet.
      
      llvm-svn: 113789
      9e6ed53e
  25. Sep 01, 2010
    • Sean Callanan's avatar
      Added support for dynamic sanity checking in · 6961e878
      Sean Callanan authored
      expressions.  Values used by the expression are
      checked by validation functions which cause the
      program to crash if the values are unsafe.
      
      Major changes:
      
      - Added IRDynamicChecks.[ch], which contains the
        core code related to this feature
      
      - Modified CommandObjectExpression to install the
        validator functions into the target process.
      
      - Added an accessor to Process that gets/sets the
        helper functions
      
      llvm-svn: 112690
      6961e878
  26. Aug 28, 2010
    • Sean Callanan's avatar
      Added a ClangUtilityFunction class that allows the · e71d553c
      Sean Callanan authored
      debugger to insert self-contained functions for use by
      expressions (mainly for error-checking).
      
      In order to support detecting whether a crash occurred
      in one of these helpers -- currently our preferred way
      of reporting that an error-check failed -- added a bit
      of support for getting the extent of a JITted function
      in addition to just its base.
      
      llvm-svn: 112324
      e71d553c
Loading