## Commands of μCsim to manage breakpoints

Two kind of breakpoint can be used: fetch and event breakpoint. Fetch breakpoints are classical breakpoints. They can be placed at any instruction in the code memory. Breakpoint will be hit if CPU fetches instruction code from the memory location specified by the breakpoint. Only fetching of first byte of the instruction hits the breakpoint. If the execution reaches a breakpoint it stops before the instruction at location specified by the breakpoint would be executed.

Event breakpoints are special onces. They cause stop of execution if event specified by the breakpoint occurs. Event can be a read or a write operation on any address space location. Event breakpoint stops execution after specified event occurred.

Every breakpoint can be fix (permanent) or dynamic (temporary). Dynamic breakpoints are automatically removed when they reached. Some commands place dynamic fetch breakpoints into the code, for example go or next.

A hit number can be associated to any breakpoint. This hit number specifies how many times the breakpoint must be hit before it causes the execution to stop. This hit number is 1 by default.

### break addr [hit] [if expression]
break memory_type r|w addr [hit] [if expression]

### tbreak addr [hit] [if expression]
tbreak memory_type r|w addr [hit] [if expression]

Set fetch or event breakpoint. The command specifies if the breakpoint will be fix (break) or dynamic (temporary) (tbreak).

Fetch or event breakpoint can be defined. First form defines fetch while second form defines event breakpoint.

Fetch breakpoint
  First parameter specifies address where the breakpoint must be placed to. It should be address of an instruction.
  Second parameter is optional and it specifies the hit number. It is 1 by default.
Event breakpoint
  First parameter specifies class name of memory where we are going to watch for en event. Class names of memories can be checked by info memory command.
  Second parameter specifies the event. It can be r to specify read operation or w which means write operation.
  Remaining parameters are address of watched memory location and an optional hit number (1 by default).

    $ s51 remoansi.hex
    ucsim 0.2.24, Copyright (C) 1997 Daniel Drotos, Talker Bt.
    ucsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.
    58659 bytes read from remoansi.hex
    > dc 0 0x10
       000000 02 01 60 LJMP  0160
     * 000003 02 00 3c LJMP  003c
     * 000006 ff       MOV   R7,A
     * 000007 ff       MOV   R7,A
     * 000008 ff       MOV   R7,A
     * 000009 ff       MOV   R7,A
     * 00000a ff       MOV   R7,A
     * 00000b 02 3b e0 LJMP  3be0
     * 00000e ff       MOV   R7,A
     * 00000f ff       MOV   R7,A
     * 000010 ff       MOV   R7,A
    > break 0x160
    Breakpoint 1 at 0x000160: CLR   P1.0
    > tbreak 8 2
    Breakpoint 2 at 0x000008: MOV   R7,A
    > g
    Simulation started, PC=0x000000
    Stop at 000160: (4) Breakpoint
    F 000160
    >

### clear [addr...]

Delete fetch breakpoint. Parameter specifies address of breakpoint. If there is no breakpoint specified at given address this command prints out a warning message.

If parameter is not given then breakpoint at current PC will be deleted if it exists. If more than one address is specified then all breakpoints at specified addresses will be deleted.

    > i b
    Num Type       Disp Hit   Cnt   Address  What
    1   fetch      keep 1     1     0x000160 CLR   P1.0
    2   fetch      del  1     1     0x000180 LJMP  022a
    1   event      keep 1     1     0x000006 wi
    > clear 160
    No breakpoint at 0000a0
    > clear 0x160
    > i b
    Num Type       Disp Hit   Cnt   Address  What
    2   fetch      del  1     1     0x000180 LJMP  022a
    1   event      keep 1     1     0x000006 wi
    >

### delete [number...]

Delete breakpoint(s) by its number.

If parameter is not used then all breakpoints are deleted.

### commands script