Keil Logo

BreakSet

Syntax Description
BreakSet exp , cnt , "cmd" Sets an execution or conditional breakpoint.
BreakSet READ exp , cnt , "cmd" Sets a read access breakpoint.
BreakSet WRITE exp , cnt , "cmd" Sets a write access breakpoint.
BreakSet READWRITE exp , cnt , "cmd" Sets a read/write access breakpoint.

The BreakSet command sets a breakpoint for the specified expression (exp). Breakpoints are program addresses or expressions that, when true, halt execution of your target program or execute a specified command.

You may specify the following parameters for a breakpoint definition:

where:  
exp is an address specification or an expression that µVision3 evaluates during execution.
cnt is an expression that determines the number of times a breakpoint condition is met before the target program halts or the specified command is executed. The default count value is 1.
cmd is a command string that specifies a µVision3 command to execute when the breakpoint occurs. When no command is specified, µVision3 halts program execution when a breakpoint occurs. If a command is specified, µVision3 only executes the command and the target program does not stop. The command may specify a µVision3 user or signal function. You may set the _break_ variable to 1 to halt program execution.

µVision3 recognizes three types of breakpoints: execution breakpoints, conditional breakpoints, and access breakpoints. µVision3 categorizes each breakpoint using the following rules:

  1. When a memory access mode (READ, WRITE, or READWRITE) is specified, the breakpoint is an access breakpoint.
  2. When the specified expression is a simple address, the breakpoint is an execution breakpoint.
  3. When the specified expression cannot be reduced to an address, the breakpoint is a conditional breakpoint.

The breakpoint types are described below.

Execution Breakpoints

Execution breakpoints halt program execution or execute a command when the specified code address is reached. Execution speed is not affected by execution breakpoints.

The code address specified must be the first byte of an instruction. If you set an execution breakpoint on the second or third byte of an instruction, the breakpoint never occurs.

An execution breakpoint for a code address may be specified only once. Multiple definitions are not allowed.

Conditional Breakpoints

Conditional breakpoints halt program execution or execute a command when a specified conditional expression is true. The conditional expression is recalculated after each assembly instruction. Program execution speed may slow down considerably depending on the complexity of the conditional expression. Execution speed is also affected by the number of conditional breakpoints.

Conditional breakpoints are the most flexible type of breakpoint since optional conditions may be calculated by the expression.

Access Breakpoints

Memory access breakpoints halt program execution or execute a command when a specific address is read, written, or accessed or when a specific address is read or written with a certain value. Program execution speed is not dramatically affected by memory access breakpoints since access expressions are evaluated only with the specified access event occurs.

Expressions specified for memory access breakpoints must reduce to a memory address and memory type. The following rules apply to memory access breakpoints:

  1. Expressions used in a memory access breakpoint must have unique memory types. Expressions that include multiple objects are not allowed.
  2. Only a few operators (&, &&, <, <=, >, >=, ==, and !=) are allowed in a memory access breakpoint expression.

For example, the following breakpoint:

BS WRITE time.sec                      /* Valid expression   */

is valid while the following breakpoint:

BS WRITE time.sec + i0                 /* Invalid expression */

is invalid because adding two values (timer.sec and i0) does not result in a memory type.

Note

  • When listed using the BreakList command, memory access breakpoints are preceded by READ, WRITE, or READWRITE.
Example

The following example sets an execution breakpoint on the address of the main function.

>BS main

The following example sets an execution breakpoint on the address of the timer0 function. The breakpoint occurs and the command "MyRegs()" is executed only after the 10th invocation of timer0. Program execution continues after the command executes.

>BS timer0,10,"MyRegs()"

The following example sets a conditional breakpoint on the sindex symbol. When sindex is equal to 8, program execution halts.

>BS sindex == 8

The following example sets a conditional breakpoint on the save_record array. Program execution halts on the third time save_record[5].time.sec is greater than 3.

>BS save_record[5].time.sec > 5, 3

The following example sets a memory access breakpoint on READ accesses of the interval.min symbol. Program execution halts when the min element of the interval structure or union is 3.

>BS READ interval.min == 3

The following example sets a memory access breakpoint on WRITE accesses to the savefirst symbol. Program execution halts when savefirst is 5 and the accumulator (acc) is 0x12 after savefirst is written.

>BS WRITE savefirst == 5 && acc == 0x12

You may also define breakpoints via the Breakpoints dialog. This dialog opens from the main menu with Debug — Breakpoints....

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.