Skip to content
  1. Oct 19, 2012
    • Greg Clayton's avatar
      Added the infrastructure necessary for plug-ins to be able to add their own... · e8cd0c98
      Greg Clayton authored
      Added the infrastructure necessary for plug-ins to be able to add their own settings instead of having settings added to existing ones. In particular "target.disable-kext-loading" was added to "target" where it should actually be specific to the the dynamic loader plugin. Now the plug-in manager has the ability to create settings at the root level starting with "plugin". Each plug-in type can add new sub dictionaries, and then each plug-in can register a setting dictionary under its own short name. For example the DynamicLoaderDarwinKernel plug-in now registers a setting dictionary at:
      
      plugin
          dynamic-loader
              macosx-kernel
                  (bool) disable-kext-loading
                  
      To settings can be set using:
      
      (lldb) settings set plugin.dynamic-loader.macosx-kernel.disable-kext-loading true
      
      I currently only hooked up the DynamicLoader plug-ins, but the code is very easy to duplicate when and if we need settings for other plug-ins.
      
      llvm-svn: 166294
      e8cd0c98
  2. Feb 05, 2012
    • Greg Clayton's avatar
      <rdar://problem/10560053> · c9660546
      Greg Clayton authored
      Fixed "target modules list" (aliased to "image list") to output more information
      by default. Modified the "target modules list" to have a few new options:
      
      "--header" or "-h" => show the image header address
      "--offset" or "-o" => show the image header address offset from the address in the file (the slide applied to the shared library)
      
      Removed the "--symfile-basename" or "-S" option, and repurposed it to 
      "--symfile-unique" "-S" which will show the symbol file if it differs from
      the executable file.
      
      ObjectFile's can now be loaded from memory for cases where we don't have the
      files cached locally in an SDK or net mounted root. ObjectFileMachO can now
      read mach files from memory.
      
      Moved the section data reading code into the ObjectFile so that the object
      file can get the section data from Process memory if the file is only in
      memory.
      
      lldb_private::Module can now load its object file in a target with a rigid 
      slide (very common operation for most dynamic linkers) by using:
      
      bool 
      Module::SetLoadAddress (Target &target, lldb::addr_t offset, bool &changed)
      
      lldb::SBModule() now has a new constructor in the public interface:
      
      SBModule::SBModule (lldb::SBProcess &process, lldb::addr_t header_addr);
      
      This will find an appropriate ObjectFile plug-in to load an image from memory
      where the object file header is at "header_addr".
      
      llvm-svn: 149804
      c9660546
  3. Aug 22, 2011
    • Greg Clayton's avatar
      Added a new plug-in type: lldb_private::OperatingSystem. The operating system · 56d9a1b3
      Greg Clayton authored
      plug-ins are add on plug-ins for the lldb_private::Process class that can add
      thread contexts that are read from memory. It is common in kernels to have
      a lot of threads that are not currently executing on any cores (JTAG debugging
      also follows this sort of thing) and are context switched out whose state is
      stored in memory data structures. Clients can now subclass the OperatingSystem
      plug-ins and then make sure their Create functions correcltly only enable 
      themselves when the right binary/target triple are being debugged. The 
      operating system plug-ins get a chance to attach themselves to processes just
      after launching or attaching and are given a lldb_private::Process object 
      pointer which can be inspected to see if the main executable, target triple,
      or any shared  libraries match a case where the OS plug-in should be used.
      Currently the OS plug-ins can create new threads, define the register contexts
      for these threads (which can all be different if desired), and populate and
      manage the thread info (stop reason, registers in the register context) as
      the debug session goes on.
      
      llvm-svn: 138228
      56d9a1b3
  4. May 11, 2011
    • Greg Clayton's avatar
      Moved all code from ArchDefaultUnwindPlan and ArchVolatileRegs into their · 31f1d2f5
      Greg Clayton authored
      respective ABI plugins as they were plug-ins that supplied ABI specfic info.
      
      Also hookep up the UnwindAssemblyInstEmulation so that it can generate the
      unwind plans for ARM.
      
      Changed the way ABI plug-ins are handed out when you get an instance from
      the plug-in manager. They used to return pointers that would be mananged
      individually by each client that requested them, but now they are handed out
      as shared pointers since there is no state in the ABI objects, they can be
      shared.
      
      llvm-svn: 131193
      31f1d2f5
  5. Apr 25, 2011
  6. Apr 18, 2011
    • Greg Clayton's avatar
      Centralized a lot of the status information for processes, · 7260f620
      Greg Clayton authored
      threads, and stack frame down in the lldb_private::Process,
      lldb_private::Thread, lldb_private::StackFrameList and the 
      lldb_private::StackFrame classes. We had some command line
      commands that had duplicate versions of the process status
      output ("thread list" and "process status" for example). 
      
      Removed the "file" command and placed it where it should
      have been: "target create". Made an alias for "file" to
      "target create" so we stay compatible with GDB commands.
      
      We can now have multple usable targets in lldb at the
      same time. This is nice for comparing two runs of a program
      or debugging more than one binary at the same time. The
      new command is "target select <target-idx>" and also to see
      a list of the current targets you can use the new "target list"
      command. The flow in a debug session can be:
      
      (lldb) target create /path/to/exe/a.out
      (lldb) breakpoint set --name main
      (lldb) run
      ... hit breakpoint
      (lldb) target create /bin/ls
      (lldb) run /tmp
      Process 36001 exited with status = 0 (0x00000000) 
      (lldb) target list
      Current targets:
        target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
      * target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
      (lldb) target select 0
      Current targets:
      * target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
        target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
      (lldb) bt
      * thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
        frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
        frame #1: 0x0000000100000b64 a.out`start + 52
      
      Above we created a target for "a.out" and ran and hit a
      breakpoint at "main". Then we created a new target for /bin/ls
      and ran it. Then we listed the targest and selected our original
      "a.out" program, so we showed two concurent debug sessions
      going on at the same time.
      
      llvm-svn: 129695
      7260f620
  7. Apr 14, 2011
    • Greg Clayton's avatar
      Added auto completion for architecture names and for platforms. · ab65b34f
      Greg Clayton authored
      Modified the OptionGroupOptions to be able to specify only some of the options
      that should be appended by using the usage_mask in the group defintions and
      also provided a way to remap them to a new usage mask after the copy. This 
      allows options to be re-used and also targetted for specific option groups.
      
      Modfied the CommandArgumentType to have a new eArgTypePlatform enumeration.
      Taught the option parser to be able to automatically use the appropriate
      auto completion for a given options if nothing is explicitly specified
      in the option definition. So you don't have to specify it in the option
      definition tables.
      
      Renamed the default host platform name to "host", and the default platform
      hostname to be "localhost".
      
      Modified the "file" and "platform select" commands to make sure all options
      and args are good prior to creating a new platform. Also defer the computation
      of the architecture in the file command until all options are parsed and the
      platform has either not been specified or reset to a new value to avoid
      computing the arch more than once.
      
      Switch the PluginManager code over to using llvm::StringRef for string
      comparisons and got rid of all the AccessorXXX functions in lieu of the newer
      mutex + collection singleton accessors.
      
      llvm-svn: 129483
      ab65b34f
  8. Apr 08, 2011
    • Stephen Wilson's avatar
      Add missing headers. · 8acdbb8a
      Stephen Wilson authored
      Something changed in commit r129112 where a few standard headers vanished from
      the include chain when building on Linux.  Fix up by including limits.h for
      INT_MAX and PATH_MAX where needed, and stdio.h for printf().
      
      llvm-svn: 129130
      8acdbb8a
  9. Mar 24, 2011
    • Greg Clayton's avatar
      Did a lot more work on abtracting and organizing the platforms. · 1cb6496e
      Greg Clayton authored
      On Mac OS X we now have 3 platforms:
      PlatformDarwin - must be subclassed to fill in the missing pure virtual funcs
                       but this implements all the common functionality between
                       remote-macosx and remote-ios. It also allows for another
                       platform to be used (remote-gdb-server for now) when doing
                       remote connections. Keeping this pluggable will allow for
                       flexibility.
      PlatformMacOSX - Now implements both local and remote macosx desktop platforms.
      PlatformRemoteiOS - Remote only iOS that knows how to locate SDK files in the
                          cached SDK locations on the host.
      
      A new agnostic platform has been created:
      PlatformRemoteGDBServer - this implements the platform using the GDB remote 
                                protocol and uses the built in lldb_private::Host
                                static functions to implement many queries.
      
      llvm-svn: 128193
      1cb6496e
  10. Mar 19, 2011
    • Greg Clayton's avatar
      Added more platform support. There are now some new commands: · ded470d3
      Greg Clayton authored
      platform status -- gets status information for the selected platform
      platform create <platform-name> -- creates a new instance of a remote platform
      platform list -- list all available platforms
      platform select -- select a platform instance as the current platform (not working yet)
      
      When using "platform create" it will create a remote platform and make it the
      selected platform. For instances for iPhone OS debugging on Mac OS X one can 
      do:
      
      (lldb) platform create remote-ios --sdk-version=4.0
      Remote platform: iOS platform
      SDK version: 4.0
      SDK path: "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0"
      Not connected to a remote device.
      (lldb) file ~/Documents/a.out
      Current executable set to '~/Documents/a.out' (armv6).
      (lldb) image list
      [  0] /Volumes/work/gclayton/Documents/devb/attach/a.out
      [  1] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/dyld
      [  2] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libSystem.B.dylib
      
      
      Note that this is all happening prior to running _or_ connecting to a remote
      platform. Once connected to a remote platform the OS version might change which
      means we will need to update our dependecies. Also once we run, we will need
      to match up the actualy binaries with the actualy UUID's to files in the
      SDK, or download and cache them locally.
      
      This is just the start of the remote platforms, but this modification is the
      first iteration in getting the platforms really doing something.
      
      llvm-svn: 127934
      ded470d3
  11. Mar 08, 2011
    • Greg Clayton's avatar
      LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide · e996fd30
      Greg Clayton authored
      an interface to a local or remote debugging platform. By default each host OS
      that supports LLDB should be registering a "default" platform that will be
      used unless a new platform is selected. Platforms are responsible for things
      such as:
      - getting process information by name or by processs ID
      - finding platform files. This is useful for remote debugging where there is 
        an SDK with files that might already or need to be cached for debug access.
      - getting a list of platform supported architectures in the exact order they
        should be selected. This helps the native x86 platform on MacOSX select the
        correct x86_64/i386 slice from universal binaries.
      - Connect to remote platforms for remote debugging
      - Resolving an executable including finding an executable inside platform
        specific bundles (macosx uses .app bundles that contain files) and also
        selecting the appropriate slice of universal files for a given platform.
      
      So by default there is always a local platform, but remote platforms can be
      connected to. I will soon be adding a new "platform" command that will support
      the following commands:
      (lldb) platform connect --name machine1 macosx connect://host:port
      Connected to "machine1" platform.
      (lldb) platform disconnect macosx
      
      This allows LLDB to be well setup to do remote debugging and also once 
      connected process listing and finding for things like:
      (lldb) process attach --name x<TAB>
      
      The currently selected platform plug-in can now auto complete any available
      processes that start with "x". The responsibilities for the platform plug-in
      will soon grow and expand.
      
      llvm-svn: 127286
      e996fd30
  12. Feb 18, 2011
    • Greg Clayton's avatar
      Added new target instance settings for execution settings: · bfe5f3bf
      Greg Clayton authored
      Targets can now specify some additional parameters for when we debug 
      executables that can help with plug-in selection:
      
      target.execution-level = auto | user | kernel
      target.execution-mode  = auto | dynamic | static
      target.execution-os-type = auto | none | halted | live
      
      On some systems, the binaries that are created are the same wether you use
      them to debug a kernel, or a user space program. Many times inspecting an 
      object file can reveal what an executable should be. For these cases we can
      now be a little more complete by specifying wether to detect all of these
      things automatically (inspect the main executable file and select a plug-in
      accordingly), or manually to force the selection of certain plug-ins.
      
      To do this we now allow the specficifation of wether one is debugging a user
      space program (target.execution-level = user) or a kernel program 
      (target.execution-level = kernel).
      
      We can also specify if we want to debug a program where shared libraries
      are dynamically loaded using a DynamicLoader plug-in 
      (target.execution-mode = dynamic), or wether we will treat all symbol files
      as already linked at the correct address (target.execution-mode = static).
      
      We can also specify if the inferior we are debugging is being debugged on 
      a bare board (target.execution-os-type = none), or debugging an OS where
      we have a JTAG or other direct connection to the inferior stops the entire
      OS (target.execution-os-type = halted), or if we are debugging a program on
      something that has live debug services (target.execution-os-type = live).
      
      For the "target.execution-os-type = halted" mode, we will need to create 
      ProcessHelper plug-ins that allow us to extract the process/thread and other
      OS information by reading/writing memory.
      
      This should allow LLDB to be used for a wide variety of debugging tasks and
      handle them all correctly.
      
      llvm-svn: 125815
      bfe5f3bf
  13. Feb 08, 2011
  14. Feb 02, 2011
    • Greg Clayton's avatar
      Modified the PluginManager to be ready for loading plug-ins from a system · 4272cc7d
      Greg Clayton authored
      LLDB plugin directory and a user LLDB plugin directory. We currently still
      need to work out at what layer the plug-ins will be, but at least we are 
      prepared for plug-ins. Plug-ins will attempt to be loaded from the 
      "/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins" 
      folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
      MacOSX. Each plugin will be scanned for:
      
      extern "C" bool LLDBPluginInitialize(void);
      extern "C" void LLDBPluginTerminate(void);
      
      If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
      LLDBPluginInitialize function returns a bool that indicates if the plug-in
      should stay loaded or not (plug-ins might check the current OS, current
      hardware, or anything else and determine they don't want to run on the current
      host). The plug-in is uniqued by path and added to a static loaded plug-in
      map. The plug-in scanning happens during "lldb_private::Initialize()" which
      calls to the PluginManager::Initialize() function. Likewise with termination
      lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
      plug-in directories is fetched through new Host calls:
      
          bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
          bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
      
      This way linux and other systems can define their own appropriate locations
      for plug-ins to be loaded.
      
      To allow dynamic shared library loading, the Host layer has also been modified
      to include shared library open, close and get symbol:
      
          static void *
          Host::DynamicLibraryOpen (const FileSpec &file_spec, 
                                    Error &error);
      
          static Error
          Host::DynamicLibraryClose (void *dynamic_library_handle);
      
          static void *
          Host::DynamicLibraryGetSymbol (void *dynamic_library_handle, 
                                        const char *symbol_name, 
                                        Error &error);
      
      lldb_private::FileSpec also has been modified to support directory enumeration
      in an attempt to abstract the directory enumeration into one spot in the code.
      The directory enumertion function is static and takes a callback:
      
      
          typedef enum EnumerateDirectoryResult
          {
              eEnumerateDirectoryResultNext,  // Enumerate next entry in the current directory
              eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
              eEnumerateDirectoryResultExit,  // Exit from the current directory at the current level.
              eEnumerateDirectoryResultQuit   // Stop directory enumerations at any level
          };
      
          typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
                                                                                        FileSpec::FileType file_type,
                                                                                        const FileSpec &spec);
      
          static FileSpec::EnumerateDirectoryResult
          FileSpec::EnumerateDirectory (const char *dir_path,
                                        bool find_directories,
                                        bool find_files,
                                        bool find_other,
                                        EnumerateDirectoryCallbackType callback,
                                        void *callback_baton);
      
      This allow clients to specify the directory to search, and specifies if only
      files, directories or other (pipe, symlink, fifo, etc) files will cause the
      callback to be called. The callback also gets to return with the action that
      should be performed after this directory entry. eEnumerateDirectoryResultNext
      specifies to continue enumerating through a directory with the next entry.
      eEnumerateDirectoryResultEnter specifies to recurse down into a directory
      entry, or if the file is not a directory or symlink/alias to a directory, then
      just iterate to the next entry. eEnumerateDirectoryResultExit specifies to 
      exit the current directory and skip any entries that might be remaining, yet
      continue enumerating to the next entry in the parent directory. And finally
      eEnumerateDirectoryResultQuit means to abort all directory enumerations at 
      all levels.
      
      Modified the Declaration class to not include column information currently
      since we don't have any compilers that currently support column based 
      declaration information. Columns support can be re-enabled with the
      additions of a #define.
      
      Added the ability to find an EmulateInstruction plug-in given a target triple
      and optional plug-in name in the plug-in manager.
      
      Fixed a few cases where opendir/readdir was being used, but yet not closedir
      was being used. Soon these will be deprecated in favor of the new directory
      enumeration call that was added to the FileSpec class.
      
      llvm-svn: 124716
      4272cc7d
  15. Feb 01, 2011
  16. Sep 23, 2010
  17. Sep 22, 2010
  18. Sep 10, 2010
    • Jason Molenda's avatar
      The first part of an lldb native stack unwinder. · fbcb7f2c
      Jason Molenda authored
      The Unwind and RegisterContext subclasses still need
      to be finished; none of this code is used by lldb at
      this point (unless you call into it by hand).
      
      The ObjectFile class now has an UnwindTable object.
      
      The UnwindTable object has a series of FuncUnwinders
      objects (Function Unwinders) -- one for each function
      in that ObjectFile we've backtraced through during this
      debug session.
      
      The FuncUnwinders object has a few different UnwindPlans.
      UnwindPlans are a generic way of describing how to find
      the canonical address of a given function's stack frame
      (the CFA idea from DWARF/eh_frame) and how to restore the
      caller frame's register values, if they have been saved
      by this function.
      
      UnwindPlans are created from different sources.  One source is the
      eh_frame exception handling information generated by the compiler
      for unwinding an exception throw.  Another source is an assembly
      language inspection class (UnwindAssemblyProfiler, uses the Plugin
      architecture) which looks at the instructions in the funciton
      prologue and describes the stack movements/register saves that are
      done.
      
      Two additional types of UnwindPlans that are worth noting are
      the "fast" stack UnwindPlan which is useful for making a first
      pass over a thread's stack, determining how many stack frames there
      are and retrieving the pc and CFA values for each frame (enough
      to create StackFrameIDs).  Only a minimal set of registers is
      recovered during a fast stack walk.  
      
      The final UnwindPlan is an architectural default unwind plan.
      These are provided by the ArchDefaultUnwindPlan class (which uses
      the plugin architecture).  When no symbol/function address range can
      be found for a given pc value -- when we have no eh_frame information
      and when we don't have a start address so we can't examine the assembly
      language instrucitons -- we have to make a best guess about how to 
      unwind.  That's when we use the architectural default UnwindPlan.
      On x86_64, this would be to assume that rbp is used as a stack pointer
      and we can use that to find the caller's frame pointer and pc value.
      It's a last-ditch best guess about how to unwind out of a frame.
      
      There are heuristics about when to use one UnwindPlan versues the other --
      this will all happen in the still-begin-written UnwindLLDB subclass of
      Unwind which runs the UnwindPlans.
      
      llvm-svn: 113581
      fbcb7f2c
  19. Jun 12, 2010
  20. Jun 08, 2010
Loading