Esempio n. 1
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)

    core_addr = DeviceDB(args.device_db).get("core")["arguments"]["host"]
    mgmt = CommMgmt(core_addr)
    try:
        if args.action == "start":
            mgmt.start_profiler(args.interval, args.hits_size, args.edges_size)
        elif args.action == "stop":
            mgmt.stop_profiler()
        elif args.action == "save":
            hits, edges = mgmt.get_profile()
            writer = CallgrindWriter(args.output, args.firmware,
                                     not args.no_compression)
            writer.header()
            for addr, count in hits.items():
                writer.hit(addr, count)
            for (caller, callee), count in edges.items():
                writer.edge(caller, callee, count)
    finally:
        mgmt.close()
Esempio n. 2
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)

    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        core_addr = DeviceDB(args.device_db).get("core")["arguments"]["host"]
        mgmt = CommMgmt(core_addr)

        if args.tool == "log":
            if args.action == "set_level":
                mgmt.set_log_level(args.level)
            if args.action == "set_uart_level":
                mgmt.set_uart_log_level(args.level)
            if args.action == "clear":
                mgmt.clear_log()
            if args.action == None:
                print(mgmt.get_log(), end="")

        if args.tool == "config":
            if args.action == "read":
                value = mgmt.config_read(args.key)
                if not value:
                    print("Key {} does not exist".format(args.key))
                else:
                    print(value)
            if args.action == "write":
                for key, value in args.string:
                    mgmt.config_write(key, value.encode("utf-8"))
                for key, filename in args.file:
                    with open(filename, "rb") as fi:
                        mgmt.config_write(key, fi.read())
            if args.action == "remove":
                for key in args.key:
                    mgmt.config_remove(key)
            if args.action == "erase":
                mgmt.config_erase()

        if args.tool == "reboot":
            mgmt.reboot()

        if args.tool == "hotswap":
            mgmt.hotswap(args.image.read())

        if args.tool == "profile":
            if args.action == "start":
                mgmt.start_profiler(args.interval, args.hits_size, args.edges_size)
            elif args.action == "stop":
                mgmt.stop_profiler()
            elif args.action == "save":
                hits, edges = mgmt.get_profile()
                writer = CallgrindWriter(args.output, args.firmware, "or1k-linux",
                                         args.compression, args.demangle)
                writer.header()
                for addr, count in hits.items():
                    writer.hit(addr, count)
                for (caller, callee), count in edges.items():
                    writer.edge(caller, callee, count)

        if args.tool == "debug":
            if args.action == "allocator":
                mgmt.debug_allocator()

    finally:
        device_mgr.close_devices()
Esempio n. 3
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)

    if args.device is None:
        core_addr = DeviceDB(args.device_db).get("core")["arguments"]["host"]
    else:
        core_addr = args.device
    mgmt = CommMgmt(core_addr)

    if args.tool == "log":
        if args.action == "set_level":
            mgmt.set_log_level(args.level)
        if args.action == "set_uart_level":
            mgmt.set_uart_log_level(args.level)
        if args.action == "clear":
            mgmt.clear_log()
        if args.action == None:
            print(mgmt.get_log(), end="")

    if args.tool == "config":
        if args.action == "read":
            value = mgmt.config_read(args.key)
            if not value:
                print("Key {} does not exist".format(args.key))
            else:
                print(value)
        if args.action == "write":
            for key, value in args.string:
                mgmt.config_write(key, value.encode("utf-8"))
            for key, filename in args.file:
                with open(filename, "rb") as fi:
                    mgmt.config_write(key, fi.read())
        if args.action == "remove":
            for key in args.key:
                mgmt.config_remove(key)
        if args.action == "erase":
            mgmt.config_erase()

    if args.tool == "reboot":
        mgmt.reboot()

    if args.tool == "hotswap":
        mgmt.hotswap(args.image.read())

    if args.tool == "profile":
        if args.action == "start":
            mgmt.start_profiler(args.interval, args.hits_size, args.edges_size)
        elif args.action == "stop":
            mgmt.stop_profiler()
        elif args.action == "save":
            hits, edges = mgmt.get_profile()
            writer = CallgrindWriter(args.output, args.firmware, "or1k-linux",
                                     args.compression, args.demangle)
            writer.header()
            for addr, count in hits.items():
                writer.hit(addr, count)
            for (caller, callee), count in edges.items():
                writer.edge(caller, callee, count)

    if args.tool == "debug":
        if args.action == "allocator":
            mgmt.debug_allocator()