Пример #1
0
 def do_include_path(cls, args):
     sdk = args.sdk or sdk_manager.get_current_sdk()
     path = sdk_manager.path_for_sdk(sdk)
     path = os.path.join(path, "pebble", args.platform, "include")
     if not os.path.exists(path):
         raise MissingSDK("No platform '{}' available for SDK {}".format(args.platform, sdk))
     print(path)
Пример #2
0
 def do_include_path(cls, args):
     sdk = args.sdk or sdk_manager.get_current_sdk()
     path = sdk_manager.path_for_sdk(sdk)
     path = os.path.join(path, "pebble", args.platform, "include")
     if not os.path.exists(path):
         raise MissingSDK("No platform '{}' available for SDK {}".format(
             args.platform, sdk))
     print(path)
Пример #3
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)

        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)
        fw_elf = os.path.join(sdk_root, 'pebble', platform, 'qemu',
                              '{}_sdk_debug.elf'.format(platform))
        if not os.path.exists(fw_elf):
            raise ToolError(
                "SDK {} does not support app debugging. You need at least SDK 3.10."
                .format(sdk_version))

        base_address = self._find_app_load_offset(fw_elf)

        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.")

        offsets = self._find_real_app_section_offsets(base_address,
                                                      app_elf_path)

        gdb_commands = [
            "target remote :{}".format(gdb_port),
            "set confirm off",
            'add-symbol-file "{elf}" {text} -s .data {data} -s .bss {bss}'.
            format(elf=app_elf_path, **offsets),
            "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', 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)
Пример #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)
        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)
Пример #5
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)

        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)
        fw_elf = os.path.join(sdk_root, 'pebble', platform, 'qemu', '{}_sdk_debug.elf'.format(platform))
        if not os.path.exists(fw_elf):
            raise ToolError("SDK {} does not support app debugging. You need at least SDK 3.10.".format(sdk_version))

        base_address = self._find_app_load_offset(fw_elf)

        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.")

        offsets = self._find_real_app_section_offsets(base_address, app_elf_path)

        gdb_commands = [
            "target remote :{}".format(gdb_port),
            "set confirm off",
            'add-symbol-file "{elf}" {text} -s .data {data} -s .bss {bss}'.format(elf=app_elf_path, **offsets),
            "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', 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)
Пример #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 get_sdk_path(self):
     path = sdk_manager.path_for_sdk(self.sdk) if self.sdk is not None else sdk_path()
     logger.debug("SDK path: %s", path)
     if not os.path.exists(os.path.join(path, "pebble", "waf")):
         raise MissingSDK("SDK unavailable; can't run this command.")
     return path
Пример #8
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)
Пример #9
0
 def get_sdk_path(self):
     path = sdk_manager.path_for_sdk(self.sdk) if self.sdk is not None else sdk_path()
     logger.debug("SDK path: %s", path)
     if not os.path.exists(os.path.join(path, 'pebble', 'waf')):
         raise MissingSDK("SDK unavailable; can't run this command.")
     return path