MDL V8 - Using C Expressions With the Debugger


Using C Expressions With the Debugger

C expressions can also be entered at the debugger prompt. C expressions are used with the MDL debugger to display and modify data in memory. The debugger accepts C expressions, which include the standard operators, variables and structure definitions. The debugger does not accept declarations or function calls for functions in the MDL program. The debugger does accept function calls for MDL's built-in functions.

 

The debugger knows the type and location of variables. It knows the format of structures referenced, so structure names can be used in casting. However, it does not know of typedefs included in the source code.

 

The debugger evaluates the expression and performs any assignments included in the statement. It then displays the result of the expression. If the result is an array, it displays all members of the array. If the result is a structure, it displays all members of the structure.

 

To display the elements of an array, enter only the array name. To display an array address, request the address of the first element. For example, if the source code contains the declaration char sampleArray[10];, the debugger command sampleArray would display the values of all 10 array elements. The &sampleArray[0] command would display the address of the array's first element.

 

To display data with a format different from the format declared in the program, use a cast or use the display command. For example, if the source code contains the declaration int *pInteger and you want to view the second byte as a character, key in *((char *)pInteger+1). You can cast a constant as the array's address with an expression like (long [10])0x12728. This command displays 10 longs starting at the address 0x12728. The expression (long [10])&sampleArray[4] displays 10 longs starting at the address of the fourth element in sampleArray.

 

When you enter a request, the debugger first tries to parse it as a command. If parsing for a keyword does not find a match, the entire line is evaluated as a C expression. In ambiguous cases, the first word is interpreted as a reserved keyword. To specify a C expression that may be mistaken for a command, enclose the expression in parentheses. For example, to display the value of a variable b, enter the command (b). Entering b without parentheses displays a list of break points.