Exemplo n.º 1
0
    def __call__(self, args):
        BaseCommand.__call__(self, args)
        self.add_arm_tools_to_path()
        sys.path.append(os.path.join(sdk_path(), 'pebble', 'common', 'tools'))

        paths = []
        if args.elf_path is None:
            try:
                project = PebbleProject()
                paths = ['build/{}/pebble-app.elf'.format(x) for x in project.target_platforms]
            except PebbleProjectException:
                raise ToolError("This is not a valid Pebble project. Please instead specify a valid elf path.")
            except Exception as e:
                print(e)
        else:
            paths.append(args.elf_path)

        # This is Super Special Magic of some form that comes from the SDK.
        import binutils

        for path in paths:
            print("\n======{}======".format(path))
            sections = binutils.analyze_elf(path, 'bdt', use_fast_nm=True)

            for s in sections.itervalues():
                s.pprint(args.summary, args.verbose)
Exemplo n.º 2
0
 def _get_project_info(self):
     project = PebbleProject()
     return {
         'uuid': str(project.uuid),
         'app_name': project.long_name,
         'is_watchface': project.is_watchface,
         'type': 'native',
         'sdk': project.sdk_version,
     }
Exemplo n.º 3
0
 def __call__(self, args):
     super(SDKProjectCommand, self).__call__(args)
     try:
         self.project = PebbleProject()
     except PebbleProjectException as e:
         event_map = {
             InvalidProjectException: "sdk_run_without_project",
             InvalidJSONException: "sdk_json_error",
             OutdatedProjectException: "sdk_json_error",
         }
         if type(e) in event_map:
             post_event(event_map[type(e)])
         raise
Exemplo n.º 4
0
 def _maybe_handle_crash(self, packet):
     result = re.search(
         r"(App|Worker) fault! {([0-9a-f-]{36})} PC: (\S+) LR: (\S+)",
         packet.message)
     if result is None:
         return
     crash_uuid = uuid.UUID(result.group(2))
     try:
         project = PebbleProject()
     except PebbleProjectException:
         self._print(packet,
                     "Crashed, but no active project available to desym.")
         return
     if crash_uuid != project.uuid:
         self._print(packet,
                     "An app crashed, but it wasn't the active project.")
         return
     self._handle_crash(packet,
                        result.group(1).lower(), result.group(3),
                        result.group(4))
Exemplo n.º 5
0
    def _ensure_correct_app(self, try_install=True):
        project = PebbleProject()
        if project.project_type != 'native':
            raise ToolError("Only native apps can be debugged using gdb.")

        current_app_uuid = self.pebble.send_and_read(
            AppRunState(data=AppRunStateRequest()), AppRunState).data.uuid
        if current_app_uuid != project.uuid:
            print("Launching {}...".format(project.long_name))
            # Try launching the app we want. This just does nothing if the app doesn't exist.
            # Edge case: the app exists in blobdb but isn't installed. This shouldn't come up with the pebble tool.
            queue = self.pebble.get_endpoint_queue(AppRunState)
            try:
                self.pebble.send_packet(
                    AppRunState(data=AppRunStateStart(uuid=project.uuid)))
                while True:
                    packet = queue.get(timeout=0.5)
                    if isinstance(packet.data, AppRunStateStart
                                  ) and packet.data.uuid == project.uuid:
                        break
            except TimeoutError:
                if try_install:
                    print("App did not launch. Trying to install it...")
                    try:
                        ToolAppInstaller(self.pebble).install()
                    except IOError:
                        raise ToolError(
                            "The app to debug must be built and installed on the watch."
                        )
                    self._ensure_correct_app(try_install=False)
                else:
                    raise ToolError(
                        "The app to debug must be running on the watch to start gdb."
                    )
            finally:
                queue.close()