Exemplo n.º 1
0
    def run(self):
        self.args = self.build_parser().parse_args()
        self.gdb_server_settings = self.get_gdb_server_settings(self.args)
        self.setup_logging(self.args)

        self.process_commands(self.args.commands)

        gdb = None
        if self.args.list_all == True:
            MbedBoard.listConnectedBoards()
        else:
            try:
                board_selected = MbedBoard.chooseBoard(
                    board_id=self.args.board_id,
                    target_override=self.args.target_override,
                    frequency=self.args.frequency)
                with board_selected as board:
                    # Boost speed with deferred transfers
                    board.transport.setDeferredTransfer(True)
                    gdb = GDBServer(board, self.args.port_number,
                                    self.gdb_server_settings)
                    while gdb.isAlive():
                        gdb.join(timeout=0.5)
            except KeyboardInterrupt:
                if gdb != None:
                    gdb.stop()
            except Exception as e:
                print "uncaught exception: %s" % e
                traceback.print_exc()
                if gdb != None:
                    gdb.stop()
                return 1

        # Successful exit.
        return 0
Exemplo n.º 2
0
def _launchPyOCDGDBServer(msg_queue):
    logger.info('starting PyOCD gdbserver...')
    # ignore Ctrl-C, so we don't interrupt the GDB server when the
    # being-debugged program is being stopped:
    signal.signal(signal.SIGINT, _ignoreSignal);
    from pyOCD.gdbserver import GDBServer
    from pyOCD.board import MbedBoard
    gdb = None
    try:
        board_selected = MbedBoard.chooseBoard()
        with board_selected as board:
            gdb = GDBServer(
                board, 3333, {
                     'break_at_hardfault': True,
                    'step_into_interrupt': False,
                         'break_on_reset': False,
                }
            )
            if gdb.isAlive():
                msg_queue.put('alive')
                while gdb.isAlive():
                    gdb.join(timeout = 0.5)
                    # check for a "kill" message from the parent process:
                    try:
                        msg = msg_queue.get(False)
                        if msg == 'kill':
                            gdb.stop()
                            break
                    except Queue.Empty:
                        pass
    except Exception as e:
        if gdb != None:
            gdb.stop()
        raise
    msg_queue.put('dead')
Exemplo n.º 3
0
def main():
    args = parser.parse_args()
    gdb_server_settings = get_gdb_server_settings(args)
    setup_logging(args)

    gdb = None
    if args.list_all == True:
        MbedBoard.listConnectedBoards()
    else:
        try:
            board_selected = MbedBoard.chooseBoard(
                board_id=args.board_id,
                target_override=args.target_override,
                frequency=args.frequency)
            with board_selected as board:
                # Boost speed with deferred transfers
                board.transport.setDeferredTransfer(True)
                gdb = GDBServer(board, args.port_number, gdb_server_settings)
                while gdb.isAlive():
                    gdb.join(timeout=0.5)
        except KeyboardInterrupt:
            if gdb != None:
                gdb.stop()
        except Exception as e:
            print "uncaught exception: %s" % e
            traceback.print_exc()
            if gdb != None:
                gdb.stop()
Exemplo n.º 4
0
def main():
    args = parser.parse_args()
    gdb_server_settings = get_gdb_server_settings(args)
    setup_logging(args)

    gdb = None
    if args.list_all == True:
        MbedBoard.listConnectedBoards()
    else:
        try:
            board_selected = MbedBoard.chooseBoard(
                board_id=args.board_id,
                target_override=args.target_override,
                frequency=args.frequency)
            with board_selected as board:
                # Boost speed with deferred transfers
                board.transport.setDeferredTransfer(True)
                gdb = GDBServer(board, args.port_number, gdb_server_settings)
                while gdb.isAlive():
                    gdb.join(timeout=0.5)
        except KeyboardInterrupt:
            if gdb != None:
                gdb.stop()
        except Exception as e:
            print "uncaught exception: %s" % e
            traceback.print_exc()
            if gdb != None:
                gdb.stop()
Exemplo n.º 5
0
    def run(self):
        self.args = self.build_parser().parse_args()
        self.gdb_server_settings = self.get_gdb_server_settings(self.args)
        self.setup_logging(self.args)

        self.process_commands(self.args.commands)

        gdb = None
        if self.args.list_all == True:
            MbedBoard.listConnectedBoards()
        else:
            try:
                board_selected = MbedBoard.chooseBoard(
                    board_id=self.args.board_id,
                    target_override=self.args.target_override,
                    frequency=self.args.frequency)
                with board_selected as board:
                    # Boost speed with deferred transfers
                    board.transport.setDeferredTransfer(True)
                    gdb = GDBServer(board, self.args.port_number, self.gdb_server_settings)
                    while gdb.isAlive():
                        gdb.join(timeout=0.5)
            except KeyboardInterrupt:
                if gdb != None:
                    gdb.stop()
            except Exception as e:
                print "uncaught exception: %s" % e
                traceback.print_exc()
                if gdb != None:
                    gdb.stop()
                return 1

        # Successful exit.
        return 0
Exemplo n.º 6
0
    def run(self, args=None):
        try:
            self.args = self.build_parser().parse_args(args)
            self.gdb_server_settings = self.get_gdb_server_settings(self.args)
            self.setup_logging(self.args)
            DAPAccess.set_args(self.args.daparg)

            self.process_commands(self.args.commands)

            gdb = None
            gdbs = []
            if self.args.list_all == True:
                self.list_boards()
            elif self.args.list_targets == True:
                self.list_targets()
            else:
                try:
                    board_selected = MbedBoard.chooseBoard(
                        board_id=self.args.board_id,
                        target_override=self.args.target_override,
                        frequency=self.args.frequency)
                    if board_selected is None:
                        print("No board selected")
                        return 1
                    with board_selected as board:
                        baseTelnetPort = self.gdb_server_settings['telnet_port']
                        for core_number, core in board.target.cores.iteritems():
                            self.gdb_server_settings['telnet_port'] = baseTelnetPort + core_number
                            gdb = GDBServer(board, self.args.port_number + core_number, self.gdb_server_settings, core=core_number)
                            gdbs.append(gdb)
                        gdb = gdbs[0]
                        while gdb.isAlive():
                            gdb.join(timeout=0.5)
                except KeyboardInterrupt:
                    for gdb in gdbs:
                        gdb.stop()
                except Exception as e:
                    print("uncaught exception: %s" % e)
                    traceback.print_exc()
                    for gdb in gdbs:
                        gdb.stop()
                    return 1

            # Successful exit.
            return 0
        except InvalidArgumentError as e:
            self.parser.error(e)
            return 1
Exemplo n.º 7
0
    def run(self, args=None):
        try:
            self.args = self.build_parser().parse_args(args)
            self.gdb_server_settings = self.get_gdb_server_settings(self.args)
            self.setup_logging(self.args)
            DAPAccess.set_args(self.args.daparg)

            self.process_commands(self.args.commands)

            gdb = None
            if self.args.list_all == True:
                self.list_boards()
            elif self.args.list_targets == True:
                self.list_targets()
            else:
                try:
                    board_selected = MbedBoard.chooseBoard(
                        board_id=self.args.board_id,
                        target_override=self.args.target_override,
                        frequency=self.args.frequency)
                    if board_selected is None:
                        print "No board selected"
                        return 1
                    with board_selected as board:
                        gdb = GDBServer(board, self.args.port_number,
                                        self.gdb_server_settings)
                        while gdb.isAlive():
                            gdb.join(timeout=0.5)
                except KeyboardInterrupt:
                    if gdb != None:
                        gdb.stop()
                except Exception as e:
                    print "uncaught exception: %s" % e
                    traceback.print_exc()
                    if gdb != None:
                        gdb.stop()
                    return 1

            # Successful exit.
            return 0
        except InvalidArgumentError as e:
            self.parser.error(e)
            return 1
Exemplo n.º 8
0
def _launchPyOCDGDBServer(msg_queue):
    logger.info('preparing PyOCD gdbserver...')
    from pyOCD.gdbserver import GDBServer
    from pyOCD.board import MbedBoard
    gdb = None
    try:
        logger.info('finding connected board...')
        board_selected = MbedBoard.chooseBoard(blocking=False)
        if board_selected is not None:
            with board_selected as board:
                logger.info('starting PyOCD gdbserver...')
                gdb = GDBServer(
                    board, 3333, {
                         'break_at_hardfault': True,
                        'step_into_interrupt': False,
                             'break_on_reset': False,
                    }
                )
                if gdb.isAlive():
                    msg_queue.put('alive')
                    while gdb.isAlive():
                        gdb.join(timeout = 0.5)
                        # check for a "kill" message from the parent process:
                        try:
                            msg = msg_queue.get(False)
                            if msg == 'kill':
                                gdb.stop()
                                break
                        except Queue.Empty:
                            pass
        else:
            logger.error('failed to find a connected board')
    except Exception as e:
        logger.error('exception in GDB server thread: %s', e)
        if gdb != None:
            gdb.stop()
        raise
    msg_queue.put('dead')
Exemplo n.º 9
0
    def run(self, args=None):
        try:
            self.args = self.build_parser().parse_args(args)
            self.gdb_server_settings = self.get_gdb_server_settings(self.args)
            self.setup_logging(self.args)
            DAPAccess.set_args(self.args.daparg)

            self.process_commands(self.args.commands)

            gdb = None
            if self.args.list_all == True:
                self.list_boards()
            elif self.args.list_targets == True:
                self.list_targets()
            else:
                try:
                    board_selected = MbedBoard.chooseBoard(
                        board_id=self.args.board_id,
                        target_override=self.args.target_override,
                        frequency=self.args.frequency)
                    with board_selected as board:
                        gdb = GDBServer(board, self.args.port_number, self.gdb_server_settings)
                        while gdb.isAlive():
                            gdb.join(timeout=0.5)
                except KeyboardInterrupt:
                    if gdb != None:
                        gdb.stop()
                except Exception as e:
                    print "uncaught exception: %s" % e
                    traceback.print_exc()
                    if gdb != None:
                        gdb.stop()
                    return 1

            # Successful exit.
            return 0
        except InvalidArgumentError as e:
            self.parser.error(e)
            return 1
Exemplo n.º 10
0
    def run(self):
        self.args = self.build_parser().parse_args()
        self.gdb_server_settings = self.get_gdb_server_settings(self.args)
        self.setup_logging(self.args)

        self.process_commands(self.args.commands)

        gdb = None
        if self.args.list_all == True:
            print("Supported modules:")
            for module in lipicano_board.MODULES.values():
                print("- %s" % module.name)
        else:
            board_selected = lipicano_board.get_lipicano_board()
            if (board_selected == None):
                print("Lipicano or supported module not found.")
                return
            board_selected.init()
            try:
                with board_selected as board:
                    # Boost speed with deferred transfers
                    board.transport.setDeferredTransfer(True)
                    gdb = GDBServer(board, self.args.port_number, self.gdb_server_settings)
                    while gdb.isAlive():
                        gdb.join(timeout=0.5)
            except KeyboardInterrupt:
                if gdb != None:
                    gdb.stop()
            except Exception as e:
                print "uncaught exception: %s" % e
                traceback.print_exc()
                if gdb != None:
                    gdb.stop()
                return 1

        # Successful exit.
        return 0
Exemplo n.º 11
0
from pyOCD.gdbserver import GDBServer
from pyOCD.board import MbedBoard

import logging
logging.basicConfig(level=logging.INFO)

board = MbedBoard.chooseBoard()

# start gdbserver
gdb = GDBServer(board, 3333)
Exemplo n.º 12
0
                  "--target",
                  dest="target_override",
                  default=None,
                  help="Override target to debug")
(option, args) = parser.parse_args()

gdb = None
level = LEVELS.get(option.debug_level, logging.NOTSET)
logging.basicConfig(level=level)
if option.list_all == True:
    MbedBoard.listConnectedBoards()
else:
    try:
        board_selected = MbedBoard.chooseBoard(
            board_id=option.board_id, target_override=option.target_override)
        if board_selected != None:
            try:
                gdb = GDBServer(board_selected, int(option.port_number))
                while gdb.isAlive():
                    gdb.join(timeout=0.5)
            except ValueError:
                logging.error("Port number error!")
    except KeyboardInterrupt:
        if gdb != None:
            gdb.stop()
    except Exception as e:
        print "uncaught exception: %s" % e
        traceback.print_exc()
        if gdb != None:
            gdb.stop()
Exemplo n.º 13
0
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

import logging

from pyOCD.gdbserver import GDBServer
from pyOCD.board import MbedBoard

logging.basicConfig(level=logging.INFO)

try:
    board_selected = MbedBoard.chooseBoard()
    if board_selected != None:
        gdb = GDBServer(board_selected, 3333)
        while gdb.isAlive():
            gdb.join(timeout = 0.5)

except KeyboardInterrupt:
    gdb.stop()
except Exception as e:
    print "uncaught exception: %s" % e
    gdb.stop()
Exemplo n.º 14
0
gdb = None
level = LEVELS.get(option.debug_level, logging.NOTSET)
logging.basicConfig(level=level)
if option.list_all == True:
    MbedBoard.listConnectedBoards()
else:
    try:
        board_selected = MbedBoard.chooseBoard(
            board_id=option.board_id,
            target_override=option.target_override,
            frequency=option.debug_clock_frequency)
        print board_selected
        with board_selected as board:
            gdb = GDBServer(
                board, int(option.port_number), {
                    'break_at_hardfault': option.break_at_hardfault,
                    'step_into_interrupt': option.step_into_interrupt,
                    'break_on_reset': option.break_on_reset,
                    'persist': option.persist
                })
            while gdb.isAlive():
                gdb.join(timeout=0.5)
    except KeyboardInterrupt:
        if gdb != None:
            gdb.stop()
    except Exception as e:
        print "uncaught exception: %s" % e
        traceback.print_exc()
        if gdb != None:
            gdb.stop()
Exemplo n.º 15
0
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

import logging

from pyOCD.gdbserver import GDBServer
from pyOCD.board import MbedBoard

logging.basicConfig(level=logging.INFO)

try:
    board_selected = MbedBoard.chooseBoard()
    if board_selected != None:
        gdb = GDBServer(board_selected, 3333)
        while gdb.isAlive():
            gdb.join(timeout = 0.5)

except KeyboardInterrupt:
    gdb.stop()
except Exception as e:
    print "uncaught exception: %s" % e
    gdb.stop()
Exemplo n.º 16
0
    "Disable breakpoint at hardfault handler. Required for nrf51 chip with SoftDevice based application."
)
(option, args) = parser.parse_args()

gdb = None
level = LEVELS.get(option.debug_level, logging.NOTSET)
logging.basicConfig(level=level)
if option.list_all == True:
    MbedBoard.listConnectedBoards()
else:
    try:
        board_selected = MbedBoard.chooseBoard(
            board_id=option.board_id, target_override=option.target_override)
        if board_selected != None:
            try:
                gdb = GDBServer(
                    board_selected, int(option.port_number),
                    {'break_at_hardfault': option.break_at_hardfault})
                while gdb.isAlive():
                    gdb.join(timeout=0.5)
            except ValueError:
                logging.error("Port number error!")
    except KeyboardInterrupt:
        if gdb != None:
            gdb.stop()
    except Exception as e:
        print "uncaught exception: %s" % e
        traceback.print_exc()
        if gdb != None:
            gdb.stop()