Пример #1
0
    def __call__(self, args):
        super(GdbCommand, self).__call__(args)
        # We poke around in the ManagedEmulatorTransport, so it's important that we actually have one.
        # Just asserting is okay because this should already be enforced by valid_connections.
        assert isinstance(self.pebble.transport, ManagedEmulatorTransport)
        add_tools_to_path()

        platform = self.pebble.transport.platform
        sdk_version = self.pebble.transport.version
        gdb_port = self.pebble.transport.qemu_gdb_port
        if gdb_port is None:
            raise ToolError("The emulator does not have gdb support. Try killing and re-running it.")

        sdk_root = sdk_manager.path_for_sdk(sdk_version)
        self._fw_elf = os.path.join(sdk_root, 'pebble', platform, 'qemu', '{}_sdk_debug.elf'.format(platform))

        if not os.path.exists(self._fw_elf):
            raise ToolError("SDK {} does not support app debugging. You need at least SDK 3.10.".format(sdk_version))

        app_elf_path = os.path.join(os.getcwd(), 'build', platform, 'pebble-app.elf')
        if not os.path.exists(app_elf_path):
            raise ToolError("No app debugging information available. "
                            "You must be in a project directory and have built the app.")

        gdb_commands = [
            "set charset US-ASCII",  # Avoid a bug in the ancient version of libiconv apple ships.
            "target remote :{}".format(gdb_port),
            "set confirm off",
            self._get_symbol_command(app_elf_path, 'app')
        ]

        # Optionally add the worker symbols, if any exist.
        worker_elf_path = os.path.join(os.getcwd(), 'build', platform, 'pebble-worker.elf')
        if os.path.exists(worker_elf_path):
            gdb_commands.append(self._get_symbol_command(worker_elf_path, 'worker'))

        gdb_commands.extend([
            "set confirm on",
            "break app_crashed",  # app crashes (as of FW 3.10) go through this symbol for our convenience.
            'echo \nPress ctrl-D or type \'quit\' to exit.\n',
            'echo Try `pebble gdb --help` for a short cheat sheet.\n',
        ])

        gdb_args = ['arm-none-eabi-gdb', self._fw_elf, '-q'] + ['--ex={}'.format(x) for x in gdb_commands]

        # Ignore SIGINT, or we'll die every time the user tries to pause execution.
        signal.signal(signal.SIGINT, signal.SIG_IGN)

        subprocess.call(gdb_args)
Пример #2
0
 def __init__(self, pebble, force_colour=None):
     """
     :param pebble: libpebble2.communication.PebbleConnection
     :param force_colour: Bool
     """
     self.pebble = pebble
     self.print_with_colour = force_colour if force_colour is not None else sys.stdout.isatty()
     pebble.send_packet(AppLogShippingControl(enable=True))
     self.handles = []
     self.handles.append(pebble.register_endpoint(AppLogMessage, self.handle_watch_log))
     self.handles.append(pebble.register_transport_endpoint(MessageTargetPhone, WebSocketPhoneAppLog,
                                                            self.handle_phone_log))
     self.handles.append(pebble.register_transport_endpoint(MessageTargetPhone, WebSocketConnectionStatusUpdate,
                                                            self.handle_connection))
     add_tools_to_path()
Пример #3
0
 def __init__(self, pebble, force_colour=None):
     """
     :param pebble: libpebble2.communication.PebbleConnection
     :param force_colour: Bool
     """
     self.pebble = pebble
     self.print_with_colour = force_colour if force_colour is not None else sys.stdout.isatty(
     )
     pebble.send_packet(AppLogShippingControl(enable=True))
     self.handles = []
     self.handles.append(
         pebble.register_endpoint(AppLogMessage, self.handle_watch_log))
     self.handles.append(
         pebble.register_transport_endpoint(MessageTargetPhone,
                                            WebSocketPhoneAppLog,
                                            self.handle_phone_log))
     self.handles.append(
         pebble.register_transport_endpoint(
             MessageTargetPhone, WebSocketConnectionStatusUpdate,
             self.handle_connection))
     add_tools_to_path()
Пример #4
0
    def __call__(self, args):
        super(GdbCommand, self).__call__(args)
        # We poke around in the ManagedEmulatorTransport, so it's important that we actually have one.
        # Just asserting is okay because this should already be enforced by valid_connections.
        assert isinstance(self.pebble.transport, ManagedEmulatorTransport)
        self._ensure_correct_app()
        add_tools_to_path()

        platform = self.pebble.transport.platform
        sdk_version = self.pebble.transport.version
        gdb_port = self.pebble.transport.qemu_gdb_port
        if gdb_port is None:
            raise ToolError(
                "The emulator does not have gdb support. Try killing and re-running it."
            )

        sdk_root = sdk_manager.path_for_sdk(sdk_version)
        self._fw_elf = os.path.join(sdk_root, 'pebble', platform, 'qemu',
                                    '{}_sdk_debug.elf'.format(platform))

        if not os.path.exists(self._fw_elf):
            raise ToolError(
                "SDK {} does not support app debugging. You need at least SDK 3.10."
                .format(sdk_version))

        app_elf_path = os.path.join(os.getcwd(), 'build', platform,
                                    'pebble-app.elf')
        if not os.path.exists(app_elf_path):
            raise ToolError(
                "No app debugging information available. "
                "You must be in a project directory and have built the app.")

        if self.pebble.firmware_version.major >= 4:
            # Type information for symbols is not currently written into the
            # debugging symbols generated by fw_elf_obfuscate.py. We must
            # explicitly tell GDB what type the symbols are so that their values
            # can be read.
            app_load_address = '*(void**)&g_app_load_address'
            worker_load_address = '*(void**)&g_worker_load_address'
        else:
            # The version of fw_elf_obfuscate.py which generated the debugging
            # symbol files for 3.x SDKs wrote out the symbol information for
            # variables in a way that caused them to be unavailable to GDB.
            # We have to use readelf to work around that and get the symbol
            # addresses.
            app_load_address = '(void*){:#x}'.format(
                self._find_legacy_app_load_offset(self._fw_elf, 'app'))
            worker_load_address = '(void*){:#x}'.format(
                self._find_legacy_app_load_offset(self._fw_elf, 'worker'))

        gdb_commands = [
            "set charset US-ASCII",  # Avoid a bug in the ancient version of libiconv apple ships.
            "target remote :{}".format(gdb_port),
            "set confirm off",
            self._get_symbol_command(app_elf_path, app_load_address)
        ]

        # Optionally add the worker symbols, if any exist.
        worker_elf_path = os.path.join(os.getcwd(), 'build', platform,
                                       'pebble-worker.elf')
        if os.path.exists(worker_elf_path):
            gdb_commands.append(
                self._get_symbol_command(worker_elf_path, worker_load_address))

        gdb_commands.extend([
            "set confirm on",
            "break app_crashed",  # app crashes (as of FW 3.10) go through this symbol for our convenience.
            'echo \nPress ctrl-D or type \'quit\' to exit.\n',
            'echo Try `pebble gdb --help` for a short cheat sheet.\n',
        ])

        gdb_args = ['arm-none-eabi-gdb', self._fw_elf, '-q'
                    ] + ['--ex={}'.format(x) for x in gdb_commands]

        # Ignore SIGINT, or we'll die every time the user tries to pause execution.
        signal.signal(signal.SIGINT, signal.SIG_IGN)

        subprocess.call(gdb_args)
Пример #5
0
 def add_arm_tools_to_path(self):
     add_tools_to_path()
Пример #6
0
    def __call__(self, args):
        super(GdbCommand, self).__call__(args)
        # We poke around in the ManagedEmulatorTransport, so it's important that we actually have one.
        # Just asserting is okay because this should already be enforced by valid_connections.
        assert isinstance(self.pebble.transport, ManagedEmulatorTransport)
        self._ensure_correct_app()
        add_tools_to_path()

        platform = self.pebble.transport.platform
        sdk_version = self.pebble.transport.version
        gdb_port = self.pebble.transport.qemu_gdb_port
        if gdb_port is None:
            raise ToolError("The emulator does not have gdb support. Try killing and re-running it.")

        sdk_root = sdk_manager.path_for_sdk(sdk_version)
        self._fw_elf = os.path.join(sdk_root, 'pebble', platform, 'qemu', '{}_sdk_debug.elf'.format(platform))

        if not os.path.exists(self._fw_elf):
            raise ToolError("SDK {} does not support app debugging. You need at least SDK 3.10.".format(sdk_version))

        app_elf_path = os.path.join(os.getcwd(), 'build', platform, 'pebble-app.elf')
        if not os.path.exists(app_elf_path):
            raise ToolError("No app debugging information available. "
                            "You must be in a project directory and have built the app.")

        if self.pebble.firmware_version.major >= 4:
            # Type information for symbols is not currently written into the
            # debugging symbols generated by fw_elf_obfuscate.py. We must
            # explicitly tell GDB what type the symbols are so that their values
            # can be read.
            app_load_address = '*(void**)&g_app_load_address'
            worker_load_address = '*(void**)&g_worker_load_address'
        else:
            # The version of fw_elf_obfuscate.py which generated the debugging
            # symbol files for 3.x SDKs wrote out the symbol information for
            # variables in a way that caused them to be unavailable to GDB.
            # We have to use readelf to work around that and get the symbol
            # addresses.
            app_load_address = '(void*){:#x}'.format(
                    self._find_legacy_app_load_offset(self._fw_elf, 'app'))
            worker_load_address = '(void*){:#x}'.format(
                    self._find_legacy_app_load_offset(self._fw_elf, 'worker'))

        gdb_commands = [
            "set charset US-ASCII",  # Avoid a bug in the ancient version of libiconv apple ships.
            "target remote :{}".format(gdb_port),
            "set confirm off",
            self._get_symbol_command(app_elf_path, app_load_address)
        ]

        # Optionally add the worker symbols, if any exist.
        worker_elf_path = os.path.join(os.getcwd(), 'build', platform, 'pebble-worker.elf')
        if os.path.exists(worker_elf_path):
            gdb_commands.append(self._get_symbol_command(worker_elf_path,
                                                         worker_load_address))

        gdb_commands.extend([
            "set confirm on",
            "break app_crashed",  # app crashes (as of FW 3.10) go through this symbol for our convenience.
            'echo \nPress ctrl-D or type \'quit\' to exit.\n',
            'echo Try `pebble gdb --help` for a short cheat sheet.\n',
        ])

        gdb_args = ['arm-none-eabi-gdb', self._fw_elf, '-q'] + ['--ex={}'.format(x) for x in gdb_commands]

        # Ignore SIGINT, or we'll die every time the user tries to pause execution.
        signal.signal(signal.SIGINT, signal.SIG_IGN)

        subprocess.call(gdb_args)
Пример #7
0
 def add_arm_tools_to_path(self):
     add_tools_to_path()