! @brief Handle 'gdbserver' subcommand.

def do_gdbserver(self):
        """! @brief Handle 'gdbserver' subcommand."""
        self._process_commands(self._args.commands)

        gdbs = []
        try:
            # Build dict of session options.
            sessionOptions = convert_session_options(self._args.options)
            sessionOptions.update({
                'gdbserver_port' : self._args.port_number,
                'telnet_port' : self._args.telnet_port,
                'persist' : self._args.persist,
                'step_into_interrupt' : self._args.step_into_interrupt,
                'chip_erase': ERASE_OPTIONS[self._args.erase],
                'fast_program' : self._args.trust_crc,
                'enable_semihosting' : self._args.enable_semihosting,
                'serve_local_only' : self._args.serve_local_only,
                'vector_catch' : self._args.vector_catch,
                })
            
            session = ConnectHelper.session_with_chosen_probe(
                blocking=(not self._args.no_wait),
                project_dir=self._args.project_dir,
                user_script=self._args.script,
                config_file=self._args.config,
                no_config=self._args.no_config,
                pack=self._args.pack,
                unique_id=self._args.unique_id,
                target_override=self._args.target_override,
                frequency=self._args.frequency,
                **sessionOptions)
            if session is None:
                LOG.error("No probe selected.")
                return
            with session:
                # Set ELF if provided.
                if self._args.elf:
                    session.board.target.elf = self._args.elf
                for core_number, core in session.board.target.cores.items():
                    gdb = GDBServer(session,
                        core=core_number,
                        server_listening_callback=self.server_listening)
                    gdbs.append(gdb)
                gdb = gdbs[0]
                while gdb.isAlive():
                    gdb.join(timeout=0.5)
        except (KeyboardInterrupt, Exception):
            for gdb in gdbs:
                gdb.stop()
            raise