def getTrace(target=None, **kwargs): """ Return a tracer object appropriate for this platform. This is the function you will use to get a tracer object with the appropriate ancestry for your host. ex. mytrace = vtrace.getTrace() NOTE: Use the release() method on the tracer once debugging is complete. This releases the tracer thread and allows garbage collection to function correctly. Some specialized tracers may be constructed by specifying the "target" name from one of the following list. Additionally, each "specialized" tracer may require additional kwargs (which are listed). Examples: # A tracer for *this* os t = vtrace.getTrace() # A tracer for the gdbstub debugging a vmware 32bit hypervisor t = vtrace.getTrace(target='vmware32', host='localhost', port=8832) Targets: Alpha Targets: vmware32 - host=<host> ( probably 'localhost' ) port=<port> ( probably 8832 ) """ if target == 'gdbserver': host = reqTargOpt(kwargs, 'gdbserver', 'host', '<host>') port = reqTargOpt(kwargs, 'gdbserver', 'port', '<port>') arch = reqTargOpt(kwargs, 'gdbserver', 'arch', '<i386|amd64|arm>') plat = reqTargOpt(kwargs, 'gdbserver', 'plat', '<windows|linux>') if arch not in ('i386', 'amd64', 'arm'): raise Exception('Invalid arch specified for "gdbserver" target: %s' % arch) if plat not in ('windows', 'linux'): raise Exception('Invalid plat specified for "gdbserver" target: %s' % plat) if target == 'vmware32': import vtrace.platforms.vmware as vt_vmware host = reqTargOpt(kwargs, 'vmware32', 'host', '<host>') port = int( reqTargOpt(kwargs, 'vmware32', 'port', '<port>') ) plat = 'windows' #plat = reqTargOpt(kwargs, 'vmware32', 'plat', '<windows|linux>') #if plat not in ('windows', 'linux'): #raise Exception('Invalid plat specified for "vmware32" target: %s' % plat) return vt_vmware.VMWare32WindowsTrace( host=host, port=port ) if remote: #We have a remote server! return getRemoteTrace() # From here down, we're trying to build a trace for *this* platform! os_name = platform.system().lower() # Like "linux", "darwin","windows" arch = envi.getCurrentArch() if os_name == "linux": import vtrace.platforms.linux as v_linux if arch == "amd64": return v_linux.LinuxAmd64Trace() elif arch == "i386": return v_linux.Linuxi386Trace() # Keep separate just in case elif arch == "armv7l": return v_linux.LinuxArmTrace() elif arch == "armv6l": return v_linux.LinuxArmTrace() else: raise Exception("Sorry, no linux support for %s" % arch) elif os_name == "freebsd": import vtrace.platforms.freebsd as v_freebsd if arch == "i386": return v_freebsd.FreeBSDi386Trace() elif arch == "amd64": return v_freebsd.FreeBSDAmd64Trace() else: raise Exception("Sorry, no FreeBSD support for %s" % arch) elif os_name == "sunos5": raise Exception("Solaris needs porting!") #import vtrace.platforms.posix as v_posix #import vtrace.platforms.solaris as v_solaris #ilist.append(v_posix.PosixMixin) #if arch == "i386": #import vtrace.archs.intel as v_intel #ilist.append(v_intel.i386Mixin) #ilist.append(v_solaris.SolarisMixin) #ilist.append(v_solaris.Solarisi386Mixin) elif os_name == "darwin": #if 9 not in os.getgroups(): #print 'You MUST be in the procmod group....' #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth' #print '(put your username in there unless you want to put me in too... ;)' #raise Exception('procmod group membership required') if os.getuid() != 0: logger.error('For NOW you *must* be root. There are some crazy MACH perms...') raise Exception('You must be root for now (on OSX)....') logger.warning('Also... the darwin port is not even REMOTELY working yet. Solid progress though...') #'sudo dscl . append /Groups/procmod GroupMembership invisigoth' #'sudo dscl . read /Groups/procmod GroupMembership' import vtrace.platforms.darwin as v_darwin if arch == 'i386': return v_darwin.Darwini386Trace() elif arch == 'amd64': return v_darwin.DarwinAmd64Trace() else: raise Exception('Darwin not supported on %s (only i386...)' % arch) elif os_name in ['microsoft', 'windows']: import vtrace.platforms.win32 as v_win32 if arch == "i386": return v_win32.Windowsi386Trace() elif arch == "amd64": return v_win32.WindowsAmd64Trace() else: raise Exception("Windows with arch %s is not supported!" % arch) else: raise Exception("ERROR - OS %s not supported yet" % os_name)
def getTrace(): """ Return a tracer object appropriate for this platform. This is the function you will use to get a tracer object with the appropriate ancestry for your host. ex. mytrace = vtrace.getTrace() """ if remote: #We have a remote server! return getRemoteTrace() os_name = platform.system() # Like "Linux", "Darwin","Windows" arch = envi.getCurrentArch() if os_name == "Linux": import vtrace.platforms.linux as v_linux if arch == "amd64": return v_linux.LinuxAmd64Trace() elif arch == "i386": return v_linux.Linuxi386Trace() else: raise Exception("Sorry, no linux support for %s" % arch) elif os_name == "FreeBSD": import vtrace.platforms.freebsd as v_freebsd if arch == "i386": return v_freebsd.FreeBSDi386Trace() elif arch == "amd64": return v_freebsd.FreeBSDAmd64Trace() else: raise Exception("Sorry, no FreeBSD support for %s" % arch) #import vtrace.platforms.posix as v_posix #import vtrace.platforms.freebsd as v_freebsd #ilist.append(v_posix.PosixMixin) #ilist.append(v_posix.ElfMixin) #if arch == "i386": #import vtrace.archs.intel as v_intel #ilist.append(v_intel.i386Mixin) #ilist.append(v_freebsd.FreeBSDMixin) #ilist.append(v_freebsd.FreeBSDIntelRegisters) #else: #raise Exception("Sorry, no FreeBSD support for %s" % arch) elif os_name == "sunos5": raise Exception("Solaris needs porting!") #import vtrace.platforms.posix as v_posix #import vtrace.platforms.solaris as v_solaris #ilist.append(v_posix.PosixMixin) #if arch == "i386": #import vtrace.archs.intel as v_intel #ilist.append(v_intel.i386Mixin) #ilist.append(v_solaris.SolarisMixin) #ilist.append(v_solaris.Solarisi386Mixin) elif os_name == "Darwin": #if 9 not in os.getgroups(): #print 'You MUST be in the procmod group....' #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth' #print '(put your username in there unless you want to put me in too... ;)' #raise Exception('procmod group membership required') if os.getuid() != 0: print 'For NOW you *must* be root. There are some crazy MACH perms...' raise Exception('You must be root for now....') print 'Also... the darwin port is not even REMOTELY working yet. Solid progress though...' #'sudo dscl . append /Groups/procmod GroupMembership invisigoth' #'sudo dscl . read /Groups/procmod GroupMembership' import vtrace.platforms.darwin as v_darwin if arch == 'i386': return v_darwin.Darwini386Trace() elif arch == 'amd64': return v_darwin.DarwinAmd64Trace() else: raise Exception('Darwin not supported on %s (only i386...)' % arch) elif os_name in ['Microsoft', 'Windows']: import vtrace.platforms.win32 as v_win32 if arch == "i386": return v_win32.Windowsi386Trace() elif arch == "amd64": return v_win32.WindowsAmd64Trace() else: raise Exception("Windows with arch %s is not supported!" % arch) else: raise Exception("ERROR - OS %s not supported yet" % os_name)
def getTrace(plat=None, **kwargs): """ Return a tracer object appropriate for this platform. This is the function you will use to get a tracer object with the appropriate ancestry for your host. ex. mytrace = vtrace.getTrace() NOTE: Use the release() method on the tracer once debugging is complete. This releases the tracer thread and allows garbage collection to function correctly. Some specialized tracers may be constructed by specifying the "plat" name from one of the following list. Additionally, each "specialized" tracer may require additional kwargs (which are listed). android - Debug android apps through adb (adb must be in your path) avd=<name> (None will let adb decide) vmware32 - Debug a 32bit VMWare target. host=<host> - Where is the gdb server listening? (default 127.0.0.1) port=<port> - What port (default: 8832) os=<osname> - On of "Windows", "Linux" (that's all we support now...) vmware64 - Debug a 64bit VMWare target. host=<host> - Where is the gdb server listening? (default 127.0.0.1) port=<port> - What port (default: 8864) os=<osname> - On of "Windows", "Linux" (that's all we support now...) Examples: t = vtrace.getTrace() # A tracer for *this* os t = vtrace.getTrace(plat='android') # The default ADB device t = vtrace.getTrace(plat='vmware32', host='localhost', port=31337) """ # FIXME make "remote" traces use plat="remote"! if plat == 'android': import vtrace.platforms.android as v_android return v_android.getTrace(**kwargs) if remote: #We have a remote server! return getRemoteTrace() # From here down, we're trying to build a trace for *this* platform! os_name = platform.system() # Like "Linux", "Darwin","Windows" arch = envi.getCurrentArch() if os_name == "Linux": import vtrace.platforms.linux as v_linux if arch == "amd64": return v_linux.LinuxAmd64Trace() elif arch == "i386": return v_linux.Linuxi386Trace() else: raise Exception("Sorry, no linux support for %s" % arch) elif os_name == "FreeBSD": import vtrace.platforms.freebsd as v_freebsd if arch == "i386": return v_freebsd.FreeBSDi386Trace() elif arch == "amd64": return v_freebsd.FreeBSDAmd64Trace() else: raise Exception("Sorry, no FreeBSD support for %s" % arch) #import vtrace.platforms.posix as v_posix #import vtrace.platforms.freebsd as v_freebsd #ilist.append(v_posix.PosixMixin) #ilist.append(v_posix.ElfMixin) #if arch == "i386": #import vtrace.archs.intel as v_intel #ilist.append(v_intel.i386Mixin) #ilist.append(v_freebsd.FreeBSDMixin) #ilist.append(v_freebsd.FreeBSDIntelRegisters) #else: #raise Exception("Sorry, no FreeBSD support for %s" % arch) elif os_name == "sunos5": raise Exception("Solaris needs porting!") #import vtrace.platforms.posix as v_posix #import vtrace.platforms.solaris as v_solaris #ilist.append(v_posix.PosixMixin) #if arch == "i386": #import vtrace.archs.intel as v_intel #ilist.append(v_intel.i386Mixin) #ilist.append(v_solaris.SolarisMixin) #ilist.append(v_solaris.Solarisi386Mixin) elif os_name == "Darwin": #if 9 not in os.getgroups(): #print 'You MUST be in the procmod group....' #print 'Use: sudo dscl . append /Groups/procmod GroupMembership invisigoth' #print '(put your username in there unless you want to put me in too... ;)' #raise Exception('procmod group membership required') if os.getuid() != 0: print 'For NOW you *must* be root. There are some crazy MACH perms...' raise Exception('You must be root for now (on OSX)....') print 'Also... the darwin port is not even REMOTELY working yet. Solid progress though...' #'sudo dscl . append /Groups/procmod GroupMembership invisigoth' #'sudo dscl . read /Groups/procmod GroupMembership' import vtrace.platforms.darwin as v_darwin if arch == 'i386': return v_darwin.Darwini386Trace() elif arch == 'amd64': return v_darwin.DarwinAmd64Trace() else: raise Exception('Darwin not supported on %s (only i386...)' % arch) elif os_name in ['Microsoft', 'Windows']: import vtrace.platforms.win32 as v_win32 if arch == "i386": return v_win32.Windowsi386Trace() elif arch == "amd64": return v_win32.WindowsAmd64Trace() else: raise Exception("Windows with arch %s is not supported!" % arch) else: raise Exception("ERROR - OS %s not supported yet" % os_name)