CAPITULO II: MARCO TEÓRICO CIENTÍFICO
2.5. DEFINICIONES OPERACIONALES
This section provides information about running your application in the debug context, including:
● Run commands ● Stepping modes
● Program and STVD status bar display ● Monitoring execution in source windows
5.3.1 Run commands
The commands available in the Debug menu and on the Debug toolbar are listed in
Table 60.
Table 60. Debug menu run commands
Command Description
Start Debugging
Start a debugging session. In order to start a debug session, you must have built your application into an executable, specified a debug instrument that supports the application’s target MCU and specified the connection port for the debug instrument.
Stop Debugging End the debugging session. You cannot build your application or change the target MCU
while a debugging session is open.
Go to PC (Program Counter)
The program information displayed in the STVD windows is modified to show the program environment and values as they should be at the current source code statement pointed to by the PC. This command may be used to retrieve the current source code statements after having scrolled in the source file, or after changing source file viewing.
Run Resets the microcontroller and executes the application.
Restart
Resets the PC to first instruction of the main function for applications in C language. For applications in Assembly, the PC is set to the first instruction of the function labelled main, if one exists.
Chip Reset Resets the microcontroller. The PC is reset to the beginning of the startup routine.
Continue
Continues execution of the application from the position at which it is halted. When execution has stopped at a breakpoint, it will be continued from the following instruction (as if no break occurred).
Stop Stops program execution.
Step Into, Step Over, Step Out: These three commands permit enhanced control of single-stepping. Each
The commands Go To PC, Run to Cursor and Set PC are also available in the Editor contextual menu for ease of access when using the Editor during debugging.
5.3.2 Stepping modes
For the Step Over and Step Into commands, you can choose one of two modes of
execution. To change the modes, select Debug Instrument>Stepping Mode, the resulting dialog box will allow you to select either:
● Enter Interrupts When Stepping Into: This is the default mode. In this mode, STVD uses the debug instrument’s primitive single step to execute one assembler step at a time. When Stepping Into, STVD will stop at the entry of any interrupts that occur during the stepping process.
● Don’t Enter Interrupts When Stepping Into: In this mode, to step through a single assembler instruction, STVD sets an instruction breakpoint on the next instruction to be executed if no interrupt occurs. It then runs the application up to this breakpoint. When Stepping Into, STVD will not stop at any interrupts that occur during this stepping process, unless you have placed a breakpoint there prior to executing the step command.
Limitations:
– Cannot handle an instruction that jumps to itself only once. In this case, the instruction is executed again and again. As a result stepping into or over such an instruction (Step Into ASM or Step Over ASM) does not work as expected.
Step Over:
To avoid single-stepping through functions that are not relevant to the debug operation. When a function call occurs, the command Step Over will cause the program to execute the function, update the program data displayed by STVD and stop at the next instruction line in the main program. This avoids having to single-step line by line through a function call which is not of current interest (for example already debugged).
Step Into:
This command single-steps each time it is employed, so at a function call it will single step line by line through the function which has been called. It is equivalent to, and replaces, a Single Step command.
Step Out:
When used inside a function, the Step Out command runs the executable to the point of return from the function call and then updates program data.
In all three cases, the program data is updated to reflect the new PC location after execution of the step command. This corresponds to the values which would exist at that PC location if the program were running normally.
Run to Cursor
This command runs the program from the current Program Counter location to the executable code corresponding to the cursor's current position in the program text. If a breakpoint is encountered before the cursor position, the execution stops at the breakpoint, but if restarted will not stop at the cursor position unless this option is again selected.
Set PC
Set a new value for the Program Counter: move PC from its current location to a new location. This is done without running the program (unlike the Run to Cursor command, described above). Debug actions can then be carried out with the new PC value. Table 60. Debug menu run commands (continued)
5.3.3
Program and STVD status bar display
Figure 109. Debugger status on status bar
● The left panel of the status bar shows the state of the loaded program.
– Run/Stop indicates whether the loaded program is running or has been stopped. – Halted the microcontroller is executing the "Halt" instruction.
– WFI the microcontroller is executing the "WFI" instruction.
– No Access (SWIM only) the microcontroller is either executing "Halt", "WFI", "WFE" instructions or protected code. In this state no core resource is accessible for the debugger.
● The right panel of the status bar shows the state of the STVD debugger software. – Ready indicates the Core Debugger is available and will accept all user
commands.
– Debugger indicates the Core Debugger is working. Only the user command Stop Debug is accepted by the Core Debugger when working.
5.3.4
Monitoring execution in source windows
Program execution is followed in the source windows—meaning the Editor window(s) and the Disassembly window. Whenever execution stops (for example at a breakpoint or after a step command has been completed) the Editor and Disassembly windows are updated automatically so that the new Program Counter (PC) location is visible.
Other STVD windows are also automatically updated to show the current values of variables or register values for example.
5.4 Editor debug actions
To complement its Editing features the Editor’s debug actions provide a rapid graphic method for controlling application execution and viewing the parameters resulting from execution during the debugging phase of application development. Changes in variable values can be traced with ease and related directly to their originating lines in the Assembler or C-language source files.
For debugging, the Editor's active window may contain either a C-language or an Assembly language source file that constitutes a part of the application (and containing debug information).
Debug icons are placed in the Editor debug margin. When the application is run, the Program Counter (PC) indicator is visible in the Editor window, indicating the current program line. You can set breakpoints at selected lines to halt program execution wherever you want.
Run options are accessed from the Debug menu. Program controls include a selection of run and single step actions. The results of these actions, for example the Program Counter position, the real values of program variables at that location, the Stack contents and other debug data, are available in the Editor and the various view windows.
In addition, a Call Stack Frame indicator may be displayed relative to the Program Counter (PC) indicator. The values of program variables at the position marked by the Call Stack Frame indicator are available, whatever the location of the PC.
Editor contextual menu
In addition to editing features, the Editor contextual menu (available by right-clicking with the mouse in the Editor window) gives you direct access to the debugging features described in
Table 61.
Table 61. Editor contextual menu commands
Command Description
Insert Read/Change Data Breakpoint Refer to Section 5.9: Data breakpoints on page 186.
QuickWatch Refer to Section 5.4.2: QuickWatch window on page 174.
Go to... Move to the line specified.
Go to Disassembly Move to the corresponding line in the disassembly window.