📄 tutorial.gml
字号:
.figure *depth='2.75' *scale=40 *file='ide7c' The &edname for Windows
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.figure *depth='2.84' *scale=40 *file='ide7f' The &edname for Windows
.do end
.np
Now we will edit one of the source files and introduce an error into
the application.
.if '&lang' eq 'C/C++' .do begin
.autonote
.note
Double-click on the "draw" source file (i.e.,
.fi draw???&cxt
.ct ) to load the source file into the editor.
.note
Scroll down to line 227 using the keyboard or mouse. You can also pull
down the
.us Edit
menu, select
.us Goto Line...,
and enter 227.
The &edname makes full use of colors and fonts to achieve syntax
highlighting. File templates for C, C++, and FORTRAN files are defined
to assist you in distinguishing the components of your code.
.note
Pull down the
.us Options
menu and select the
.us Colors
item.
.note
Click on a color from the palette, drag it to the word
.id if
on line 218, and release it. All keywords are now displayed in the
chosen color. Drag a different color to a comment line (line 225) and
all comments will display in that color. Similarly, you can select the
Fonts item from the Options menu, select a font style and size, and
drag it to your source file. Close the Fonts and Colors dialog by
double-clicking in the upper left hand corner.
.note
You can now save this color and font configuration for all
.fi &xxt.
files by pulling down the
.us Options
menu, selecting the
.us General...,
item and clicking next to
.us Save configuration on exit
in the "Features" box. Press Enter or click on OK.
.note
Now, to introduce an error into the application, replace the line
.id #if 0
with
.id #if 1.
.note
Save your changes by clicking on the "Write the current file to disk"
icon or select
.us Save
from the
.us File
menu.
.note
Return to the &vip (by clicking on it if it is visible on your screen,
or by using Alt-Tab), re-make your project, and run it. A fault occurs
in your application, so the next step is to track down the problem
using the &dbgname..
.endnote
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.autonote
.note
Double-click on the "draw" source file (i.e.,
.fi draw???&cxt
.ct ) to load the source file into the editor.
.note
Search for the line containing the text:
.millust begin
c$ifdef undefined
.millust end
.np
For Windows users, "Find" is in the "Edit" menu.
If you are building a WIN386 application, search for the second line
containing this text (located in subroutine
.mono memclear
.ct ).
.note
Now, to introduce an error into the application, add the line
.millust begin
c$define undefined
.millust end
just before the line containing
.mono c$ifdef.
.note
Save your changes by clicking on the "Write the current file to disk"
icon or select
.us Save
from the
.us File
menu.
.note
Return to the &vip (by clicking on it if it is visible on your screen,
or by using Alt-Tab), re-make your project, and run it. A fault occurs
in your application, so the next step is to track down the problem
using the &dbgname..
.endnote
.do end
.*
.section Debugging the Program
.*
.np
To debug a program it must first be compiled to include debugging
information. The &vip maintains two sets of switches for each target in
a project. These are known as the Development Switches and the Release
Switches.
.autonote
.note
Right click on
.fi draw???&cxt.
and select
.us Source options
from the pop-up menu.
Select
.if '&lang' eq 'C/C++' .do begin
.us C Compiler Switches
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.us Fortran Compiler Switches
.do end
from the sub-menu.
.np
By default, your target is placed in development mode with the
debugging switches for the compiler and linker set to include
debugging information. You can either set the switches in each
category manually or you can copy the default Release switches using
the CopyRel button. This method of setting switches is especially
convenient since you can specify everything from diagnostic,
optimization, and code generation switches to special linker switches
all without having to memorize a cryptic switch name &mdash. you
simply click next to the switches you wish to use for a particular
item.
.note
Scroll through the categories using the >> button until you get to:
.millust begin
.if '&lang' eq 'C/C++' .do begin
6. Debugging Switches
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
4. Debugging Switches
.do end
.millust end
.pc
We can see that full debugging information was used in the compile, so
just click on
.us Cancel
to exit this screen.
.if '&lang' eq 'C/C++' .do begin
.figure *depth='2.49' *scale=37 *file='ide8c' Setting compiler switches
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.figure *depth='2.30' *scale=37 *file='ide8f' Setting compiler switches
.do end
.note
To invoke the debugger, pull down the
.us Targets
menu and choose the
.us Debug
item or select the "Debug the current target" icon from the toolbar.
.endnote
.np
The &dbgname is designed to be as convenient and intuitive as
possible, while at the same time providing a comprehensive and
flexible environment for serious debugging. You can configure your
environment to display exactly the information you require to be most
productive. Among the windows available are source and assembly,
modules, functions, calls, threads, images, watches, locals, globals,
file variables, registers, 80x87 FPU, stack, I/O ports, memory display,
and a log window. You can step through your source
using the keys or icons on the toolbar. Execute one line at a time by
stepping over calls or stepping into calls, or execute until the
current function returns. Right-mouse button functionality gives
context-sensitive pop-up menus.
.if '&lang' eq 'C/C++' .do begin
.figure *depth='4.43' *scale=55 *file='ide9c' The &dbgname
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.figure *depth='4.66' *scale=50 *file='ide9f' The &dbgname
.do end
.np
We know that a fault has occurred in
.fi draw???.exe,
so we will run the application and examine the state of the program
when the fault occurs.
.if '&lang' eq 'C/C++' .do begin
.autonote
.note
Click on the "go!" icon on the toolbar to begin execution of the
program. The exception occurs and the source window shows the line
.millust begin
*pwidth = bitmap.bmWidth + 5;
.millust end
in the function
.id button_size
as the last line executed before the exception. Examining the Locals
window you will see that
.id pwidth
is a NULL pointer, hence the exception.
.note
We can now move up the call stack by clicking on the "Move up the call stack"
icon on the toolbar (red up arrow) to follow the program's
execution. On the previous line, we see
.id button_size
is called from
.id add_button.
Moving up the call stack again, we see
.id add_button
is called with NULL as its fifth parameter. An artificial error has been
introduced for the purposes of this tutorial. It is located several lines
back in the source file.
.note
By replacing the line
.id #if 1
with
.id #if 0
we can bypass this error.
Right-click on the line
.id #if 1
and select Show, then Line... from the pop-up menus to see the line
number which must be corrected, then exit the debugger.
.note
Double-click on
.fi draw???&cxt.
to load the source file into the editor.
.note
Scroll down to line 227 using the keyboard or mouse, or pull down the
.us Edit
menu, select
.us Goto Line...,
and enter 227.
.note
Replace the line
.id #if 1
with
.id #if 0
and save your changes by clicking on the "Write the current file to
disk" icon or selecting
.us Save
from the
.us File
menu.
.note
Return to the &vip (by clicking on it if it is visible on your screen,
or by using Alt-Tab) and re-make your project.
.note
Run your project to see the kitchen demo.
.endnote
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.autonote
.note
Click on the "go!" icon on the toolbar to begin execution of the
program. The exception occurs and the source window shows the line
.millust begin
arr( cnt ) = ch
.millust end
in the subroutine
.id memclear
as the last line executed before the exception. Examining the Locals
window you will see that the array location or address,
.id locale,
is 0.
This means that the array
.id arr
was mapped to location 0.
For the 32-bit Windows example, we also needed to use the "array"
pragma to force a far pointer reference to cause the exception.
.note
We can now move up the call stack by clicking on the "Move up the call stack"
icon on the toolbar (red up arrow) to follow the program's
execution.
On the previous executable line of code, we see
.id memclear
is called from the main program with three arguments.
.millust begin
call memclear( 0, loc(Draw_area), isizeof(RECTL) )
.millust end
.np
We see that
.id memclear
is called with 0 as the first argument and
.id loc(Draw_area)
as the second argument which is backwards to the way it should be.
An artificial error was introduced for the purposes of this tutorial.
.note
By removing the line
.millust begin
c$define undefined
.millust end
.pc
we can undo this error.
Exit the debugger.
.note
Double-click on
.fi draw???&cxt.
to load the source file into the editor.
.note
Go to the line in question using "find" or "search" and delete the
line.
Save your changes by clicking on the "Write the current file to disk"
icon or selecting
.us Save
from the
.us File
menu.
.note
Return to the &vip (by clicking on it if it is visible on your screen,
or by using Alt-Tab) and re-make your project.
.note
Run your project to see the kitchen demo.
.endnote
.do end
.*
.if '&lang' eq 'C/C++' .do begin
.*
.section Using the Source Browser
.*
.np
Suppose you wanted to change the color of the tabletop in your
application. You can use the &brname to determine the code you will
need to change. The &brname provides an easy way to examine the class
definitions, member functions, and inheritance trees
associated with your C++ code.
First, you need to instruct the compiler to emit &brname information.
.figure *depth='3.58' *scale=45 *file='ide10c' The &brname
.autonote
.note
Right click on
.fi furnitu&xxt.,
then select
.us Source options
from the pop-up menus.
Select
.if '&lang' eq 'C/C++' .do begin
.us C++ Compiler Switches
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.us FORTRAN 77 Compiler Switches
.do end
from the sub-menu.
.cp 10
.note
Go to the
.millust begin
6. Debugging Switches
.millust end
.pc
category by selecting it from the drop-down list box or by scrolling
through the categories using the >> button.
.note
Select
.mono Emit Browser information [-db]
and click on OK.
.note
Click the "Make all targets in the project" icon to re-make the project.
The compiler will emit Browser information for
.fi furnitu&xxt.
in a file called
.fi draw???.dbr.
Now you are ready to browse the target's source.
.note
Pull down the
.us Targets
menu and select
.us Browse,
or click the "Browse the current target" icon on the toolbar. The
inheritance tree for the target is displayed.
.note
To view details on any particular class, double-click on the item for
information such as the location of the class definition, the private,
public, and protected functions of the class, and the class
inheritance. Branches of the inheritance tree can be collapsed and
expanded. A variety of tools are available to help you navigate your
.if '&lang' eq 'C/C++' .do begin
C++
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
FORTRAN 77
.do end
source. Double-click on the
.id table
class.
.note
Double-click on the function
.id top_and_four_legs()
to see the details on this function.
.note
Select the variable
.id tabletop,
pull down the
.us Detail
menu, and select the
.us Goto Definition...
item. The Editor is invoked, loading the file
.fi furnitu&xxt.
which contains the definition of
.id top_and_four_legs.
.note
Next we will make some changes to
.fi furnitu&xxt.
in order to change the color of the tabletop. Scroll down to line 143
using the keyboard or mouse, or pull down the
.us Edit
menu, select
.us Goto Line...,
and enter 143
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -