Skip to content
  1. 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
  2. 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
  3. 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
  4. Mar 06, 2013
  5. Jan 25, 2013
    • Greg Clayton's avatar
      <rdar://problem/13069948> · c7bece56
      Greg Clayton authored
      Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary.
      
      So I defined a new "lldb::offset_t" which should be used for all file offsets.
      
      After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed.
      
      Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections.
      
      llvm-svn: 173463
      c7bece56
  6. Jan 15, 2013
    • Jim Ingham's avatar
      Separated the "expr --unwind-on-error" behavior into two parts, actual errors... · 184e9811
      Jim Ingham authored
      Separated the "expr --unwind-on-error" behavior into two parts, actual errors (i.e. crashes) which continue to be
      controlled by the --unwind-on-error flag, and --ignore-breakpoint which separately controls behavior when a called
      function hits a breakpoint.  For breakpoints, we don't unwind, we either stop, or ignore the breakpoint, which makes
      more sense.  
      Also make both these behaviors globally settable through "settings set".
      Also handle the case where a breakpoint command calls code that ends up re-hitting the breakpoint.  We were recursing
      and crashing.  Now we just stop without calling the second command.
      
      <rdar://problem/12986644>
      <rdar://problem/9119325>
      
      llvm-svn: 172503
      184e9811
  7. Jan 14, 2013
  8. Jan 02, 2013
  9. Dec 07, 2012
  10. Nov 29, 2012
  11. Oct 16, 2012
  12. Sep 18, 2012
  13. Sep 11, 2012
  14. Aug 09, 2012
  15. Aug 04, 2012
  16. May 11, 2012
  17. Mar 27, 2012
    • Greg Clayton's avatar
      <rdar://problem/11113279> · 84db9105
      Greg Clayton authored
      Fixed type lookups to "do the right thing". Prior to this fix, looking up a type using "foo::bar" would result in a type list that contains all types that had "bar" as a basename unless the symbol file was able to match fully qualified names (which our DWARF parser does not). 
      
      This fix will allow type matches to be made based on the basename and then have the types that don't match filtered out. Types by name can be fully qualified, or partially qualified with the new "bool exact_match" parameter to the Module::FindTypes() method.
      
      This fixes some issue that we discovered with dynamic type resolution as well as improves the overall type lookups in LLDB.
      
      llvm-svn: 153482
      84db9105
  18. Feb 24, 2012
    • Greg Clayton's avatar
      <rdar://problem/10103468> · e72dfb32
      Greg Clayton authored
      I started work on being able to add symbol files after a debug session
      had started with a new "target symfile add" command and quickly ran into
      problems with stale Address objects in breakpoint locations that had 
      lldb_private::Section pointers into modules that had been removed or 
      replaced. This also let to grabbing stale modules from those sections. 
      So I needed to thread harded the Address, Section and related objects.
      
      To do this I modified the ModuleChild class to now require a ModuleSP
      on initialization so that a weak reference can created. I also changed
      all places that were handing out "Section *" to have them hand out SectionSP.
      All ObjectFile, SymbolFile and SymbolVendors were inheriting from ModuleChild
      so all of the find plug-in, static creation function and constructors now
      require ModuleSP references instead of Module *. 
      
      Address objects now have weak references to their sections which can
      safely go stale when a module gets destructed. 
      
      This checkin doesn't complete the "target symfile add" command, but it
      does get us a lot clioser to being able to do such things without a high
      risk of crashing or memory corruption.
      
      llvm-svn: 151336
      e72dfb32
  19. Feb 18, 2012
    • Greg Clayton's avatar
      The second part in thread hardening the internals of LLDB where we make · d9e416c0
      Greg Clayton authored
      the lldb_private::StackFrame objects hold onto a weak pointer to the thread
      object. The lldb_private::StackFrame objects the the most volatile objects
      we have as when we are doing single stepping, frames can often get lost or
      thrown away, only to be re-created as another object that still refers to the
      same frame. We have another bug tracking that. But we need to be able to 
      have frames no longer be able to get the thread when they are not part of
      a thread anymore, and this is the first step (this fix makes that possible
      but doesn't implement it yet).
      
      Also changed lldb_private::ExecutionContextScope to return shared pointers to
      all objects in the execution context to further thread harden the internals.
      
      llvm-svn: 150871
      d9e416c0
  20. 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
  21. Dec 22, 2011
  22. Dec 17, 2011
  23. 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
  24. Sep 20, 2011
  25. 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
  26. Aug 12, 2011
    • Greg Clayton's avatar
      We were leaking a stack frame in StackFrameList in Thread.cpp which could · 7e9b1fd0
      Greg Clayton authored
      cause extra shared pointer references to one or more modules to be leaked.
      This would cause many object files to stay around the life of LLDB, so after
      a recompile and rexecution, we would keep adding more and more memory. After
      fixing the leak, we found many cases where leaked stack frames were still
      being used and causing crashes in the test suite. These are now all resolved.
      
      llvm-svn: 137516
      7e9b1fd0
  27. Jun 30, 2011
  28. 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
    • Greg Clayton's avatar
      Added new lldb_private::Process memory read/write functions to stop a bunch · f3ef3d2a
      Greg Clayton authored
      of duplicated code from appearing all over LLDB:
      
      lldb::addr_t
      Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
      
      bool
      Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
      
      size_t
      Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
      
      size_t
      Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
      
      in lldb_private::Process the following functions were renamed:
      
      From:
      uint64_t
      Process::ReadUnsignedInteger (lldb::addr_t load_addr, 
                                    size_t byte_size,
                                    Error &error);
      
      To:
      uint64_t
      Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr, 
                                              size_t byte_size,
                                              uint64_t fail_value, 
                                              Error &error);
      
      Cleaned up a lot of code that was manually doing what the above functions do
      to use the functions listed above.
      
      Added the ability to get a scalar value as a buffer that can be written down
      to a process (byte swapping the Scalar value if needed):
      
      uint32_t 
      Scalar::GetAsMemoryData (void *dst,
                              uint32_t dst_len, 
                              lldb::ByteOrder dst_byte_order,
                              Error &error) const;
      
      The "dst_len" can be smaller that the size of the scalar and the least 
      significant bytes will be written. "dst_len" can also be larger and the
      most significant bytes will be padded with zeroes. 
      
      Centralized the code that adds or removes address bits for callable and opcode
      addresses into lldb_private::Target:
      
      lldb::addr_t
      Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
      
      lldb::addr_t
      Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
      
      All necessary lldb_private::Address functions now use the target versions so
      changes should only need to happen in one place if anything needs updating.
      
      Fixed up a lot of places that were calling :
      
      addr_t
      Address::GetLoadAddress(Target*);
      
      to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
      as needed. There were many places in the breakpoint code where things could
      go wrong for ARM if these weren't used.
      
      llvm-svn: 131878
      f3ef3d2a
  29. May 07, 2011
  30. Mar 24, 2011
  31. Mar 17, 2011
  32. Feb 17, 2011
  33. Feb 15, 2011
  34. Jan 20, 2011
  35. Jan 18, 2011
  36. Dec 14, 2010
    • Greg Clayton's avatar
      Modified LLDB expressions to not have to JIT and run code just to see variable · 8b2fe6dc
      Greg Clayton authored
      values or persistent expression variables. Now if an expression consists of
      a value that is a child of a variable, or of a persistent variable only, we
      will create a value object for it and make a ValueObjectConstResult from it to
      freeze the value (for program variables only, not persistent variables) and
      avoid running JITed code. For everything else we still parse up and JIT code
      and run it in the inferior. 
      
      There was also a lot of clean up in the expression code. I made the 
      ClangExpressionVariables be stored in collections of shared pointers instead
      of in collections of objects. This will help stop a lot of copy constructors on
      these large objects and also cleans up the code considerably. The persistent
      clang expression variables were moved over to the Target to ensure they persist
      across process executions.
      
      Added the ability for lldb_private::Target objects to evaluate expressions.
      We want to evaluate expressions at the target level in case we aren't running
      yet, or we have just completed running. We still want to be able to access the
      persistent expression variables between runs, and also evaluate constant 
      expressions. 
      
      Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects
      can now dump their contents with the UUID, arch and full paths being logged with
      appropriate prefix values.
      
      Thread hardened the Communication class a bit by making the connection auto_ptr
      member into a shared pointer member and then making a local copy of the shared
      pointer in each method that uses it to make sure another thread can't nuke the
      connection object while it is being used by another thread.
      
      Added a new file to the lldb/test/load_unload test that causes the test a.out file
      to link to the libd.dylib file all the time. This will allow us to test using
      the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else.
      
      llvm-svn: 121745
      8b2fe6dc
  37. 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
Loading