Texas Instruments TMS320C6 Series User Manual
Texas Instruments TMS320C6 Series User Manual

Texas Instruments TMS320C6 Series User Manual

C source debugger for sparcstations
Table of Contents

Advertisement

Quick Links

TMS320C6x
C Source Debugger
User's Guide
For SPARCstations
Literature Number: SPRU224
Manufacturing Part Number: D426029-9761 revision *
January 1997
Preliminary
Printed on Recycled Paper

Advertisement

Table of Contents
loading

Summary of Contents for Texas Instruments TMS320C6 Series

  • Page 1 TMS320C6x C Source Debugger User’s Guide For SPARCstations Literature Number: SPRU224 Manufacturing Part Number: D426029-9761 revision * January 1997 Preliminary Printed on Recycled Paper...
  • Page 2 Running Title—Attribute Reference IMPORTANT NOTICE Texas Instruments (TI) reserves the right to make changes to its products or to discontinue any semiconductor product or service without notice, and advises its customers to obtain the latest version of relevant information to verify, before placing orders, that the information being relied on is current.
  • Page 3 C source debugger and any necessary hardware. How to Use This Manual The goal of this book is to help you learn to use the Texas Instruments standard programmer’s interface for debugging. This book is divided into three parts: Part I: Hands-On Information is presented first so that you can start using your debugger the same day you receive it.
  • Page 4 How to Use This Manual Part III: Reference Material provides supplementary information. Chapter 11 gives a complete summary of all the tasks introduced in Parts I and II. This includes a functional and an alphabetical summary of the debugger commands and a topical summary of function key ac- tions.
  • Page 5 Notational Conventions Notational Conventions This document uses the following conventions. The TMS320C6x family of devices is referred to as ’C6x. The C source debugger has a very flexible command-entry system; there are usually a variety of ways to perform any specific action. For example, you may be able to perform the same action by typing in a command, using the mouse, or using function keys.
  • Page 6 Notational Conventions Program listings and examples, interactive displays, and window contents are shown in a special font. Some examples use a bold version to identify code, commands, or portions of an example that you enter. Here is an example: Command Result displayed in the COMMAND window whatis aai int aai[10][5];...
  • Page 7 Related Documentation From Texas Instruments Related Documentation From Texas Instruments The following books describe the TMS320C6x DSPs and related support tools. To obtain a copy of any of these TI documents, call the Texas Instru- ments Literature Response Center at (800) 477–8924. When ordering, please identify the book by its title and literature number.
  • Page 8 Related Documentation / Trademarks Related Documentation If you are an assembly language programmer and would like more information about C or C expressions, you may find these books useful: American National Standard for Information Systems—Programming Language C X3.159-1989 , American National Standards Institute (ANSI standard for C) Programming in C, Kochan, Steve G., Hayden Book Company The C Programming Language (second edition, 1988), by Brian W.
  • Page 9 When making suggestions or reporting errors in documentation, please include the following information that is on the title page: the full title of the book, the publication date, and the literature number. Mail: Texas Instruments Incorporated Email: comments@books.sc.ti.com Technical Documentation Services, MS 702 P.O.
  • Page 11: Table Of Contents

    Contents Contents Part I: Hands-On Information Overview of a Code Development and Debugging System ......Discusses features of the debugger, describes additional software tools, and tells you how to invoke the debugger.
  • Page 12 Contents Zoom the active window ............Move the active window .
  • Page 13 Contents The Active Window ............3-21 Identifying the active window .
  • Page 14 Contents Loading, Displaying, and Running Code ......... . Tells you how to use the three debugger modes to view the type of source files that you’d like to see, how to load source files and object files, how to run your programs, and how to halt program execution.
  • Page 15 Contents Using Software Breakpoints ............Describes the use of software breakpoints to halt code execution.
  • Page 16 Contents Part III: Reference Material 11 Summary of Commands and Special Keys ........11-1 Provides a functional summary of the debugger commands, profiling commands, and function keys;...
  • Page 17 Contents What the Debugger Does During Invocation ........In some circumstances, you may find it helpful to know the steps that the debugger goes through during the invocation process;...
  • Page 18 Figures Figures 1–1 The Basic Debugger Display ........... 1–2 The Profiling-Environment Display .
  • Page 19 Tables Tables 1–1 Summary of Debugger Options ..........1-12 4–1 Predefined Constants for Use With Conditional Commands...
  • Page 21 Chapter 1 Overview of a Code Development and Debugging System The TMS320C6x C source debugger is an advanced programmer’s interface that helps you to develop, test, and refine ’C6x C programs (compiled with the ’C6x optimizing ANSI C compiler) and assembly language programs. The debugger is the interface to the ’C6x simulator.
  • Page 22: The Basic Debugger Display

    ’C6x debugger’s higher level features are available even when you’re debugging assembly language code. The Texas Instruments advanced programmer’s interface is easy to learn and use. Its friendly window-, mouse-, and menu-oriented interface reduces learn- ing time and eliminates the need to memorize complex commands. The debugger’s customizable displays and flexible command entry let you develop...
  • Page 23 Description of the C Source Debugger Key features of the debugger Multilevel debugging. The debugger allows you to debug both C and assembly language code. If you’re debugging a C program, you can choose to view only the C source, the disassembly of the object code created from the C source, or both.
  • Page 24: Description Of The C Source Debugger

    Description of the C Source Debugger Flexible command entry. There are a variety of ways to enter com- mands. You can type commands or use a mouse, function keys, or the pulldown menus; choose the method that you like best. Want to reenter a command? No need to retype it—simply use the command history.
  • Page 25: The Profiling-Environment Display

    Description of the Profiling Environment 1.2 Description of the Profiling Environment In addition to the basic debugging environment, a second environment—the profiling environment— is available. The profiling environment provides a method for collecting execution statistics about specific areas in your code. This gives you immediate feedback on your application’s performance.
  • Page 26: Description Of The Profiling Environment

    Description of the Profiling Environment Statistics on multiple areas. You can collect statistics about individual statements in disassembly or C, about ranges in disassembly or C, and about C functions. When you are collecting statistics on many areas, you can choose to view the statistics for all the areas or a subset of the areas. Comprehensive display of statistics.
  • Page 27: Developing Code For The Tms320C6X

    Developing Code for the TMS320C6x 1.3 Developing Code for the TMS320C6x The ’C6x is well supported by a complete set of hardware and software development tools, including a C compiler, assembler, and linker. Figure 1–3 illustrates the ’C6x code development flow. The most common paths of soft- ware development are highlighted in grey;...
  • Page 28 Developing Code for the TMS320C6x Common object file format (COFF) allows you to divide your code into logical blocks, define your system’s memory map, and then link code into specific memory areas. COFF also provides rich support for source-level debugging. The following list describes the tools shown in Figure 1–3.
  • Page 29 Developing Code for the TMS320C6x The assembler translates ’C6x assembly language source files into machine assembler language object files. The linker combines object files into a single, executable object module. As linker the linker creates the executable module, it performs relocation and resolves external references.
  • Page 30: Preparing Your Program For Debugging

    Preparing Your Program for Debugging 1.4 Preparing Your Program for Debugging Figure 1–4 illustrates the steps you must go through to prepare a program for debugging. Figure 1–4. Steps You Go Through to Prepare a Program If you’re working with a C program, start here.
  • Page 31 Preparing Your Program for Debugging For your convenience, here’s the command for invoking the shell program when preparing a program for debugging: cl60 [– options ] –g [ filenames ] [–z [ link options ]] cl60 invokes the compiler and assembler. –...
  • Page 32: Invoking The Debugger

    Invoking the Debugger 1.5 Invoking the Debugger Enter the following command on the command-line to invoke the standalone debugger: [ filename ] [ –options ] sim6x sim6x invokes the debugger. filename an optional parameter that names an object file that the debug- ger loads into memory during invocation.
  • Page 33: Selecting The Screen Size (-B, -Bb Options)

    Invoking the Debugger Selecting the screen size (–b, –bb options) By default, the debugger uses an 80-character-by-25-line screen. When you run multiple debuggers, the default screen size is a good choice be- cause you can more easily view multiple default-size debuggers on your screen.
  • Page 34: Identifying Additional Directories (-I Option)

    Invoking the Debugger Identifying additional directories (–i option) The –i option identifies additional directories that contain your source files. Replace pathname with an appropriate directory name. You can specify sev- eral pathnames; use the –i option as many times as necessary. For example: sim6x –i pathname –i pathname –i pathname...
  • Page 35: Identifying A New Initialization File (-T Option)

    Exiting the Debugger Invoking the Debugger / Exiting the Debugger Identifying a new initialization file (–t option) The –t option allows you to specify an initialization command file that will be used instead of siminit.cmd or init.cmd. The format for the –t option is: –t filename Loading without the symbol table (–v option) The –v option prevents the debugger from loading the entire symbol table...
  • Page 36: Debugging Your Programs

    Debugging Your Programs 1.7 Debugging Your Programs Debugging a program is a multiple-step process. These steps are described below, with references to parts of this book that will help you accomplish each step. Step 1 See Section 1.4, Preparing Prepare a C program or assem- bly language program for de- Your Program for Debugging , bugging.
  • Page 37 Chapter 2 An Introductory Tutorial to the C Source Debugger This chapter provides a step-by-step, hands-on demonstration of the ’C6x C source debugger’s basic features. This is not the kind of tutorial that you can take home to read—it is effective only if you’re sitting at your terminal, perform- ing the lessons in the order that they’re presented.
  • Page 38: How To Use This Tutorial

    How to Use This Tutorial / A Note About Entering Commands How to use this tutorial This tutorial contains three basic types of information: Primary actions Primary actions identify the main lessons in the tutorial; they’re boxed so that you can find them easily.
  • Page 39: An Escape Route (Just In Case)

    An Escape Route / Invoke the Debugger and Load the Sample Program’s Object Code An escape route (just in case) The steps in this tutorial create a path for you to follow. The tutorial won’t purposely lead you off the path. But sometimes when people use new products, they accidently press the wrong key, push the wrong mouse button, or mistype a command.
  • Page 40: Take A Look At The Display

    Take a Look at the Display Take a look at the display. . . Now you should see a display similar to this. (It may not be exactly the same, but it should be close.) Menu bar with Load Break Watch Memory Color...
  • Page 41: What's In The Disassembly Window

    What’s in the DISASSEMBLY Window? / Select the Active Window What’s in the DISASSEMBLY window? The DISASSEMBLY window always shows the reverse assembly of memory contents; in this case, it shows an assembly language version of sample.out. The MEMORY window displays the current contents of memory. Because you loaded the object file sample.out when you invoked the debugger, memory contains the object code version of the sample file.
  • Page 42 Select the Active Window Important! Notice the appearance of the CPU window (especially its bor- ders) in contrast to the other, inactive windows. This is how you can tell which window is active. Important! If you don’t see a change in the appearance of the CPU window, look at the way you entered the command.
  • Page 43: Resize The Active Window

    Resize the Active Window Resize the active window This lesson shows you how to resize the active window. Important! Be sure the CPU window is still active. Make the CPU window as small as possible: size 4,3 This tells the debugger to make the window 4 characters by 3 lines, which is the smallest a window can be.
  • Page 44: Zoom The Active Window

    Zoom the Active Window Zoom the active window Another way to resize the active window is to zoom it. Zooming the window makes it as large as possible. Important! Be sure the CPU window is still active. Make the active window as large as possible: zoom The window should now be as large as possible, taking up the entire display (except for the menu bar) and hiding all the other windows.
  • Page 45: Move The Active Window

    Move the Active Window Move the active window This lesson shows you how to move the active window. Important! Be sure the CPU window is still active. Move the CPU window to the upper left portion of the screen: The debugger doesn’t let you move the window move 0,1 to the very top—that would hide the menu bar The MOVE command’s first parameter identifies the window’s new X position...
  • Page 46: Scroll Through A Window's Contents

    Scroll Through a Window’s Contents Scroll through a window’s contents Many of the windows contain more information than can possibly be displayed at one time. You can view hidden information by moving through a window’s contents. The easiest way to do this is to use the mouse to scroll the display up or down.
  • Page 47: Display The C Source Version Of The Sample File

    Display the C Source Version of the Sample File Display the C source version of the sample file Now that you can find your way around the debugger interface, you can become familiar with some of the debugger’s more significant features. It’s time to load C code.
  • Page 48: Execute Some Code

    Execute Some Code / Become Familiar With the Four Debugging Modes Execute some code Let’s run some code —not the whole program, just a portion of it. Important! You will be looking at the contents of the PC register in this lesson. If you cannot see the contents of the PC register in your CPU window, either resize your CPU window or scroll down until you can see the PC value.
  • Page 49: Become Familiar With The Four Debugging Modes

    Become Familiar With the Four Debugging Modes The following steps show you how to switch debugging modes. Use the MoDe menu to select assembly mode: 1) Look at the top of the display: the first line shows a row of pull- down menu selections.
  • Page 50 Become Familiar With the Four Debugging Modes You’re still in auto mode, but you should now see the DISASSEMBLY window. The current PC should be at the statement that defines the c_int00 label (the first statement in the sample program). Try This: You can also switch modes by typing one of these commands: switches to assembly-only mode...
  • Page 51: Open Another Text File, Then Redisplay A C Source File

    Open Another Text File, Then Redisplay a C Source File Open another text file, then redisplay a C source file In addition to what you already know about the FILE window and the FILE command, you should also know that: You can display any text file in the FILE window.
  • Page 52: Use The Basic Run Command

    Use the Basic RUN Command / Set Some Breakpoints Use the basic RUN command The debugger provides you with several ways of running code, but it has one basic run command. Run your entire program: The label in the COMMAND window changes to COMMAND [RUNNING...] to indicate that your program is executing.
  • Page 53: Set Some Breakpoints

    Set Some Breakpoints Set a software breakpoint and run your program: 1) Scroll to line 42 in the FILE window (the call(newvalue) statement) and set a breakpoint at that line: a) Point the mouse cursor at the statement on line 42. b) Click the left mouse button.
  • Page 54: Watch Some Values And Single-Step Through Code

    Watch Some Values and Single-Step Through Code Watch some values and single-step through code Now you know how to update the display without running your entire program; you can set software breakpoints to obtain information at specific points in your program.
  • Page 55 Watch Some Values and Single-Step Through Code Now try out the single-step commands. Hint: Watch the PC in the FILE and DISASSEMBLY windows; watch the values that you set up in the WATCH win- dow. Single-step through the sample program: step 20 Try This: Notice that the step command single-stepped each assembly...
  • Page 56: Run Code Conditionally

    Run Code Conditionally Run code conditionally Try executing this loop one more time. Take a look at this code; it’s doing a lot of work with a variable named i. You may want to check the value of i at specific points instead of after each statement.
  • Page 57: Whatis That

    Run Code Conditionally / WHATIS That? When the conditional run completes, close the WATCH window. Close the WATCH window: WHATIS that? At some point, you might like to obtain some information about the types of data in your C program. Maybe things won’t be working quite the way you’d planned, and you’ll find yourself saying something like “...
  • Page 58: Clear The Command Window Display Area

    Clear the COMMAND Window Display Area / Display the Contents of an Aggregate Data Type Clear the COMMAND window display area After displaying all of these types, you may want to clear them away. This is easy to do. Clear the COMMAND window display area: Display the contents of an aggregate data type The WATCH window is convenient for watching single, or scalar , values.
  • Page 59 Display the Contents of an Aggregate Data Type Now you should see a display like the one below. The newly opened DISP window becomes the active window. Like the FILE window, you can always tell what’s being displayed because of the way the DISP window is labeled. Right now, it should say DISP: big1.
  • Page 60 Display the Contents of an Aggregate Data Type Display array q1 in another DISP window: 1) Point at the [. . .] displayed next to the q1 label in big1’s display. 2) Click the left mouse button. This opens another DISP window labeled DISP: big1.q1. Try This: Display structure q2 in another DISP window.
  • Page 61: Display Data In Another Format

    Display Data in Another Format Display data in another format Usually, when you add an item to the WATCH window or open a DISP window, the data is shown in its natural format . This means that ints are shown as integers, floats are shown as floating-point values, pointers are shown as hex- adecimal values, etc.
  • Page 62 Display Data in Another Format You can also change display formats according to data type. This affects all data of a specific C data type. Change display formats according to data types by using the SETF (set format) command: 1) For comparison, watch the following variables. Their C data types are listed on the right.
  • Page 63 Display Data in Another Format A third way to display data in another format is to use the DISP, ?, MEM, or WA command with an optional parameter that identifies the new display format. The following examples are for ? and WA—DISP and MEM work similarly. Use display formats with the ? and WA commands: 1) Evaluate a variable and display it as a character: ? small.ra[1],c...
  • Page 64: Change Some Values

    Change Some Values Change some values You can edit the values displayed in the MEMORY, CPU, WATCH, and DISP windows. Important! Make sure no other windows are obscuring your view of the MEMORY window. Change a value in memory: 1) Display memory beginning with address 0x0100: mem 0x100 2) Point to the contents of memory location 0x0100.
  • Page 65: Define A Memory Map

    Define a Memory Map Define a memory map You can set up a memory map to tell the debugger which areas of memory it can and can’t access. This is called memory mapping . When you invoked the debugger for this tutorial, the debugger automatically read a default memory map from the initialization batch file included in the sim6x directory.
  • Page 66: Define Your Own Command String

    Define Your Own Command String / Close the Debugger Define your own command string If you find that you often enter a command with the same parameters, or often enter the same commands in sequence, you will find it helpful to have a short- hand method for entering these commands.
  • Page 67: The Debugger Display

    Chapter 3 The Debugger Display The ’C6x C source debugger has a window-oriented display. This chapter shows what windows look like and describes the basic types of windows that you’ll use. Topic Page Debugging Modes and Default Displays ......Descriptions of the Different Kinds of Windows .
  • Page 68: Debugging Modes And Default Displays

    Debugging Modes and Default Displays 3.1 Debugging Modes and Default Displays The debugger has four debugging modes: Auto Assembly Mixed Minimal Each mode changes the debugger display by adding or hiding specific win- dows. This section shows the default displays and the windows that the debug- ger automatically displays for these modes.
  • Page 69: Typical Assembly Display (For Auto Mode And Assembly Mode)

    Debugging Modes and Default Displays Figure 3–1. Typical Assembly Display (for Auto Mode and Assembly Mode) Load Break Watch Memory Color MoDe Run=F5 Step=F8 Next=F10 DISASSEMBLY 00007cdc 00000000 00000000 00007ce0 07d5142a c_int00 MVK,S2 0xfffaa28,B15 00000000 00007ce4 0780606a MVKH,S2 0xc00000,B15 00000000 00007ce8 0007fe2a MVK,S2...
  • Page 70: Assembly Mode

    Debugging Modes and Default Displays Assembly mode Assembly mode is for viewing assembly language programs only. In this mode, you’ll see a display similar to the one shown in Figure 3–1. When you’re in assembly mode, you’ll always see the assembly display, regardless of whether C or assembly language is currently running.
  • Page 71: Minimal Mode

    Debugging Modes and Default Displays Minimal mode Minimal mode allows you to query the target system without displaying any additional information. You can display the contents of CPU registers, memory addresses, or symbols within the COMMAND window by using the WA, DISP, and ?/EVAL commands (described on page 7-3).
  • Page 72: Descriptions Of The Different Kinds Of Windows And Their Contents

    Descriptions of the Different Kinds of Windows and Their Contents 3.2 Descriptions of the Different Kinds of Windows and Their Contents The debugger can show several types of windows. This section lists the various types of windows and describes their characteristics. Every window is identified by a name in its upper left corner.
  • Page 73: Command Window

    Descriptions of the Different Kinds of Windows and Their Contents COMMAND window COMMAND Display area Loading sample.out Done file sample.c Command >>> go main line Command line cursor Purpose Provides an area for entering commands Provides an area for echoing commands and displaying command output, errors, and messages Editable? Command line is editable;...
  • Page 74: Disassembly Window

    Descriptions of the Different Kinds of Windows and Their Contents DISASSEMBLY window Memory Object Disassembly (assembly language address code constructed from object code) Current PC DISASSEMBLY 00007cdc 00000000 00007ce0 07d5142a c_int00 MVK,S2 0xfffaa28,B15 00007ce4 0780606a MVKH,S2 0xc00000,B15 00007ce8 0007fe2a MVK,S2 0x0ffc,B0 00007cec 0000006a...
  • Page 75: File Window

    Descriptions of the Different Kinds of Windows and Their Contents FILE window FILE: sample.c 00001 struct xxx { int a,b,c; int f1 : 2; int f2 : 4; struct xx 00002 str, astr[10], aastr[ 00003 union { int u1, u2, u3, u4, u5[6]; struct xxx u6; } Text 00004 struct zzz { int b1,b2,be,b4,b5;...
  • Page 76: Calls Window

    Descriptions of the Different Kinds of Windows and Their Contents CALLS window CALLS Order of functions called 3: subx() 2: call() Current function 1: main() is at top of list Names of functions called Purpose Lists the function you’re in, its caller, and its caller, etc., as long as each function is a C function Editable? No;...
  • Page 77 Descriptions of the Different Kinds of Windows and Their Contents If a function name is listed in the CALLS window, you can easily display the function code in the FILE window: 1) Point the mouse cursor at the appropriate function name that is listed in the CALLS window.
  • Page 78: Profile Window

    Descriptions of the Different Kinds of Windows and Their Contents PROFILE window Profile data PROFILE Area Name Count Inclusive Incl–Max <sample>#55 Profile xcall() areas main()–00006944 <sample>#72–77 c_int00 00007cf8 Disabled Purpose Displays statistics collected during a profiling session Editable? Modes Auto Created By invoking the debugger with the –profile option Affected by...
  • Page 79: Memory Windows

    Descriptions of the Different Kinds of Windows and Their Contents MEMORY windows MEMORY 00000100 06be14f6 063de2f6 05bdc2f6 0000010c 053da2f6 06bd82f4 063d62f4 00000118 05bd42f5 00000000 05080059 Addresses Data 00000124 053d22f4 000f8411 05a80064 00000130 01280064 00000001 00000000 0000013c 00000000 0000ae29 003d02f5 Purpose Displays the contents of memory Editable? Yes—you can edit the data (but not the addresses)
  • Page 80: Default And Additional Memory Windows

    Descriptions of the Different Kinds of Windows and Their Contents The debugger opens one MEMORY window by default. You can open any number of additional MEMORY windows to display different ranges of memory. Refer to Figure 3–4. Figure 3–4. Default and Additional MEMORY Windows The default MEMORY RANGE3 MEMORY...
  • Page 81 Descriptions of the Different Kinds of Windows and Their Contents The display format parameter for the MEM command is optional. When used, the data is displayed in the selected format as shown in Table 7–1 on page 7-17. You can close and reopen any of the MEMORY windows as often as you like. Closing a MEMORY window Closing a window is a two-step process: 1) Make the appropriate MEMORY window the active window (see Sec-...
  • Page 82: Cpu Window

    Descriptions of the Different Kinds of Windows and Their Contents CPU window 00006ce8 Register 00000000 name 00000000 00000000 00000100 00000000 ffffffdd 00000001 00000002 00000100 00000001 00000000 Register 00007754 00000000 contents 00000000 00000000 00000000 00000000 00006ce8 00000000 00000000 00000000 00000100 00000000 The display changes ffffffdd 00000001...
  • Page 83: Disp Windows

    Descriptions of the Different Kinds of Windows and Their Contents DISP windows DISP: str Structure members DISP: str.f4 [0] 44276127 [1] 1778712578 0x18740001 Member [2] 555492660 [...] values [3] 356713217 [4] 138412802 [5] 182452229 [6] 35659888 This member is an array, and you [7] 37749506 can display its contents in a sec- [8] 134742016...
  • Page 84: Watch Windows

    Descriptions of the Different Kinds of Windows and Their Contents WATCH windows WATCH Watch index 0x00007f24 0x000079c0 Label Current value Purpose Displays the values of selected expressions Editable? Yes—you can edit the value of any expression whose value corresponds to a single storage location (in registers or memory).
  • Page 85 Descriptions of the Different Kinds of Windows and Their Contents To delete individual entries from a WATCH window, use the WD command with the appropriate window name . To delete all entries at once and close a WATCH window, use the WR command with the appropriate window name . Note that you don’t need to specify a window name if you are deleting items from the de- fault WATCH window.
  • Page 86: Cursors

    Cursors 3.3 Cursors The debugger display has three types of cursors: The command-line cursor is a block-shaped cursor that identifies the cur- rent character position on the command line. When the COMMAND win- dow is active (see Section 3.4, The Active Window ), arrow keys affect the position of this cursor.
  • Page 87: The Active Window

    The Active Window 3.4 The Active Window The windows in the debugger display aren’t fixed in their position or in their size. You can resize them, move them around, and, in some cases, close them. The window that you’re going to move, resize, or close must be active . You can move, resize, zoom, or close only one window at a time ;...
  • Page 88: Selecting The Active Window

    The Active Window Selecting the active window You can use one of several methods for selecting the active window: 1) Point to any location within the boundaries or on any border of the desired window. 2) Click the left mouse button. Note that if you point within the window, you might also select the current field.
  • Page 89 The Active Window If several windows of the same type are visible on the screen, don’t use the WIN command to select one of them. If you supply an ambiguous name (such as C, which could stand for CPU or CALLS), the debugger selects the first window it finds whose name matches the name you supplied.
  • Page 90: Manipulating A Window

    Manipulating a Window 3.5 Manipulating a Window A window’s size and its position in the debugger display aren’t fixed —you can resize and move windows. Note: You can resize or move any window, but first the window must be active . For information about selecting the active window, see Section 3.4 on page 3-21.
  • Page 91: Manipulating A Window's Contents

    Manipulating a Window size The SIZE command allows you to size the active window. The format of this command is: size [ width , length ] You can use the SIZE command in one of two ways: Method 1 Supply a specific width and length. Method 2 Omit the width and length parameters and use arrow keys to interactively resize the window.
  • Page 92: Zooming A Window

    Manipulating a Window Zooming a window Another way to resize the active window is to zoom it. Zooming a window makes it as large as possible, so that it takes up the entire display (except for the menu bar) and hides all the other windows. Unlike the SIZE command, zooming is not affected by the window’s position in the display.
  • Page 93: Moving A Window

    Manipulating a Window Moving a window The windows in the debugger display don’t have fixed positions—you can move them around. There are two ways to move a window: By using the mouse By using the MOVE command 1) Point to the left or top edge of the window. COMMAND Point to the top edge or the left edge...
  • Page 94 Manipulating a Window MOVE, method 1: Use the X position and Y position parameters. You can move a window by defining a new XY position for the window’s upper left cor- ner. Valid X and Y positions depend on the screen size and the window size. X positions are valid if the X position plus the window width in characters is less than or equal to the screen width in characters.
  • Page 95: Manipulating A Window's Contents

    Manipulating a Window’s Contents 3.6 Manipulating a Window’s Contents Although you may be concerned with changing the way windows appear in the display—where they are and how big/small they are—you’ll usually be interested in something much more important: what’s in the windows . Some windows contain more information than can be displayed on a screen;...
  • Page 96 Manipulating a Window’s Contents To scroll window contents up or down: 1) Point to the appropriate scroll arrow. 2) Press the left mouse button; continue to press it until the information you’re interested in is displayed within the window. 3) Release the mouse button when you’re finished scrolling. You can scroll up/down one line at a time by pressing the mouse button and releasing it immediately.
  • Page 97: Editing The Data Displayed In Windows

    Manipulating a Window’s Contents Editing the data displayed in windows You can edit the data displayed in the MEMORY, CPU, DISP, and WATCH windows by using an overwrite click-and-type method or by using commands that change the values. This is described in detail in Section 7.3, Basic Methods for Changing Data Values , page 7-4.
  • Page 98: Closing A Window

    Closing a Window 3.7 Closing a Window The debugger opens various windows on the display according to the debug- ging mode you select. When you switch modes, the debugger may close some windows and open others. Additionally, you can choose to open DISP, WATCH, and MEMORY windows.
  • Page 99: Entering And Using Commands

    Chapter 4 Entering and Using Commands The debugger provides you with several methods for entering commands: From the command line From the pulldown menus (using keyboard combinations or the mouse) With function keys From a batch file Mouse use and function key use differ from situation to situation and are described throughout this book whenever applicable.
  • Page 100: Entering Commands From The Command Line

    Entering Commands From the Command Line 4.1 Entering Commands From the Command Line The debugger supports a complete set of commands that help you to control and monitor program execution, customize the display, and perform other tasks. These commands are discussed in the various sections throughout this book, as they apply to the topic that is being discussed.
  • Page 101: Typing In And Entering Commands

    Entering Commands From the Command Line Typing in and entering commands You can type a command at almost any time; the debugger automatically places the text on the command line when you type. When you want to enter a command, just type—no matter which window is active. You don’t have to worry about making the COMMAND window active or moving the field cursor to the command line.
  • Page 102: Sometimes, You Can't Type A Command

    Entering Commands From the Command Line Notes: 1) When the COMMAND window is not active, you cannot use the arrow keys to move through or edit text on the command line. 2) Typing a command doesn’t make the COMMAND window the active window.
  • Page 103: Using The Command History

    Entering Commands From the Command Line Using the command history The debugger keeps an internal list, or command history , of the commands that you enter. It remembers the last 50 commands that you entered. If you want to reenter a command, you can move through this list, select a command that you’ve already executed, and reexecute it.
  • Page 104: Recording Information From The Display Area

    Entering Commands From the Command Line Recording information from the display area The information shown in the display area of the COMMAND window can be written to a log file. The log file is a system file that contains commands you’ve entered, their results, and error or progress messages.
  • Page 105: Using The Menu Bar And The Pulldown Menus

    Using the Menu Bar and the Pulldown Menus 4.2 Using the Menu Bar and the Pulldown Menus In all four of the debugger modes, you’ll see a menu bar at the top of the screen. The menu selections offer you an alternative method for entering many of the debugger commands.
  • Page 106: Pulldown Menus In The Profiling Environment

    Using the Menu Bar and the Pulldown Menus Pulldown menus in the profiling environment The debugger displays a different menu bar in the profiling environment: Load Mark Enable Disable Unmark View Stop–points Profile The Load menu corresponds to the Load menu in the basic debugger environ- ment.
  • Page 107: Escaping From The Pulldown Menus

    Using the Menu Bar and the Pulldown Menus Mouse method 2 1) Point the cursor at one of the appropriate selections in the menu bar. 2) Click the left mouse button. This displays the menu until you are ready to make a selection.
  • Page 108: Using Menu Bar Selections That Don't Have Pulldown Menus

    Using the Menu Bar and the Pulldown Menus Using menu bar selections that don’t have pulldown menus These three menu bar selections are single-level entries without pulldown me- nus: Step=F8 Run=F5 Next=F10 There are two ways to execute these choices. 1) Point the cursor at one of these selections in the menu bar.
  • Page 109: Using Dialog Boxes

    Using Dialog Boxes 4.3 Using Dialog Boxes Many of the debugger commands have parameters. When you execute these commands from pulldown menus, you must have some way of providing parameter information. The debugger allows you to do this by displaying a dialog box that asks for this information.
  • Page 110 Using Dialog Boxes Modifying text in a dialog box is similar to editing text on the command line: When you display a dialog box for the first time during a debugging ses- sion, the parameter fields are empty. When you bring up the same dialog box again, the box displays the last values that you entered.
  • Page 111: Entering Commands From A Batch File

    Entering Commands From a Batch File 4.4 Entering Commands From a Batch File You can place debugger commands in a batch file and execute the file from within the debugger environment. This is useful, for example, for setting up a memory map that contains several MA commands followed by a MAP command to enable memory mapping.
  • Page 112: Echoing Strings In A Batch File

    Entering Commands From a Batch File Echoing strings in a batch file When executing a batch file, you can display a string to the COMMAND win- dow by using the ECHO command. The syntax for the command is: echo string This displays the string in the display area of the COMMAND window.
  • Page 113: Predefined Constants For Use With Conditional Commands

    Entering Commands From a Batch File The debugger includes some predefined constants for use with IF. These constants evaluate to 0 (false) or 1 (true). Table 4–1 shows the constants and their corresponding tools. Table 4–1. Predefined Constants for Use With Conditional Commands Constant Debugger Tool $$SIM$$...
  • Page 114 Entering Commands From a Batch File If you use a Boolean expression , the debugger executes the com- mands repeatedly as long as the expression is true. This type of expression uses one of the following operators as the highest prece- dence operator in the expression: >...
  • Page 115: Defining Your Own Command Strings

    Defining Your Own Command Strings 4.5 Defining Your Own Command Strings The debugger provides a shorthand method of entering often-used com- mands or command sequences. This processing is called aliasing . Aliasing enables you to define an alias name for the command(s) and then enter the alias name as if it were a debugger command.
  • Page 116 Defining Your Own Command Strings Listing all aliases. To display a list of all the defined aliases, enter the ALIAS command with no parameters. The debugger lists the aliases and their definitions in the COMMAND window. For example, assume that the init and mfil aliases have been defined as shown on page 4-17.
  • Page 117 Defining Your Own Command Strings Notes: 1) Alias definitions are lost when you exit the debugger. If you want to reuse aliases, define them in a batch file. 2) Individual commands within a command string are limited to an expand- ed length of 132 characters.
  • Page 118 4-20...
  • Page 119: Defining A Memory Map

    Chapter 5 Defining a Memory Map Before you begin a debugging session, you must supply the debugger with a memory map. The memory map tells the debugger which areas of memory it can and can’t access. Note that the commands described in this chapter can also be entered by using the Memory pulldown menu (see Section 4.2, Using the Menu Bar and the Pulldown Menus , page 4-7).
  • Page 120: The Memory Map: What It Is And Why You Must Define It

    The Memory Map: What It Is and Why You Must Define It 5.1 The Memory Map: What It Is and Why You Must Define It A memory map tells the debugger which areas of memory it can and can’t access. Memory maps vary, depending on the application. Typically, the map matches the MEMORY definition in your linker command file.
  • Page 121: Potential Memory Map Problems

    The Memory Map: What It Is and Why You Must Define It Potential memory map problems You may experience these problems if the memory map isn’t correctly defined and enabled: Accessing invalid memory addresses. If you don’t supply a batch file containing memory-map commands, the debugger is initially unable to ac- cess any target memory locations.
  • Page 122: A Sample Memory Map

    A Sample Memory Map 5.2 A Sample Memory Map Because you must define a memory map before you can run any programs, it’s convenient to define the memory map in the initialization batch files. Figure 5–1 (a) shows the memory map commands that are defined in the ini- tialization batch file that accompanies the ’C6x simulator.
  • Page 123: Identifying Usable Memory Ranges

    Identifying Usable Memory Ranges 5.3 Identifying Usable Memory Ranges The debugger’s MA (memory add) command identifies valid ranges of target memory. The syntax for this command is: ma address, length, type The address parameter defines the starting address of a range. This parameter can be an absolute address, any C expression, the name of a C function, or an assembly language label.
  • Page 124: Memory Mapping With The Simulator

    Identifying Usable Memory Ranges Notes: The debugger caches memory that is not defined as a port type (INPORT, OUTPORT, or IOPORT). For ranges that you don’t want cached, be sure to map them as ports. Be sure that the map ranges that you specify in a COFF file match those that you define with the MA command.
  • Page 125 Identifying Usable Memory Ranges Your memory map is now restricted only by your PC’s capabilities. As a result, there should be sufficient free space on your disk to run any memory map you want to use. If you use the MA command to allocate 20K words (40K bytes) of memory in your memory map, your disk should have at least 40K bytes of free space available.
  • Page 126: Enabling Memory Mapping

    Enabling Memory Mapping 5.4 Enabling Memory Mapping By default, mapping is enabled when you invoke the debugger. In some instances, you may want to explicitly enable or disable memory. You can use the MAP command to do this; the syntax for this command is: map on map off Note that disabling memory mapping can cause bus fault problems in the...
  • Page 127: Checking The Memory Map

    Checking the Memory Map 5.5 Checking the Memory Map If you want to see which memory ranges are defined, use the ML (list memory map) command. The syntax for this command is: The ML command lists the starting address, ending address, and read/write characteristics of each defined memory range.
  • Page 128: Modifying The Memory Map During A Debugging Session

    Modifying the Memory Map During a Debugging Session 5.6 Modifying the Memory Map During a Debugging Session If you need to modify the memory map during a debugging session, use these commands. To delete a range of memory from the memory map, use the MD (memory delete) command.
  • Page 129 Chapter 6 Loading, Displaying, and Running Code The main purpose of a debugging system is to allow you to load and run your programs in a test environment. This chapter tells you how to load your pro- grams into the debugging environment, run them on the target system, and view the associated source code.
  • Page 130 Code-Display Windows: Viewing Assembly Language Code, C Code, or Both 6.1 Code-Display Windows: Viewing Assembly Language Code, C Code, or Both The debugger has three code-display windows: The DISASSEMBLY window displays the reverse assembly of program memory contents. The FILE window displays any text file; its main purpose is to display C source files.
  • Page 131 Code-Display Windows: Viewing Assembly Language Code, C Code, or Both Selecting a debugging mode Unless you use the –min command-line option (which selects minimal mode and is discussed on page 1-14), when you first invoke the debugger, it auto- matically comes up in auto mode. You can then choose assembly or mixed mode.
  • Page 132: Contents

    Displaying Your Source Programs (or Other Text Files) 6.2 Displaying Your Source Programs (or Other Text Files) The debugger displays two types of code: It displays assembly language code in the DISASSEMBLY window in auto, assembly, or mixed mode. It displays C code in the FILE window in auto and mixed modes. The DISASSEMBLY and FILE windows are primarily intended for displaying code that the program counter (PC) points to.
  • Page 133 Displaying Your Source Programs (or Other Text Files) When you invoke the debugger, it comes up in auto mode. If you load an object file when you invoke the debugger, the DISASSEMBLY window displays the reverse assembly of the object file that’s loaded into memory. If you don’t load an object file, the DISASSEMBLY window shows the reverse assembly of whatever is in memory.
  • Page 134 Displaying Your Source Programs (or Other Text Files) Displaying C code Unlike assembly language code, C code isn’t reconstructed from memory contents—the C code that you view is your original C source. You can display C code explicitly or implicitly: You can force the debugger to show C source by entering a FILE, FUNC, or ADDR command.
  • Page 135 Displaying Your Source Programs (or Other Text Files) addr Use the ADDR command to display C or assembly code beginning at a specific point. The syntax for this command is: addr address addr function name In a C display, ADDR works like the FUNC command, positioning the code starting at address or at function name as the first line of code in the FILE window.
  • Page 136 Loading Object Code 6.3 Loading Object Code In order to debug a program, you must load the program’s object code into memory. You can do this as you’re invoking the debugger, or you can do it after you’ve invoked the debugger. (Note that you create an object file by compiling, assembling, and linking your source files;...
  • Page 137 Where the Debugger Looks for Source Files 6.4 Where the Debugger Looks for Source Files Some commands (FILE, LOAD, RELOAD, and SLOAD) expect a filename as a parameter. If the filename includes path information, the debugger uses the file from the specified directory and doesn’t search for the file in any other directory.
  • Page 138 Running Your Programs 6.5 Running Your Programs To debug your programs, you must execute them on a ’C6x debugging tool (the simulator). The debugger provides two basic types of commands to help you run your code: Basic run commands run your code without updating the display until you explicitly halt execution.
  • Page 139 Running Your Programs ?/eval You can directly modify the PC’s contents with one of these commands: ?PC = new value eval pc = new value After halting execution, you can continue from the current PC by reissuing any of the run or single-step commands. Running code The debugger supports several run commands.
  • Page 140 Running Your Programs Single-stepping through code Single-step execution is similar to running a program that has a breakpoint set on each line. The debugger executes one statement, updates the display, and halts execution. (You can supply a parameter that tells the debugger to single-step more than one statement;...
  • Page 141 Running Your Programs cstep The CSTEP command is similar to STEP, but CSTEP always single-steps in terms of a C statement. If you’re in C code, STEP and CSTEP behave identically. In assembly language code, however, CSTEP executes all assem- bly language statements associated with one C statement before updating the display.
  • Page 142 Running Your Programs Running code while disconnected from the target system reset The RESET command resets the simulator and reloads the monitor. This is a software reset. The format for this command is: reset If you execute the RESET command, the simulator simulates the ’C6x proces- sor and peripheral reset operation, putting the processor in a known state.
  • Page 143 Halting Program Execution 6.6 Halting Program Execution Whenever you’re running or single-stepping code, program execution halts automatically if the debugger encounters a breakpoint or if it reaches a particular point where you told it to stop (by supplying a count or an address ). If you’d like to explicitly halt program execution, there are two ways to accom- plish this: Click the left mouse button.
  • Page 144 6-16...
  • Page 145 Chapter 7 Managing Data The debugger allows you to examine and modify many different types of data related to the ’C6x and to your program. You can display and modify the values Individual memory locations or a range of memory ’C6x registers Variables, including scalar types (ints, chars, etc.) and aggregate types (arrays, structures, etc.)
  • Page 146 Where Data Is Displayed Where Data Is Displayed / Basic Commands for Managing Data 7.1 Where Data Is Displayed Four windows are dedicated to displaying the various types of data. Type of data Window name and purpose Memory locations MEMORY window Displays the contents of a range of data memory, program memory, or I/O space Register values...
  • Page 147 Basic Commands for Managing Data The ? (evaluate expression) command evaluates an expression and shows the result in the display area of the COMMAND window. The syntax for this command is: ? expression The expression can be any C expression, including an expression with side effects.
  • Page 148 Basic Methods for Changing Data Values 7.3 Basic Methods for Changing Data Values The debugger provides you with a great deal of flexibility in modifying various types of data. You can use the debugger’s overwrite editing capability, which allows you to change a value simply by typing over its displayed value. You can also use the data-management commands for more complex editing.
  • Page 149 Basic Methods for Changing Data Values 4) Type the new information. If you make a mistake or change your mind, press ; this resets the field to its original value. 5) When you finish typing the new information, press or any arrow key. This replaces the original value with the new value.
  • Page 150 Managing Data in Memory 7.4 Managing Data in Memory In mixed and assembly modes, the debugger maintains a MEMORY window that displays the contents of memory. For details concerning the MEMORY window, see MEMORY windows on page 3-13. MEMORY 00000100 06be14f6 063de2f6 05bdc2f6...
  • Page 151 Managing Data in Memory Expression can be an absolute address, a symbolic address, or any C expression. Here are several examples: Absolute address. Suppose that you want to display data memory beginning from the very first address. You might enter this command: mem 0x00 Hint: MEMORY window addresses are shown in hexadecimal format.
  • Page 152 Managing Data in Memory Displaying memory contents while you’re debugging C If you’re debugging C code in auto mode, you won’t see a MEMORY window— the debugger doesn’t show the MEMORY window in the C-only display. However, there are several ways to display memory in this situation. Hint: If you want to use the contents of an address as a parameter, be sure to prefix the address with the C indirection operator (*).
  • Page 153 Managing Data in Memory Saving memory values to a file Sometimes it’s useful to save a block of memory values to a file. You can use the MS (memory save) command to do this; the files are saved in COFF for- mat.
  • Page 154 Managing Register Data 7.5 Managing Register Data In mixed and assembly modes, the debugger maintains a CPU window that displays the contents of individual registers. For details, see CPU window on page 3-16. Register 00006ce8 00000000 00000000 name 00000000 00000100 00000000 ffffffdd 00000001...
  • Page 155 Managing Data in a DISP (Display) Window 7.6 Managing Data in a DISP (Display) Window The main purpose of the DISP window is to display members of complex, aggregate data types such as arrays and structures. The debugger shows DISP windows only when you specifically request to see DISP windows with the DISP command (described below).
  • Page 156 Managing Data in a DISP (Display) Window Once you open a DISP window, you may find that a displayed member is another one of these types. This is how you identify the members that are arrays, structures, or pointers: A member that is an array looks like this [.
  • Page 157 Managing Data in a DISP (Display) Window Closing a DISP window Closing a DISP window is a simple, two-step process. 1) Make the DISP window that you want to close active (see Section 3.4, The Active Window , on page 3-21). 2) Press Note that you can close a window and all of its children by closing the original window.
  • Page 158 Managing Data in a WATCH Window 7.7 Managing Data in a WATCH Window The debugger doesn’t maintain a dedicated window that tells you about the status of all the symbols defined in your program. Such a window might be so large that it wouldn’t be useful.
  • Page 159 Managing Data in a WATCH Window Displaying data in the WATCH window The debugger has one command for adding items to a WATCH window. To open a WATCH window, use the WA (watch add) command. The syntax is: wa expression [ , [ label ] [ , [ display format ] [, window name ] ] ] When you first execute WA, the debugger opens a WATCH window.
  • Page 160 Managing Data in a WATCH Window Deleting watched values and closing the WATCH window The debugger supports two commands for deleting items from the WATCH window. If you’d like to close a WATCH window and delete all of the items in that window in a single step, use the WR (watch reset) command.
  • Page 161: Display Formats For Debugger Data

    Displaying Data in Alternative Formats 7.8 Displaying Data in Alternative Formats By default, all data is displayed in its natural format. This means that: Integer values are displayed as decimal numbers. Floating-point values are displayed in floating-point format. Pointers are displayed as hexadecimal addresses (with a 0x prefix). Enumerated types are displayed symbolically.
  • Page 162: Data Types For Displaying Debugger Data

    Displaying Data in Alternative Formats Table 7–2. Data Types for Displaying Debugger Data Valid Display Formats Data Type Default Display Format char ASCII (c) uchar Decimal (d) short Decimal (d) Decimal (d) uint Decimal (d) long Decimal (d) ulong Decimal (d) float Exponential floating point (e) double...
  • Page 163 Displaying Data in Alternative Formats Changing the default format with ?, MEM, DISP, and WA You can also use the ?, MEM, DISP, and WA commands to show data in alter- native display formats. (The ? and DISP commands use alternative formats only for scalar types, arrays of scalar types, and individual members of aggre- gate types.) Each of these commands has an optional display format parameter that works...
  • Page 164 7-20...
  • Page 165 Chapter 8 Using Software Breakpoints During the debugging process, you may want to halt execution temporarily so that you can examine the contents of selected variables, registers, and memory locations before continuing with program execution. You can do this by setting software breakpoints at critical points in your code. You can set soft- ware breakpoints in assembly language code and in C code.
  • Page 166 Setting a Software Breakpoint 8.1 Setting a Software Breakpoint When you set a software breakpoint, the debugger highlights the breakpointed line in two ways: It prefixes the statement with the characters BP>. It shows the line in a bolder or brighter font. (You can use screen-customi- zation commands to change this highlighting method.) If you set a breakpoint in the disassembly, the debugger also highlights the associated C statement.
  • Page 167 Setting a Software Breakpoint There are several ways to set a software breakpoint: 1) Point to the line of assembly language code or C code where you’d like to set a breakpoint. 2) Click the left button. Repeating this action clears the breakpoint. 1) Make the FILE or DISASSEMBLY window the active window.
  • Page 168 Clearing a Software Breakpoint 8.2 Clearing a Software Breakpoint There are several ways to clear a software breakpoint. If you clear a breakpoint from an assembly language statement, the breakpoint is also cleared from any associated C statement; if you clear a breakpoint from a C statement, the breakpoint is also cleared from the associated statement in the disassembly.
  • Page 169 Finding the Software Breakpoints That Are Set 8.3 Finding the Software Breakpoints That Are Set Sometimes you may need to know where software breakpoints are set. For example, the BD command’s address parameter must correspond to the address of a breakpoint that is set. The BL (breakpoint list) command provides an easy way to get a complete listing of all the software breakpoints that are currently set in your program.
  • Page 171 Chapter 9 Customizing the Debugger Display The debugger display is completely configurable; you can create the interface that is best suited for your use. Besides being able to size and position indi- vidual windows, you can change the appearance of many of the display features, such as window borders, how the current statement is highlighted, etc.
  • Page 172: Colors And Other Attributes For The Color And Scolor Commands

    Changing the Colors of the Debugger Display 9.1 Changing the Colors of the Debugger Display You can use the debugger with a color or a monochrome display; the com- mands described in this section are most useful if you have a color display. If you are using a monochrome display, these commands change the shades on your display.
  • Page 173: Summary Of Area Names For The Color And Scolor Commands

    Changing the Colors of the Debugger Display Table 9–2. Summary of Area Names for the COLOR and SCOLOR Commands menu_bar menu_border menu_entry menu_cmd menu_hilite menu_hicmd win_border win_hiborder win_resize field_text field_hilite field_edit field_label field_error cmd_prompt cmd_input cmd_cursor cmd_echo asm_data asm_cdata asm_label asm_clabel background blanks...
  • Page 174 Changing the Colors of the Debugger Display Area names: window borders WATCH An inactive win_border 0x00007f24 window 0x000079c0 win_resize An active COMMAND window win_hiborder Loading sample.out Done >>> Area identification Parameter name Window border for any window that isn’t active win_border The reversed L in the lower right corner of a resizable win_resize...
  • Page 175 Changing the Colors of the Debugger Display Area names: DISASSEMBLY and FILE windows asm_cdata DISASSEMBLY file_pc 00006930 073d94f4 main: STW.D2 00006934 003ce2f4 STW.D2 00006938 053d02f4 STW.D2 asm_clabel 0000693c 05bd22f4 STW.D2 00006940 063d42f4 STW.D2 file_brk asm_label 00006944 06bd62f4 STW.D2 asm_data file_text file_line FILE: t1.c 00053...
  • Page 176 Changing the Colors of the Debugger Display Area names: data-display windows field_label field_text field_hilite MEMORY 00000100 06be14f6 063de2f6 05bdc2f6 0000010c 053da2f6 06bd82f4 063d62f4 00000118 05bd42f5 00000000 05080059 00000124 053d22f4 000f8411 05a80064 00000130 01280064 00000001 00000000 0000013c 00000000 0000ae29 003d02f5 field_edit field_error Area identification Parameter name...
  • Page 177 Changing the Colors of the Debugger Display Area names: menu bar and pulldown menus menu_bar Break Memory Color Mode Load Watch menu_hilite menu_hicmd Delete Reset menu_entry menu_cmd menu_border Area identification Parameter name Top line of display screen; background to main menu menu_bar choices Border of any pulldown menu...
  • Page 178 Changing the Border Styles of the Windows 9.2 Changing the Border Styles of the Windows In addition to changing the colors of areas in the display, the debugger allows you to modify the border styles of the windows. border Use the BORDER command to change window border styles. The format for this command is: border [ active window style ] [,[ inactive window style ] [, resize style ] ] This command changes the border styles of the active window, the inactive...
  • Page 179 Saving and Using Custom Displays 9.3 Saving and Using Custom Displays The debugger allows you to save and use as many custom configurations as you like. When you invoke the debugger, it looks for a screen configuration file called init.clr. The screen configuration file defines how various areas of the display will appear.
  • Page 180 Saving and Using Custom Displays Saving a custom display ssave Once you’ve customized the debugger display to your liking, you can use the SSAVE command to save the current screen configuration to a file. The format for this command is: ssave [ filename ] This saves the screen resolution, border styles, colors, window positions, win- dow sizes, and (on PCs) video mode (EGA, VGA, etc.) for all debugging...
  • Page 181 Saving and Using Custom Displays Note: The file created by the SSAVE command in this version of the debugger saves positional, screen size, and video mode information that was not saved by SSAVE in previous versions of the debugger. The format of this new information is not compatible with the old format.
  • Page 182 Changing the Prompt 9.4 Changing the Prompt prompt The debugger enables you to change the command-line prompt by using the PROMPT command. The format of this command is: prompt new prompt The new prompt can be any string of characters, excluding semicolons and commas.
  • Page 183 Chapter 10 Profiling Code Execution The profiling environment is a special debugger environment that lets you collect execution statistics for your code. Note that the profiling environment is separate from the basic debugging envi- ronment; the only way to switch between the two environments is by exiting and then reinvoking the debugger.
  • Page 184 An Overview of the Profiling Process 10.1 An Overview of the Profiling Process Profiling consists of five simple steps: Step 1 Enter the profiling environment. See Entering the Profiling Envi- ronment , page 10-3. Step 2 Identify the areas of code where See Defining Areas for Profiling , you’d like to collect statistics.
  • Page 185: Debugger Commands That Can/Can't Be Used In The Profiling Environment

    Entering the Profiling Environment 10.2 Entering the Profiling Environment To enter the profiling environment, invoke the debugger with the –profile op- tion. At the system command line, enter the appropriate command: sim6x –profile Use any additional debugger options that you desire (–b, –p, etc.). Restrictions of the profiling environment Some restrictions apply to the profiling environment: You’ll always be in mixed mode.
  • Page 186 Entering the Profiling Environment Using pulldown menus in the profiling environment The debugger displays a different menu bar in the profiling environment: Load Mark Enable Disable Unmark View Stop–points Profile The Load menu corresponds to the Load menu in the basic debugger environ- ment.
  • Page 187 Defining Areas for Profiling 10.3 Defining Areas for Profiling Within the profiling environment, you can collect statistics on three types of areas: Individual lines in C or disassembly Ranges in C or disassembly Functions in C only To identify any of these areas for profiling, mark the line, range, or function. You can disable areas so that they won’t affect the profile data, and you can reen- able areas that have been disabled.
  • Page 188 Defining Areas for Profiling Marking a line. These instructions apply to both C and disassembly. 4) Point to the line you want to mark. 5) Click the left mouse button. The beginning of the line will be highlighted with >>. 6) Click the left mouse button again.
  • Page 189: Menu Selections For Marking Areas

    Defining Areas for Profiling Table 10–2 lists the menu selections for marking areas. The highlighted areas show the keys that you can use if you prefer to use the function-key method of selecting menu choices. Table 10–2. Menu Selections for Marking Areas C only: Disassembly only: To mark this area...
  • Page 190 Defining Areas for Profiling The simplest way to disable an area is to use the mouse, as described below. Disabling a range area: 1) Point to the marked line. 2) Click the left mouse button once. The beginning of the line will be highlighted with Rd> (range disabled). Disabling a function area: 1) Point to the marked statement that declares the function.
  • Page 191: Menu Selections For Disabling Areas

    Defining Areas for Profiling Table 10–3 lists the menu selections for disabling areas. The highlighted areas show the keys that you can use if you prefer to use the function-key method of selecting menu choices. Table 10–3. Menu Selections for Disabling Areas C only: Disassembly only: C and disassembly:...
  • Page 192: Menu Selections For Enabling Areas

    Defining Areas for Profiling Reenabling a disabled area When an area has been disabled and you would like to profile it once again, you must enable the area. To use the mouse, just point to the line, the function, or the first line of a range, and click the left mouse button; the range will once again be highlighted in the same way as a marked area.
  • Page 193 Defining Areas for Profiling Unmarking an area If you want to stop collecting information about a specific area, unmark it. You can use the mouse or key method. Unmarking a line area: 1) Point to the marked line. 2) Click the right mouse button once. The line will no longer be highlighted.
  • Page 194: Menu Selections For Unmarking Areas

    Defining Areas for Profiling Table 10–5 lists the selections on the Unmark menu. Menu Selections for Unmarking Areas Table 10–5. C and disassembly: C only: Disassembly only: To unmark this area Unmark C level Unmark Asm level Unmark Both levels Lines Line areas Line areas...
  • Page 195 Defining a Stopping Point 10.4 Defining a Stopping Point Before you run a profiling session, you must identify the point where the debug- ger should stop collecting statistics. By default, C programs contain an exit la- bel, and this is defined as the default stopping point when you load your pro- gram.
  • Page 196 Defining a Stopping Point The debugger supports several commands for adding, deleting, resetting, and listing stopping points (described below); all of these commands can also be entered from the Stop-points menu. To add a stopping point, use the SA (stop add) command. The syntax for this command is: sa address This adds address as a stopping point.
  • Page 197 Running a Profiling Session 10.5 Running a Profiling Session Once you have defined profile areas and a stopping point, you can run a profil- ing session. You can run two types of profiling sessions: A full profile collects a full set of statistics for the defined profile areas. A quick profile collects a subset of the available statistics (it doesn’t collect exclusive or exclusive max data, which are described in Section 10.6, Viewing Profile Data ).
  • Page 198 Running a Profiling Session No matter which update rate you choose, you can force the PROFILE window to be updated during a profiling session by pointing to the window header and clicking a mouse button. After you enter a PF or PQ command, your program restarts and runs to the defined starting point.
  • Page 199: An Example Of The Profile Window

    Viewing Profile Data 10.6 Viewing Profile Data The statistics collected during a profiling session are displayed in the PROFILE window. Figure 10–1 shows an example of this window. Figure 10–1. An Example of the PROFILE Window Profile data PROFILE Area Name Count Inclusive Incl–Max <sample>#55...
  • Page 200: Types Of Data Shown In The Profile Window

    Viewing Profile Data Table 10–6. Types of Data Shown in the PROFILE Window Label Profile data Count The number of times a profile area is entered during a session. Inclusive The total execution time (cycle count) of a profile area, including the execution time of any subroutines called from within the profile area.
  • Page 201 Viewing Profile Data Data accuracy During a profiling session, the debugger sets many internal breakpoints and issues a series of RUNB commands. As a result, the processor is momentarily halted when entering and exiting profiling areas. This stopping and starting can affect the cycle count information (due to pipeline flushing and the mechanics of software breakpoints) so that it varies from session to session.
  • Page 202: Menu Selections For Displaying Areas In The Profile Window

    Viewing Profile Data Table 10–7. Menu Selections for Displaying Areas in the PROFILE Window To view these areas C only: Disassembly only: C and disassembly: View Filter C level View Filter Asm level View Filter Both levels Lines Line areas Line areas Line areas By line number...
  • Page 203 Viewing Profile Data Viewing code associated with a profile area You can view the code associated with a displayed profile area. The debugger will update the display so that the associated C or disassembly statements are shown in the FILE or DISASSEMBLY windows. Use the mouse to select the profile area in the PROFILE window and display the associated code: 1) Point to the appropriate area name in the PROFILE window.
  • Page 204 Saving Profile Data to a File 10.7 Saving Profile Data to a File You may want to run several profiling sessions during a debugging session. Whenever you start a new profiling session,the results of the previous session are lost. However, you can save the results of the current profiling session to a system file.
  • Page 205 Chapter 11 Summary of Commands and Special Keys This chapter summarizes the basic debugger commands, profiling com- mands, and the debugger’s special key sequences. Topic Page 11.1 Functional Summary of Debugger Commands ....11-2 11.2 How the Menu Selections Correspond to Commands .
  • Page 206 Functional Summary of Debugger Commands 11.1 Functional Summary of Debugger Commands This section summarizes the debugger commands according to these catego- ries: Changing modes. These commands (listed on page 11-3) enable you to switch freely between the debugging modes (auto, mixed, minimal, and assembly).
  • Page 207 Functional Summary of Debugger Commands Changing modes Use this To put the debugger in See page command Assembly mode 11-12 Auto mode for debugging C code 11-15 Minimal mode minimal 11-27 Mixed mode 11-27 Managing windows Use this To do this See page command Reposition the active window...
  • Page 208 Functional Summary of Debugger Commands Performing system tasks Use this To do this See page command Define your own command string alias 11-12 Clear all displayed information from the display 11-15 area of the COMMAND window Record the information shown in the display area of dlog 11-20 the COMMAND window...
  • Page 209 Functional Summary of Debugger Commands Displaying files and loading programs Use this To do this See page command Display C and/or assembly language code at a addr 11-11 specific point Reopen the CALLS window calls 11-15 Display assembly language code at a specific dasm 11-18 address...
  • Page 210 Functional Summary of Debugger Commands Running programs Use this To do this See page command Single-step through assembly language or C code, cnext 11-16 one C statement at a time; step over function calls Single-step through assembly language or C code, cstep 11-17 one C statement at a time...
  • Page 211 Functional Summary of Debugger Commands Profiling commands All of the profiling commands can be entered from the pulldown menus. In many cases, using the pulldown menus is the easiest way to use some of these commands. For this reason and also because there are over 100 profiling commands, most of these commands are not described individually in this chapter (as the basic debugger commands are).
  • Page 212 How the Menu Selections Correspond to Commands 11.2 How the Menu Selections Correspond to Commands The following sample screens illustrate the relationship of the basic debugger commands to the menu bar and pulldown menus. You can use the menus with or without a mouse. To access a menu from the keyboard, press the key and the letter that’s highlighted in the menu name.
  • Page 213 How the Menu Selections Correspond to Commands Watch commands Watch WA command WD command Delete Reset WR command Memory commands MA command Memory MD command Delete MR command Reset ML command List Enable MAP command Fill FILL command Save MS command Screen-configuration commands SCONFIG command Color...
  • Page 214 Alphabetical Summary of Debugger Commands 11.3 Alphabetical Summary of Debugger Commands Commands are not case sensitive; to emphasize this, command names are shown in both uppercase and lowercase throughout this book. Evaluate Expression Syntax ? expression [ , display format ] Menu selection none Environments...
  • Page 215 addr Alphabetical Summary of Debugger Commands Display Code at Specified Address addr addr address Syntax addr function name Menu selection none Environments basic debugger profiling Description Use the ADDR command to display C code or the disassembly at a specific point.
  • Page 216 alias, asm Alphabetical Summary of Debugger Commands Define Custom Command String alias alias [ alias name [, ” command string ” ] ] Syntax Menu selection none Environments basic debugger profiling Description You can use the ALIAS command to associate one or more debugger commands with a single alias name.
  • Page 217 ba, bd, bl Alphabetical Summary of Debugger Commands Add Software Breakpoint Syntax ba address Menu selection Break Add Environments basic debugger profiling Description The BA command sets a software breakpoint at a specific address . This command is useful because it doesn’t require you to search through code to find the desired line.
  • Page 218 border, br Alphabetical Summary of Debugger Commands Change Style of Window Border border border [ active window style ] [, [ inactive window style ] [ ,resize window style ]] Syntax Menu selection Color Border Environments basic debugger profiling Description The BORDER command changes the border style of the active window, the inactive windows, and the border style of any window that you’re resizing.
  • Page 219 c, calls, cls Alphabetical Summary of Debugger Commands Enter Auto Mode Syntax Menu selection MoDe C (auto) Environments basic debugger profiling Description The C command changes from the current debugging mode to auto mode. If you’re already in auto mode, the C command has no effect. Open CALLS Window calls Syntax...
  • Page 220 cnext, color Alphabetical Summary of Debugger Commands Single-Step C, Next Statement cnext Syntax cnext [ expression ] Menu selection Next=F10 (in C code) Environments basic debugger profiling Description The CNEXT command is similar to the CSTEP command. It runs a program one C statement at a time, updating the display after executing each state- ment.
  • Page 221 color, cstep Alphabetical Summary of Debugger Commands Valid values for the area name parameters include: menu_bar menu_border menu_entry menu_cmd menu_hilite menu_hicmd win_border win_hiborder win_resize field_text field_hilite field_edit field_label field_error cmd_prompt cmd_input cmd_cursor cmd_echo asm_data asm_cdata asm_label asm_clabel background blanks error_msg file_line file_eof file_text...
  • Page 222 dasm, disp Alphabetical Summary of Debugger Commands Display Disassembly at Specific Address dasm dasm address Syntax dasm function name Menu selection none Environments basic debugger profiling Description The DASM command displays code beginning at a specific point within the DISASSEMBLY window. Open DISP Window disp Syntax...
  • Page 223 disp Alphabetical Summary of Debugger Commands When you use the optional display format parameter, data is displayed in one of the following formats: Parameter Result Parameter Result Default for the data type Octal ASCII character (bytes) Valid address Decimal ASCII string Exponential floating point Unsigned decimal Decimal floating point...
  • Page 224 dlog Alphabetical Summary of Debugger Commands Record Display Window dlog dlog filename [,{a | w}] Syntax dlog close Menu selection none Environments basic debugger profiling Description The DLOG command allows you to record the information displayed in the COMMAND window into a log file. To begin recording the information shown in the display area of the COMMAND window, use: dlog filename...
  • Page 225 echo, else, endif, endloop Alphabetical Summary of Debugger Commands Echo String to Display Area echo echo string Syntax Menu selection none Environments basic debugger profiling Description The ECHO command displays string in the display area of the COMMAND window. You can’t use quote marks around the string, and any leading blanks in your command string are removed when the ECHO command is executed.
  • Page 226 eval, file, fill Alphabetical Summary of Debugger Commands Evaluate Expression eval Syntax eval expression e expression Menu selection none Environments basic debugger profiling Description The EVAL command evaluates an expression like the ? command does but does not show the result in the display area of the COMMAND window. EVAL is useful for assigning values to registers or memory locations in a batch file (where it’s not necessary to display the result).
  • Page 227 func, go, if/else/endif Alphabetical Summary of Debugger Commands Display Function func func function name Syntax func address Menu selection none Environments basic debugger profiling Description The FUNC command displays a specified C function in the FILE window. You can identify the function by its name or its address. Note that FUNC works the same way FILE works, but with FUNC you don’t need to identify the name of the file that contains the function.
  • Page 228 load, loop/endloop Alphabetical Summary of Debugger Commands Load Executable Object File load load object filename Syntax Menu selection Load Load Environments basic debugger profiling Description The LOAD command loads both an object file and its associated symbol table into memory. In effect, the LOAD command performs both a RELOAD and an SLOAD.
  • Page 229 ma, map Alphabetical Summary of Debugger Commands Add Block to Memory Map Syntax ma address, length, type Menu selection Memory Add Environments basic debugger profiling Description The MA command identifies valid ranges of target memory. Note that a new memory map must not overlap an existing entry; if you define a range that over- laps an existing range, the debugger ignores the new range.
  • Page 230 md, mem Alphabetical Summary of Debugger Commands Delete Block From Memory Map md address Syntax Menu selection Memory Delete Environments basic debugger profiling Description The MD command deletes a range of memory from the debugger’s memory map. The address parameter identifies the starting address of the range of memory. If you supply an address that is not the starting address of a range, the debugger displays this error message in the display area of the COMMAND window:...
  • Page 231 minimal, mix, ml Alphabetical Summary of Debugger Commands Enter Minimal Mode minimal Syntax minimal Menu selection MoDe MiNimal Environments basic debugger profiling Description The MINIMAL command changes from the current debugging mode to minimal mode. If you’re already in minimal mode, the MINIMAL command has no effect.
  • Page 232 move Alphabetical Summary of Debugger Commands Move Active Window move Syntax move [ X position , Y position [, width , length ] ] Menu selection none Environments basic debugger profiling Description The MOVE command moves the active window to the specified XY position. If you choose, you can resize the window while you move it (see the SIZE command for valid width and length values).
  • Page 233 mr, ms, next Alphabetical Summary of Debugger Commands Reset Memory Map Syntax Menu selection Memory Reset Environments basic debugger profiling Description The MR command resets the debugger’s memory map by deleting all defined memory ranges from the map. Save Memory Block to File Syntax ms address, length, filename Menu selection...
  • Page 234 pause, pf Alphabetical Summary of Debugger Commands Pause Execution pause Syntax pause Menu selection none Environments basic debugger profiling Description The PAUSE command allows you to pause the debugger while running a batch file. Pausing is especially helpful in debugging the commands in a batch file. When the debugger reads this command in a batch file, the debugger stops execution and displays the following message: <<...
  • Page 235 pq, pr, prompt Alphabetical Summary of Debugger Commands Profile, Quick pq starting point [, update rate ] Syntax Menu selection Profile Quick Environments basic debugger profiling Description The PQ command initiates a RUN command and collects a subset of the avail- able statistics on the defined areas between the starting point and the first-en- countered stopping point.
  • Page 236 quit, reload, reset, restart Alphabetical Summary of Debugger Commands Exit Debugger quit Syntax quit Menu selection none Environments basic debugger profiling Description The QUIT command exits the debugger and returns to the operating system. Reload Object Code reload Syntax reload [ object filename ] Menu selection Load Reload Environments...
  • Page 237 return, run, sa Alphabetical Summary of Debugger Commands Return to Function’s Caller return Syntax return Menu selection none Environments basic debugger profiling Description The RETURN or RET command executes the code in the current C function and halts when execution reaches the caller. Breakpoints do not affect this command, but you can halt execution by pressing the left mouse button or pressing Run Code...
  • Page 238 safehalt, scolor Alphabetical Summary of Debugger Commands Toggle Safehalt Mode safehalt Syntax safehalt {on | off} Menu selection none Environments basic debugger profiling Description The SAFEHALT command places the debugger in safehalt mode. When safe- halt mode is off (the default), you can halt a running target device either by pressing or by clicking a mouse button.
  • Page 239 scolor, sconfig, sd Alphabetical Summary of Debugger Commands You don’t have to type an entire attribute or area name ; you need to type only enough letters to uniquely identify the attribute. If you supply ambiguous attribute names, the debugger interprets the names in this order: black, blue, bright, blink.
  • Page 240 setf Alphabetical Summary of Debugger Commands Set Default Data-Display Format setf Syntax setf [ data type , display format ] Menu selection none Environments basic debugger profiling Description The SETF command changes the display format for a specific data type. If you enter SETF with no parameters, the debugger lists the current display format for each data type.
  • Page 241 size, sl Alphabetical Summary of Debugger Commands Size Active Window size Syntax size [ width , length ] Menu selection none Environments basic debugger profiling Description The SIZE command changes the size of the active window. You can use the SIZE command in one of two ways: By supplying a specific width and length or By omitting the width and length parameters and using function keys to...
  • Page 242 sload, sound, sr Alphabetical Summary of Debugger Commands Load Symbol Table sload sload object filename Syntax Menu selection Load Symbols Environments basic debugger profiling Description The SLOAD command loads the symbol table of the specified object file. SLOAD is useful in a debugging environment in which the debugger cannot, or need not, load the object code (for example, if the code is in ROM).
  • Page 243 ssave, step Alphabetical Summary of Debugger Commands Save Screen Configuration ssave Syntax ssave [ filename ] Menu selection Color Save Environments basic debugger profiling Description The SSAVE command saves the current screen configuration to a file. This saves the screen colors, window positions, window sizes, and border styles. SSAVE also saves the location of multiple WATCH and MEMORY windows.
  • Page 244 take, unalias Alphabetical Summary of Debugger Commands Execute Batch File take Syntax take batch filename [ , suppress echo flag ] Menu selection none Environments basic debugger profiling Description The TAKE command tells the debugger to read and execute commands from a batch file.
  • Page 245 use, vaa, vac, version Alphabetical Summary of Debugger Commands Use New Directory use [ directory name ] Syntax Menu selection none Environments basic debugger profiling Description The USE command allows you to name an additional directory that the debugger can search when looking for source files. You can specify only one directory at a time.
  • Page 246 vr, wa Alphabetical Summary of Debugger Commands Reset PROFILE Window Display Syntax Menu selection View Reset Environments basic debugger profiling Description The VR command resets the display in the PROFILE window so that all marked areas are listed and statistics are displayed with default labels and in the default sort order.
  • Page 247 wa, wd, whatis Alphabetical Summary of Debugger Commands You can open additional WATCH windows by using the window name parame- ter. When you open an additional WATCH window, the debugger appends the window name to the WATCH window label. You can create as many WATCH windows as you need.
  • Page 248 win, wr Alphabetical Summary of Debugger Commands Select Active Window win WINDOW NAME Syntax Menu selection none Environments basic debugger profiling Description The WIN command allows you to select the active window by name. Note that the WINDOW NAME is in uppercase (matching the name exactly as displayed).
  • Page 249 zoom Alphabetical Summary of Debugger Commands Zoom Active Window zoom Syntax zoom Menu selection none Environments basic debugger profiling Description The ZOOM command makes the active window as large as possible. To unzoom a window, enter the ZOOM command a second time; this returns the window to its prezoom size and position.
  • Page 250 Summary of Profiling Commands 11.4 Summary of Profiling Commands The following tables summarize the profiling commands that are used for marking, enabling, disabling, and unmarking areas and for changing the display in the PROFILE window. These commands are easiest to use from the pulldown menus, so they are not included in the alphabetical command summary.
  • Page 251: Enabling Disabled Areas

    Summary of Profiling Commands Table 11–2. Disabling Marked Areas (Continued) To disable this area C only Disassembly only C and disassembly Functions By function name DCFE function not applicable not applicable All functions in a module DCFM filename DBFM filename All functions everywhere DCFG DBFG...
  • Page 252: Unmarking Areas

    Summary of Profiling Commands Table 11–4. Unmarking Areas To unmark this area C only Disassembly only C and disassembly Lines UCLE filename , line number UALE address By line number, address not applicable All lines in a function UCLF function UALF function UBLF function All lines in a module...
  • Page 253: Changing The Profile Window Display

    Summary of Profiling Commands Table 11–5. Changing the PROFILE Window Display (a) Viewing specific areas To view this area C only Disassembly only C and disassembly Lines By line number, address VFCLE filename , line number VFALE address not applicable All lines in a function VFCLF function VFALF function...
  • Page 254 Summary of Special Keys 11.5 Summary of Special Keys The debugger provides function key, cursor key, and command key sequences for performing a variety of actions: Editing text on the command line Using the command history Switching modes Halting or escaping from an action Displaying the pulldown menus Running code Selecting or closing a window...
  • Page 255 Summary of Special Keys Switching modes Use these To do this function keys Switch debugging modes in this order: auto assembly mixed Halting or escaping from an action The escape key acts as an end or undo key in several situations. Use this To do this function key...
  • Page 256 Summary of Special Keys Running code Use these To do this function keys Run code from the current PC (equivalent to the RUN command without an expression parameter) Single-step code from the current PC (equivalent to the STEP command without an expression parameter) Single-step code from the current PC;...
  • Page 257 Summary of Special Keys Scrolling a window’s contents These descriptions and instructions for scrolling apply to the active window. Some of these descriptions refer to specific windows; if no specific window is named, then the description/instructions refer to any window that is active. Use these To do this function keys...
  • Page 258 Summary of Special Keys Editing data or selecting the active field The F9 function key makes the current field (the field that the cursor is pointing to) active. This has various effects, depending on the field. Use this To do this function key FILE or DISASSEMBLY window: Set or clear a breakpoint CALLS window: Display the source to a listed function...
  • Page 259 Chapter 12 Basic Information About C Expressions Many of the debugger commands take C expressions as parameters. This allows the debugger to have a relatively small, yet powerful, instruction set. Because C expressions can have side effects—that is, the evaluation of some types of expressions can affect existing values—you can use the same com- mand to display or to change a value.
  • Page 260 C Expressions for Assembly Language Programmers 12.1 C Expressions for Assembly Language Programmers It’s not necessary for you to be an experienced C programmer in order to use the debugger. However, in order to use the debugger’s full capabilities, you should be familiar with the rules governing C expressions.
  • Page 261 C Expressions for Assembly Language Programmers Increment and decrement operators increment – – decrement These unary operators can precede or follow a symbol. When the operator precedes a symbol, the symbol value is incremented/decremented before it is used in the expression; when the operator follows a symbol, the sym- bol value is incremented/decremented after it is used in the expression.
  • Page 262 Using Expression Analysis in the Debugger 12.2 Using Expression Analysis in the Debugger The debugger’s expression analysis is based on C expression analysis. This includes all mathematical, relational, pointer, and assignment operators. However, a few limitations, as well as a few additional features, are not described in K&R C.
  • Page 263 Using Expression Analysis in the Debugger This expression format is useful for examining the automatic variables of a function that is not currently being executed. Unless the variable is static, however, the function must be somewhere in the current call stack. Note that if you want to see local variables from the currently executing function, you need not use this form;...
  • Page 264 Using Expression Analysis in the Debugger Note how the first expression differs from the expression: (float)*10 In this case, the debugger fetches an integer from address 10 and con- verts the integer to a floating-point value. You can also typecast to user-defined types such as structures. For exam- ple, in the expression: ((struct STR *)10)–>field the debugger treats memory location 10 as a pointer to a structure of type...
  • Page 265 What the Debugger Does During Invocation Appendix A Appendix A What the Debugger Does During Invocation In some circumstances, you may find it helpful to know the steps that the debugger goes through during the invocation process. These are the steps, in order, that the debugger performs.
  • Page 266 What the Debugger Does During Invocation 7) Loads any object filenames specified with D_OPTIONS or specified on the command line during invocation. 8) Determines the initial mode (auto, assembly, mixed, or minimal) and dis- plays the appropriate windows on the screen. At this point, the debugger is ready to process any commands that you enter.
  • Page 267 Running Title—Attribute Reference Appendix B Appendix A Debugger Messages This appendix contains an alphabetical listing of the progress and error mes- sages that the debugger might display in the display area of the COMMAND window. Each message contains both a description of the situation that causes the message and an action to take if the message indicates a problem or error.
  • Page 268 Associating Sound With Error Messages / Alphabetical Summary of Debugger Messages Associating Sound With Error Messages / Alphabetical Summary of Debugger Messages B.1 Associating Sound With Error Messages You can associate a beeping sound with the display of error messages. To do this, use the SOUND command.
  • Page 269 Alphabetic Summary of Debugger Messages Breakpoint already exists at address Description During single-step execution, the debugger attempted to set a breakpoint where one already existed. (This isn’t neces- sarily a breakpoint that you set—it may have been an internal breakpoint that was used for single-stepping). Action None should be required;...
  • Page 270 Alphabetical Summary of Debugger Messages Cannot edit field Description Expressions that are displayed in the WATCH window cannot be edited. Action If you attempted to edit an expression in the WATCH window, you may have actually wanted to change the value of a sym- bol or register used in the expression.
  • Page 271 Alphabetical Summary of Debugger Messages Cannot open “ filename ” Description The debugger attempted to show filename in the FILE win- dow but could not find the file. Action Be sure that the file exists as named. If it does, enter the USE command to identify the file’s directory.
  • Page 272 Alphabetical Summary of Debugger Messages Cannot set/verify breakpoint at address Description Either you attempted to set a breakpoint in read-only or protected memory, or there are hardware problems with the target system. This may also happen when you enable or dis- able on-chip memory while using breakpoints.
  • Page 273 Alphabetical Summary of Debugger Messages Corrupt call stack Description The debugger tried to update the CALLS window and couldn’t. This may be because a function was called that didn’t return. Or it could be that the program stack was over- written in target memory.
  • Page 274 Alphabetical Summary of Debugger Messages File not found : “ filename ” Description The filename specified for the LOAD, RELOAD, SLOAD, or TAKE command was not found in the current directory or any of the directories identified with D_SRC. Action Be sure that the filename was typed correctly.
  • Page 275 Alphabetical Summary of Debugger Messages Illegal control transfer instruction Description The instruction following a delayed branch/call instruction was modifying the program counter. Action Modify your source code. Illegal left hand side of assignment Description This is an expression error—the lefthand side of an assign- ment expression doesn’t meet C language assignment rules.
  • Page 276 Alphabetical Summary of Debugger Messages Illegal structure reference Description This is an expression error—either the item being referenced as a structure is not a structure, or you are attempting to refer- ence a nonexistent portion of a structure. Action See Section B.3, Additional Instructions for Expression Errors , page B-17.
  • Page 277 Alphabetical Summary of Debugger Messages Invalid attribute name Description The COLOR and SCOLOR commands accept a specific set of area names for their first parameter. The parameter entered did not match one of the valid attributes. Action Reenter the COLOR or SCOLOR command with a valid area name parameter.
  • Page 278 Alphabetical Summary of Debugger Messages Invalid watch delete Description The debugger can’t delete the parameter supplied with the WD command. Usually, this is because the watch index doesn’t exist or because a symbol name was typed instead of a watch index. Action Reenter the WD command.
  • Page 279 Alphabetic Summary of Debugger Messages Load aborted Description This message always follows another message. Action Refer to the message that preceded Load aborted . Lval required Description This is an expression error—an assignment expression was entered that requires a legal left-hand side. Action See Section B.3, Additional Instructions for Expression Errors , page B-17.
  • Page 280 Alphabetical Summary of Debugger Messages Pointer not allowed Description This is an expression error. Action See Section B.3, Additional Instructions for Expression Errors , page B-17. Processor is already running Description One of the RUN commands was entered while the debugger was running free from the target system.
  • Page 281 Alphabetical Summary of Debugger Messages Structure not allowed Description This is an expression error—the expression is attempting an operation that cannot be performed on a structure. Action See Section B.3, Additional Instructions for Expression Errors , page B-17. Take file stack too deep Description Batch files can be nested up to 10 levels deep.
  • Page 282 Alphabetic Summary of Debugger Messages Undeclared port address Description You attempted to do a connect/disconnect on an address that isn’t declared as a port. Action Verify the address of the port to be connected or discon- nected. User halt Description The debugger halted program execution because you pressed the key.
  • Page 283 Additional Instructions for Expression Errors B.3 Additional Instructions for Expression Errors Whenever you receive an expression error, you should reenter the command and edit the expression so that it follows the C language expression rules. If necessary, refer to a C language manual such as The C Programming Language by Brian W.
  • Page 284 B-18...
  • Page 285 Glossary Appendix C Appendix A Glossary active window: The window that is currently selected for moving, sizing, editing, closing, or some other function. aggregate type: A C data type, such as a structure or array, in which a vari- able is composed of multiple variables, called members. aliasing: A method of customizing debugger commands;...
  • Page 286 Glossary C: A high-level, general-purpose programming language useful for writing compilers and operating systems and for programming microproces- sors. CALLS window: A window that lists the functions called by your program. casting: A feature of C expressions that allows you to use one type of data as if it were a different type of data.
  • Page 287 Glossary data-display windows: Windows for observing and modifying various types of data. This category includes the MEMORY, CPU, DISP, and WATCH windows. D_DIR: An environment variable that identifies the directory containing the commands and files necessary for running the debugger. debugger: A window-oriented software interface that helps you to debug ’C6x programs running on a ’C6x simulator.
  • Page 288 Glossary FILE window: A window that displays the contents of the current C code. The FILE window is intended primarily for displaying C code but can be used to display any text file. init.cmd: A batch file that contains debugger-initialization commands. If this file isn’t present when you first invoke the debugger, then all memory is invalid.
  • Page 289 Glossary pulldown menu: A command menu that is accessed by name or with the mouse from the menu bar at the top of the debugger display. scalar type: A C type in which the variable is a single variable, not composed of other variables.
  • Page 291 Index Index ? command 7-3, 11-10 addresses (continued) display formats 2-27, 7-19, 11-10 symbolic addresses 7-7 examining register contents 7-10 undefined areas 5-3, 5-8 modifying PC 6-11 aggregate types side effects 7-5 definition C-1 $$SIM$$ 4-15 displaying 2-22, 3-17, 7-11 to 7-13 ALIAS command 2-30, 4-17 to 4-20, 11-12 See also aliasing supplying parameters 4-17...
  • Page 292 Index –as shell option 1-10, 1-11, 10-2 –bb debugger option 2-3 See also –b debugger option ASM command 2-14, 6-3, 11-12 BD command 8-4, 11-13 menu selection 6-3, 11-9 menu selection 11-8 assembler 1-9, 1-10 benchmarking, definition C-1 assembly language code, displaying 3-2 to 3-3, bitwise operators 12-3 3-4, 6-4 BL command 8-5, 11-13...
  • Page 293 Index C source comma operator 12-4 displaying 2-11, 3-2 to 3-3, 3-4, 6-4, 11-22 command history 4-5 managing memory data 7-8 function key summary 11-50 CALLS command 3-10, 3-11, 6-7, 11-15 command line 3-7, 4-2 effect on debugging modes 3-5 changing the prompt 9-12, 11-31 CALLS window 2-12, 3-6, 3-10 to 3-32, 6-2, 6-7 cursor 3-20...
  • Page 294 Index CPU window 3-6, 3-16, 7-2, 7-10 data-display windows 3-6, 7-2 colors 9-6 colors 9-6 customizing 9-6 CPU window 3-6, 3-16, 7-2, 7-10 definition C-2 definition C-3 editing registers 7-4 DISP window 2-22, 3-6, 3-17, 7-2, 7-11 to 7-13 MEMORY window 2-5, 3-6, 3-13 to 3-32, 7-2, CSTEP command 2-19, 6-13, 11-17 7-6 to 7-9 current directory, changing 6-9...
  • Page 295 Index debugging modes 2-12 to 2-14, 3-2 to 3-5, 6-2 to DISASSEMBLY window 2-5, 3-6, 3-8, 6-2, 6-4 colors 9-5 customizing 9-5 assembly mode 2-12 to 2-14, 3-4, 6-2 definition C-3 auto mode 2-12 to 2-14, 3-2 to 3-3, 6-2 modifying display 11-18 commands 11-3 ASM command 2-14, 6-3, 11-12...
  • Page 296 Index displaying (continued) environment variables source programs 6-4 to 6-7 D_DIR 9-10, 11-35 text files 6-7 effects on debugger invocation A-1 text when executing a batch file 4-14, 11-21 D_OPTIONS 1-15 effects on debugger invocation A-1, A-2 DLOG command 4-6 to 4-20, 11-20 D_SRC 1-12, 6-9 ending recording session 4-6 effects on debugger invocation A-1...
  • Page 297 Index F9 key 2-24, 2-28, 3-8, 3-9, 3-10, 3-11, 3-31, 6-7, 7-4, 7-12, 8-3, 8-4 clearing a breakpoint 11-54 –g shell option 1-10, 1-11, 10-2 displaying a function 11-54 GO command 2-12, 6-11, 11-23 editing data 11-54 grouping/reference operators 12-2 opening a DISP window 11-54 setting a breakpoint 11-54 F10 key 4-10, 6-13, 11-8, 11-52...
  • Page 298 Index ISA, definition C-4 loading batch files 4-13 COFF files, restrictions 5-3 custom displays 9-10 object code 2-3, 6-8 key sequences after invoking the debugger 6-8 displaying functions 11-54 symbol table only 6-8, 11-38 displaying previous commands (command histo- while invoking the debugger 1-12, 6-8 ry) 11-50 without symbol table 6-8, 11-32 editing...
  • Page 299 Index memory (continued) menu bar 2-4, 4-7 customizing its appearance 9-7 adding ranges 11-25 definition C-4 items without menus 4-10 defining 5-2 to 5-10 using menus 4-7 to 4-10 interactively 5-2 definition C-4 menu selections 4-7, 11-8 to 11-9 deleting ranges 11-26 colors 9-7 modifying 5-2 to 5-10 customizing their appearance 9-7...
  • Page 300 Index moving a window 3-27 to 3-32, 11-28 to 11-29 pointers function key method 2-9, 3-28, 11-52 displaying/modifying contents 2-23, 7-11 mouse method 2-9, 3-27 format in DISP window 2-23, 3-17, 7-12, 11-18 MOVE command 2-9, 3-27 natural format 12-5 XY screen limits 3-28, 11-28 typecasting 12-5 MR command 5-10, 11-29...
  • Page 301 Index profiling, defining areas (continued) program memory unmarking areas 10-11 to 10-22 adding to memory map 11-25 function key method 10-12 deleting from memory map 11-26 mouse method 10-11 filling 7-9, 11-22 description 1-5 to 1-6 saving 7-9, 11-29 entering environment 10-3 PROMPT command 9-12, 11-31 key features 1-5 to 1-6 menu selection 11-9...
  • Page 302 Index RETURN (RET) command 6-11, 11-33 SD command 10-14, 11-35 RUN command 2-16, 6-11, 11-33 SETF command 2-26 to 2-30, 7-17 to 7-20, from the menu bar 4-10 11-36 to 11-37 function key entry 4-10, 6-11, 11-52 shell program 1-11 menu bar selections 4-10 with conditional expression 2-20 side effects 7-5, 12-3...
  • Page 303 Index sizing a window 3-24 to 3-32 system commands (continued) function key method 2-7, 3-25, 11-52 PAUSE command 11-30 mouse method 2-7, 3-24 QUIT command 1-15, 2-30, 11-32 SIZE command 2-7, 3-25 RESET command 2-4, 11-32 size limits 3-25, 11-37 SOUND command 11-38, B-2 while moving it 3-28, 11-28 to 11-29 TAKE command 4-13, 5-10, 11-40...
  • Page 304 Index viewing profile data 10-17 to 10-21 windows (continued) associated code 10-21 commands data accuracy 10-19 MOVE command 2-9, 3-27 displaying areas 10-19 to 10-22 SIZE command 2-7, 3-25, 11-37 displaying different data 10-17 to 10-22 WIN command 2-5 to 2-6, 3-22, 11-28 to 11-29, 11-44 sorting data 10-19 ZOOM command 2-8, 3-26, 11-45...

Table of Contents