コード例 #1
0
ファイル: shell.py プロジェクト: w542380601/tcf
 def onChannelOpen(self, channel):
     wrapper = sync.DispatchWrapper(channel)
     self.locals["channel"] = wrapper
     self.locals["disconnect"] = wrapper.close
     self.locals["cmd"] = sync.CommandControl(channel, interactive=True)
     self.locals["events"] = event.EventRecorder(channel)
     protocol.invokeAndWait(protocol.removeChannelOpenListener, self)
     wrapper.addChannelListener(self)
コード例 #2
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testFileSystem(c):
    cmd = sync.CommandControl(c)
    try:
        fs = cmd.FileSystem
    except AttributeError:
        # no FileSystem service
        return
    roots = fs.roots().get()
    print("FileSystem roots: " + str(roots))
    user = fs.user().get()
    print("User info: " + str(user))
コード例 #3
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testExpressions(c):
    if not _suspended:
        return
    from tcf.services import expressions  # @UnresolvedImport
    ctl = sync.CommandControl(c)
    exprs = ctl.Expressions
    e = exprs.create(_suspended[0], None, "1+2*(3-4/2)").getE()
    eid = e.get(expressions.PROP_ID)
    val, cls = exprs.evaluate(eid).getE()
    print(e.get(expressions.PROP_EXPRESSION) + " = " + str(val))
    exprs.dispose(eid)
コード例 #4
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testSysMonitor(c):
    cmd = sync.CommandControl(c)
    try:
        sm = cmd.SysMonitor
    except AttributeError:
        # no SysMonotor service
        return
    lock = threading.Condition()
    from tcf.services import sysmonitor  # @UnresolvedImport
    processes = []

    def getProcesses():
        sm = c.getRemoteService(sysmonitor.NAME)
        pending = []

        class DoneGetChildren(sysmonitor.DoneGetChildren):
            def doneGetChildren(self, token, error, context_ids):
                pending.remove(token)
                if error:
                    protocol.log("Error from SysMonitor.getChildren", error)
                else:

                    class DoneGetContext(sysmonitor.DoneGetContext):
                        def doneGetContext(self, token, error, context):
                            pending.remove(token)
                            if error:
                                protocol.log(
                                    "Error from SysMonitor.getContext", error)
                            else:
                                processes.append(context)
                            if not pending:
                                with lock:
                                    lock.notify()

                    for ctx_id in context_ids:
                        pending.append(sm.getContext(ctx_id, DoneGetContext()))
                if not pending:
                    with lock:
                        lock.notify()

        pending.append(sm.getChildren(None, DoneGetChildren()))

    with lock:
        protocol.invokeLater(getProcesses)
        lock.wait(5)
    print("%d processes found:" % len(processes))
    for p in processes:
        print(p)
        cmdl = sm.getCommandLine(p.getID()).get()
        if cmdl:
            print("Command line: " + str(cmdl))
        envp = sm.getEnvironment(p.getID()).get()
        print("Environment: " + str(envp))
コード例 #5
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testMemoryMap(c):
    if not _memory:
        return
    cmd = sync.CommandControl(c)
    try:
        mm = cmd.MemoryMap
    except AttributeError:
        # no MemoryMap service
        return
    map_id = _memory[0]
    lock = threading.Condition()
    from tcf.services import memorymap  # @UnresolvedImport

    def getMap():
        mm = c.getRemoteService(memorymap.NAME)

        class DoneGet(memorymap.DoneGet):
            def doneGet(self, token, error, mmap):
                if error:
                    protocol.log("Error from MemoryMap.get", error)
                else:
                    print(mmap)
                with lock:
                    lock.notify()

        mm.get(map_id, DoneGet())

    with lock:
        protocol.invokeLater(getMap)
        lock.wait(1)

    def setMap():
        mm = c.getRemoteService(memorymap.NAME)

        class DoneSet(memorymap.DoneSet):
            def doneSet(self, token, error):
                if error:
                    protocol.log("Error from MemoryMap.set", error)
                with lock:
                    lock.notify()

        mm.set(map_id, {memorymap.PROP_FILE_NAME: "/tmp/system.elf"},
               DoneSet())

    with lock:
        protocol.invokeLater(setMap)
        lock.wait(1)
    mmap = mm.get(map_id).get()
    print("Memory map: " + str(mmap))
コード例 #6
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testPathMap(c):
    cmd = sync.CommandControl(c)
    try:
        pm = cmd.PathMap
    except AttributeError:
        # no PathMap service
        return
    lock = threading.Condition()
    from tcf.services import pathmap  # @UnresolvedImport

    def getMap():
        pm = c.getRemoteService(pathmap.NAME)

        class DoneGet(pathmap.DoneGet):
            def doneGet(self, token, error, mmap):
                if error:
                    protocol.log("Error from PathMap.get", error)
                else:
                    print(mmap)
                with lock:
                    lock.notify()

        pm.get(DoneGet())

    with lock:
        protocol.invokeLater(getMap)
        lock.wait(1)

    def setMap():
        pm = c.getRemoteService(pathmap.NAME)

        class DoneSet(pathmap.DoneSet):
            def doneSet(self, token, error):
                if error:
                    protocol.log("Error from PathMap.set", error)
                with lock:
                    lock.notify()

        pm.set({
            pathmap.PROP_SOURCE: "/tmp",
            pathmap.PROP_DESTINATION: "/home"
        }, DoneSet())

    with lock:
        protocol.invokeLater(setMap)
        lock.wait(1)
    mmap = pm.get().get()
    print("Path map: " + str(mmap))
コード例 #7
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testLineNumbers(c):
    if not _suspended:
        return
    from tcf.services import stacktrace  # @UnresolvedImport
    ctl = sync.CommandControl(c)
    stack = ctl.StackTrace
    lineNumbers = ctl.LineNumbers
    for ctx_id in _suspended:
        bt = stack.getChildren(ctx_id).get()
        if bt:
            bt = stack.getContext(bt).get()
            for frame in bt:
                addr = frame.get(stacktrace.PROP_INSTRUCTION_ADDRESS) or 0
                area = lineNumbers.mapToSource(ctx_id, addr, addr + 1).get()
                print("Frame %d - CodeArea: %s" %
                      (frame.get(stacktrace.PROP_LEVEL), area))
コード例 #8
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testEvents(c):
    from tcf.util import event  # @UnresolvedImport
    recorder = event.EventRecorder(c)
    recorder.record("RunControl")
    ctl = sync.CommandControl(c)
    try:
        rc = ctl.RunControl
    except AttributeError:
        # no RunControl service
        return
    ctxs = rc.getChildren(None).get()
    if not ctxs:
        return
    ctx = ctxs[0]
    rc.resume(ctx, 0, 1, None).wait()
    print(recorder)
    rc.suspend(ctx).wait()
    print(recorder)
    recorder.stop()
コード例 #9
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testSyncCommands(c):
    # simplified command execution
    ctl = sync.CommandControl(c)
    try:
        diag = ctl.Diagnostics
    except AttributeError:
        # no Diagnostics service
        return
    s = "Hello TCF World"
    r = diag.echo(s).getE()
    assert s == r
    pi = 3.141592654
    r = diag.echoFP(pi).getE()
    assert pi == r
    e = errors.ErrorReport("Test", errors.TCF_ERROR_OTHER)
    r = diag.echoERR(e.getAttributes()).getE()
    assert e.getAttributes() == r
    print("Diagnostic tests: " + str(diag.getTestList().getE()))

    for ctx_id in _suspended:
        print("Symbols: " + str(ctl.Symbols.list(ctx_id)))
    for ctx_id in _suspended:
        frame_ids = ctl.StackTrace.getChildren(ctx_id).get()
        if frame_ids:
            error, args = ctl.StackTrace.getContext(frame_ids)
            if not error:
                print("Stack contexts: " + str(args))
    try:
        ctl.Breakpoints
    except AttributeError:
        # no Breakpoints service
        return

    def gotBreakpoints(error, bps):
        print("Got breakpoint list: " + str(bps))

    ctl.Breakpoints.getIDs(onDone=gotBreakpoints)
    try:
        print(ctl.Processes.getChildren(None, False))
    except:
        pass  # no Processes service
コード例 #10
0
ファイル: BasicTests.py プロジェクト: w542380601/tcf
def testDisassembly(c):
    if not _suspended:
        return
    ctl = sync.CommandControl(c)
    try:
        dis = ctl.Disassembly
    except AttributeError:
        # no Disassembly service
        return
    for ctx_id in _suspended:
        frames = ctl.StackTrace.getChildren(ctx_id).get()
        if frames:
            frameData = ctl.StackTrace.getContext(frames).get()
            if frameData:
                addr = frameData[0].get("IP")
                if addr:
                    print("Disassemble context %s from 0x%x" % (ctx_id, addr))
                    lines = dis.disassemble(ctx_id, addr, 256, None).get()
                    if lines:
                        for line in lines:
                            print(line)