Esempio n. 1
0
    def add_bpt_mem(self,
                    address,
                    memory_space=None,
                    on_read=True,
                    on_write=True,
                    on_modify=True):
        """
        Set a new breakpoint, which will be hit when a memory location is accessed

        :param address:
            The address to set the breakpoint on

        :param memory_space:
            The name of the memory space that ``address`` is in.
            If None, the current memory space of the core is used

        :param on_read:
            If True, the breakpoint will be triggered when the memory location
            is read from.

        :param on_write:
            If True, the breakpoint will be triggered when the memory location
            is written to.

        :param on_modify:
            If True, the breakpoint will be triggered when the memory location
            is modified.
        """

        space = self._get_address_space(memory_space)

        cadi_address = CADI.CADIAddrComplete(
            CADI.CADI_NO_OVERLAY, CADI.CADIAddr(space.memSpaceId, address))

        trigger_type = 0
        if on_read:
            trigger_type |= CADI.CADI_BPT_TRIGGER_ON_READ
        if on_write:
            trigger_type |= CADI.CADI_BPT_TRIGGER_ON_WRITE
        if on_modify:
            trigger_type |= CADI.CADI_BPT_TRIGGER_ON_MODIFY

        if trigger_type == 0:
            raise ValueError(
                "At least one of on_read, on_write and on_modify must be True")

        request = CADI.CADIBptRequest(enabled_par=1,
                                      type_par=CADI.CADI_BPT_MEMORY,
                                      address_par=cadi_address,
                                      triggerType_par=trigger_type)
        bpt = Breakpoint(self, self.__cadi, request)
        self.breakpoints[bpt.number] = bpt
        return self.breakpoints[bpt.number]
Esempio n. 2
0
    def add_bpt_reg(self,
                    reg_name,
                    on_read=True,
                    on_write=True,
                    on_modify=True):
        """
        Set a new breakpoint, which will be hit when a register is accessed

        :param reg_name:
            The name of the register to set the breakpoint on.
            The name can be in one of the following formats:
                * ``<group>.<register>``
                * ``<group>.<register>.<field>``
                * ``<register>``
                * ``<register>.<field>``
            
            The last two forms can only be used if the register name is unambiguous

        :param on_read:
            If True, the breakpoint will be triggered when the register is read from.

        :param on_write:
            If True, the breakpoint will be triggered when the register is written to.

        :param on_modify:
            If True, the breakpoint will be triggered when the register is modified.
        """

        # No ARM models support register breakpoints (as of Apr 2013), so this is untested
        register = self._get_register_by_name(reg_name)

        trigger_type = 0
        if on_read:
            trigger_type |= CADI.CADI_BPT_TRIGGER_ON_READ
        if on_write:
            trigger_type |= CADI.CADI_BPT_TRIGGER_ON_WRITE
        if on_modify:
            trigger_type |= CADI.CADI_BPT_TRIGGER_ON_MODIFY

        if trigger_type == 0:
            raise ValueError(
                "At least one of on_read, on_write and on_modify must be True")

        request = CADI.CADIBptRequest(enabled_par=1,
                                      type_par=CADI.CADI_BPT_REGISTER,
                                      regNumber_par=register._info.regNumber,
                                      triggerType_par=trigger_type)

        bpt = Breakpoint(self, self.__cadi, request)
        self.breakpoints[bpt.number] = bpt
        return self.breakpoints[bpt.number]
Esempio n. 3
0
    def add_bpt_prog(self, address, memory_space=None):
        """
        Set a new breakpoint, which will be hit when program execution reaches a memory address

        :param address:
            The address to set the breakpoint on

        :param memory_space:
            The name of the memory space that ``address`` is in.
            If None, the current memory space of the core is used
        """

        space = self._get_address_space(memory_space)

        cadi_address = CADI.CADIAddrComplete(
            CADI.CADI_NO_OVERLAY, CADI.CADIAddr(space.memSpaceId, address))
        request = CADI.CADIBptRequest(enabled_par=1,
                                      type_par=CADI.CADI_BPT_PROGRAM,
                                      address_par=cadi_address)
        bpt = Breakpoint(self, self.__cadi, request)
        self.breakpoints[bpt.number] = bpt
        return self.breakpoints[bpt.number]