llvm-project/lldb/source/Core
Greg Clayton 32e0a7509c Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make 
sense by default so that subclasses can check:

int
PlatformSubclass::Foo ()
{
    if (IsHost())
        return Platform::Foo (); // Let the platform base class do the host specific stuff
    
    // Platform subclass specific code...
    int result = ...
    return result;
}

Added new functions to the platform:

    virtual const char *Platform::GetUserName (uint32_t uid);
    virtual const char *Platform::GetGroupName (uint32_t gid);

The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.

Added the parent process ID to the ProcessInfo class. 

Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value, 
    euid == value, egid == value, arch == value, parent == value.
    
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class 
implements the process lookup routines, you can now lists processes on 
your local machine:

machine1.foo.com % lldb
(lldb) platform process list 
PID    PARENT USER       GROUP      EFF USER   EFF GROUP  TRIPLE                   NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538  1      username   usergroup  username   usergroup  x86_64-apple-darwin      FileMerge
94943  1      username   usergroup  username   usergroup  x86_64-apple-darwin      mdworker
94852  244    username   usergroup  username   usergroup  x86_64-apple-darwin      Safari
94727  244    username   usergroup  username   usergroup  x86_64-apple-darwin      Xcode
92742  92710  username   usergroup  username   usergroup  i386-apple-darwin        debugserver


This of course also works remotely with the lldb-platform:

machine1.foo.com % lldb-platform --listen 1234

machine2.foo.com % lldb
(lldb) platform create remote-macosx
  Platform: remote-macosx
 Connected: no
(lldb) platform connect connect://localhost:1444
  Platform: remote-macosx
    Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
    Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
  Hostname: machine1.foo.com
 Connected: yes
(lldb) platform process list 
PID    PARENT USER       GROUP      EFF USER   EFF GROUP  TRIPLE                   NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556  244    username   usergroup  username   usergroup  x86_64-apple-darwin      trustevaluation
99548  65539  username   usergroup  username   usergroup  x86_64-apple-darwin      lldb
99538  1      username   usergroup  username   usergroup  x86_64-apple-darwin      FileMerge
94943  1      username   usergroup  username   usergroup  x86_64-apple-darwin      mdworker
94852  244    username   usergroup  username   usergroup  x86_64-apple-darwin      Safari

The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.

Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:

% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out

Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.

Modified the disassembly to show the current PC value. Example output:

(lldb) disassemble --frame
a.out`main:
   0x1eb7:  pushl  %ebp
   0x1eb8:  movl   %esp, %ebp
   0x1eba:  pushl  %ebx
   0x1ebb:  subl   $20, %esp
   0x1ebe:  calll  0x1ec3                   ; main + 12 at test.c:18
   0x1ec3:  popl   %ebx
-> 0x1ec4:  calll  0x1f12                   ; getpid
   0x1ec9:  movl   %eax, 4(%esp)
   0x1ecd:  leal   199(%ebx), %eax
   0x1ed3:  movl   %eax, (%esp)
   0x1ed6:  calll  0x1f18                   ; printf
   0x1edb:  leal   213(%ebx), %eax
   0x1ee1:  movl   %eax, (%esp)
   0x1ee4:  calll  0x1f1e                   ; puts
   0x1ee9:  calll  0x1f0c                   ; getchar
   0x1eee:  movl   $20, (%esp)
   0x1ef5:  calll  0x1e6a                   ; sleep_loop at test.c:6
   0x1efa:  movl   $12, %eax
   0x1eff:  addl   $20, %esp
   0x1f02:  popl   %ebx
   0x1f03:  leave
   0x1f04:  ret
   
This can be handy when dealing with the new --line options that was recently
added:

(lldb) disassemble --line
a.out`main + 13 at test.c:19
   18  	{
-> 19  		printf("Process: %i\n\n", getpid());
   20  	    puts("Press any key to continue..."); getchar();
-> 0x1ec4:  calll  0x1f12                   ; getpid
   0x1ec9:  movl   %eax, 4(%esp)
   0x1ecd:  leal   199(%ebx), %eax
   0x1ed3:  movl   %eax, (%esp)
   0x1ed6:  calll  0x1f18                   ; printf

Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.

Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two 
following functions to retrieve both paths:

const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;

llvm-svn: 128563
2011-03-30 18:16:51 +00:00
..
Address.cpp Fixed the LLDB build so that we can have private types, private enums and 2011-03-24 21:19:54 +00:00
AddressRange.cpp Made lldb_private::ArchSpec contain much more than just an architecture. It 2011-02-15 21:59:32 +00:00
AddressResolver.cpp
AddressResolverFileLine.cpp Modified all logging calls to hand out shared pointers to make sure we 2010-11-06 01:53:30 +00:00
AddressResolverName.cpp Changed the SymbolFile::FindFunction() function calls to only return 2011-01-27 06:44:37 +00:00
ArchSpec.cpp Added the ability to get the min and max instruction byte size for 2011-03-26 19:14:58 +00:00
Baton.cpp
Broadcaster.cpp Fixed a crasher when enabling logging that is due to the new hijack listener stack changes. 2011-02-10 06:51:22 +00:00
Communication.cpp Did a lot more work on abtracting and organizing the platforms. 2011-03-24 04:28:38 +00:00
Connection.cpp
ConnectionFileDescriptor.cpp Did a lot more work on abtracting and organizing the platforms. 2011-03-24 04:28:38 +00:00
ConstString.cpp Made many ConstString functions inlined in the header file. 2010-10-15 22:48:33 +00:00
DataBufferHeap.cpp
DataBufferMemoryMap.cpp Moved FileSpec into the Host layer since it will vary from host to host. 2011-02-08 05:05:52 +00:00
DataExtractor.cpp Applied a fix to qualify "UUID" with the lldb_private namespace to fix 2011-02-04 18:53:10 +00:00
Debugger.cpp Fixed the LLDB build so that we can have private types, private enums and 2011-03-24 21:19:54 +00:00
Disassembler.cpp Many improvements to the Platform base class and subclasses. The base Platform 2011-03-30 18:16:51 +00:00
DynamicLoader.cpp The DynamicLoader plug-in instance now lives up in lldb_private::Process where 2011-02-16 04:46:07 +00:00
EmulateInstruction.cpp Made the lldb_private::Opcode struct into a real boy... I mean class. 2011-03-24 23:53:38 +00:00
Error.cpp LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide 2011-03-08 22:40:15 +00:00
Event.cpp Endian patch from Kirk Beitz that allows better cross platform building. 2011-02-01 01:31:41 +00:00
FileSpecList.cpp Add missing includes. 2010-06-09 08:50:27 +00:00
InputReader.cpp Use Host::File in lldb_private::StreamFile and other places to cleanup host 2011-02-09 01:08:52 +00:00
Language.cpp Created lldb::LanguageType by moving an enumeration from the 2010-07-28 02:04:09 +00:00
Listener.cpp Modified all logging calls to hand out shared pointers to make sure we 2010-11-06 01:53:30 +00:00
Log.cpp Abtracted all mach-o and ELF out of ArchSpec. This patch is a modified form 2011-02-23 00:35:02 +00:00
Makefile Merged Eli Friedman's linux build changes where he added Makefile files that 2010-07-09 20:39:50 +00:00
Mangled.cpp Move the demangle-failed indication out a bit so other failing cases 2010-12-15 04:27:04 +00:00
Module.cpp Many improvements to the Platform base class and subclasses. The base Platform 2011-03-30 18:16:51 +00:00
ModuleChild.cpp
ModuleList.cpp Many improvements to the Platform base class and subclasses. The base Platform 2011-03-30 18:16:51 +00:00
Opcode.cpp Added the ability to get the min and max instruction byte size for 2011-03-26 19:14:58 +00:00
PluginManager.cpp Did a lot more work on abtracting and organizing the platforms. 2011-03-24 04:28:38 +00:00
RegularExpression.cpp Improved our argument parsing abilities to be able to handle stuff more like 2010-12-19 03:41:24 +00:00
Scalar.cpp Endian patch from Kirk Beitz that allows better cross platform building. 2011-02-01 01:31:41 +00:00
SearchFilter.cpp Merged Eli Friedman's linux build changes where he added Makefile files that 2010-07-09 20:39:50 +00:00
Section.cpp Fixed the LLDB build so that we can have private types, private enums and 2011-03-24 21:19:54 +00:00
SourceManager.cpp Many improvements to the Platform base class and subclasses. The base Platform 2011-03-30 18:16:51 +00:00
State.cpp Added support for attaching to a remote debug server with the new command: 2011-02-04 01:58:07 +00:00
Stream.cpp Use Host::File in lldb_private::StreamFile and other places to cleanup host 2011-02-09 01:08:52 +00:00
StreamFile.cpp Use Host::File in lldb_private::StreamFile and other places to cleanup host 2011-02-09 01:08:52 +00:00
StreamString.cpp Add missing includes. 2010-06-09 08:50:27 +00:00
StringList.cpp Declare some const functions as const. 2011-03-11 01:48:52 +00:00
Timer.cpp Added a setting to "log timer" so you can see the incremental timings as well: 2010-11-04 23:19:21 +00:00
UUID.cpp Header patch, virtual dtor patch and missed UUID patch from Kirk Beitz. 2011-02-05 02:56:16 +00:00
UserID.cpp Move trivial parts of UserID into the header. 2010-06-22 10:44:12 +00:00
UserSettingsController.cpp - Changed all the places where CommandObjectReturn was exporting a StreamString to just exporting 2011-02-19 02:53:09 +00:00
VMRange.cpp Added support for inlined stack frames being represented as real stack frames 2010-08-24 00:45:41 +00:00
Value.cpp Fixed the LLDB build so that we can have private types, private enums and 2011-03-24 21:19:54 +00:00
ValueObject.cpp Fixed the LLDB build so that we can have private types, private enums and 2011-03-24 21:19:54 +00:00
ValueObjectChild.cpp Fixed up the SBValue::GetExpressionPath() to be more correct under more 2011-01-21 01:59:00 +00:00
ValueObjectConstResult.cpp Fixed the LLDB build so that we can have private types, private enums and 2011-03-24 21:19:54 +00:00
ValueObjectList.cpp StackFrame objects now own ValueObjects for any frame variables (locals, args, 2010-09-02 02:59:18 +00:00
ValueObjectRegister.cpp A few of the issue I have been trying to track down and fix have been due to 2011-01-17 03:46:26 +00:00
ValueObjectVariable.cpp Made lldb_private::ArchSpec contain much more than just an architecture. It 2011-02-15 21:59:32 +00:00