Skip to content
  1. Nov 08, 2011
    • Sean Callanan's avatar
      Added a language parameter to the expression parser, · c7b65067
      Sean Callanan authored
      which will in the future allow expressions to be
      compiled as C, C++, and Objective-C instead of the
      current default Objective-C++.  This feature requires
      some additional support from Clang -- specifically, it
      requires reference types in the parser regardless of
      language -- so it is not yet exposed to the user.
      
      llvm-svn: 144042
      c7b65067
  2. Nov 04, 2011
    • Sean Callanan's avatar
      Updated LLVM/Clang to pick up a fix for imports of · bfb237bc
      Sean Callanan authored
      C++ vtables, fixing a record layout problem in the
      expression parser.
      
      Also fixed various problems with the generation 
      and unpacking of llvm.zip given our new better
      handling of multiple architectures in the LLVM
      build.
      
      (And added a log message that will hopefully catch
      record layout problems in the future.)
      
      llvm-svn: 143741
      bfb237bc
  3. Nov 01, 2011
  4. Oct 29, 2011
    • 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
  5. Oct 22, 2011
  6. 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
  7. Oct 08, 2011
  8. 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
  9. Sep 21, 2011
  10. 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
  11. Aug 23, 2011
    • Sean Callanan's avatar
      Added support for persistent types to the · bccce813
      Sean Callanan authored
      expression parser.  You can use a persistent
      type like this:
      
      (lldb) expr struct $foo { int a; int b; };
      (lldb) struct $foo i; i.a = 2; i.b = 3; i
      ($foo) $0 = {
        (int) a = 2
        (int) b = 3
      }
      
      typedefs work similarly.
      
      This patch affects the following files:
      
      test/expression_command/persistent_types/*
        A test case for persistent types,
        in particular structs and typedefs.
      
      ClangForward.h
        Added TypeDecl, needed to declare some
        functions in ASTResultSynthesizer.h
      
      ClangPersistentVariables.[h,cpp]
        Added a list of persistent types to the
        persistent variable store.
      
      ASTResultSynthesizer.[h,cpp]
        Made the AST result synthesizer iterate
        across TypeDecls in the expression, and
        record any persistent types found.  Also
        made a minor documentation fix.
      
      ClangUserExpression.[h,cpp]
        Extended the user expression class to
        keep the state needed to report the
        persistent variable store for the target
        to the AST result synthesizers. 
      
        Also introduced a new error code for
        expressions that executed normally but
        did not return a result.
      
      CommandObjectExpression.cpp
        Improved output for expressions (like 
        declarations of new persistent types) that
        don't return a result.  This is no longer
        treated as an error.
      
      llvm-svn: 138383
      bccce813
  12. Jul 31, 2011
  13. 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
  14. Jul 19, 2011
    • Johnny Chen's avatar
      Patch by Matt Johnson to silence G++ warnings! · 4480530a
      Johnny Chen authored
      Used hand merge to apply the diffs.  I did not apply the diffs for FormatManager.h and
      the diffs for memberwise initialization for ValueObject.cpp because they changed since.
      I will ask my colleague to apply them later.
      
      llvm-svn: 135508
      4480530a
    • Enrico Granata's avatar
      The implementation of categories is now synchronization safe · 20edcdbe
      Enrico Granata authored
      Code cleanup:
       - The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the
         actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and
         FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...)
         are contained. The wrapper code always remains in Debugger.{h|cpp}
       - Several leftover fields, methods and comments from previous design choices have been removed
      type category subcommands (enable, disable, delete) now can take a list of category names as input
       - for type category enable, saying "enable A B C" is the same as saying
          enable C
          enable B
          enable A
         (the ordering is relevant in enabling categories, and it is expected that a user typing
          enable A B C wants to look into category A, then into B, then into C and not the other
          way round)
       - for the other two commands, the order is not really relevant (however, the same inverted ordering
         is used for consistency)
      
      llvm-svn: 135494
      20edcdbe
  15. Jun 03, 2011
  16. 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
  17. May 16, 2011
  18. May 15, 2011
    • Greg Clayton's avatar
      Added the ability to get the return value from a ThreadPlanCallFunction · 70b57657
      Greg Clayton authored
      thread plan. In order to get the return value, you can call:
      
              void
              ThreadPlanCallFunction::RequestReturnValue (lldb::ValueSP &return_value_sp);
              
      This registers a shared pointer to a return value that will get filled in if
      everything goes well. After the thread plan is run the return value will be
      extracted for you.
      
      Added an ifdef to be able to switch between the LLVM MCJIT and the standand JIT.
      We currently have the standard JIT selected because we have some work to do to
      get the MCJIT fuctioning properly.
      
      Added the ability to call functions with 6 argument in the x86_64 ABI.
      
      Added the ability for GDBRemoteCommunicationClient to detect if the allocate
      and deallocate memory packets are supported and to not call allocate memory 
      ("_M") or deallocate ("_m") if we find they aren't supported.
      
      Modified the ProcessGDBRemote::DoAllocateMemory(...) and ProcessGDBRemote::DoDeallocateMemory(...) 
      to be able to deal with the allocate and deallocate memory packets not being 
      supported. If they are not supported, ProcessGDBRemote will switch to calling
      "mmap" and "munmap" to allocate and deallocate memory instead using our 
      trivial function call support.
      
      Modified the "void ProcessGDBRemote::DidLaunchOrAttach()" to correctly ignore 
      the qHostInfo triple information if any was specified in the target. Currently 
      if the target only specifies an architecture when creating the target:
      
      (lldb) target create --arch i386 a.out
      
      Then the vendor, os and environemnt will be adopted by the target.
      
      If the target was created with any triple that specifies more than the arch:
      
      (lldb) target create --arch i386-unknown-unknown a.out
      
      Then the target will maintain its triple and not adopt any new values. This
      can be used to help force bare board debugging where the dynamic loader for
      static files will get used and users can then use "target modules load ..."
      to set addressses for any files that are desired.
      
      Added back some convenience functions to the lldb_private::RegisterContext class
      for writing registers with unsigned values. Also made all RegisterContext
      constructors explicit to make sure we know when an integer is being converted
      to a RegisterValue. 
      
      llvm-svn: 131370
      70b57657
  19. 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
  20. May 07, 2011
  21. Apr 14, 2011
  22. Mar 26, 2011
    • Greg Clayton's avatar
      Added the ability to get the min and max instruction byte size for · 357132eb
      Greg Clayton authored
      an architecture into ArchSpec:
      
      uint32_t
      ArchSpec::GetMinimumOpcodeByteSize() const;
      
      uint32_t
      ArchSpec::GetMaximumOpcodeByteSize() const;
      
      Added an AddressClass to the Instruction class in Disassembler.h.
      This allows decoded instructions to know know if they are code,
      code with alternate ISA (thumb), or even data which can be mixed
      into code. The instruction does have an address, but it is a good
      idea to cache this value so we don't have to look it up more than 
      once.
      
      Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
      getting set.
      
      Changed:
      
      	bool
      	SymbolContextList::AppendIfUnique (const SymbolContext& sc);
      
      To:
      	bool
      	SymbolContextList::AppendIfUnique (const SymbolContext& sc, 
      									   bool merge_symbol_into_function);
      
      This function was typically being used when looking up functions
      and symbols. Now if you lookup a function, then find the symbol,
      they can be merged into the same symbol context and not cause
      multiple symbol contexts to appear in a symbol context list that
      describes the same function.
      
      Fixed the SymbolContext not equal operator which was causing mixed
      mode disassembly to not work ("disassembler --mixed --name main").
      
      Modified the disassembler classes to know about the fact we know,
      for a given architecture, what the min and max opcode byte sizes
      are. The InstructionList class was modified to return the max
      opcode byte size for all of the instructions in its list.
      These two fixes means when disassemble a list of instructions and dump 
      them and show the opcode bytes, we can format the output more 
      intelligently when showing opcode bytes. This affects any architectures
      that have varying opcode byte sizes (x86_64 and i386). Knowing the max
      opcode byte size also helps us to be able to disassemble N instructions
      without having to re-read data if we didn't read enough bytes.
      
      Added the ability to set the architecture for the disassemble command.
      This means you can easily cross disassemble data for any supported 
      architecture. I also added the ability to specify "thumb" as an 
      architecture so that we can force disassembly into thumb mode when
      needed. In GDB this was done using a hack of specifying an odd
      address when disassembling. I don't want to repeat this hack in LLDB,
      so the auto detection between ARM and thumb is failing, just specify
      thumb when disassembling:
      
      (lldb) disassemble --arch thumb --name main
      
      You can also have data in say an x86_64 file executable and disassemble
      data as any other supported architecture:
      % lldb a.out
      Current executable set to 'a.out' (x86_64).
      (lldb) b main
      (lldb) run
      (lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
      0x100001080:  0xb580 push   {r7, lr}
      0x100001082:  0xaf00 add    r7, sp, #0
      
      Fixed Target::ReadMemory(...) to be able to deal with Address argument object
      that isn't section offset. When an address object was supplied that was
      out on the heap or stack, target read memory would fail. Disassembly uses
      Target::ReadMemory(...), and the example above where we disassembler thumb
      opcodes in an x86 binary was failing do to this bug.
      
      llvm-svn: 128347
      357132eb
  23. Mar 25, 2011
    • Greg Clayton's avatar
      Cleaned up the Disassembler code a bit more. You can now request a disassembler · 1080edbc
      Greg Clayton authored
      plugin by name on the command line for when there is more than one disassembler
      plugin.
      
      Taught the Opcode class to dump itself so that "disassembler -b" will dump
      the bytes correctly for each opcode type. Modified all places that were passing
      the opcode bytes buffer in so that the bytes could be displayed to just pass
      in a bool that indicates if we should dump the opcode bytes since the opcode
      now lives inside llvm_private::Instruction.
      
      llvm-svn: 128290
      1080edbc
  24. Mar 24, 2011
  25. Mar 22, 2011
  26. Mar 15, 2011
  27. Feb 23, 2011
    • Greg Clayton's avatar
      Abtracted all mach-o and ELF out of ArchSpec. This patch is a modified form · 64195a2c
      Greg Clayton authored
      of Stephen Wilson's idea (thanks for the input Stephen!). What I ended up
      doing was:
      - Got rid of ArchSpec::CPU (which was a generic CPU enumeration that mimics
        the contents of llvm::Triple::ArchType). We now rely upon the llvm::Triple 
        to give us the machine type from llvm::Triple::ArchType.
      - There is a new ArchSpec::Core definition which further qualifies the CPU
        core we are dealing with into a single enumeration. If you need support for
        a new Core and want to debug it in LLDB, it must be added to this list. In
        the future we can allow for dynamic core registration, but for now it is
        hard coded.
      - The ArchSpec can now be initialized with a llvm::Triple or with a C string
        that represents the triple (it can just be an arch still like "i386").
      - The ArchSpec can still initialize itself with a architecture type -- mach-o
        with cpu type and subtype, or ELF with e_machine + e_flags -- and this will
        then get translated into the internal llvm::Triple::ArchSpec + ArchSpec::Core.
        The mach-o cpu type and subtype can be accessed using the getter functions:
        
        uint32_t
        ArchSpec::GetMachOCPUType () const;
      
        uint32_t
        ArchSpec::GetMachOCPUSubType () const;
        
        But these functions are just converting out internal llvm::Triple::ArchSpec 
        + ArchSpec::Core back into mach-o. Same goes for ELF.
      
      All code has been updated to deal with the changes.
      
      This should abstract us until later when the llvm::TargetSpec stuff gets
      finalized and we can then adopt it.
      
      llvm-svn: 126278
      64195a2c
  28. Feb 15, 2011
  29. Jan 27, 2011
  30. Jan 20, 2011
  31. Jan 19, 2011
  32. Jan 18, 2011
  33. Jan 15, 2011
  34. Dec 16, 2010
    • Sean Callanan's avatar
      Implemented a feature where the expression parser · e4ec90e9
      Sean Callanan authored
      can avoid running the code in the target if the
      expression's result is known and the expression
      has no side effects.
      
      Right now this feature is quite conservative in
      its guess about side effects, and it only computes
      integer results, but the machinery to make it more
      sophisticated is there.
      
      llvm-svn: 121952
      e4ec90e9
  35. 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
  36. Dec 03, 2010
  37. Nov 19, 2010
    • Sean Callanan's avatar
      Modifications to type handling logic. We no longer · 6abfabff
      Sean Callanan authored
      perform recursive type lookups, because these are not
      required for full type fidelity.  We also make the
      SelectorTable last for the full lifetime of the Clang
      compiler; this was the source of many bugs.
      
      llvm-svn: 119835
      6abfabff
  38. Nov 18, 2010
Loading